Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding spacing to theme #1862

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions src/stories/Spacing.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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 { theme } from '../ui/theme/theme';

Check warning on line 7 in src/stories/Spacing.stories.tsx

View check run for this annotation

Codecov / codecov/patch

src/stories/Spacing.stories.tsx#L3-L7

Added lines #L3 - L7 were not covered by tests

const SpacingDemo = ({ space, value }: { space: string; value: string }) => (
<Stack align="start" spacing={2}>
<Flex gap={4} align="center">
<Box w={value} h="24px" bg="blue.500" />
<Text fontSize="sm" fontWeight="bold">
{space}
</Text>
<Text fontSize="sm">{value}</Text>
</Flex>
</Stack>
);

const SpacingShowcase = () => (
<Stack align="stretch" spacing={8}>
<Text fontSize="2xl" fontWeight="bold">
Theme Spacing
</Text>
{Object.entries(theme.space).map(([space, value]) => (
<SpacingDemo key={space} space={space} value={(value as string).toString()} />

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

View check run for this annotation

Codecov / codecov/patch

src/stories/Spacing.stories.tsx#L27

Added line #L27 was not covered by tests
))}
</Stack>
);

const meta = {

Check warning on line 32 in src/stories/Spacing.stories.tsx

View check run for this annotation

Codecov / codecov/patch

src/stories/Spacing.stories.tsx#L32

Added line #L32 was not covered by tests
title: 'Theme/Spacing',
component: SpacingShowcase,
parameters: {
layout: 'padded',
docs: {
source: {
code: `
// Example SpacingDemo for spacing 4. See w={4}
<Stack align="start" spacing={2}>
<Flex gap={4} align="center">
<Box w={4} h="24px" bg="blue.500" />
<Text fontSize="sm" fontWeight="bold">
4
</Text>
<Text fontSize="sm">1rem</Text>
</Flex>
</Stack>
`,
language: 'tsx',
type: 'auto',
},
},
},
tags: ['autodocs'],
} satisfies Meta<typeof SpacingShowcase>;

export default meta;

Check warning on line 59 in src/stories/Spacing.stories.tsx

View check run for this annotation

Codecov / codecov/patch

src/stories/Spacing.stories.tsx#L59

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

export const AllSpacing: Story = {};

Check warning on line 62 in src/stories/Spacing.stories.tsx

View check run for this annotation

Codecov / codecov/patch

src/stories/Spacing.stories.tsx#L62

Added line #L62 was not covered by tests
12 changes: 12 additions & 0 deletions src/ui/theme/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,19 @@ export const theme = extendTheme({
4.5: '1.125rem',
},
space: {
0: '0px',
1: '0.25rem', // 4px
2: '0.5rem', // 8px
3: '0.75rem', // 12px
4: '1rem', // 16px
4.5: '1.125rem',
5: '1.25rem', // 20px
6: '1.5rem', // 24px
8: '2rem', // 32px
10: '2.5rem', // 40px
12: '3rem', // 48px
16: '4rem', // 64px
18: '4.5rem', // 72px
},
borders: {
'1px': '1px solid var(--stacks-colors-borderPrimary)',
Expand Down
Loading