Skip to content

Commit

Permalink
Start building out theme
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepinho committed Jul 10, 2024
1 parent 98927e5 commit b505518
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/ui/.storybook/preview.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
import React from 'react';
import globalsCssUrl from '../styles/globals.css?url';
import penumbraTheme from './penumbraTheme';
import { Normalize } from '../src/Normalize';
import { ThemeProvider } from 'styled-components';
import { theme } from '../src/utils/theme';

/** @type { import('@storybook/react').Preview } */
const preview = {
decorators: [
(Story, { title }) => {
const css = title.startsWith('Deprecated/') ? (
<link rel='stylesheet' type='text/css' href={globalsCssUrl} />
) : (
<Normalize />
);
const isDeprecatedComponent = title.startsWith('Deprecated/');

if (isDeprecatedComponent) {
return (
<>
<link rel='stylesheet' type='text/css' href={globalsCssUrl} />
<Story />
</>
);
}

return (
<>
{css}
<ThemeProvider theme={theme}>
<Story />
</>
</ThemeProvider>
);
},
],
Expand Down
26 changes: 26 additions & 0 deletions packages/ui/src/styled-components.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'styled-components';

declare module 'styled-components' {
export interface DefaultTheme {
fonts: {
default: string;
mono: string;
heading: string;
};
fontSizes: {
text9xl: string;
text8xl: string;
text7xl: string;
text6xl: string;
text5xl: string;
text4xl: string;
text3xl: string;
text2xl: string;
textXl: string;
textLg: string;
textBase: string;
textSm: string;
textXs: string;
};
}
}
24 changes: 24 additions & 0 deletions packages/ui/src/utils/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { DefaultTheme } from 'styled-components';

export const theme: DefaultTheme = {
fonts: {
default: 'Poppins',
mono: 'Iosevka Term, monospace',
heading: 'Work Sans',
},
fontSizes: {
text9xl: '8rem',
text8xl: '6rem',
text7xl: '4.5rem',
text6xl: '3.75rem',
text5xl: '3rem',
text4xl: '2.25rem',
text3xl: '1.875rem',
text2xl: '1.5rem',
textXl: '1.25rem',
textLg: '1.125rem',
textBase: '1rem',
textSm: '0.875rem',
textXs: '0.75rem',
},
};

0 comments on commit b505518

Please sign in to comment.