Skip to content
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
3 changes: 2 additions & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require('path');

/** @type { import('@storybook/react-webpack5').StorybookConfig } */
const config = {
stories: ['../packages/**/*.stories.@(js|jsx|mjs|ts|tsx)', '../stories/*.stories.@(js|jsx|mjs|ts|tsx)'],
stories: ['../packages/**/*.stories.@(js|jsx|mjs|ts|tsx)', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
staticDirs: ['../packages/assets/src/'],
addons: [
'@storybook/addon-docs',
Expand Down Expand Up @@ -54,6 +54,7 @@ const config = {
webpackConfig.resolve.alias = {
...webpackConfig.resolve.alias,
'@ids-context': path.resolve(__dirname, '../packages/components/src/context'),
'@ids-core': path.resolve(__dirname, '../packages/components/src/core'),
'@ids-internal': path.resolve(__dirname, '../packages/components/src/internal'),
};

Expand Down
Binary file removed packages/assets/src/font/NotoSans-Bold.ttf
Binary file not shown.
Binary file removed packages/assets/src/font/NotoSans-BoldItalic.ttf
Binary file not shown.
Binary file added packages/assets/src/font/WorkSans-Regular.ttf
Binary file not shown.
15 changes: 4 additions & 11 deletions packages/assets/src/scss/_fonts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@
font-style: normal;
}

@font-face {
font-family: 'Noto Sans';
src: assets('font/NotoSans-Bold.ttf');
font-weight: 700;
font-style: normal;
}

@font-face {
font-family: 'Noto Sans';
src: assets('font/NotoSans-Italic.ttf');
Expand All @@ -36,10 +29,10 @@
}

@font-face {
font-family: 'Noto Sans';
src: assets('font/NotoSans-BoldItalic.ttf');
font-weight: 700;
font-style: italic;
font-family: 'Work Sans';
src: assets('font/WorkSans-Regular.ttf');
font-weight: 400;
font-style: normal;
}

@font-face {
Expand Down
7 changes: 7 additions & 0 deletions packages/assets/src/scss/_links.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@use 'variables' as *;

.ids-link {
font-family: $font-family-alt;
text-decoration: underline;
color: $color-neutral-240;
}
2 changes: 2 additions & 0 deletions packages/assets/src/scss/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
@use 'expander';
@use 'fonts';
@use 'form-control';
@use 'headers';
@use 'helper-text';
@use 'icons';
@use 'input';
@use 'inputs-list';
@use 'label';
@use 'links';

@use 'inputs/checkbox';
@use 'inputs/input-text';
Expand Down
3 changes: 3 additions & 0 deletions packages/assets/src/scss/variables/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ $h4-font-size: $text-font-size-l !default;
$h5-font-size: $text-font-size-m !default;
$h6-font-size: $text-font-size-s !default;

$text-font-weight-normal: 400 !default;
$text-font-weight-semi: 600 !default;

$font-family:
'Noto Sans',
-apple-system,
Expand Down
35 changes: 35 additions & 0 deletions stories/typography/Typography.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';

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

import TypographyBase from './TypographyBase';
import TypographyHeaders from './TypographyHeaders';
import TypographyLinks from './TypographyLinks';

import './typography.styles.scss';

const Typography = () => {
return (
<div className="dev-typography-container">
<TypographyHeaders />
<TypographyBase />
<TypographyLinks />
</div>
);
};

const meta: Meta<typeof Typography> = {
component: Typography,
parameters: {
layout: 'padded',
},
tags: [],
};

export default meta;

type Story = StoryObj<typeof Typography>;

export const Default: Story = {
name: 'Default',
};
75 changes: 75 additions & 0 deletions stories/typography/TypographyBase.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import React from 'react';

const TypographyBase = () => {
const sentence = 'The quick brown fox jumps over the lazy dog';
const fontSizesBase = [
{ lineHeight: 30, name: '2xl', size: 20 },
{ lineHeight: 28, name: 'xl', size: 18 },
{ lineHeight: 24, name: 'l', size: 16 },
{ lineHeight: 21, name: 'm', size: 14 },
{ lineHeight: 18, name: 's', size: 12 },
{ lineHeight: 15, name: 'xs', size: 10 },
];
const fontSizesHighlighted = [
{ lineHeight: 36, name: '3xl', size: 24 },
{ lineHeight: 30, name: '2xl', size: 20 },
{ lineHeight: 28, name: 'xl', size: 18 },
{ lineHeight: 24, name: 'l', size: 16 },
{ lineHeight: 21, name: 'm', size: 14 },
{ lineHeight: 18, name: 's', size: 12 },
];
const fontWeights = [
{ name: 'normal', weight: '400' },
{ name: 'semi', weight: '600' },
];
const fontStyles = [
{ name: 'normal', style: 'normal' },
{ name: 'italic', style: 'italic' },
];
const renderRow = (className: string, name: string, style: string, weight: string, size: number, lineHeight: number) => {
return (
<tr className="ids-table__row" key={className}>
<td className="ids-table__cell">
<span className={className}>{sentence}</span>
</td>
<td className="ids-table__cell">{name}</td>
<td className="ids-table__cell">{style}</td>
<td className="ids-table__cell">{weight}</td>
<td className="ids-table__cell">{size}px</td>
<td className="ids-table__cell">{lineHeight}px</td>
</tr>
);
};

return (
<table className="ids-table">
<caption className="ids-table__caption">Base font</caption>
<thead className="ids-table__header">
<tr className="ids-table__row">
<th className="ids-table__header-cell">Sentence</th>
<th className="ids-table__header-cell">Name</th>
<th className="ids-table__header-cell">Style</th>
<th className="ids-table__header-cell">Weight</th>
<th className="ids-table__header-cell">Size</th>
<th className="ids-table__header-cell">Line-height</th>
</tr>
</thead>
<tbody className="ids-table__body">
{fontWeights.map(({ name: weightName, weight }) => {
return fontStyles.map(({ name: styleName, style }) => {
return fontSizesBase.map(({ name: sizeName, size, lineHeight }) => {
return renderRow(`base-${sizeName}-${weightName}-${styleName}`, 'Noto sans', style, weight, size, lineHeight);
});
});
})}
{fontWeights.map(({ name: weightName, weight }) => {
return fontSizesHighlighted.map(({ name: sizeName, size, lineHeight }) => {
return renderRow(`base-${sizeName}-${weightName}-normal`, 'Work sans', 'normal', weight, size, lineHeight);
});
})}
</tbody>
</table>
);
};

export default TypographyBase;
47 changes: 47 additions & 0 deletions stories/typography/TypographyHeaders.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';

const TypographyHeaders = () => {
const sentence = 'The quick brown fox jumps over the lazy dog';
const headers = [
{ content: <h1>{sentence}</h1>, lineHeight: 36, name: 'h1', size: 24 },
{ content: <h2>{sentence}</h2>, lineHeight: 30, name: 'h2', size: 20 },
{ content: <h3>{sentence}</h3>, lineHeight: 28, name: 'h3', size: 18 },
{ content: <h4>{sentence}</h4>, lineHeight: 24, name: 'h4', size: 16 },
{ content: <h5>{sentence}</h5>, lineHeight: 21, name: 'h5', size: 14 },
{ content: <h6>{sentence}</h6>, lineHeight: 18, name: 'h6', size: 12 },
];

return (
<table className="ids-table">
<caption className="ids-table__caption">Header</caption>
<thead className="ids-table__header">
<tr className="ids-table__row">
<th className="ids-table__header-cell">Sentence</th>
<th className="ids-table__header-cell">Tag</th>
<th className="ids-table__header-cell">Name</th>
<th className="ids-table__header-cell">Style</th>
<th className="ids-table__header-cell">Weight</th>
<th className="ids-table__header-cell">Size</th>
<th className="ids-table__header-cell">Line-height</th>
</tr>
</thead>
<tbody className="ids-table__body">
{headers.map(({ name, content, size, lineHeight }) => {
return (
<tr className="ids-table__row" key={name}>
<td className="ids-table__cell">{content}</td>
<td className="ids-table__cell">{name}</td>
<td className="ids-table__cell">Work sans</td>
<td className="ids-table__cell">normal</td>
<td className="ids-table__cell">semi-bold</td>
<td className="ids-table__cell">{size}px</td>
<td className="ids-table__cell">{lineHeight}px</td>
</tr>
);
})}
</tbody>
</table>
);
};

export default TypographyHeaders;
55 changes: 55 additions & 0 deletions stories/typography/TypographyLinks.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from 'react';

const TypographyLinks = () => {
const sentence = 'The quick brown fox jumps over the lazy dog';
const fontSizesLinks = [
{ lineHeight: 24, name: 'l', size: 16 },
{ lineHeight: 21, name: 'm', size: 14 },
{ lineHeight: 18, name: 's', size: 12 },
{ lineHeight: 15, name: 'xs', size: 10 },
];
const fontWeights = [
{ name: 'normal', weight: '400' },
{ name: 'semi', weight: '600' },
];

return (
<table className="ids-table">
<caption className="ids-table__caption">Header</caption>
<thead className="ids-table__header">
<tr className="ids-table__row">
<th className="ids-table__header-cell">Sentence</th>
<th className="ids-table__header-cell">Name</th>
<th className="ids-table__header-cell">Style</th>
<th className="ids-table__header-cell">Weight</th>
<th className="ids-table__header-cell">Size</th>
<th className="ids-table__header-cell">Line-height</th>
</tr>
</thead>
<tbody className="ids-table__body">
{fontWeights.map(({ name: weightName, weight }) => {
return fontSizesLinks.map(({ name: sizeName, size, lineHeight }) => {
const className = `link-${sizeName}-${weightName} ids-link`;

return (
<tr className="ids-table__row" key={className}>
<td className="ids-table__cell">
<a className={className} href="#">
{sentence}
</a>
</td>
<td className="ids-table__cell">Work sans</td>
<td className="ids-table__cell">normal</td>
<td className="ids-table__cell">{weight}</td>
<td className="ids-table__cell">{size}px</td>
<td className="ids-table__cell">{lineHeight}px</td>
</tr>
);
});
})}
</tbody>
</table>
);
};

export default TypographyLinks;
92 changes: 92 additions & 0 deletions stories/typography/typography.styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
@use '../../packages/assets/src/scss/functions/calculate.rem' as *;
@use '../../packages/assets/src/scss/variables/colors' as *;
@use '../../packages/assets/src/scss/variables/typography' as *;

$font-sizes-base: (
'2xl': $text-font-size-2xl,
'xl': $text-font-size-xl,
'l': $text-font-size-l,
'm': $text-font-size-m,
's': $text-font-size-s,
'xs': $text-font-size-xs
);
$font-sizes-highlighted: (
'3xl': $text-font-size-3xl,
'2xl': $text-font-size-2xl,
'xl': $text-font-size-xl,
'l': $text-font-size-l,
'm': $text-font-size-m,
's': $text-font-size-s
);
$font-sizes-links: (
'l': $text-font-size-l,
'm': $text-font-size-m,
's': $text-font-size-s,
'xs': $text-font-size-xs
);
$font-weights: (
'normal': $text-font-weight-normal,
'semi': $text-font-weight-semi
);
$font-styles: (
'normal': normal,
'italic': italic
);

.dev-typography-container {
display: flex;
flex-direction: column;
justify-content: center;
gap: calculateRem(32px);

.ids-table,
.ids-table .ids-table__header-cell,
.ids-table .ids-table__cell {
border: calculateRem(1px) solid $color-neutral-240;
}

.ids-table .ids-table__header-cell,
.ids-table .ids-table__cell {
padding: calculateRem(4px) calculateRem(16px);
}

.ids-table .ids-table__caption {
caption-side: top;
font-size: $text-font-size-2xl;
font-weight: $text-font-weight-semi;
}

@each $weight-name, $weight in $font-weights {
@each $style-name, $style in $font-styles {
@each $size-name, $size in $font-sizes-base {
.base-#{$size-name}-#{$weight-name}-#{$style-name} {
font-size: $size;
font-weight: $weight;
font-style: $style;
font-family: $font-family;
}
}
}
}

@each $weight-name, $weight in $font-weights {
@each $size-name, $size in $font-sizes-highlighted {
.base-#{$size-name}-#{$weight-name}-normal {
font-size: $size;
font-weight: $weight;
font-style: normal;
font-family: $font-family-alt;
}
}
}

@each $weight-name, $weight in $font-weights {
@each $size-name, $size in $font-sizes-links {
.link-#{$size-name}-#{$weight-name} {
font-size: $size;
font-weight: $weight;
font-family: $font-family-alt;
}
}
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"@ids-types/*": ["./types/*"]
}
},
"include": ["src/**/*", ".storybook/*", "types/*", "stories/*"]
"include": ["src/**/*", ".storybook/*", "types/*", "stories/**/*"]
}