Skip to content

Commit

Permalink
chore: setup custom viewports in storybook to match our breakpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
pete-watters committed Jan 16, 2024
1 parent 8e2ed87 commit 664e46b
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ const config: StorybookConfig = {
},
],
},

{
test: /\.(ts|tsx)$/,
loader: 'esbuild-loader',
options: { tsconfig: './tsconfig.json', target: 'es2020' },
},
],
},
},
Expand Down
6 changes: 6 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Preview } from '@storybook/react';

import '../src/app/index.css';
import { customViewports } from './viewports';

const preview: Preview = {
parameters: {
Expand All @@ -11,6 +12,11 @@ const preview: Preview = {
date: /Date$/i,
},
},
viewport: {
viewports: {
...customViewports,
},
},
},
};

Expand Down
48 changes: 48 additions & 0 deletions .storybook/viewports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { breakpoints } from '@leather-wallet/tokens';

import { POPUP_HEIGHT, POPUP_WIDTH } from '../src/shared/constants';

export const customViewports = {
extension: {
name: 'Extension Popout',
styles: {
width: `${POPUP_WIDTH}px`,
height: `${POPUP_HEIGHT}px`,
},
},
sm: {
name: 'sm',
styles: {
width: breakpoints.sm,
height: '100%',
},
},
md: {
name: 'md',
styles: {
width: breakpoints.md,
height: '100%',
},
},
lg: {
name: 'lg',
styles: {
width: breakpoints.lg,
height: '100%',
},
},
xl: {
name: 'xl',
styles: {
width: breakpoints.xl,
height: '100%',
},
},
'2xl': {
name: '2xl',
styles: {
width: breakpoints['2xl'],
height: '100%',
},
},
};

0 comments on commit 664e46b

Please sign in to comment.