From 558faa97254c1bb2b1778f00b90cc54ba376733e Mon Sep 17 00:00:00 2001 From: Jakub Kotula <520927+jkbktl@users.noreply.github.com> Date: Tue, 11 Apr 2023 12:30:25 +0200 Subject: [PATCH] Migrate to border radius tokens (#365) * fix border radius tokens across components + fix counter structure * adjust border radius * adjust highest token * temporary hardcode values for blur view and image * remove accordion * fix new tokens * remove unused import --------- Co-authored-by: Pavel Prichodko <14926950+prichodko@users.noreply.github.com> --- packages/components/src/avatar/avatar.tsx | 10 +++--- .../components/src/avatar/channel-avatar.tsx | 2 +- .../components/src/avatar/icon-avatar.tsx | 2 +- packages/components/src/button/button.tsx | 8 ++--- packages/components/src/channel/channel.tsx | 2 +- packages/components/src/composer/composer.tsx | 4 +-- .../src/context-tag/context-tag.tsx | 2 +- packages/components/src/counter/counter.tsx | 31 +++++++++++------ .../components/src/dialog/dialog.stories.tsx | 2 +- packages/components/src/dialog/dialog.tsx | 2 +- .../src/dropdown-menu/dropdown-menu.tsx | 4 +-- .../src/dynamic-button/dynamic-button.tsx | 4 +-- .../src/gap-messages/gap-messages.tsx | 4 +-- .../src/icon-button/icon-button.tsx | 2 +- packages/components/src/image/image.tsx | 4 +-- .../src/information-box/information-box.tsx | 2 +- packages/components/src/input/input.tsx | 2 +- .../src/messages/components/actions.tsx | 2 +- .../messages/components/reactions-dialog.tsx | 2 +- .../src/messages/components/reactions.tsx | 2 +- packages/components/src/messages/message.tsx | 2 +- .../src/pinned-message/pinned-message.tsx | 2 +- packages/components/src/popover/popover.tsx | 2 +- .../src/react-button/react-button.tsx | 2 +- .../components/src/shadow/shadow.stories.tsx | 8 ++--- .../src/skeleton/sidebar-skeleton.tsx | 34 +++++++++---------- packages/components/src/skeleton/skeleton.tsx | 5 +-- .../src/skeleton/topbar-skeleton.tsx | 6 ++-- packages/components/src/tabs/tabs.tsx | 4 +-- packages/components/src/toast/toast.tsx | 2 +- packages/components/src/tokens.ts | 19 +++++++++-- packages/components/src/tooltip/tooltip.tsx | 2 +- .../components/src/user-list/user-list.tsx | 2 +- 33 files changed, 104 insertions(+), 79 deletions(-) diff --git a/packages/components/src/avatar/avatar.tsx b/packages/components/src/avatar/avatar.tsx index 5cb8fa4c..b679eeb9 100644 --- a/packages/components/src/avatar/avatar.tsx +++ b/packages/components/src/avatar/avatar.tsx @@ -88,10 +88,10 @@ const Base = styled(Stack, { shape: { circle: { - borderRadius: 80, // big enough to cover all sizes + borderRadius: '$full', }, rounded: { - borderRadius: 16, + borderRadius: '$16', }, }, @@ -115,10 +115,10 @@ const Shape = styled(Stack, { variants: { shape: { circle: { - borderRadius: 80, // big enough to cover all sizes + borderRadius: '$full', }, rounded: { - borderRadius: 16, + borderRadius: '$16', }, }, }, @@ -131,7 +131,7 @@ const Indicator = styled(Stack, { zIndex: 2, borderWidth: 2, borderColor: '$white-100', - borderRadius: 10, + borderRadius: '$10', variants: { size: { diff --git a/packages/components/src/avatar/channel-avatar.tsx b/packages/components/src/avatar/channel-avatar.tsx index 377d452e..c8ad96b4 100644 --- a/packages/components/src/avatar/channel-avatar.tsx +++ b/packages/components/src/avatar/channel-avatar.tsx @@ -60,7 +60,7 @@ const LockBase = styled(Stack, { height: 16, backgroundColor: '$white-100', position: 'absolute', - borderRadius: 16, + borderRadius: '$16', variants: { variant: { diff --git a/packages/components/src/avatar/icon-avatar.tsx b/packages/components/src/avatar/icon-avatar.tsx index 945617d2..e972d577 100644 --- a/packages/components/src/avatar/icon-avatar.tsx +++ b/packages/components/src/avatar/icon-avatar.tsx @@ -24,7 +24,7 @@ const IconAvatar = (props: Props) => { } const Base = styled(Stack, { - borderRadius: 80, + borderRadius: '$full', justifyContent: 'center', alignItems: 'center', diff --git a/packages/components/src/button/button.tsx b/packages/components/src/button/button.tsx index 27d3cb9c..7f5f82b0 100644 --- a/packages/components/src/button/button.tsx +++ b/packages/components/src/button/button.tsx @@ -162,16 +162,16 @@ const Base = styled(Stack, { radius: { full: { - borderRadius: 40, + borderRadius: '$full', }, 40: { - borderRadius: 12, + borderRadius: '$12', }, 32: { - borderRadius: 10, + borderRadius: '$10', }, 24: { - borderRadius: 8, + borderRadius: '$8', }, }, diff --git a/packages/components/src/channel/channel.tsx b/packages/components/src/channel/channel.tsx index 9af9a530..dc8382fc 100644 --- a/packages/components/src/channel/channel.tsx +++ b/packages/components/src/channel/channel.tsx @@ -114,7 +114,7 @@ const Base = styled(Stack, { justifyContent: 'space-between', alignItems: 'center', padding: 8, - borderRadius: 12, + borderRadius: '$12', userSelect: 'none', variants: { diff --git a/packages/components/src/composer/composer.tsx b/packages/components/src/composer/composer.tsx index 9e52862c..ac1c847b 100644 --- a/packages/components/src/composer/composer.tsx +++ b/packages/components/src/composer/composer.tsx @@ -50,7 +50,7 @@ const Composer = (props: Props) => { @@ -143,7 +143,7 @@ const Composer = (props: Props) => { backgroundColor="$background" width={15} height={15} - borderRadius={7} + borderRadius="$8" position="absolute" zIndex={1} /> diff --git a/packages/components/src/context-tag/context-tag.tsx b/packages/components/src/context-tag/context-tag.tsx index 3eee5430..2aa3520d 100644 --- a/packages/components/src/context-tag/context-tag.tsx +++ b/packages/components/src/context-tag/context-tag.tsx @@ -98,7 +98,7 @@ export type { Props as ContextTagProps } const Base = styled(View, { backgroundColor: '$neutral-10', paddingVertical: 1, - borderRadius: 20, + borderRadius: '$20', display: 'inline-flex', flexDirection: 'row', alignItems: 'center', diff --git a/packages/components/src/counter/counter.tsx b/packages/components/src/counter/counter.tsx index a5965555..840b4d7f 100644 --- a/packages/components/src/counter/counter.tsx +++ b/packages/components/src/counter/counter.tsx @@ -16,10 +16,12 @@ const Counter = (props: Props) => { const { value, type = 'default' } = props return ( - - - {value > 99 ? '99+' : value} - + + + + {value > 99 ? '99+' : value} + + ) } @@ -28,17 +30,24 @@ export { Counter } export type { Props as CounterProps } const Base = styled(View, { - backgroundColor: '$primary-50', - paddingHorizontal: 3, - paddingVertical: 0, - borderRadius: 6, // TODO: use tokens when fixed its definition - height: 16, - minWidth: 16, - maxWidth: 28, + padding: 2, display: 'inline-flex', justifyContent: 'center', alignItems: 'center', flexBasis: 'fit-content', +}) + +const Content = styled(View, { + backgroundColor: '$primary-50', + paddingHorizontal: 3, + paddingVertical: 0, + borderRadius: '$6', + minHeight: 16, + maxHeight: 16, + minWidth: 16, + maxWidth: 28, + justifyContent: 'center', + alignItems: 'center', borderWidth: 1, borderColor: 'transparent', diff --git a/packages/components/src/dialog/dialog.stories.tsx b/packages/components/src/dialog/dialog.stories.tsx index b616533f..7f8ed71e 100644 --- a/packages/components/src/dialog/dialog.stories.tsx +++ b/packages/components/src/dialog/dialog.stories.tsx @@ -25,7 +25,7 @@ export const Default: Story = { - + test diff --git a/packages/components/src/dialog/dialog.tsx b/packages/components/src/dialog/dialog.tsx index 306dda0f..82b5c4c8 100644 --- a/packages/components/src/dialog/dialog.tsx +++ b/packages/components/src/dialog/dialog.tsx @@ -73,7 +73,7 @@ const PressableTrigger = forwardRef(function _PressableTrigger( interface DialogContentProps { children: React.ReactNode - borderRadius: 8 | 12 | 16 + borderRadius: '$8' | '$12' | '$16' width: number initialFocusRef?: React.RefObject } diff --git a/packages/components/src/dropdown-menu/dropdown-menu.tsx b/packages/components/src/dropdown-menu/dropdown-menu.tsx index 8621706e..53e5b511 100644 --- a/packages/components/src/dropdown-menu/dropdown-menu.tsx +++ b/packages/components/src/dropdown-menu/dropdown-menu.tsx @@ -60,7 +60,7 @@ const Content = styled(DropdownMenuContent, { width: 256, padding: 4, - borderRadius: 12, + borderRadius: '$12', backgroundColor: '$white-100', shadowRadius: 30, @@ -76,7 +76,7 @@ const ItemBase = styled(DropdownMenuItem, { alignItems: 'center', height: 32, paddingHorizontal: 8, - borderRadius: 10, + borderRadius: '$10', cursor: 'pointer', userSelect: 'none', gap: 8, diff --git a/packages/components/src/dynamic-button/dynamic-button.tsx b/packages/components/src/dynamic-button/dynamic-button.tsx index 090feb40..bf7a4e28 100644 --- a/packages/components/src/dynamic-button/dynamic-button.tsx +++ b/packages/components/src/dynamic-button/dynamic-button.tsx @@ -24,7 +24,7 @@ const DynamicButton = (props: Props, ref: Ref) => { const showCount = Boolean(count) return ( - +