Skip to content

Commit

Permalink
feat: added elevation to redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
BLuEScioN committed Oct 18, 2024
1 parent e5ad0bb commit d81a69c
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
77 changes: 77 additions & 0 deletions src/stories/Elevation.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import type { Meta, StoryObj } from '@storybook/react';

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

Check warning on line 8 in src/stories/Elevation.stories.tsx

View check run for this annotation

Codecov / codecov/patch

src/stories/Elevation.stories.tsx#L3-L8

Added lines #L3 - L8 were not covered by tests

const ElevationDemo = () => {
const { colorMode } = useColorMode();

Check warning on line 11 in src/stories/Elevation.stories.tsx

View check run for this annotation

Codecov / codecov/patch

src/stories/Elevation.stories.tsx#L10-L11

Added lines #L10 - L11 were not covered by tests

return (
<Stack gap={8}>
<Flex direction="column" gap={8} p={4}>
<Text fontSize="2xl" fontWeight="bold">
Elevation Showcase
</Text>
{Object.entries(theme.semanticTokens.shadows).map(([elevationName, elevationValue]) => (
<Flex key={elevationName} align="center" gap={4}>

Check warning on line 20 in src/stories/Elevation.stories.tsx

View check run for this annotation

Codecov / codecov/patch

src/stories/Elevation.stories.tsx#L20

Added line #L20 was not covered by tests
<Box
width="200px"
height="100px"
bg={colorMode === 'light' ? 'white' : 'gray.800'}
boxShadow={(elevationValue as any).default}
borderRadius="md"
display="flex"
alignItems="center"
justifyContent="center"
>
<Text>{elevationName}</Text>
</Box>
<Text>
{elevationName}:{' '}
{(elevationValue as any)[colorMode === 'light' ? 'default' : '_dark']}
</Text>
</Flex>
))}
</Flex>
<Flex direction="column" gap={8} bg="#211F1F" p={4}>
{Object.entries(theme.semanticTokens.shadows).map(([elevationName, elevationValue]) => (
<Flex key={elevationName} align="center" gap={4}>

Check warning on line 42 in src/stories/Elevation.stories.tsx

View check run for this annotation

Codecov / codecov/patch

src/stories/Elevation.stories.tsx#L42

Added line #L42 was not covered by tests
<Box
width="200px"
height="100px"
bg={'#211F1F'}
boxShadow={(elevationValue as any)._dark}
borderRadius="md"
display="flex"
alignItems="center"
justifyContent="center"
>
<Text>{elevationName}</Text>
</Box>
<Text color="white">
{elevationName}: {(elevationValue as any)._dark}
</Text>
</Flex>
))}
</Flex>
</Stack>
);
};

const meta = {

Check warning on line 65 in src/stories/Elevation.stories.tsx

View check run for this annotation

Codecov / codecov/patch

src/stories/Elevation.stories.tsx#L65

Added line #L65 was not covered by tests
title: 'Theme/Elevation',
component: ElevationDemo,
parameters: {
layout: 'padded',
},
tags: ['autodocs'],
} satisfies Meta<typeof ElevationDemo>;

export default meta;

Check warning on line 74 in src/stories/Elevation.stories.tsx

View check run for this annotation

Codecov / codecov/patch

src/stories/Elevation.stories.tsx#L74

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

export const AllElevations: Story = {};

Check warning on line 77 in src/stories/Elevation.stories.tsx

View check run for this annotation

Codecov / codecov/patch

src/stories/Elevation.stories.tsx#L77

Added line #L77 was not covered by tests
14 changes: 14 additions & 0 deletions src/ui/theme/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ export const theme = extendTheme({
_dark: 'white',
},
},
shadows: {
elevation1: {
default: '0 2px 6px rgba(183, 180, 176, 0.2)',
_dark: '0 2px 6px rgba(0, 0, 0, 0.2)',
},
elevation2: {
default: '0 8px 16px rgba(183, 180, 176, 0.2)',
_dark: '0 8px 16px rgba(0, 0, 0, 0.2)',
},
elevation3: {
default: '0 16px 32px rgba(183, 180, 176, 0.2)',
_dark: '0 16px 32px rgba(0, 0, 0, 0.2)',
},
},
},
styles: {
global: (props: StyleFunctionProps) => ({
Expand Down

0 comments on commit d81a69c

Please sign in to comment.