diff --git a/packages/web-react/src/components/Heading/Heading.tsx b/packages/web-react/src/components/Heading/Heading.tsx index 8a32fa7626..7aad8c1acb 100644 --- a/packages/web-react/src/components/Heading/Heading.tsx +++ b/packages/web-react/src/components/Heading/Heading.tsx @@ -7,8 +7,9 @@ import { SpiritHeadingProps } from '../../types'; import { useHeadingStyleProps } from './useHeadingStyleProps'; const defaultProps: Partial = { - size: 'medium', elementType: 'div', + emphasis: 'bold', + size: 'medium', }; export const Heading = (props: SpiritHeadingProps): JSX.Element => { diff --git a/packages/web-react/src/components/Heading/README.md b/packages/web-react/src/components/Heading/README.md index 196f8b980d..638128ca9b 100644 --- a/packages/web-react/src/components/Heading/README.md +++ b/packages/web-react/src/components/Heading/README.md @@ -3,15 +3,34 @@ The Heading component provides helper classes to render headings. ```jsx - + ``` +With all props: + +```jsx + + Heading + +``` + +## Emphasis + +Use the `emphasis` prop to set the emphasis of the text. + +```jsx +Semibold heading +``` + +See [API](#api) for all available options. + ## API -| Name | Type | Default | Required | Description | -| ------------- | ------------------------------------------- | -------- | -------- | ---------------- | -| `elementType` | `React.Element` | `div` | ✕ | HTML tag | -| `size` | [Size Extended dictionary][dictionary-size] | `medium` | ✕ | Size of the text | +| Name | Type | Default | Required | Description | +| ------------- | ------------------------------------------- | -------- | -------- | -------------------- | +| `elementType` | `React.Element` | `div` | ✕ | HTML tag | +| `emphasis` | [Emphasis dictionary][dictionary-emphasis] | `bold` | ✕ | Emphasis of the text | +| `size` | [Size Extended dictionary][dictionary-size] | `medium` | ✕ | Size of the text | 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] @@ -33,6 +52,7 @@ const CustomText = (props: SpiritHeadingProps): JSX.Element => { }; ``` +[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-react/README.md#additional-attributes [readme-escape-hatches]: https://github.com/lmc-eu/spirit-design-system/blob/main/packages/web-react/README.md#escape-hatches diff --git a/packages/web-react/src/components/Heading/__tests__/Heading.test.tsx b/packages/web-react/src/components/Heading/__tests__/Heading.test.tsx index b01a416f7a..72402dfedb 100644 --- a/packages/web-react/src/components/Heading/__tests__/Heading.test.tsx +++ b/packages/web-react/src/components/Heading/__tests__/Heading.test.tsx @@ -1,16 +1,16 @@ -import { render } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import React from 'react'; import '@testing-library/jest-dom'; import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest'; import { sizeExtendedPropsTest, sizePropsTest } from '../../../../tests/providerTests/dictionaryPropsTest'; import { restPropsTest } from '../../../../tests/providerTests/restPropsTest'; import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest'; -import { SizesDictionaryType, SizeExtendedDictionaryType } from '../../../types'; +import { SizesDictionaryType, SizeExtendedDictionaryType, EmphasisDictionaryType } from '../../../types'; import Heading from '../Heading'; import headingSizeDataProvider from './headingSizeDataProvider'; describe('Heading', () => { - classNamePrefixProviderTest(Heading, 'typography-heading-medium-text'); + classNamePrefixProviderTest(Heading, 'typography-heading-medium-bold'); stylePropsTest(Heading); @@ -20,9 +20,15 @@ describe('Heading', () => { restPropsTest(Heading, 'div'); - it.each(headingSizeDataProvider)('should have for size %s an expected class %s', (size, expectedClassName) => { - const dom = render( as SizeExtendedDictionaryType} />); + it.each(headingSizeDataProvider)('should have classname', (size, emphasis, expectedClassName) => { + render( + as SizeExtendedDictionaryType} + emphasis={emphasis as EmphasisDictionaryType} + elementType="h1" + />, + ); - expect(dom.container.querySelector('div')).toHaveClass(expectedClassName); + expect(screen.getByRole('heading')).toHaveClass(expectedClassName as string); }); }); diff --git a/packages/web-react/src/components/Heading/__tests__/headingSizeDataProvider.ts b/packages/web-react/src/components/Heading/__tests__/headingSizeDataProvider.ts index a18a682e21..8d0b2542bf 100644 --- a/packages/web-react/src/components/Heading/__tests__/headingSizeDataProvider.ts +++ b/packages/web-react/src/components/Heading/__tests__/headingSizeDataProvider.ts @@ -1,10 +1,25 @@ const headingSizeDataProvider = [ - // size, expected class - ['xlarge', 'typography-heading-xlarge-text'], - ['large', 'typography-heading-large-text'], - ['medium', 'typography-heading-medium-text'], - ['small', 'typography-heading-small-text'], - ['xsmall', 'typography-heading-xsmall-text'], + // [size, emphasis, expectedClassName] + ['xsmall', 'regular', 'typography-heading-xsmall-regular'], + ['small', 'regular', 'typography-heading-small-regular'], + ['medium', 'regular', 'typography-heading-medium-regular'], + ['large', 'regular', 'typography-heading-large-regular'], + ['xlarge', 'regular', 'typography-heading-xlarge-regular'], + ['xsmall', 'italic', 'typography-heading-xsmall-italic'], + ['small', 'italic', 'typography-heading-small-italic'], + ['medium', 'italic', 'typography-heading-medium-italic'], + ['large', 'italic', 'typography-heading-large-italic'], + ['xlarge', 'italic', 'typography-heading-xlarge-italic'], + ['xsmall', 'bold', 'typography-heading-xsmall-bold'], + ['small', 'bold', 'typography-heading-small-bold'], + ['medium', 'bold', 'typography-heading-medium-bold'], + ['large', 'bold', 'typography-heading-large-bold'], + ['xlarge', 'bold', 'typography-heading-xlarge-bold'], + ['xsmall', 'semibold', 'typography-heading-xsmall-semibold'], + ['small', 'semibold', 'typography-heading-small-semibold'], + ['medium', 'semibold', 'typography-heading-medium-semibold'], + ['large', 'semibold', 'typography-heading-large-semibold'], + ['xlarge', 'semibold', 'typography-heading-xlarge-semibold'], ]; export default headingSizeDataProvider; diff --git a/packages/web-react/src/components/Heading/__tests__/useHeadingStyleProps.ts b/packages/web-react/src/components/Heading/__tests__/useHeadingStyleProps.ts index fcb23a6196..e7b1286978 100644 --- a/packages/web-react/src/components/Heading/__tests__/useHeadingStyleProps.ts +++ b/packages/web-react/src/components/Heading/__tests__/useHeadingStyleProps.ts @@ -4,8 +4,8 @@ import { useHeadingStyleProps } from '../useHeadingStyleProps'; import headingSizeDataProvider from './headingSizeDataProvider'; describe('useHeadingStyleProps', () => { - it.each(headingSizeDataProvider)('should return for size %s expected class %s', (size, expectedClassName) => { - const props = { size } as SpiritHeadingProps; + it.each(headingSizeDataProvider)('should return typography heading class', (size, emphasis, expectedClassName) => { + const props = { size, emphasis } as SpiritHeadingProps; const { result } = renderHook(() => useHeadingStyleProps(props)); expect(result.current.classProps).toBe(expectedClassName); diff --git a/packages/web-react/src/components/Heading/demo/HeadingEmphasis.tsx b/packages/web-react/src/components/Heading/demo/HeadingEmphasis.tsx new file mode 100644 index 0000000000..0bfda9b5cf --- /dev/null +++ b/packages/web-react/src/components/Heading/demo/HeadingEmphasis.tsx @@ -0,0 +1,13 @@ +import React from 'react'; +import Heading from '../Heading'; + +const HeadingEmphasis = () => ( + <> + Heading regular + Heading semibold + Heading bold + Heading italic + +); + +export default HeadingEmphasis; diff --git a/packages/web-react/src/components/Heading/demo/index.tsx b/packages/web-react/src/components/Heading/demo/index.tsx index ac71223f24..f621ff3660 100644 --- a/packages/web-react/src/components/Heading/demo/index.tsx +++ b/packages/web-react/src/components/Heading/demo/index.tsx @@ -2,6 +2,7 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import DocsSection from '../../../../docs/DocsSections'; import HeadingDefault from './HeadingDefault'; +import HeadingEmphasis from './HeadingEmphasis'; import HeadingSizes from './HeadingSizes'; ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( @@ -12,5 +13,8 @@ ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( + + + , ); diff --git a/packages/web-react/src/components/Heading/stories/Heading.stories.tsx b/packages/web-react/src/components/Heading/stories/Heading.stories.tsx index 1db823cfd8..ccc8d17bbe 100644 --- a/packages/web-react/src/components/Heading/stories/Heading.stories.tsx +++ b/packages/web-react/src/components/Heading/stories/Heading.stories.tsx @@ -1,7 +1,7 @@ import { Markdown } from '@storybook/blocks'; import type { Meta, StoryObj } from '@storybook/react'; import React from 'react'; -import { SizesExtended } from '../../../constants'; +import { Emphasis, SizesExtended } from '../../../constants'; import ReadMe from '../README.md'; import { Heading } from '..'; @@ -20,6 +20,13 @@ const meta: Meta = { elementType: { control: 'text', }, + emphasis: { + control: 'select', + options: [...Object.values(Emphasis), undefined], + table: { + defaultValue: { summary: undefined }, + }, + }, size: { control: 'select', options: [...Object.values(SizesExtended)], @@ -31,6 +38,7 @@ const meta: Meta = { args: { children: 'Heading', elementType: 'h1', + emphasis: undefined, size: SizesExtended.MEDIUM, }, }; diff --git a/packages/web-react/src/components/Heading/useHeadingStyleProps.ts b/packages/web-react/src/components/Heading/useHeadingStyleProps.ts index bb23cb90a5..b9a4732802 100644 --- a/packages/web-react/src/components/Heading/useHeadingStyleProps.ts +++ b/packages/web-react/src/components/Heading/useHeadingStyleProps.ts @@ -12,10 +12,10 @@ export interface HeadingStyles { export function useHeadingStyleProps( props: SpiritHeadingProps, ): HeadingStyles { - const { size, ...restProps } = props; + const { size, emphasis, ...restProps } = props; const headingClass = useClassNamePrefix('typography-heading'); - const className = `${headingClass}-${size}-text`; + const className = `${headingClass}-${size}-${emphasis}`; return { classProps: className, diff --git a/packages/web-react/src/components/Link/__tests__/linkPropsDataProvider.ts b/packages/web-react/src/components/Link/__tests__/linkPropsDataProvider.ts index be06224748..09938a79ae 100644 --- a/packages/web-react/src/components/Link/__tests__/linkPropsDataProvider.ts +++ b/packages/web-react/src/components/Link/__tests__/linkPropsDataProvider.ts @@ -2,13 +2,13 @@ const linkPropsDataProvider = [ // color, isUnderlined, isDisabled, expectedClassName ['primary', false, false, 'link-primary'], ['secondary', false, false, 'link-secondary'], - ['inverted', false, false, 'link-inverted'], + ['tertiary', false, false, 'link-tertiary'], ['primary', true, false, 'link-primary link-underlined'], ['secondary', true, false, 'link-secondary link-underlined'], - ['inverted', true, false, 'link-inverted link-underlined'], + ['tertiary', true, false, 'link-tertiary link-underlined'], ['primary', true, true, 'link-primary link-disabled link-underlined'], ['secondary', true, true, 'link-secondary link-disabled link-underlined'], - ['inverted', true, true, 'link-inverted link-disabled link-underlined'], + ['tertiary', true, true, 'link-tertiary link-disabled link-underlined'], ]; export default linkPropsDataProvider; diff --git a/packages/web-react/src/components/Link/demo/LinkColors.tsx b/packages/web-react/src/components/Link/demo/LinkColors.tsx index 7263dd6674..5bc43fc277 100644 --- a/packages/web-react/src/components/Link/demo/LinkColors.tsx +++ b/packages/web-react/src/components/Link/demo/LinkColors.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import DocsBox from '../../../../docs/DocsBox'; import Link from '../Link'; const LinkColors = () => ( @@ -12,11 +11,9 @@ const LinkColors = () => ( Secondary Link - - - Inverted Link - - + + Tertiary Link + ); diff --git a/packages/web-react/src/components/Link/demo/LinkDisabled.tsx b/packages/web-react/src/components/Link/demo/LinkDisabled.tsx index 9f50a128d5..f6bdd78fd9 100644 --- a/packages/web-react/src/components/Link/demo/LinkDisabled.tsx +++ b/packages/web-react/src/components/Link/demo/LinkDisabled.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import DocsBox from '../../../../docs/DocsBox'; import Link from '../Link'; const LinkDisabled = () => ( @@ -12,11 +11,9 @@ const LinkDisabled = () => ( Secondary Disabled Link - - - Inverted Disabled Link - - + + Tertiary Disabled Link + ); diff --git a/packages/web-react/src/components/Text/README.md b/packages/web-react/src/components/Text/README.md index fb38571699..a78d65ee3e 100644 --- a/packages/web-react/src/components/Text/README.md +++ b/packages/web-react/src/components/Text/README.md @@ -6,13 +6,23 @@ The Text component provides helper classes to render text. ``` +## Emphasis + +Use the `emphasis` prop to set the emphasis of the text. + +```jsx +Bold text +``` + +See [API](#api) for all available options. + ## API -| Name | Type | Default | Required | Description | -| ------------- | ------------------------------------------- | -------- | -------- | -------------------- | -| `elementType` | `React.Element` | `p` | ✕ | HTML tag | -| `emphasis` | [`italic` \| `bold`] | — | ✕ | Emphasis of the text | -| `size` | [Size Extended dictionary][dictionary-size] | `medium` | ✕ | Size of the text | +| Name | Type | Default | Required | Description | +| ------------- | ------------------------------------------- | --------- | -------- | -------------------- | +| `elementType` | `React.Element` | `p` | ✕ | HTML tag | +| `emphasis` | [Emphasis dictionary][dictionary-emphasis] | `regular` | ✕ | Emphasis of the text | +| `size` | [Size Extended dictionary][dictionary-size] | `medium` | ✕ | Size of the text | 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] @@ -34,6 +44,7 @@ const CustomText = (props: SpiritTextProps): JSX.Element => { }; ``` +[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-react/README.md#additional-attributes [readme-escape-hatches]: https://github.com/lmc-eu/spirit-design-system/blob/main/packages/web-react/README.md#escape-hatches diff --git a/packages/web-react/src/components/Text/Text.tsx b/packages/web-react/src/components/Text/Text.tsx index 506b47dd88..5432114255 100644 --- a/packages/web-react/src/components/Text/Text.tsx +++ b/packages/web-react/src/components/Text/Text.tsx @@ -8,6 +8,7 @@ import { useTextStyleProps } from './useTextStyleProps'; const defaultProps: Partial = { elementType: 'p', + emphasis: 'regular', size: 'medium', }; diff --git a/packages/web-react/src/components/Text/__tests__/Text.test.tsx b/packages/web-react/src/components/Text/__tests__/Text.test.tsx index eac6c49c97..ce836ccfaa 100644 --- a/packages/web-react/src/components/Text/__tests__/Text.test.tsx +++ b/packages/web-react/src/components/Text/__tests__/Text.test.tsx @@ -1,16 +1,16 @@ -import { render } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import React from 'react'; import '@testing-library/jest-dom'; import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest'; import { sizeExtendedPropsTest, sizePropsTest } from '../../../../tests/providerTests/dictionaryPropsTest'; import { restPropsTest } from '../../../../tests/providerTests/restPropsTest'; import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest'; -import { SizesDictionaryType, SizeExtendedDictionaryType, TextEmphasis } from '../../../types'; +import { EmphasisDictionaryType, SizesDictionaryType, SizeExtendedDictionaryType } from '../../../types'; import Text from '../Text'; import textPropsDataProvider from './textPropsDataProvider'; describe('Text', () => { - classNamePrefixProviderTest(Text, 'typography-body-medium-text-regular'); + classNamePrefixProviderTest(Text, 'typography-body-medium-regular'); stylePropsTest(Text); @@ -21,13 +21,15 @@ describe('Text', () => { restPropsTest(Text, 'p'); it.each(textPropsDataProvider)('should have classname', (size, emphasis, expectedClassName) => { - const dom = render( + render( as SizeExtendedDictionaryType} - emphasis={emphasis as TextEmphasis} - />, + emphasis={emphasis as EmphasisDictionaryType} + > + Text + , ); - expect(dom.container.querySelector('p')).toHaveClass(expectedClassName as string); + expect(screen.getByText('Text')).toHaveClass(expectedClassName as string); }); }); diff --git a/packages/web-react/src/components/Text/__tests__/textPropsDataProvider.ts b/packages/web-react/src/components/Text/__tests__/textPropsDataProvider.ts index 889453ed43..bf3095614d 100644 --- a/packages/web-react/src/components/Text/__tests__/textPropsDataProvider.ts +++ b/packages/web-react/src/components/Text/__tests__/textPropsDataProvider.ts @@ -1,20 +1,25 @@ const textPropsDataProvider = [ // [size, emphasis, expectedClassName] - ['xsmall', undefined, 'typography-body-xsmall-text-regular'], - ['small', undefined, 'typography-body-small-text-regular'], - ['medium', undefined, 'typography-body-medium-text-regular'], - ['large', undefined, 'typography-body-large-text-regular'], - ['xlarge', undefined, 'typography-body-xlarge-text-regular'], - ['xsmall', 'italic', 'typography-body-xsmall-text-italic'], - ['small', 'italic', 'typography-body-small-text-italic'], - ['medium', 'italic', 'typography-body-medium-text-italic'], - ['large', 'italic', 'typography-body-large-text-italic'], - ['xlarge', 'italic', 'typography-body-xlarge-text-italic'], - ['xsmall', 'bold', 'typography-body-xsmall-text-bold'], - ['small', 'bold', 'typography-body-small-text-bold'], - ['medium', 'bold', 'typography-body-medium-text-bold'], - ['large', 'bold', 'typography-body-large-text-bold'], - ['xlarge', 'bold', 'typography-body-xlarge-text-bold'], + ['xsmall', 'regular', 'typography-body-xsmall-regular'], + ['small', 'regular', 'typography-body-small-regular'], + ['medium', 'regular', 'typography-body-medium-regular'], + ['large', 'regular', 'typography-body-large-regular'], + ['xlarge', 'regular', 'typography-body-xlarge-regular'], + ['xsmall', 'italic', 'typography-body-xsmall-italic'], + ['small', 'italic', 'typography-body-small-italic'], + ['medium', 'italic', 'typography-body-medium-italic'], + ['large', 'italic', 'typography-body-large-italic'], + ['xlarge', 'italic', 'typography-body-xlarge-italic'], + ['xsmall', 'bold', 'typography-body-xsmall-bold'], + ['small', 'bold', 'typography-body-small-bold'], + ['medium', 'bold', 'typography-body-medium-bold'], + ['large', 'bold', 'typography-body-large-bold'], + ['xlarge', 'bold', 'typography-body-xlarge-bold'], + ['xsmall', 'semibold', 'typography-body-xsmall-semibold'], + ['small', 'semibold', 'typography-body-small-semibold'], + ['medium', 'semibold', 'typography-body-medium-semibold'], + ['large', 'semibold', 'typography-body-large-semibold'], + ['xlarge', 'semibold', 'typography-body-xlarge-semibold'], ]; export default textPropsDataProvider; diff --git a/packages/web-react/src/components/Text/demo/TextEmphasis.tsx b/packages/web-react/src/components/Text/demo/TextEmphasis.tsx index 5d17e895bb..6153c4c2b0 100644 --- a/packages/web-react/src/components/Text/demo/TextEmphasis.tsx +++ b/packages/web-react/src/components/Text/demo/TextEmphasis.tsx @@ -3,7 +3,8 @@ import Text from '../Text'; const TextEmphasis = () => ( <> - Text regular + Text regular + Text semibold Text bold Text italic diff --git a/packages/web-react/src/components/Text/stories/Text.stories.tsx b/packages/web-react/src/components/Text/stories/Text.stories.tsx index 99e854a0eb..04fd637e83 100644 --- a/packages/web-react/src/components/Text/stories/Text.stories.tsx +++ b/packages/web-react/src/components/Text/stories/Text.stories.tsx @@ -22,7 +22,7 @@ const meta: Meta = { }, emphasis: { control: 'select', - options: ['italic', 'bold', undefined], + options: ['italic', 'bold', 'semibold', undefined], table: { defaultValue: { summary: undefined }, }, diff --git a/packages/web-react/src/components/Text/useTextStyleProps.ts b/packages/web-react/src/components/Text/useTextStyleProps.ts index 53ac923687..04622487fe 100644 --- a/packages/web-react/src/components/Text/useTextStyleProps.ts +++ b/packages/web-react/src/components/Text/useTextStyleProps.ts @@ -13,7 +13,7 @@ export function useTextStyleProps(props: const { size, emphasis, ...restProps } = props; const textClass = useClassNamePrefix('typography-body'); - const className = `${textClass}-${size}-text-${emphasis || 'regular'}`; + const className = `${textClass}-${size}-${emphasis}`; return { classProps: className, diff --git a/packages/web-react/src/components/UNSTABLE_EmptyState/demo/EmptyStateDefault.tsx b/packages/web-react/src/components/UNSTABLE_EmptyState/demo/EmptyStateDefault.tsx index a5a385be3d..55323b9647 100644 --- a/packages/web-react/src/components/UNSTABLE_EmptyState/demo/EmptyStateDefault.tsx +++ b/packages/web-react/src/components/UNSTABLE_EmptyState/demo/EmptyStateDefault.tsx @@ -21,7 +21,9 @@ const EmptyStateDefault = () => ( />
- Placeholder + + Placeholder + Replace me with your own component
diff --git a/packages/web-react/src/constants/dictionaries.ts b/packages/web-react/src/constants/dictionaries.ts index e760452f96..2e1d335127 100644 --- a/packages/web-react/src/constants/dictionaries.ts +++ b/packages/web-react/src/constants/dictionaries.ts @@ -37,9 +37,11 @@ export const ActionButtonColors = { TERTIARY: 'tertiary', } as const; +// TODO - Remove INVERTED from ActionLinkColors when Toast is updated in DS-1446 export const ActionLinkColors = { PRIMARY: 'primary', SECONDARY: 'secondary', + TERTIARY: 'tertiary', INVERTED: 'inverted', } as const; @@ -50,6 +52,13 @@ export const EmotionColors = { DANGER: 'danger', } as const; +export const Emphasis = { + REGULAR: 'regular', + SEMIBOLD: 'semibold', + BOLD: 'bold', + ITALIC: 'italic', +} as const; + export const TextColors = { PRIMARY: 'primary', SECONDARY: 'secondary', diff --git a/packages/web-react/src/types/heading.ts b/packages/web-react/src/types/heading.ts index 106ed4705f..b04fda84c2 100644 --- a/packages/web-react/src/types/heading.ts +++ b/packages/web-react/src/types/heading.ts @@ -1,5 +1,12 @@ import { ElementType, JSXElementConstructor } from 'react'; -import { ChildrenProps, SizeExtendedDictionaryType, SizeProps, StyleProps, TransferProps } from './shared'; +import { + ChildrenProps, + EmphasisDictionaryType, + SizeExtendedDictionaryType, + SizeProps, + StyleProps, + TransferProps, +} from './shared'; export interface HeadingElementTypeProps { /** @@ -18,4 +25,7 @@ export interface HeadingProps export interface SpiritHeadingProps extends HeadingProps, - SizeProps> {} + SizeProps> { + /** Emphasis of the heading */ + emphasis?: EmphasisDictionaryType | undefined | null; +} diff --git a/packages/web-react/src/types/shared/dictionaries.ts b/packages/web-react/src/types/shared/dictionaries.ts index fefded746a..7e49c90fa3 100644 --- a/packages/web-react/src/types/shared/dictionaries.ts +++ b/packages/web-react/src/types/shared/dictionaries.ts @@ -7,6 +7,7 @@ import { AlignmentY, AlignmentYExtended, EmotionColors, + Emphasis, Placements, Sizes, SizesExtended, @@ -48,6 +49,9 @@ export type ActionLinkColorsDictionaryType = export type EmotionColorsDictionaryKeys = keyof typeof EmotionColors; export type EmotionColorsDictionaryType = (typeof EmotionColors)[EmotionColorsDictionaryKeys] | C; +export type EmphasisDictionaryKeys = keyof typeof Emphasis; +export type EmphasisDictionaryType = (typeof Emphasis)[EmphasisDictionaryKeys] | C; + export type TextColorsDictionaryKeys = keyof typeof TextColors; export type TextColorsDictionaryType = (typeof TextColors)[TextColorsDictionaryKeys] | C; diff --git a/packages/web-react/src/types/text.ts b/packages/web-react/src/types/text.ts index c2988c9ccd..d187b3d601 100644 --- a/packages/web-react/src/types/text.ts +++ b/packages/web-react/src/types/text.ts @@ -1,7 +1,12 @@ import { ElementType, JSXElementConstructor } from 'react'; -import { ChildrenProps, SizeExtendedDictionaryType, SizeProps, StyleProps, TransferProps } from './shared'; - -export type TextEmphasis = 'bold' | 'italic'; +import { + ChildrenProps, + EmphasisDictionaryType, + SizeExtendedDictionaryType, + SizeProps, + StyleProps, + TransferProps, +} from './shared'; export interface TextElementTypeProps { /** @@ -22,5 +27,5 @@ export interface SpiritTextProps extends TextProps, SizeProps> { /** Emphasis of the text */ - emphasis?: TextEmphasis | undefined | null; + emphasis?: EmphasisDictionaryType | undefined | null; } diff --git a/tests/e2e/demo-components-compare.spec.ts-snapshots/heading-chromium-linux.png b/tests/e2e/demo-components-compare.spec.ts-snapshots/heading-chromium-linux.png index 1cf3e10816..ad560373ad 100644 Binary files a/tests/e2e/demo-components-compare.spec.ts-snapshots/heading-chromium-linux.png and b/tests/e2e/demo-components-compare.spec.ts-snapshots/heading-chromium-linux.png differ