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>
This commit is contained in:
Jakub Kotula 2023-04-11 12:30:25 +02:00 committed by GitHub
parent a0406e834a
commit 558faa9725
No known key found for this signature in database
GPG Key ID: 0EB8D75C775AB6F1
33 changed files with 104 additions and 79 deletions

View File

@ -88,10 +88,10 @@ const Base = styled(Stack, {
shape: { shape: {
circle: { circle: {
borderRadius: 80, // big enough to cover all sizes borderRadius: '$full',
}, },
rounded: { rounded: {
borderRadius: 16, borderRadius: '$16',
}, },
}, },
@ -115,10 +115,10 @@ const Shape = styled(Stack, {
variants: { variants: {
shape: { shape: {
circle: { circle: {
borderRadius: 80, // big enough to cover all sizes borderRadius: '$full',
}, },
rounded: { rounded: {
borderRadius: 16, borderRadius: '$16',
}, },
}, },
}, },
@ -131,7 +131,7 @@ const Indicator = styled(Stack, {
zIndex: 2, zIndex: 2,
borderWidth: 2, borderWidth: 2,
borderColor: '$white-100', borderColor: '$white-100',
borderRadius: 10, borderRadius: '$10',
variants: { variants: {
size: { size: {

View File

@ -60,7 +60,7 @@ const LockBase = styled(Stack, {
height: 16, height: 16,
backgroundColor: '$white-100', backgroundColor: '$white-100',
position: 'absolute', position: 'absolute',
borderRadius: 16, borderRadius: '$16',
variants: { variants: {
variant: { variant: {

View File

@ -24,7 +24,7 @@ const IconAvatar = (props: Props) => {
} }
const Base = styled(Stack, { const Base = styled(Stack, {
borderRadius: 80, borderRadius: '$full',
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',

View File

@ -162,16 +162,16 @@ const Base = styled(Stack, {
radius: { radius: {
full: { full: {
borderRadius: 40, borderRadius: '$full',
}, },
40: { 40: {
borderRadius: 12, borderRadius: '$12',
}, },
32: { 32: {
borderRadius: 10, borderRadius: '$10',
}, },
24: { 24: {
borderRadius: 8, borderRadius: '$8',
}, },
}, },

View File

@ -114,7 +114,7 @@ const Base = styled(Stack, {
justifyContent: 'space-between', justifyContent: 'space-between',
alignItems: 'center', alignItems: 'center',
padding: 8, padding: 8,
borderRadius: 12, borderRadius: '$12',
userSelect: 'none', userSelect: 'none',
variants: { variants: {

View File

@ -50,7 +50,7 @@ const Composer = (props: Props) => {
<BlurView <BlurView
intensity={40} intensity={40}
style={{ style={{
borderRadius: 20, borderRadius: 20, // hardcoded, once blur view is hooked up to theme, this should be changed to token
width: '100%', width: '100%',
}} }}
> >
@ -143,7 +143,7 @@ const Composer = (props: Props) => {
backgroundColor="$background" backgroundColor="$background"
width={15} width={15}
height={15} height={15}
borderRadius={7} borderRadius="$8"
position="absolute" position="absolute"
zIndex={1} zIndex={1}
/> />

View File

@ -98,7 +98,7 @@ export type { Props as ContextTagProps }
const Base = styled(View, { const Base = styled(View, {
backgroundColor: '$neutral-10', backgroundColor: '$neutral-10',
paddingVertical: 1, paddingVertical: 1,
borderRadius: 20, borderRadius: '$20',
display: 'inline-flex', display: 'inline-flex',
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',

View File

@ -16,10 +16,12 @@ const Counter = (props: Props) => {
const { value, type = 'default' } = props const { value, type = 'default' } = props
return ( return (
<Base type={type}> <Base>
<Content type={type}>
<Text size={11} weight="medium" color={textColors[type]}> <Text size={11} weight="medium" color={textColors[type]}>
{value > 99 ? '99+' : value} {value > 99 ? '99+' : value}
</Text> </Text>
</Content>
</Base> </Base>
) )
} }
@ -28,17 +30,24 @@ export { Counter }
export type { Props as CounterProps } export type { Props as CounterProps }
const Base = styled(View, { const Base = styled(View, {
backgroundColor: '$primary-50', padding: 2,
paddingHorizontal: 3,
paddingVertical: 0,
borderRadius: 6, // TODO: use tokens when fixed its definition
height: 16,
minWidth: 16,
maxWidth: 28,
display: 'inline-flex', display: 'inline-flex',
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
flexBasis: 'fit-content', 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, borderWidth: 1,
borderColor: 'transparent', borderColor: 'transparent',

View File

@ -25,7 +25,7 @@ export const Default: Story = {
<Dialog> <Dialog>
<Button>Trigger</Button> <Button>Trigger</Button>
<Dialog.Content borderRadius={16} width={400}> <Dialog.Content borderRadius="$16" width={400}>
test test
</Dialog.Content> </Dialog.Content>
</Dialog> </Dialog>

View File

@ -73,7 +73,7 @@ const PressableTrigger = forwardRef(function _PressableTrigger(
interface DialogContentProps { interface DialogContentProps {
children: React.ReactNode children: React.ReactNode
borderRadius: 8 | 12 | 16 borderRadius: '$8' | '$12' | '$16'
width: number width: number
initialFocusRef?: React.RefObject<HTMLElement> initialFocusRef?: React.RefObject<HTMLElement>
} }

View File

@ -60,7 +60,7 @@ const Content = styled(DropdownMenuContent, {
width: 256, width: 256,
padding: 4, padding: 4,
borderRadius: 12, borderRadius: '$12',
backgroundColor: '$white-100', backgroundColor: '$white-100',
shadowRadius: 30, shadowRadius: 30,
@ -76,7 +76,7 @@ const ItemBase = styled(DropdownMenuItem, {
alignItems: 'center', alignItems: 'center',
height: 32, height: 32,
paddingHorizontal: 8, paddingHorizontal: 8,
borderRadius: 10, borderRadius: '$10',
cursor: 'pointer', cursor: 'pointer',
userSelect: 'none', userSelect: 'none',
gap: 8, gap: 8,

View File

@ -24,7 +24,7 @@ const DynamicButton = (props: Props, ref: Ref<HTMLButtonElement>) => {
const showCount = Boolean(count) const showCount = Boolean(count)
return ( return (
<Shadow variant="$2" borderRadius={999}> <Shadow variant="$2" borderRadius="$full">
<Button <Button
{...(pressableProps as unknown as object)} // TODO: Tamagui has incorrect types for PressableProps {...(pressableProps as unknown as object)} // TODO: Tamagui has incorrect types for PressableProps
ref={ref} ref={ref}
@ -60,7 +60,7 @@ const Button = styled(Stack, {
justifyContent: 'center', justifyContent: 'center',
flexShrink: 0, flexShrink: 0,
height: 24, height: 24,
borderRadius: 999, borderRadius: '$full',
animation: 'fast', animation: 'fast',
space: 3, space: 3,

View File

@ -84,7 +84,7 @@ const Circle = styled(Stack, {
name: 'Circle', name: 'Circle',
width: 8, width: 8,
height: 8, height: 8,
borderRadius: 4, borderRadius: '$4',
backgroundColor: '$neutral-5', backgroundColor: '$neutral-5',
marginRight: 7, marginRight: 7,
}) })
@ -93,7 +93,7 @@ const EmptyCircle = styled(Stack, {
name: 'EmptyCircle', name: 'EmptyCircle',
width: 8, width: 8,
height: 8, height: 8,
borderRadius: 4, borderRadius: '$4',
backgroundColor: 'transparent', backgroundColor: 'transparent',
borderWidth: 1, borderWidth: 1,
borderColor: '$neutral-40', borderColor: '$neutral-40',

View File

@ -68,7 +68,7 @@ const Base = styled(Stack, {
cursor: 'pointer', cursor: 'pointer',
userSelect: 'none', userSelect: 'none',
borderRadius: 10, borderRadius: '$10',
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',

View File

@ -60,10 +60,10 @@ const Base = styled(RNImage, {
radius: { radius: {
none: {}, none: {},
12: { 12: {
borderRadius: 12, borderRadius: 12, // fix this once Image is migrated to tamagui image
}, },
full: { full: {
borderRadius: 9999, borderRadius: 999, // fix this once Image is migrated to tamagui image
}, },
}, },
}, },

View File

@ -113,7 +113,7 @@ const Base = styled(Stack, {
py: 11, py: 11,
px: 16, px: 16,
borderRadius: 12, borderRadius: '$12',
variants: { variants: {
variant: { variant: {

View File

@ -25,7 +25,7 @@ export const InputFrame = styled(
backgroundColor: 'transparent', backgroundColor: 'transparent',
height: 32, height: 32,
borderRadius: 12, borderRadius: '$12',
animation: 'fast', animation: 'fast',

View File

@ -42,7 +42,7 @@ export const Actions = (props: Props) => {
position="absolute" position="absolute"
top={-8} top={-8}
right={8} right={8}
borderRadius={12} borderRadius="$12"
borderWidth={1} borderWidth={1}
borderColor="$neutral-10" borderColor="$neutral-10"
backgroundColor="$white-100" backgroundColor="$white-100"

View File

@ -60,7 +60,7 @@ export const ReactionsDialog = (props: Props) => {
}, [reactions]) }, [reactions])
return ( return (
<Dialog.Content width={352} borderRadius={12}> <Dialog.Content width={352} borderRadius="$12">
<Tabs defaultValue={initialReactionType}> <Tabs defaultValue={initialReactionType}>
<Stack padding={16}> <Stack padding={16}>
<Tabs.List size={24}> <Tabs.List size={24}>

View File

@ -80,7 +80,7 @@ const Reaction = (props: ReactionProps) => {
</Text> </Text>
<Stack <Stack
backgroundColor="$turquoise-50-opa-10" backgroundColor="$turquoise-50-opa-10"
borderRadius={6} borderRadius="$6"
paddingHorizontal={4} paddingHorizontal={4}
> >
<Text size={13} weight="medium" color="$turquoise-50"> <Text size={13} weight="medium" color="$turquoise-50">

View File

@ -27,7 +27,7 @@ const Base = styled(Stack, {
position: 'relative', position: 'relative',
paddingHorizontal: 8, paddingHorizontal: 8,
paddingVertical: 8, paddingVertical: 8,
borderRadius: 16, borderRadius: '$16',
alignItems: 'flex-start', alignItems: 'flex-start',
variants: { variants: {

View File

@ -26,7 +26,7 @@ const PinnedMessage = (props: Props) => {
</Banner> </Banner>
</Pressable> </Pressable>
<Dialog.Content width={480} borderRadius={16}> <Dialog.Content width={480} borderRadius="$16">
<Stack padding={16} alignItems="flex-start"> <Stack padding={16} alignItems="flex-start">
<Close asChild> <Close asChild>
<Button variant="grey" size={32} icon={<CloseIcon />} /> <Button variant="grey" size={32} icon={<CloseIcon />} />

View File

@ -38,7 +38,7 @@ const PopoverContent = (props: ContentProps) => {
return ( return (
<Stack <Stack
backgroundColor="$white-100" backgroundColor="$white-100"
borderRadius={12} borderRadius="$12"
shadowRadius={30} shadowRadius={30}
shadowOffset="0px 8px" shadowOffset="0px 8px"
shadowColor="rgba(9, 16, 28, 0.12)" shadowColor="rgba(9, 16, 28, 0.12)"

View File

@ -81,7 +81,7 @@ const Button = styled(Stack, {
animation: 'fast', animation: 'fast',
space: 4, space: 4,
borderRadius: 8, borderRadius: '$8',
minWidth: 36, minWidth: 36,
height: 24, height: 24,
paddingHorizontal: 8, paddingHorizontal: 8,

View File

@ -30,7 +30,7 @@ export const Default: Story = {
height={50} height={50}
borderWidth={1} borderWidth={1}
borderColor="$neutral-20" borderColor="$neutral-20"
borderRadius={12} borderRadius="$12"
/> />
<Shadow <Shadow
variant="$2" variant="$2"
@ -38,7 +38,7 @@ export const Default: Story = {
height={50} height={50}
borderWidth={1} borderWidth={1}
borderColor="$neutral-20" borderColor="$neutral-20"
borderRadius={12} borderRadius="$12"
/> />
<Shadow <Shadow
variant="$3" variant="$3"
@ -46,7 +46,7 @@ export const Default: Story = {
height={50} height={50}
borderWidth={1} borderWidth={1}
borderColor="$neutral-20" borderColor="$neutral-20"
borderRadius={12} borderRadius="$12"
/> />
<Shadow <Shadow
variant="$4" variant="$4"
@ -54,7 +54,7 @@ export const Default: Story = {
height={50} height={50}
borderWidth={1} borderWidth={1}
borderColor="$neutral-20" borderColor="$neutral-20"
borderRadius={12} borderRadius="$12"
/> />
</Stack> </Stack>
), ),

View File

@ -26,7 +26,7 @@ const SidebarSkeleton = () => {
<Skeleton <Skeleton
height={80} height={80}
width={80} width={80}
borderRadius={40} borderRadius="$full"
borderWidth={2} borderWidth={2}
borderColor="$white-100" borderColor="$white-100"
variant="secondary" variant="secondary"
@ -35,21 +35,21 @@ const SidebarSkeleton = () => {
<Skeleton <Skeleton
height={24} height={24}
width={104} width={104}
borderRadius={8} borderRadius="$8"
mb={14} mb={14}
variant="secondary" variant="secondary"
/> />
<Skeleton <Skeleton
height={16} height={16}
width={312} width={312}
borderRadius={8} borderRadius="$8"
mb={8} mb={8}
variant="secondary" variant="secondary"
/> />
<Skeleton <Skeleton
height={16} height={16}
width={272} width={272}
borderRadius={8} borderRadius="$8"
mb={12} mb={12}
variant="secondary" variant="secondary"
/> />
@ -58,30 +58,30 @@ const SidebarSkeleton = () => {
<Skeleton <Skeleton
height={12} height={12}
width={50} width={50}
borderRadius={5} borderRadius="$6"
variant="secondary" variant="secondary"
/> />
<Skeleton height={14} width={14} ml={12} mr={4} /> <Skeleton height={14} width={14} ml={12} mr={4} />
<Skeleton <Skeleton
height={12} height={12}
width={50} width={50}
borderRadius={5} borderRadius="$6"
variant="secondary" variant="secondary"
/> />
</Stack> </Stack>
<Stack flexDirection="row" alignItems="center" mb={27} gap={8}> <Stack flexDirection="row" alignItems="center" mb={27} gap={8}>
<Skeleton height={24} width={76} borderRadius={20} /> <Skeleton height={24} width={76} borderRadius="$20" />
<Skeleton height={24} width={76} borderRadius={20} /> <Skeleton height={24} width={76} borderRadius="$20" />
<Skeleton height={24} width={76} borderRadius={20} /> <Skeleton height={24} width={76} borderRadius="$20" />
</Stack> </Stack>
<Stack mb={27}> <Stack mb={27}>
<Skeleton height={12} width={50} borderRadius={5} mb={19} /> <Skeleton height={12} width={50} borderRadius="$6" mb={19} />
<Stack flexDirection="row" alignItems="center" mb={16}> <Stack flexDirection="row" alignItems="center" mb={16}>
<Skeleton height={24} width={24} mr={8} /> <Skeleton height={24} width={24} mr={8} />
<Skeleton <Skeleton
height={12} height={12}
width={80} width={80}
borderRadius={5} borderRadius="$6"
variant="secondary" variant="secondary"
/> />
</Stack> </Stack>
@ -90,7 +90,7 @@ const SidebarSkeleton = () => {
<Skeleton <Skeleton
height={12} height={12}
width={100} width={100}
borderRadius={5} borderRadius="$6"
variant="secondary" variant="secondary"
/> />
</Stack> </Stack>
@ -99,7 +99,7 @@ const SidebarSkeleton = () => {
<Skeleton <Skeleton
height={12} height={12}
width={70} width={70}
borderRadius={5} borderRadius="$6"
variant="secondary" variant="secondary"
/> />
</Stack> </Stack>
@ -108,7 +108,7 @@ const SidebarSkeleton = () => {
<Skeleton <Skeleton
height={12} height={12}
width={90} width={90}
borderRadius={5} borderRadius="$6"
variant="secondary" variant="secondary"
/> />
</Stack> </Stack>
@ -120,7 +120,7 @@ const SidebarSkeleton = () => {
<Skeleton <Skeleton
height={12} height={12}
width={80} width={80}
borderRadius={5} borderRadius="$6"
variant="secondary" variant="secondary"
/> />
</Stack> </Stack>
@ -129,7 +129,7 @@ const SidebarSkeleton = () => {
<Skeleton <Skeleton
height={12} height={12}
width={100} width={100}
borderRadius={5} borderRadius="$6"
variant="secondary" variant="secondary"
/> />
</Stack> </Stack>
@ -138,7 +138,7 @@ const SidebarSkeleton = () => {
<Skeleton <Skeleton
height={12} height={12}
width={70} width={70}
borderRadius={5} borderRadius="$6"
variant="secondary" variant="secondary"
/> />
</Stack> </Stack>

View File

@ -1,11 +1,12 @@
import { Stack, useTheme } from '@tamagui/core' import { Stack, useTheme } from '@tamagui/core'
import type { RadiusTokens } from '../tokens'
import type { ColorTokens, StackProps } from '@tamagui/core' import type { ColorTokens, StackProps } from '@tamagui/core'
type Props = StackProps & { type Props = StackProps & {
width?: number | string width?: number | string
height?: number | string height?: number | string
borderRadius?: number borderRadius?: RadiusTokens
variant?: 'primary' | 'secondary' variant?: 'primary' | 'secondary'
} }
@ -18,7 +19,7 @@ const Skeleton = (props: Props) => {
const { const {
width = 32, width = 32,
height = 32, height = 32,
borderRadius = 16, borderRadius = '$16',
variant = 'primary', variant = 'primary',
...rest ...rest
} = props } = props

View File

@ -30,7 +30,7 @@ const TopbarSkeleton = () => {
<Skeleton <Skeleton
height={16} height={16}
width={92} width={92}
borderRadius={5} borderRadius="$6"
variant="secondary" variant="secondary"
/> />
</Stack> </Stack>
@ -42,8 +42,8 @@ const TopbarSkeleton = () => {
flexGrow={1} flexGrow={1}
flexShrink={1} flexShrink={1}
> >
<Skeleton height={32} width={32} borderRadius={10} /> <Skeleton height={32} width={32} borderRadius="$10" />
<Skeleton height={32} width={32} borderRadius={10} /> <Skeleton height={32} width={32} borderRadius="$10" />
</Stack> </Stack>
</Stack> </Stack>
</Stack> </Stack>

View File

@ -127,13 +127,13 @@ const TriggerBase = styled(Stack, {
size: { size: {
32: { 32: {
height: 32, height: 32,
borderRadius: 10, borderRadius: '$10',
paddingHorizontal: 12, paddingHorizontal: 12,
gap: 6, gap: 6,
}, },
24: { 24: {
height: 24, height: 24,
borderRadius: 8, borderRadius: '$8',
paddingHorizontal: 8, paddingHorizontal: 8,
gap: 4, gap: 4,
}, },

View File

@ -75,7 +75,7 @@ const Base = styled(Stack, {
width: 351, width: 351,
minHeight: 40, minHeight: 40,
backgroundColor: '$neutral-80-opa-70', backgroundColor: '$neutral-80-opa-70',
borderRadius: 12, borderRadius: '$12',
justifyContent: 'space-between', justifyContent: 'space-between',
variants: { variants: {

View File

@ -1,5 +1,5 @@
import { createTokens } from '@tamagui/core' import { createTokens } from '@tamagui/core'
import { radius, size, space, zIndex } from '@tamagui/theme-base' import { size, space, zIndex } from '@tamagui/theme-base'
export const tokens = createTokens({ export const tokens = createTokens({
color: { color: {
@ -184,5 +184,20 @@ export const tokens = createTokens({
size, size,
space, space,
zIndex, zIndex,
radius, radius: {
0: 0,
4: 4,
6: 6,
8: 8,
10: 10,
12: 12,
16: 16,
20: 20,
full: 1000,
},
}) })
type GetTokenString<A> = A extends string | number ? `$${A}` : `$${string}`
type RadiusTokens = GetTokenString<keyof typeof tokens.radius> | number
export { type RadiusTokens }

View File

@ -60,7 +60,7 @@ const Tooltip = (props: Props, ref: Ref<HTMLButtonElement>) => {
backgroundColor="$white-100" backgroundColor="$white-100"
paddingVertical={6} paddingVertical={6}
paddingHorizontal={12} paddingHorizontal={12}
borderRadius={8} borderRadius="$8"
> >
{typeof content === 'string' ? ( {typeof content === 'string' ? (
<Text size={13} weight="medium" color="$neutral-100"> <Text size={13} weight="medium" color="$neutral-100">

View File

@ -24,7 +24,7 @@ const UserList = (props: Props) => {
key={user.address! + index} key={user.address! + index}
padding={8} padding={8}
gap={8} gap={8}
borderRadius={12} borderRadius="$12"
alignItems="center" alignItems="center"
cursor="pointer" cursor="pointer"
hoverStyle={{ hoverStyle={{