From 8a1c342d8743785e3b5a3339f34bcaab15e56265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kry=C5=A1p=C3=ADn?= Date: Sat, 7 Sep 2024 08:51:46 +0200 Subject: [PATCH] BREAKING CHANGE(web-twig): Switch Link, Heading and Text to v3 design tokens #DS-1451 Remove inverted Link variant and introduce emphasis in Heading. --- .../components/Heading/Heading.stories.twig | 4 ++ .../Resources/components/Heading/Heading.twig | 3 +- .../Resources/components/Heading/README.md | 55 ++++++++++++++---- .../__fixtures__/headingDefault.twig | 16 +++++- .../headingDefault.twig.snap.html | 13 ++++- .../Heading/stories/HeadingEmphasis.twig | 7 +++ .../__tests__/__fixtures__/linkDefault.twig | 2 +- .../__snapshots__/linkDefault.twig.snap.html | 2 +- .../components/Link/stories/LinkColors.twig | 4 +- .../components/Link/stories/LinkDisabled.twig | 4 +- .../src/Resources/components/Text/README.md | 57 +++++++++++++++---- .../src/Resources/components/Text/Text.twig | 2 +- .../__tests__/__fixtures__/textDefault.twig | 5 ++ .../__snapshots__/textDefault.twig.snap.html | 11 +++- .../components/Text/stories/TextEmphasis.twig | 2 + .../UNSTABLE_EmptyState.twig.snap.html | 4 +- 16 files changed, 150 insertions(+), 41 deletions(-) create mode 100644 packages/web-twig/src/Resources/components/Heading/stories/HeadingEmphasis.twig diff --git a/packages/web-twig/src/Resources/components/Heading/Heading.stories.twig b/packages/web-twig/src/Resources/components/Heading/Heading.stories.twig index a0b32b032e..d2b6b29257 100644 --- a/packages/web-twig/src/Resources/components/Heading/Heading.stories.twig +++ b/packages/web-twig/src/Resources/components/Heading/Heading.stories.twig @@ -10,4 +10,8 @@ {% include '@components/Heading/stories/HeadingSizes.twig' %} + + {% include '@components/Heading/stories/HeadingEmphasis.twig' %} + + {% endblock %} diff --git a/packages/web-twig/src/Resources/components/Heading/Heading.twig b/packages/web-twig/src/Resources/components/Heading/Heading.twig index ea82df3b71..de6706ea18 100644 --- a/packages/web-twig/src/Resources/components/Heading/Heading.twig +++ b/packages/web-twig/src/Resources/components/Heading/Heading.twig @@ -1,10 +1,11 @@ {# API #} {%- set props = props | default([]) -%} +{%- set _emphasis = props.emphasis | default('bold') -%} {%- set _size = props.size | default('medium') -%} {%- set _elementType = props.elementType | default('div') -%} {# Class names #} -{%- set _rootClassName = _spiritClassPrefix ~ 'typography-heading-' ~ _size ~ '-text' -%} +{%- set _rootClassName = _spiritClassPrefix ~ 'typography-heading-' ~ _size ~ '-' ~ _emphasis -%} {# Miscellaneous #} {%- set _styleProps = useStyleProps(props) -%} diff --git a/packages/web-twig/src/Resources/components/Heading/README.md b/packages/web-twig/src/Resources/components/Heading/README.md index ff8e44f289..8fda3593ef 100644 --- a/packages/web-twig/src/Resources/components/Heading/README.md +++ b/packages/web-twig/src/Resources/components/Heading/README.md @@ -2,27 +2,60 @@ This is Twig implementation of the [Heading][heading] component. -Basic example usage: +## Basic Usage ```twig -Heading +This is a heading ``` -Advanced example usage: +## Element Type + +Use the `elementType` prop to set the HTML tag of the Heading component. + +```twig + + Heading + +``` + +## Size + +Use the `size` prop to set the size of the text. + +```twig + + Heading + +``` + +## Emphasis + +Use the `emphasis` prop to set the emphasis of the text. + +⚠️ This prop only affects styling, not the semantics of the element. + +```twig +Semibold heading +``` + +## Full Example ```twig -Text content + + Heading + ``` -Without lexer: +## Without Lexer ```twig {% embed "@spirit/heading.twig" with { props: { - size: 'medium' + emphasis: 'semibold', + size: 'medium' }} %} - {% block content %} - Text content - {% endblock %} + {% block content %} + Text content + {% endblock %} {% endembed %} ``` @@ -32,12 +65,14 @@ Without lexer: | ------------- | ------------------------------------------- | -------- | -------- | -------------------------------------------------------------- | | `size` | [Size Extended dictionary][dictionary-size] | `medium` | ✕ | Size of the text | | `elementType` | `string` | `div` | ✕ | HTML tag to render | -| `translate` | [`yes` \| `no` \| `''`] | `null` | ✕ | Set to `no` to disable machine translation of the text content | +| `emphasis` | [Emphasis dictionary][dictionary-emphasis] | `bold` | ✕ | Emphasis of the text | +| `translate` | \[`yes` \| `no` \| `''`] | `null` | ✕ | Set to `no` to disable machine translation of the text content | On top of the API options, the components accept [additional attributes][readme-additional-attributes]. If you need more control over the styling of a component, you can use [style props][readme-style-props] and [escape hatches][readme-escape-hatches]. +[dictionary-emphasis]: https://github.com/lmc-eu/spirit-design-system/tree/main/docs/DICTIONARIES.md#emphasis [dictionary-size]: https://github.com/lmc-eu/spirit-design-system/tree/main/docs/DICTIONARIES.md#size [heading]: https://github.com/lmc-eu/spirit-design-system/tree/main/packages/web-react/src/components/Heading [readme-additional-attributes]: https://github.com/lmc-eu/spirit-design-system/blob/main/packages/web-twig/README.md#additional-attributes diff --git a/packages/web-twig/src/Resources/components/Heading/__tests__/__fixtures__/headingDefault.twig b/packages/web-twig/src/Resources/components/Heading/__tests__/__fixtures__/headingDefault.twig index 748d3cf9cb..ad949c40bc 100644 --- a/packages/web-twig/src/Resources/components/Heading/__tests__/__fixtures__/headingDefault.twig +++ b/packages/web-twig/src/Resources/components/Heading/__tests__/__fixtures__/headingDefault.twig @@ -1,9 +1,23 @@ Example heading + + Example heading - + + + + Example heading + + + + Example heading diff --git a/packages/web-twig/src/Resources/components/Heading/__tests__/__snapshots__/headingDefault.twig.snap.html b/packages/web-twig/src/Resources/components/Heading/__tests__/__snapshots__/headingDefault.twig.snap.html index ef9892fb10..7065f4eafb 100644 --- a/packages/web-twig/src/Resources/components/Heading/__tests__/__snapshots__/headingDefault.twig.snap.html +++ b/packages/web-twig/src/Resources/components/Heading/__tests__/__snapshots__/headingDefault.twig.snap.html @@ -5,16 +5,23 @@ -
+
Example heading
+ -

+

Example heading

+ -
+
Example heading
+ + +

+ Example heading +

diff --git a/packages/web-twig/src/Resources/components/Heading/stories/HeadingEmphasis.twig b/packages/web-twig/src/Resources/components/Heading/stories/HeadingEmphasis.twig new file mode 100644 index 0000000000..ae22017053 --- /dev/null +++ b/packages/web-twig/src/Resources/components/Heading/stories/HeadingEmphasis.twig @@ -0,0 +1,7 @@ +Heading regular + +Heading semibold + +Heading bold + +Heading italic diff --git a/packages/web-twig/src/Resources/components/Link/__tests__/__fixtures__/linkDefault.twig b/packages/web-twig/src/Resources/components/Link/__tests__/__fixtures__/linkDefault.twig index c0aa1b77c2..e1dbd13a66 100644 --- a/packages/web-twig/src/Resources/components/Link/__tests__/__fixtures__/linkDefault.twig +++ b/packages/web-twig/src/Resources/components/Link/__tests__/__fixtures__/linkDefault.twig @@ -12,7 +12,7 @@ Example link Example link Example link - Example link + Example link diff --git a/packages/web-twig/src/Resources/components/Link/stories/LinkColors.twig b/packages/web-twig/src/Resources/components/Link/stories/LinkColors.twig index a621a8178f..fff7e609d3 100644 --- a/packages/web-twig/src/Resources/components/Link/stories/LinkColors.twig +++ b/packages/web-twig/src/Resources/components/Link/stories/LinkColors.twig @@ -2,6 +2,4 @@ Secondary Link - - Inverted Link - +Tertiary Link diff --git a/packages/web-twig/src/Resources/components/Link/stories/LinkDisabled.twig b/packages/web-twig/src/Resources/components/Link/stories/LinkDisabled.twig index 7ce10f23b8..8c162b9b2f 100644 --- a/packages/web-twig/src/Resources/components/Link/stories/LinkDisabled.twig +++ b/packages/web-twig/src/Resources/components/Link/stories/LinkDisabled.twig @@ -2,6 +2,4 @@ Secondary Disabled Link - - Inverted Disabled Link - +Tertiary Disabled Link diff --git a/packages/web-twig/src/Resources/components/Text/README.md b/packages/web-twig/src/Resources/components/Text/README.md index a0ac049414..735cf1ddec 100644 --- a/packages/web-twig/src/Resources/components/Text/README.md +++ b/packages/web-twig/src/Resources/components/Text/README.md @@ -2,28 +2,60 @@ This is Twig implementation of the [Text][text] component. -Basic example usage: +## Basic Usage ```twig -Text content +This is a text ``` -Advanced example usage: +## Element Type + +Use the `elementType` prop to set the HTML tag of the Text component. + +```twig + + Text + +``` + +## Size + +Use the `size` prop to set the size of the text. + +```twig + + Text + +``` + +## Emphasis + +Use the `emphasis` prop to set the emphasis of the text. + +⚠️ This prop only affects styling, not the semantics of the element. + +```twig +Bold text +``` + +## Full Example ```twig -Text content + + Text + ``` -Without lexer: +## Without Lexer ```twig {% embed "@spirit/text.twig" with { props: { - size: 'medium' - emphasis: 'bold' + emphasis: 'bold', + size: 'medium' }} %} - {% block content %} - Text content - {% endblock %} + {% block content %} + Text content + {% endblock %} {% endembed %} ``` @@ -32,14 +64,15 @@ Without lexer: | Name | Type | Default | Required | Description | | ------------- | ------------------------------------------- | --------- | -------- | -------------------------------------------------------------- | | `elementType` | `string` | `p` | ✕ | HTML tag to render | -| `emphasis` | [`regular` \| `bold` \| `italic`] | `regular` | ✕ | Emphasis of the text | +| `emphasis` | [Emphasis dictionary][dictionary-emphasis] | `regular` | ✕ | Emphasis of the text | | `size` | [Size Extended dictionary][dictionary-size] | `medium` | ✕ | Size of the text | -| `translate` | [`yes` \| `no` \| `''`] | `null` | ✕ | Set to `no` to disable machine translation of the text content | +| `translate` | \[`yes` \| `no` \| `''`] | `null` | ✕ | Set to `no` to disable machine translation of the text content | On top of the API options, the components accept [additional attributes][readme-additional-attributes]. If you need more control over the styling of a component, you can use [style props][readme-style-props] and [escape hatches][readme-escape-hatches]. +[dictionary-emphasis]: https://github.com/lmc-eu/spirit-design-system/tree/main/docs/DICTIONARIES.md#emphasis [dictionary-size]: https://github.com/lmc-eu/spirit-design-system/tree/main/docs/DICTIONARIES.md#size [readme-additional-attributes]: https://github.com/lmc-eu/spirit-design-system/blob/main/packages/web-twig/README.md#additional-attributes [readme-escape-hatches]: https://github.com/lmc-eu/spirit-design-system/blob/main/packages/web-twig/README.md#escape-hatches diff --git a/packages/web-twig/src/Resources/components/Text/Text.twig b/packages/web-twig/src/Resources/components/Text/Text.twig index 980cf83b60..04477b4989 100644 --- a/packages/web-twig/src/Resources/components/Text/Text.twig +++ b/packages/web-twig/src/Resources/components/Text/Text.twig @@ -5,7 +5,7 @@ {%- set _elementType = props.elementType | default('p') -%} {# Class names #} -{%- set _rootClassName = _spiritClassPrefix ~ 'typography-body-' ~ _size ~ '-text-' ~ _emphasis -%} +{%- set _rootClassName = _spiritClassPrefix ~ 'typography-body-' ~ _size ~ '-' ~ _emphasis -%} {# Miscellaneous #} {%- set _styleProps = useStyleProps(props) -%} diff --git a/packages/web-twig/src/Resources/components/Text/__tests__/__fixtures__/textDefault.twig b/packages/web-twig/src/Resources/components/Text/__tests__/__fixtures__/textDefault.twig index 85e57c8866..97b2443fef 100644 --- a/packages/web-twig/src/Resources/components/Text/__tests__/__fixtures__/textDefault.twig +++ b/packages/web-twig/src/Resources/components/Text/__tests__/__fixtures__/textDefault.twig @@ -5,6 +5,11 @@ Example text + + + Example text + + -

+

Example text

-
+
Example text
+ + +

+ Example text +

-
+
Example text
diff --git a/packages/web-twig/src/Resources/components/Text/stories/TextEmphasis.twig b/packages/web-twig/src/Resources/components/Text/stories/TextEmphasis.twig index 959bf884a7..afe0ccf2da 100644 --- a/packages/web-twig/src/Resources/components/Text/stories/TextEmphasis.twig +++ b/packages/web-twig/src/Resources/components/Text/stories/TextEmphasis.twig @@ -1,5 +1,7 @@ Text regular +Text semibold + Text bold Text italic diff --git a/packages/web-twig/src/Resources/components/UNSTABLE_EmptyState/__tests__/__snapshots__/UNSTABLE_EmptyState.twig.snap.html b/packages/web-twig/src/Resources/components/UNSTABLE_EmptyState/__tests__/__snapshots__/UNSTABLE_EmptyState.twig.snap.html index c8e9d2caca..29e8bd8637 100644 --- a/packages/web-twig/src/Resources/components/UNSTABLE_EmptyState/__tests__/__snapshots__/UNSTABLE_EmptyState.twig.snap.html +++ b/packages/web-twig/src/Resources/components/UNSTABLE_EmptyState/__tests__/__snapshots__/UNSTABLE_EmptyState.twig.snap.html @@ -15,11 +15,11 @@
-

+

Headline

-

+

In publishing and graphic design, lorem ipsum is common placeholder text used to demonstrate the graphic elements