Skip to content

Commit

Permalink
typography showcase
Browse files Browse the repository at this point in the history
  • Loading branch information
mveres committed Oct 7, 2021
1 parent 2673ee1 commit 3a1a1d0
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 20 deletions.
1 change: 0 additions & 1 deletion showcase/src/PaletteShowcase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const styles = {
} as React.CSSProperties,

label: {
margin: 0,
fontFamily: 'monospace',
},
};
Expand Down
65 changes: 65 additions & 0 deletions showcase/src/TypographyShowcase.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React from 'react';
import { useTheme } from '@mui/material/styles';
import { Caption } from '@divriots/dockit-react/caption';

const styles = {
name: {
fontSize: '1rem',
},
value: {
fontFamily: 'monospace',
fontSize: '.875rem',
},
};

export const TypographyShowcase = ({ typography }) => {
const theme = useTheme();

const definitionToStyle = ([name, value]) => ({
name,
value,
style: ['fontFamily', 'fontWeight', 'fontSize'].reduce(
(styles, styleName) =>
name.toLowerCase().includes(styleName.toLocaleLowerCase())
? { ...styles, [styleName]: value }
: styles,
{}
),
});

return (
<table>
<thead>
<tr>
<th>Definition</th>
<th>Sample</th>
</tr>
</thead>
<tbody>
{Object.entries(typography)
.map(definitionToStyle)
.map(({ name, value, style }) => (
<tr key={name}>
<td>
<Caption style={styles.name} text={name} />

<span
style={{
...styles.value,
color: theme.palette.text.secondary,
}}
>
{value}
</span>
</td>
<td>
<div style={style}>
The quick brown fox jumps over the lazy dog.
</div>
</td>
</tr>
))}
</tbody>
</table>
);
};
1 change: 1 addition & 0 deletions showcase/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './PaletteShowcase';
export * from './TypographyShowcase';
1 change: 1 addition & 0 deletions theme/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { light, dark } from '~/colors';
import { typography } from '~/typography';
import { createTheme as createThemeMui, PaletteMode } from '@mui/material';

export const createTheme = (mode: PaletteMode) =>
Expand Down
6 changes: 5 additions & 1 deletion typography/doc/typography.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { mdx } from '@mdx-js/react';
import { TypographyShowcase } from '~/showcase';
import { typography } from '~/typography';
import { MdxLayout } from '~/layout';
export default MdxLayout;

# Font Size
# Typography

<TypographyShowcase typography={typography} />
File renamed without changes.
1 change: 1 addition & 0 deletions typography/src/fonts.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&family=IBM+Plex+Sans&display=swap');
35 changes: 17 additions & 18 deletions typography/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import './fonts.css';

export const typography = {
fonts: {
normal: '-apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif',
mono: 'SFMono-Regular, Consolas, Menlo, Courier, monospace',
serif: 'Times New Roman',
},
fontSizes: ['12px', '14px', '16px', '20px', '24px', '32px', '40px', '48px'],
fontWeights: {
light: 300,
normal: 400,
semibold: 500,
bold: 600,
},
lineHeights: {
condensedUltra: 1,
condensed: 1.25,
default: 1.5,
},
letterSpacings: { tight: '-0.03rem', normal: '0.02rem', loose: '0.2rem' },
fontFamily:
'"IBM Plex Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"',
fontFamilyCode:
'"IBM Plex Mono",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"',
fontFamilyTagline:
'"PlusJakartaSans-ExtraBold",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"',
fontFamilySystem:
'-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"',
fontWeightExtraBold: 800,
htmlFontSize: 16,
fontSize: 14,
fontWeightLight: 300,
fontWeightRegular: 400,
fontWeightMedium: 500,
fontWeightBold: 700,
};

0 comments on commit 3a1a1d0

Please sign in to comment.