Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(typography): font tokens and utilities - FRONT-4696 #3740

Draft
wants to merge 3 commits into
base: v5-dev
Choose a base branch
from
Draft
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
120 changes: 107 additions & 13 deletions src/implementations/twig/utilities/typography/index.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const getArgs = (data, story) => {
args.colour = 'ecl-u-type-color-dark';
}
if (story === 'text-style') {
args.bold = false;
args.size = 'ecl-u-type-m';
args.weight = 'ecl-u-type-weight-regular';
args.style = 'ecl-u-type-none';
args.alignment = 'ecl-u-type-align-left';
}
Expand Down Expand Up @@ -75,18 +76,109 @@ const getArgTypes = (story) => {
},
};
} else if (story === 'text-style') {
argTypes.bold = {
name: 'Bold text',
description: 'Set the text size to bold',
type: 'boolean',
argTypes.size = {
name: 'Font size',
description: 'Choose different font sizes',
type: 'select',
options: [
'ecl-u-type-xs',
'ecl-u-type-s',
'ecl-u-type-m',
'ecl-u-type-l',
'ecl-u-type-xl',
'ecl-u-type-2xl',
'ecl-u-type-3xl',
'ecl-u-type-4xl',
'ecl-u-type-5xl',
'ecl-u-type-6xl',
'ecl-u-type-7xl',
'ecl-u-type-8xl',
'ecl-u-type-9xl',
'ecl-u-type-10xl',
],
control: {
labels: {
'ecl-u-type-xs': 'xs',
'ecl-u-type-s': 's',
'ecl-u-type-m': 'm',
'ecl-u-type-l': 'l',
'ecl-u-type-xl': 'xl',
'ecl-u-type-2xl': '2xl',
'ecl-u-type-3xl': '3xl',
'ecl-u-type-4xl': '4xl',
'ecl-u-type-5xl': '5xl',
'ecl-u-type-6xl': '6xl',
'ecl-u-type-7xl': '7xl',
'ecl-u-type-8xl': '8xl',
'ecl-u-type-9xl': '9xl',
'ecl-u-type-10xl': '10xl',
},
},
table: {
type: { summary: 'string' },
defaultValue: { summary: '' },
category: 'Styles',
},
mapping: {
xs: 'ecl-u-type-xs',
s: 'ecl-u-type-s',
m: 'ecl-u-type-m',
l: 'ecl-u-type-l',
xl: 'ecl-u-type-xl',
'2xl': 'ecl-u-type-2xl',
'3xl': 'ecl-u-type-3xl',
'4xl': 'ecl-u-type-4xl',
'5xl': 'ecl-u-type-5xl',
'6xl': 'ecl-u-type-6xl',
'7xl': 'ecl-u-type-7xl',
'8xl': 'ecl-u-type-8xl',
'9xl': 'ecl-u-type-9xl',
'10xl': 'ecl-u-type-10xl',
},
};
argTypes.weight = {
name: 'Font weight',
description: 'Choose different font weights',
type: 'select',
options: [
'ecl-u-type-weight-thin',
'ecl-u-type-weight-extra-light',
'ecl-u-type-weight-light',
'ecl-u-type-weight-regular',
'ecl-u-type-weight-medium',
'ecl-u-type-weight-semi-bold',
'ecl-u-type-weight-bold',
'ecl-u-type-weight-extra-bold',
'ecl-u-type-weight-black',
],
control: {
labels: {
'ecl-u-type-weight-thin': 'thin',
'ecl-u-type-weight-extra-light': 'extra light',
'ecl-u-type-weight-light': 'light',
'ecl-u-type-weight-regular': 'regular',
'ecl-u-type-weight-medium': 'medium',
'ecl-u-type-weight-semi-bold': 'semi bold',
'ecl-u-type-weight-bold': 'bold',
'ecl-u-type-weight-extra-bold': 'extra-bold',
'ecl-u-type-weight-black': 'black',
},
},
table: {
type: { summary: 'string' },
defaultValue: { summary: '' },
category: 'Styles',
},
mapping: {
0: false,
1: true,
thin: 'ecl-u-type-weight-thin',
'extra light': 'ecl-u-type-weight-extra-light',
light: 'ecl-u-type-weight-light',
regular: 'ecl-u-type-weight-regular',
medium: 'ecl-u-type-weight-medium',
'semi bold': 'ecl-u-type-weight-semi-bold',
bold: 'ecl-u-type-weight-bold',
'extra bold': 'ecl-u-type-weight-extra-bold',
black: 'ecl-u-type-weight-black',
},
};
argTypes.style = {
Expand All @@ -95,6 +187,7 @@ const getArgTypes = (story) => {
type: 'select',
options: [
'ecl-u-type-none',
'ecl-u-type-italic',
'ecl-u-type-lowercase',
'ecl-u-type-uppercase',
'ecl-u-type-capitalize',
Expand All @@ -105,6 +198,7 @@ const getArgTypes = (story) => {
control: {
labels: {
'ecl-u-type-none': 'default',
'ecl-u-type-italic': 'italic',
'ecl-u-type-lowercase': 'lowercase',
'ecl-u-type-uppercase': 'uppercase',
'ecl-u-type-capitalize': 'capitalize',
Expand All @@ -120,6 +214,7 @@ const getArgTypes = (story) => {
},
mapping: {
default: 'ecl-u-type-none',
italic: 'ecl-u-type-italic',
lowercase: 'ecl-u-type-lowercase',
uppercase: 'ecl-u-type-uppercase',
capitalize: 'ecl-u-type-capitalize',
Expand Down Expand Up @@ -185,6 +280,7 @@ Paragraph.args = getArgs(demoContentParagraph, 'paragraph');
Paragraph.argTypes = getArgTypes('paragraph');

export const Heading = (args) => `
<div class="ecl-u-type-display">Display. ${args.content}</h1>
<h1 class="ecl-u-type-heading-1">H1. ${args.content}</h1>
<h2 class="ecl-u-type-heading-2">H2. ${args.content}</h2>
<h3 class="ecl-u-type-heading-3">H3. ${args.content}</h3>
Expand All @@ -208,18 +304,16 @@ TextColour.args = getArgs(demoContentParagraph, 'text-colour');
TextColour.argTypes = getArgTypes('text-colour');

export const TextStyle = (args) => `
<p
<div
class="${classnames(
'ecl-u-type-paragraph-m',
args.size,
args.weight,
args.style,
args.alignment,
{
[`ecl-u-type-bold`]: args.bold,
},
)}"
>
${args.content}
</p>
</div>
`;

TextStyle.storyName = 'text style';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ $typography-print: null !default;
/*
* Headings
*/
.ecl-u-type-display {
color: map.get($typography, 'heading-color');
font: map.get($typography-print, 'display') !important;
font-family: #{map.get($theme, 'font-family-print', 'alt')} !important;
font-weight: map.get($typography, 'display', 'font-weight') !important;
margin: map.get($typography-print, 'heading-margin');
}

.ecl-u-type-heading-1,
%ecl-heading-1 {
color: map.get($typography, 'heading-color');
font: map.get($typography-print, 'heading1') !important;
font-family: #{map.get($theme, 'font-family-print', 'alt')} !important;
font-weight: map.get($theme, 'font-weight', 'bold') !important;
font-weight: map.get($typography, 'heading1', 'font-weight') !important;
margin: map.get($typography-print, 'heading-margin');
}

Expand All @@ -26,7 +34,7 @@ $typography-print: null !default;
color: map.get($typography, 'heading-color');
font: map.get($typography-print, 'heading2') !important;
font-family: #{map.get($theme, 'font-family-print', 'alt')} !important;
font-weight: map.get($theme, 'font-weight-print', 'bold') !important;
font-weight: map.get($typography, 'heading2', 'font-weight') !important;
margin: map.get($typography-print, 'heading-margin');
}

Expand All @@ -35,7 +43,7 @@ $typography-print: null !default;
color: map.get($typography, 'heading-color');
font: map.get($typography-print, 'heading3') !important;
font-family: #{map.get($theme, 'font-family-print', 'alt')} !important;
font-weight: map.get($theme, 'font-weight-print', 'bold') !important;
font-weight: map.get($typography, 'heading3', 'font-weight') !important;
margin: map.get($typography-print, 'heading-margin');
}

Expand All @@ -44,7 +52,7 @@ $typography-print: null !default;
color: map.get($typography, 'heading-color');
font: map.get($typography-print, 'heading4') !important;
font-family: #{map.get($theme, 'font-family-print', 'alt')} !important;
font-weight: map.get($theme, 'font-weight-print', 'bold') !important;
font-weight: map.get($typography, 'heading4', 'font-weight') !important;
margin: map.get($typography-print, 'heading-margin');
}

Expand All @@ -53,7 +61,7 @@ $typography-print: null !default;
color: map.get($typography, 'heading-color');
font: map.get($typography-print, 'heading5') !important;
font-family: #{map.get($theme, 'font-family-print', 'alt')} !important;
font-weight: map.get($theme, 'font-weight-print', 'bold') !important;
font-weight: map.get($typography, 'heading5', 'font-weight') !important;
margin: map.get($typography-print, 'heading-margin');
}

Expand All @@ -62,7 +70,7 @@ $typography-print: null !default;
color: map.get($typography, 'heading-color');
font: map.get($typography-print, 'heading6') !important;
font-family: #{map.get($theme, 'font-family-print', 'alt')} !important;
font-weight: map.get($theme, 'font-weight-print', 'bold') !important;
font-weight: map.get($typography, 'heading6', 'font-weight') !important;
margin: map.get($typography-print, 'heading-margin');
}

Expand Down Expand Up @@ -94,64 +102,10 @@ $typography-print: null !default;
/*
* Font size
*/
.ecl-u-type-xs {
font: map.get($theme, 'font-print', 'xs') !important;
}

.ecl-u-type-s {
font: map.get($theme, 'font-print', 's') !important;
}

.ecl-u-type-m {
font: map.get($theme, 'font-print', 'm') !important;
}

.ecl-u-type-l {
font: map.get($theme, 'font-print', 'l') !important;
}

.ecl-u-type-xl {
font: map.get($theme, 'font-print', 'xl') !important;
}

.ecl-u-type-2xl {
font: map.get($theme, 'font-print', '2xl') !important;
}

.ecl-u-type-3xl {
font: map.get($theme, 'font-print', '3xl') !important;
}

.ecl-u-type-4xl {
font: map.get($theme, 'font-print', '4xl') !important;
}

.ecl-u-type-5xl {
font: map.get($theme, 'font-print', '5xl') !important;
}

.ecl-u-type-6xl {
font: map.get($theme, 'font-print', '6xl') !important;
}

.ecl-u-type-prolonged-xs {
font: map.get($theme, 'font-prolonged-print', 'xs') !important;
}

.ecl-u-type-prolonged-s {
font: map.get($theme, 'font-prolonged-print', 's') !important;
}

.ecl-u-type-prolonged-m {
font: map.get($theme, 'font-prolonged-print', 'm') !important;
}

.ecl-u-type-prolonged-l {
font: map.get($theme, 'font-prolonged-print', 'l') !important;
}

.ecl-u-type-prolonged-xl {
font: map.get($theme, 'font-prolonged-print', 'xl') !important;
@each $key, $value in map.get($theme, 'font-print') {
.ecl-u-type-#{$key} {
font: map.get($theme, 'font-print', $key) !important;
}
}

/*
Expand All @@ -170,16 +124,17 @@ $typography-print: null !default;
}

/*
* Font style
* Font weight
*/
.ecl-u-type-regular {
font-weight: map.get($theme, 'font-weight-print', 'regular') !important;
}

.ecl-u-type-bold {
font-weight: map.get($theme, 'font-weight-print', 'bold') !important;
@each $key, $value in map.get($theme, 'font-weight') {
.ecl-u-type-weight-#{$key} {
font-weight: $value !important;
}
}

/*
* Font style
*/
.ecl-u-type-capitalize {
text-transform: capitalize !important;
}
Expand Down
Loading
Loading