From 1fb88b6fc003e2f76aa7ad87448c6add76d3575e Mon Sep 17 00:00:00 2001 From: ccedrone <77400920+ccedrone@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:42:00 -0500 Subject: [PATCH] fix: Updates to the Expressive font styles for both desktop and mobile (#1167) Co-authored-by: Laura Silva --- .changeset/fix-expressiveText.md | 5 + .../components/Heading/Heading.stories.tsx | 189 +++++++++--------- .../Paragraph/Paragraph.stories.tsx | 55 +++-- .../src/components/Typography/index.tsx | 29 ++- packages/react-magma-dom/src/theme/magma.ts | 33 +-- .../src/pages/api-intro/styles-and-themes.mdx | 14 +- .../src/pages/design-intro/typography.mdx | 52 +++-- 7 files changed, 211 insertions(+), 166 deletions(-) create mode 100644 .changeset/fix-expressiveText.md diff --git a/.changeset/fix-expressiveText.md b/.changeset/fix-expressiveText.md new file mode 100644 index 000000000..101c589f3 --- /dev/null +++ b/.changeset/fix-expressiveText.md @@ -0,0 +1,5 @@ +--- +'react-magma-dom': patch +--- + +fix: Updates to the expressive font styles for both desktop and mobile. diff --git a/packages/react-magma-dom/src/components/Heading/Heading.stories.tsx b/packages/react-magma-dom/src/components/Heading/Heading.stories.tsx index 3f0fe6909..f2552808d 100644 --- a/packages/react-magma-dom/src/components/Heading/Heading.stories.tsx +++ b/packages/react-magma-dom/src/components/Heading/Heading.stories.tsx @@ -11,67 +11,136 @@ import { Meta } from '@storybook/react/types-6-0'; export default { component: Heading, title: 'Heading', + argTypes: { + isInverse: { + control: { + type: 'boolean', + }, + defaultValue: false, + }, + }, } as Meta; -export const Default = () => { +export const Default = args => { return ( - <> - Heading 1 (X-Large) - Productive - Heading 2 (Large) - Productive - Heading 3 (Medium) - Productive - Heading 4 (Small) - Productive - Heading 5 (X-Small) - Productive - Heading 6 (2X-Small) - Productive + + + Heading 1 (X-Large) - Productive + + + Heading 2 (Large) - Productive + + + Heading 3 (Medium) - Productive + + + Heading 4 (Small) - Productive + + + Heading 5 (X-Small) - Productive + + + Heading 6 (2X-Small) - Productive +
Heading 1 (2X-Large) - Expressive - + Heading 1 (X-Large) - Expressive - + Heading 2 (Large) - Expressive - + Heading 3 (Medium) - Expressive - + Heading 4 (Small) - Expressive - + Heading 5 (X-Small) - Expressive - + Heading 6 (2X-Small) - Expressive
- + Heading 1 (X-Large) - Narrative - + Heading 2 (Large) - Narrative - + Heading 3 (Medium) - Narrative - + Heading 4 (Small) - Narrative - + Heading 5 (X-Small) - Narrative - + Heading 6 (2X-Small) - Narrative - +
); }; -export const Colors = () => { +export const Colors = args => { return ( <> @@ -104,78 +173,4 @@ export const Colors = () => { ); }; -export const Inverse = () => { - return ( - - - Heading 1 (X-Large) - Productive - - - Heading 2 (Large) - Productive - - - Heading 3 (Medium) - Productive - - - Heading 4 (Small) - Productive - - - Heading 5 (X-Small) - Productive - - - Heading 6 (2X-Small) - Productive - -
- - Heading 1 (2X-Large) - Expressive - - - Heading 1 (X-Large) - Expressive - - - Heading 2 (Large) - Expressive - - - Heading 3 (Medium) - Expressive - - - Heading 4 (Small) - Expressive - - - Heading 5 (X-Small) - Expressive - - - Heading 6 (2X-Small) - Expressive - -
- ); -}; +Colors.parameters = { controls: { exclude: ['isInverse'] } }; diff --git a/packages/react-magma-dom/src/components/Paragraph/Paragraph.stories.tsx b/packages/react-magma-dom/src/components/Paragraph/Paragraph.stories.tsx index 0b6fea7d6..a786583ed 100644 --- a/packages/react-magma-dom/src/components/Paragraph/Paragraph.stories.tsx +++ b/packages/react-magma-dom/src/components/Paragraph/Paragraph.stories.tsx @@ -2,77 +2,94 @@ import React from 'react'; import { Paragraph } from '.'; import { TypographyContextVariant, TypographyVisualStyle } from '../Typography'; import { Meta } from '@storybook/react/types-6-0'; +import { Card } from '../..'; export default { component: Paragraph, title: 'Paragraph', + argTypes: { + isInverse: { + control: { + type: 'boolean', + }, + defaultValue: false, + }, + }, } as Meta; -export const Default = () => { +export const Default = args => { return ( - <> - - Body Large + + + Paragraph Body Large - - Body Medium + + Paragraph Body Medium - - Body Small + + Paragraph Body Small - - Body X-Small + + Paragraph Body X-Small - Narrative Large + Paragraph Narrative Large - Narrative Medium + Paragraph Narrative Medium - Narrative Small + Paragraph Narrative Small - Narrative X-Small + Paragraph Narrative X-Small - Expressive Large + Paragraph Expressive Large - Expressive Medium + Paragraph Expressive Medium - Expressive Small + Paragraph Expressive Small - Expressive X-Small + Paragraph Expressive X-Small - + ); }; diff --git a/packages/react-magma-dom/src/components/Typography/index.tsx b/packages/react-magma-dom/src/components/Typography/index.tsx index 5d94e0cc1..1c51b60ab 100644 --- a/packages/react-magma-dom/src/components/Typography/index.tsx +++ b/packages/react-magma-dom/src/components/Typography/index.tsx @@ -58,12 +58,23 @@ export function getBodyFontFamily(props) { } } -export const colorStyles = props => css` - color: ${props.isInverse - ? props.theme.colors.neutral100 - : props.contextVariant === 'expressive' - ? props.theme.colors.primary600 - : props.theme.colors.neutral700}; +export function getBaseFontColor(props, isHeading = false) { + if (props.isInverse) { + return props.theme.colors.neutral100; + } + + // Expressive headings use primary color + if ( + props.contextVariant === TypographyContextVariant.expressive && + isHeading + ) { + return props.theme.colors.primary600; + } + return props.theme.colors.neutral700; +} + +export const colorStyles = (props, isHeading: boolean) => css` + color: ${getBaseFontColor(props, isHeading)}; ${props.color === TypographyColor.danger && !props.isInverse && @@ -104,7 +115,7 @@ ${props.color === TypographyColor.subdued && `; const baseParagraphStyles = props => css` - ${colorStyles(props)} + ${colorStyles(props, false)} font-family: ${getBodyFontFamily(props)}; font-weight: normal; `; @@ -220,7 +231,7 @@ const baseHeadingStyles = props => css` transition: border 0.1s linear; } - ${colorStyles(props)} + ${colorStyles(props, true)} `; export const heading2XLargeStyles = props => css` @@ -378,6 +389,8 @@ export const headingMediumStyles = props => css` @media (min-width: ${props.theme.breakpoints.small}px) { font-size: ${props.theme.typographyExpressiveVisualStyles.headingMedium .desktop.fontSize}; + font-weight: ${props.theme.typographyExpressiveVisualStyles.headingMedium + .fontWeight}; line-height: ${props.theme.typographyExpressiveVisualStyles.headingMedium .desktop.lineHeight}; } diff --git a/packages/react-magma-dom/src/theme/magma.ts b/packages/react-magma-dom/src/theme/magma.ts index 60fe99d25..a23f11222 100644 --- a/packages/react-magma-dom/src/theme/magma.ts +++ b/packages/react-magma-dom/src/theme/magma.ts @@ -143,6 +143,7 @@ export interface TypeScale { size13: TypeScaleSize; size14: TypeScaleSize; size15: TypeScaleSize; + size16: TypeScaleSize; } export interface VisualStyle { @@ -354,11 +355,11 @@ const typeScale = { }, size11: { fontSize: '48px', - lineHeight: '56px', + lineHeight: '64px', }, size12: { fontSize: '52px', - lineHeight: '68px', + lineHeight: '64px', }, size13: { fontSize: '54px', @@ -369,6 +370,10 @@ const typeScale = { lineHeight: '72px', }, size15: { + fontSize: '64px', + lineHeight: '84px', + }, + size16: { fontSize: '72px', lineHeight: '84px', }, @@ -575,43 +580,43 @@ export const magma = { }, typographyExpressiveVisualStyles: { heading2XLarge: { - mobile: typeScale.size13, + mobile: typeScale.size11, desktop: typeScale.size15, - fontWeight: 600, + fontWeight: 500, }, headingXLarge: { - mobile: typeScale.size10, - desktop: typeScale.size12, - fontWeight: 400, + mobile: typeScale.size09, + desktop: typeScale.size11, + fontWeight: 600, }, headingLarge: { mobile: typeScale.size07, desktop: typeScale.size09, - fontWeight: 300, + fontWeight: 600, }, headingMedium: { mobile: typeScale.size06, desktop: typeScale.size07, - fontWeight: 300, + fontWeight: 600, }, headingSmall: { mobile: typeScale.size05, desktop: typeScale.size06, - fontWeight: 300, + fontWeight: 500, }, headingXSmall: { mobile: typeScale.size04, desktop: typeScale.size05, - fontWeight: 300, + fontWeight: 500, }, heading2XSmall: { mobile: typeScale.size03, - desktop: typeScale.size03, - fontWeight: 700, + desktop: typeScale.size04, + fontWeight: 500, }, bodyLarge: { mobile: typeScale.size05, - desktop: typeScale.size06, + desktop: typeScale.size05, }, bodyMedium: { mobile: typeScale.size03, diff --git a/website/react-magma-docs/src/pages/api-intro/styles-and-themes.mdx b/website/react-magma-docs/src/pages/api-intro/styles-and-themes.mdx index a2f5b60c7..1d8e42e3f 100644 --- a/website/react-magma-docs/src/pages/api-intro/styles-and-themes.mdx +++ b/website/react-magma-docs/src/pages/api-intro/styles-and-themes.mdx @@ -516,24 +516,24 @@ typographyVisualStyles: { }, typographyExpressiveVisualStyles: { heading2XLarge: { - mobile: typeScale.size13, + mobile: typeScale.size11, desktop: typeScale.size15, - fontWeight: 600, + fontWeight: 500, }, headingXLarge: { - mobile: typeScale.size10, - desktop: typeScale.size12, - fontWeight: 400, + mobile: typeScale.size09, + desktop: typeScale.size11, + fontWeight: 600, }, headingLarge: { mobile: typeScale.size07, desktop: typeScale.size09, - fontWeight: 300, + fontWeight: 600, }, headingMedium: { mobile: typeScale.size06, desktop: typeScale.size07, - fontWeight: 300, + fontWeight: 600, }, ... }, diff --git a/website/react-magma-docs/src/pages/design-intro/typography.mdx b/website/react-magma-docs/src/pages/design-intro/typography.mdx index 9135a22b9..9370d0995 100644 --- a/website/react-magma-docs/src/pages/design-intro/typography.mdx +++ b/website/react-magma-docs/src/pages/design-intro/typography.mdx @@ -292,7 +292,7 @@ Expressive type is reserved for use in editorial and digital marketing experienc Body / Large

Typeface: Work Sans

-

Size: 24px / 1.5em

+

Size: 20px / 1.5em

Line-height: 32px / 2em

Weight: Regular / 400

Letter-spacing: 0px

@@ -331,9 +331,9 @@ Expressive type is reserved for use in editorial and digital marketing experienc Heading / 2X-Large

Typeface: Work Sans

-

Size: 72px / 4.5em

+

Size: 64px / 4em

Line-height: 84px / 5.25em

-

Weight: Semibold / 600

+

Weight: Medium / 500

Letter-spacing: 0px

@@ -341,9 +341,9 @@ Expressive type is reserved for use in editorial and digital marketing experienc Heading / 2X-Large

Typeface: Work Sans

-

Size: 54px / 3.375em

+

Size: 48px / 3em

Line-height: 64px / 4em

-

Weight: Semibold / 600

+

Weight: Medium / 500

Letter-spacing: 0px

@@ -362,9 +362,9 @@ Expressive type is reserved for use in editorial and digital marketing experienc Heading / X-Large

Typeface: Work Sans

-

Size: 52px / 3.25em

-

Line-height: 68px / 4.25em

-

Weight: Regular / 400

+

Size: 48px / 3em

+

Line-height: 64px / 4em

+

Weight: Semibold / 600

Letter-spacing: 0px

@@ -372,9 +372,9 @@ Expressive type is reserved for use in editorial and digital marketing experienc Heading / X-Large

Typeface: Work Sans

-

Size: 42px / 2.625em

+

Size: 36px / 2.25em

Line-height: 48px / 3em

-

Weight: Regular / 400

+

Weight: Semibold / 600

Letter-spacing: 0px

@@ -395,7 +395,7 @@ Expressive type is reserved for use in editorial and digital marketing experienc

Typeface: Work Sans

Size: 36px / 2.25em

Line-height: 48px / 3em

-

Weight: Light / 300

+

Weight: Semibold / 600

Letter-spacing: 0px

@@ -405,7 +405,7 @@ Expressive type is reserved for use in editorial and digital marketing experienc

Typeface: Work Sans

Size: 28px / 1.75em

Line-height: 40px / 2.5em

-

Weight: Light / 300

+

Weight: Semibold / 600

Letter-spacing: 0px

@@ -426,7 +426,7 @@ Expressive type is reserved for use in editorial and digital marketing experienc

Typeface: Work Sans

Size: 28px / 1.75em

Line-height: 40px / 2.5em

-

Weight: Light / 300

+

Weight: Semibold / 600

Letter-spacing: 0px

@@ -436,7 +436,7 @@ Expressive type is reserved for use in editorial and digital marketing experienc

Typeface: Work Sans

Size: 24px / 1.5em

Line-height: 32px / 2em

-

Weight: Light / 300

+

Weight: Semibold / 600

Letter-spacing: 0px

@@ -457,7 +457,7 @@ Expressive type is reserved for use in editorial and digital marketing experienc

Typeface: Work Sans

Size: 24px / 1.5em

Line-height: 32px / 2em

-

Weight: Light / 300

+

Weight: Medium / 500

Letter-spacing: 0px

@@ -465,9 +465,9 @@ Expressive type is reserved for use in editorial and digital marketing experienc Heading / Small

Typeface: Work Sans

-

Size: 20px / 1.5em

+

Size: 20px / 1.25em

Line-height: 32px / 2em

-

Weight: Light / 300

+

Weight: Medium / 500

Letter-spacing: 0px

@@ -488,7 +488,7 @@ Expressive type is reserved for use in editorial and digital marketing experienc

Typeface: Work Sans

Size: 20px / 1.25em

Line-height: 32px / 2em

-

Weight: Light / 300

+

Weight: Medium / 500

Letter-spacing: 0px

@@ -498,7 +498,7 @@ Expressive type is reserved for use in editorial and digital marketing experienc

Typeface: Work Sans

Size: 18px / 1.25em

Line-height: 24px / 1.5em

-

Weight: Light / 300

+

Weight: Medium / 500

Letter-spacing: 0px

@@ -512,14 +512,24 @@ Expressive type is reserved for use in editorial and digital marketing experienc This is used for layout headings and component titles
-
+
+

+ Heading / 2X-Small +

+

Typeface: Work Sans

+

Size: 18px / 1.125em

+

Line-height: 24px / 1.5em

+

Weight: Medium / 500

+

Letter-spacing: .32px

+
+

Heading / 2X-Small

Typeface: Work Sans

Size: 16px / 1em

Line-height: 24px / 1.5em

-

Weight: Bold / 700

+

Weight: Medium / 500

Letter-spacing: .32px