-
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1b0c7f
commit 3eec31a
Showing
23 changed files
with
225 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
import { EditableMessage } from '@lobehub/ui'; | ||
import { Button, Divider } from 'antd'; | ||
import { EditableMessage, StroyBook, useControls, useCreateStore } from '@lobehub/ui'; | ||
import { button } from 'leva'; | ||
import { useState } from 'react'; | ||
import { Flexbox } from 'react-layout-kit'; | ||
|
||
export default () => { | ||
const [openModal, setOpenModal] = useState(false); | ||
const [editing, setEdit] = useState(false); | ||
const store = useCreateStore(); | ||
useControls( | ||
{ | ||
editing: button(() => { | ||
setEdit(true); | ||
}), | ||
openModal: button(() => { | ||
setOpenModal(true); | ||
}), | ||
}, | ||
{ store }, | ||
); | ||
return ( | ||
<Flexbox width={400}> | ||
<Button | ||
onClick={() => { | ||
setEdit(true); | ||
}} | ||
> | ||
编辑 | ||
</Button> | ||
<Divider /> | ||
<EditableMessage value={'editable text'} editing={editing} onEditingChange={setEdit} /> | ||
</Flexbox> | ||
<StroyBook levaStore={store}> | ||
<EditableMessage | ||
value={'editable text'} | ||
openModal={openModal} | ||
editing={editing} | ||
onEditingChange={setEdit} | ||
/> | ||
</StroyBook> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { StroyBook, TextArea, TextAreaProps, useControls, useCreateStore } from '@lobehub/ui'; | ||
|
||
export default () => { | ||
const store = useCreateStore(); | ||
const controls: TextAreaProps | any = useControls( | ||
{ | ||
placeholder: 'Type keywords...', | ||
type: { | ||
value: 'ghost', | ||
options: ['ghost', 'block'], | ||
}, | ||
}, | ||
{ store }, | ||
); | ||
return ( | ||
<StroyBook levaStore={store}> | ||
<TextArea {...controls} /> | ||
</StroyBook> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Input, InputProps, StroyBook, useControls, useCreateStore } from '@lobehub/ui'; | ||
|
||
export default () => { | ||
const store = useCreateStore(); | ||
const controls: InputProps | any = useControls( | ||
{ | ||
placeholder: 'Type keywords...', | ||
type: { | ||
value: 'ghost', | ||
options: ['ghost', 'block'], | ||
}, | ||
}, | ||
{ store }, | ||
); | ||
return ( | ||
<StroyBook levaStore={store}> | ||
<Input {...controls} /> | ||
</StroyBook> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
nav: Components | ||
group: Common | ||
title: Input | ||
description: A basic widget for getting the user input is a text field. Keyboard and mouse can be used for providing or changing data. | ||
--- | ||
|
||
## Default | ||
|
||
The rest of the props of Input are exactly the same as the original [input](https://ant.design/components/input). | ||
|
||
<code src="./demos/index.tsx" nopadding></code> | ||
|
||
## TextArea | ||
|
||
<code src="./demos/TextArea.tsx" nopadding></code> | ||
|
||
## APIs | ||
|
||
<API></API> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Input as AntInput, InputProps as AntdInputProps } from 'antd'; | ||
import { TextAreaProps as AntdTextAreaProps } from 'antd/es/input/TextArea'; | ||
import { memo } from 'react'; | ||
import { useStyles } from './style'; | ||
export interface InputProps extends AntdInputProps { | ||
ref?: any; | ||
type?: 'ghost' | 'block'; | ||
} | ||
|
||
export const Input = memo<InputProps>(({ className, type = 'ghost', ...props }) => { | ||
const { styles, cx } = useStyles({ type }); | ||
return <AntInput className={cx(styles.input, className)} {...props} />; | ||
}); | ||
|
||
export interface TextAreaProps extends AntdTextAreaProps { | ||
ref?: any; | ||
type?: 'ghost' | 'block'; | ||
} | ||
|
||
export const TextArea = memo<TextAreaProps>(({ className, type = 'ghost', ...props }) => { | ||
const { styles, cx } = useStyles({ type }); | ||
return <AntInput.TextArea className={cx(styles.textarea, className)} {...props} />; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { createStyles } from 'antd-style'; | ||
import { rgba } from 'polished'; | ||
|
||
export const useStyles = createStyles(({ css, token }, { type }: { type: 'ghost' | 'block' }) => ({ | ||
input: css` | ||
position: relative; | ||
max-width: 100%; | ||
height: 36px; | ||
padding: 0 12px; | ||
background-color: ${type === 'block' ? rgba(token.colorBgElevated, 0.6) : 'transparent'}; | ||
border: 1px solid ${type === 'block' ? 'transparent' : token.colorBorder}; | ||
transition: background-color 100ms ${token.motionEaseOut}; | ||
input { | ||
background: transparent; | ||
} | ||
&:hover { | ||
background-color: ${token.colorFillTertiary}; | ||
} | ||
`, | ||
textarea: css` | ||
position: relative; | ||
max-width: 100%; | ||
padding: 8px 12px; | ||
background-color: ${type === 'block' ? rgba(token.colorBgElevated, 0.6) : 'transparent'}; | ||
border: 1px solid ${type === 'block' ? 'transparent' : token.colorBorder}; | ||
transition: background-color 100ms ${token.motionEaseOut}; | ||
textarea { | ||
background: transparent; | ||
} | ||
&:hover { | ||
background-color: ${token.colorFillTertiary}; | ||
} | ||
`, | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
3eec31a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
lobe-ui – ./
lobe-ui.vercel.app
lobe-ui-git-master-lobehub.vercel.app
lobe-ui-lobehub.vercel.app
ui.lobehub.com