Skip to content

Commit

Permalink
feat: added border radius for redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
BLuEScioN committed Oct 22, 2024
1 parent d59fb2d commit fb7c04d
Show file tree
Hide file tree
Showing 2 changed files with 167 additions and 5 deletions.
148 changes: 148 additions & 0 deletions src/stories/BorderRadius.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import type { Meta, StoryObj } from '@storybook/react';

import { Box } from '../ui/Box';
import { Flex } from '../ui/Flex';
import { Text } from '../ui/Text';
import { theme } from '../ui/theme/theme';

Check warning on line 6 in src/stories/BorderRadius.stories.tsx

View check run for this annotation

Codecov / codecov/patch

src/stories/BorderRadius.stories.tsx#L3-L6

Added lines #L3 - L6 were not covered by tests

const BorderRadiusDemo = () => {
console.log(theme.borderRadius);

Check warning on line 9 in src/stories/BorderRadius.stories.tsx

View check run for this annotation

Codecov / codecov/patch

src/stories/BorderRadius.stories.tsx#L8-L9

Added lines #L8 - L9 were not covered by tests
return (
<Flex direction="column" gap={8}>
<Text fontSize="2xl" fontWeight="bold">
Border Radius Showcase
</Text>
{Object.entries(theme.borderRadius).map(([size, value]) => (
<Flex key={size} align="center" gap={4}>

Check warning on line 16 in src/stories/BorderRadius.stories.tsx

View check run for this annotation

Codecov / codecov/patch

src/stories/BorderRadius.stories.tsx#L16

Added line #L16 was not covered by tests
<Box width="100px" height="100px" bg="blue.500" borderRadius={size} />
<Text>
{size}: {value as string}
</Text>
</Flex>
))}
</Flex>
);
};

const meta = {

Check warning on line 27 in src/stories/BorderRadius.stories.tsx

View check run for this annotation

Codecov / codecov/patch

src/stories/BorderRadius.stories.tsx#L27

Added line #L27 was not covered by tests
title: 'Theme/Border Radius',
component: BorderRadiusDemo,
parameters: {
layout: 'padded',
docs: {
source: {
code: `
const BorderRadiusDemo = () => (
<Stack spacing={8}>
<Text fontSize="2xl" fontWeight="bold">Border Radius Showcase</Text>

<Flex direction="column" gap={4}>
<Text fontSize="xl" fontWeight="semibold">xxs (2px)</Text>
<Box
width="100px"
height="100px"
bg="blue.500"
borderRadius="xxs"
display="flex"
alignItems="center"
justifyContent="center"
color="white"
>
xxs
</Box>
</Flex>

<Flex direction="column" gap={4}>
<Text fontSize="xl" fontWeight="semibold">xs (4px)</Text>
<Box
width="100px"
height="100px"
bg="blue.500"
borderRadius="xs"
display="flex"
alignItems="center"
justifyContent="center"
color="white"
>
xs
</Box>
</Flex>

<Flex direction="column" gap={4}>
<Text fontSize="xl" fontWeight="semibold">sm (6px)</Text>
<Box
width="100px"
height="100px"
bg="blue.500"
borderRadius="sm"
display="flex"
alignItems="center"
justifyContent="center"
color="white"
>
sm
</Box>
</Flex>

<Flex direction="column" gap={4}>
<Text fontSize="xl" fontWeight="semibold">md (8px)</Text>
<Box
width="100px"
height="100px"
bg="blue.500"
borderRadius="md"
display="flex"
alignItems="center"
justifyContent="center"
color="white"
>
md
</Box>
</Flex>

<Flex direction="column" gap={4}>
<Text fontSize="xl" fontWeight="semibold">lg (12px)</Text>
<Box
width="100px"
height="100px"
bg="blue.500"
borderRadius="lg"
display="flex"
alignItems="center"
justifyContent="center"
color="white"
>
lg
</Box>
</Flex>

<Flex direction="column" gap={4}>
<Text fontSize="xl" fontWeight="semibold">xl (16px)</Text>
<Box
width="100px"
height="100px"
bg="blue.500"
borderRadius="xl"
display="flex"
alignItems="center"
justifyContent="center"
color="white"
>
xl
</Box>
</Flex>
</Stack>
);
`,
language: 'tsx',
type: 'auto',
},
},
},
tags: ['autodocs'],
} satisfies Meta<typeof BorderRadiusDemo>;

export default meta;

Check warning on line 145 in src/stories/BorderRadius.stories.tsx

View check run for this annotation

Codecov / codecov/patch

src/stories/BorderRadius.stories.tsx#L145

Added line #L145 was not covered by tests
type Story = StoryObj<typeof meta>;

export const AllBorderRadii: Story = {};

Check warning on line 148 in src/stories/BorderRadius.stories.tsx

View check run for this annotation

Codecov / codecov/patch

src/stories/BorderRadius.stories.tsx#L148

Added line #L148 was not covered by tests
24 changes: 19 additions & 5 deletions src/ui/theme/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ import { tabTheme } from './componentTheme/Tab';
import { tagTheme } from './componentTheme/Tag';
import { inter, openSauce } from './fonts';

const borderRadius = {
xxs: '2px',
xs: '4px',
sm: '6px',
md: '8px',
lg: '12px',
xl: '16px',
};
export const theme = extendTheme({
config: {
initialColorMode: 'light',
Expand Down Expand Up @@ -82,11 +90,6 @@ export const theme = extendTheme({
},
},
},
styles: {
global: (props: StyleFunctionProps) => ({
body: {},
}),
},
lineHeights: {
base: 1.15,
},
Expand All @@ -110,6 +113,7 @@ export const theme = extendTheme({
'1px': '1px solid var(--stacks-colors-borderPrimary)',
dark_1px: '1px solid var(--stacks-colors-borderSecondary)',
},
borderRadius,
components: {
Switch: switchTheme,
Checkbox: checkboxTheme,
Expand All @@ -121,4 +125,14 @@ export const theme = extendTheme({
Menu: menuTheme,
Link: linkTheme,
},
styles: {
global: (props: StyleFunctionProps) => ({
body: {
...Object.entries(borderRadius).reduce((acc, [key, value]) => {
(acc as any)[`--stacks-borderRadius-${key}`] = value;
return acc;
}, {}),
},
}),
},
});

0 comments on commit fb7c04d

Please sign in to comment.