Skip to content

Commit

Permalink
refactor: migrate existing sandbox to storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
tsyirvo committed Nov 26, 2024
1 parent 715302b commit c3f2346
Show file tree
Hide file tree
Showing 44 changed files with 425 additions and 757 deletions.
7 changes: 3 additions & 4 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ const preview: Preview = {

parameters: {
backgrounds: {
default: 'plain',
default: 'dark',
values: [
{ name: 'plain', value: 'white' },
{ name: 'warm', value: 'hotpink' },
{ name: 'cool', value: 'deepskyblue' },
{ name: 'dark', value: '#1E1E1E' },
{ name: 'light', value: '#FFFFFF' },
],
},
actions: { argTypesRegex: '^on[A-Z].*' },
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
"//// QUALITY ////": "",
"lint:ts": "yarn tsc",
"lint": "eslint ./ --ext .js,.ts,.tsx,.json --fix --ignore-path .gitignore",
"prettify": "yarn prettier --write './**/*.{js,ts,tsx}'",
"pretty:check": "yarn prettier --check './**/*.{js,ts,tsx}'",
"prettify": "yarn prettier --write './**/*.{js,ts,tsx}' '!.storybook/storybook.requires.ts'",
"pretty:check": "yarn prettier --check './**/*.{js,ts,tsx}' '!.storybook/storybook.requires.ts'",
"//// UTILITIES ////": "",
"codegen": "graphql-codegen --config codegen.ts",
"image:add": "ts-node -T ./scripts/importImages/index.ts",
Expand Down Expand Up @@ -87,7 +87,7 @@
"expo-linking": "~6.3.1",
"expo-localization": "~15.0.3",
"expo-network": "~6.0.1",
"expo-router": "~3.5.23",
"expo-router": "~3.5.24",
"expo-secure-store": "~13.0.2",
"expo-splash-screen": "~0.27.6",
"expo-status-bar": "~1.12.1",
Expand Down
4 changes: 0 additions & 4 deletions src/core/providers/Providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { persistOptions, queryClient } from '$core/api/queryClient';
import { FeatureFlagsProvider } from '$core/featureFlags';
import { ErrorMonitoring } from '$core/monitoring';
import { theme } from '$core/theme';
import { Sandbox } from '$features/sandbox';
import { FullscreenErrorBoundary } from '$shared/components/FullscreenErrorBoundary';
import { Splashscreen } from '$shared/components/splashscreen';

Expand Down Expand Up @@ -75,9 +74,6 @@ const providers = [
{
component: KeyboardProvider,
},
{
component: Sandbox,
},
{
component: FeatureFlagsProvider,
},
Expand Down
38 changes: 38 additions & 0 deletions src/core/theme/stories/colors.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* eslint-disable filename-rules/match */

import type { Meta, StoryObj } from '@storybook/react';
import { ScrollView, View } from 'react-native';

import { Box, Text } from '$shared/uiKit/primitives';

import type { Colors as ThemeColors } from '../colors';
import { theme } from '../theme';

const meta = {
title: 'Theme/Colors',
component: View,
render: () => (
<ScrollView>
<Box p="spacing_16">
{(Object.keys(theme.colors) as ThemeColors[]).map((color) => (
<Box key={color} alignItems="center" mb="spacing_24">
<Text pb="spacing_8">{color}</Text>

<Box
aspectRatio={1}
bg={color}
borderRadius="radius_8"
width={100}
/>
</Box>
))}
</Box>
</ScrollView>
),
} satisfies Meta<typeof View>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Colors: Story = {};
29 changes: 29 additions & 0 deletions src/core/theme/stories/fonts.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eslint-disable filename-rules/match */

import type { Meta, StoryObj } from '@storybook/react';
import { View } from 'react-native';

import { Box, Text } from '$shared/uiKit/primitives';

import type { FontSizes as ThemeFontSizes } from '../fonts';
import { fontSizes } from '../fonts';

const meta = {
title: 'Theme/FontSizes',
component: View,
render: () => (
<Box p="spacing_16">
{(Object.keys(fontSizes) as ThemeFontSizes[]).map((size) => (
<Text key={size} mb="spacing_24" variant={size}>
{`This is a ${size} text`}
</Text>
))}
</Box>
),
} satisfies Meta<typeof View>;

export default meta;

type Story = StoryObj<typeof meta>;

export const FontSizes: Story = {};
31 changes: 31 additions & 0 deletions src/core/theme/stories/radius.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* eslint-disable filename-rules/match */

import type { Meta, StoryObj } from '@storybook/react';
import { View } from 'react-native';

import { Box, Text } from '$shared/uiKit/primitives';

import type { BorderRadii } from '../radius';
import { theme } from '../theme';

const meta = {
title: 'Theme/Radiuses',
component: View,
render: () => (
<Box p="spacing_16">
{(Object.keys(theme.borderRadii) as BorderRadii[]).map((radius) => (
<Box key={radius} alignItems="center" mb="spacing_24">
<Text mb="spacing_8">{radius}</Text>

<Box bg="bg_focus" borderRadius={radius} height={100} width={100} />
</Box>
))}
</Box>
),
} satisfies Meta<typeof View>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Radiuses: Story = {};
37 changes: 37 additions & 0 deletions src/core/theme/stories/spacing.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* eslint-disable filename-rules/match */

import type { Meta, StoryObj } from '@storybook/react';
import { Fragment } from 'react';
import { View } from 'react-native';

import { Box, Text } from '$shared/uiKit/primitives';

import { spacing, type Spacing as ThemeSpacing } from '../spacing';
import { theme } from '../theme';

const meta = {
title: 'Theme/Spacing',
component: View,
render: () => (
<Box p="spacing_16">
{(Object.keys(theme.spacing) as ThemeSpacing[]).map((space) => (
<Fragment key={space}>
<Text mb="spacing_8">{space}</Text>

<Box
bg="bg_focus"
height={spacing[space]}
mb="spacing_32"
width="100%"
/>
</Fragment>
))}
</Box>
),
} satisfies Meta<typeof View>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Spacing: Story = {};
44 changes: 0 additions & 44 deletions src/features/sandbox/Sandbox.tsx

This file was deleted.

23 changes: 0 additions & 23 deletions src/features/sandbox/components/designSystem/Button.sandbox.tsx

This file was deleted.

This file was deleted.

26 changes: 0 additions & 26 deletions src/features/sandbox/components/designSystem/Input.sandbox.tsx

This file was deleted.

22 changes: 0 additions & 22 deletions src/features/sandbox/components/designSystem/Loader.sandbox.tsx

This file was deleted.

17 changes: 0 additions & 17 deletions src/features/sandbox/components/menu/Menu.tsx

This file was deleted.

Loading

0 comments on commit c3f2346

Please sign in to comment.