-
-
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.
♻️ refactor(avatar): refactor Avatar component
- Loading branch information
1 parent
14e4cce
commit 0cf2963
Showing
9 changed files
with
151 additions
and
125 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,5 +1,29 @@ | ||
import { Avatar } from '@lobehub/ui'; | ||
import { ActionIconProps, Avatar, StroyBook, useControls, useCreateStore } from '@lobehub/ui'; | ||
|
||
export default () => { | ||
return <Avatar avatar={'https://raw.githubusercontent.com/lobehub/favicon/main/icon.png'} />; | ||
const store = useCreateStore(); | ||
const control: ActionIconProps | any = useControls( | ||
{ | ||
avatar: 'https://raw.githubusercontent.com/lobehub/favicon/main/icon.png', | ||
background: '#FEE064', | ||
size: { | ||
value: 40, | ||
step: 1, | ||
min: 16, | ||
max: 128, | ||
}, | ||
shape: { | ||
value: 'circle', | ||
options: ['circle', 'square'], | ||
}, | ||
title: 'cm', | ||
}, | ||
{ store }, | ||
); | ||
|
||
return ( | ||
<StroyBook levaStore={store}> | ||
<Avatar {...control} /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
import { createStyles } from 'antd-style'; | ||
import { readableColor } from 'polished'; | ||
|
||
export const useStyles = createStyles(({ css, token }) => ({ | ||
container: css` | ||
cursor: pointer; | ||
> * { | ||
cursor: pointer; | ||
} | ||
`, | ||
border: css` | ||
border: 1px solid ${token.colorSplit}; | ||
`, | ||
})); | ||
export const useStyles = createStyles( | ||
({ css, token }, { background, size }: { background?: string; size: number }) => { | ||
const backgroundColor = background ?? token.colorBgContainer; | ||
const color = readableColor(backgroundColor); | ||
|
||
return { | ||
avatar: css` | ||
cursor: pointer; | ||
font-size: ${size * 0.5}px; | ||
font-weight: 700; | ||
line-height: 1; | ||
color: ${color}; | ||
background: ${backgroundColor}; | ||
border: 1px solid ${background ? 'transparent' : token.colorSplit}; | ||
> * { | ||
cursor: pointer; | ||
} | ||
`, | ||
}; | ||
}, | ||
); |
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
0cf2963
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-git-master-lobehub.vercel.app
lobe-ui.vercel.app
lobe-ui-lobehub.vercel.app
ui.lobehub.com