@transferwise/components 0.0.0-experimental-91e668a → 0.0.0-experimental-3232842

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -69,8 +69,10 @@ const Header = /*#__PURE__*/React__default.default.forwardRef(({
69
69
  }, ref) => {
70
70
  const internalRef = React.useRef(null);
71
71
  const levelTypography = level === 'group' ? typography.Typography.TITLE_GROUP : typography.Typography.TITLE_SUBSECTION;
72
+ const isLegendOrNoAction = !action || as === 'legend';
72
73
  const headerClasses = clsx.clsx('np-header', className, {
73
- 'np-header--group': level === 'group'
74
+ 'np-header--group': level === 'group',
75
+ 'np-header__title': isLegendOrNoAction
74
76
  });
75
77
  const commonProps = {
76
78
  className: headerClasses,
@@ -1 +1 @@
1
- {"version":3,"file":"Header.js","sources":["../../src/header/Header.tsx"],"sourcesContent":["import { clsx } from 'clsx';\n\nimport { AriaLabelProperty, CommonProps, Heading, LinkProps, Typography } from '../common';\nimport Link from '../link';\nimport Title from '../title';\nimport React, { useEffect, useRef, FunctionComponent } from 'react';\n\ntype ActionProps = AriaLabelProperty & {\n text: string;\n onClick?: (event: React.MouseEvent) => void;\n};\n\ntype ButtonActionProps = ActionProps;\ntype LinkActionProps = ActionProps & LinkProps;\n\nexport interface HeaderProps extends CommonProps {\n /**\n * Optional prop to define the action for the header. If the `href` property\n * is provided, a `Link` will be rendered instead of a `Button`.\n */\n action?: ButtonActionProps | LinkActionProps;\n\n /**\n * Option prop to specify DOM render element of the title\n *\n * - When `as=\"legend\"`, the `Header` will render as a `<legend>` element.\n * **Note:** `<legend>` elements must be the first child of a `<fieldset>` to comply with HTML semantics.\n * If this condition is not met, a warning will be logged to the console.\n *\n * - Other valid values include standard heading tags (`h1` to `h6`) or `header`.\n */\n as?: Heading | 'legend' | 'header';\n\n /** Required prop to set the title of the Header. */\n title: string;\n\n /** Optional prop to specify the level of the Header */\n level?: 'section' | 'group';\n\n className?: string;\n testId?: string;\n}\n\n/**\n * Renders a header action which can be either a button or a link.\n *\n * @param {Object} props - The properties object.\n * @param {ButtonActionProps | LinkActionProps} props.action - The action object which can be either a button or a link.\n * @returns {JSX.Element} The rendered header action component.\n */\nconst HeaderAction = React.forwardRef<\n HTMLButtonElement | HTMLAnchorElement,\n { action: ButtonActionProps | LinkActionProps }\n>(({ action }, ref) => {\n return (\n <Link\n className=\"np-header__action-button\"\n aria-label={action['aria-label']}\n href={'href' in action ? action.href : undefined}\n target={'target' in action ? action.target : undefined}\n onClick={action.onClick}\n >\n {action.text}\n </Link>\n );\n});\n\nHeaderAction.displayName = 'HeaderAction';\n\n/**\n * @param {ButtonActionProps | LinkActionProps} [action] - Optional prop to specify the action button or link.\n * @param {Heading | 'legend'} [as='h5'] - Optional prop to override the heading element rendered for the title.\n * @param {string} title - Required prop to set the title of the section header.\n * @param {'group' | 'section'} [level='group'] - Optional prop to specify the level of the section header.\n * @param {string} [className]\n * @param {string} [testId]\n *\n * @see {@link Header } for further information.\n * @see {@link https://storybook.wise.design/?path=/docs/typography-header--docs|Storybook Wise Design}\n */\nconst Header: FunctionComponent<HeaderProps> = React.forwardRef(\n (\n { as = 'h5', action, className, testId, title, level = 'group', ...props },\n ref: React.Ref<HTMLDivElement | HTMLHeadingElement | HTMLLegendElement>,\n ) => {\n const internalRef = useRef<HTMLLegendElement>(null);\n const levelTypography =\n level === 'group' ? Typography.TITLE_GROUP : Typography.TITLE_SUBSECTION;\n const headerClasses = clsx('np-header', className, {\n 'np-header--group': level === 'group',\n });\n\n const commonProps = {\n className: headerClasses,\n 'data-testid': testId,\n };\n\n useEffect(() => {\n if (as === 'legend' && internalRef.current) {\n const { parentElement } = internalRef.current;\n if (!parentElement || parentElement.tagName.toLowerCase() !== 'fieldset') {\n console.warn(\n 'Legends should be the first child in a fieldset, and this is not possible when including an action',\n );\n }\n }\n }, [as]);\n\n if (!action) {\n return (\n <Title ref={internalRef} as={as} type={levelTypography} {...commonProps} {...props}>\n {title}\n </Title>\n );\n }\n\n return (\n <div {...commonProps} {...props} ref={ref as React.Ref<HTMLDivElement>}>\n <Title as={as} type={levelTypography} className=\"np-header__title\">\n {title}\n </Title>\n <HeaderAction action={action} />\n </div>\n );\n },\n);\n\nHeader.displayName = 'Header';\n\nexport default Header;\n"],"names":["HeaderAction","React","forwardRef","action","ref","_jsx","Link","className","href","undefined","target","onClick","children","text","displayName","Header","as","testId","title","level","props","internalRef","useRef","levelTypography","Typography","TITLE_GROUP","TITLE_SUBSECTION","headerClasses","clsx","commonProps","useEffect","current","parentElement","tagName","toLowerCase","console","warn","Title","type","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAMA,YAAY,gBAAGC,sBAAK,CAACC,UAAU,CAGnC,CAAC;AAAEC,EAAAA;AAAM,CAAE,EAAEC,GAAG,KAAI;EACpB,oBACEC,cAAA,CAACC,YAAI,EAAA;AACHC,IAAAA,SAAS,EAAC,0BAA0B;IACpC,YAAA,EAAYJ,MAAM,CAAC,YAAY,CAAE;IACjCK,IAAI,EAAE,MAAM,IAAIL,MAAM,GAAGA,MAAM,CAACK,IAAI,GAAGC,SAAU;IACjDC,MAAM,EAAE,QAAQ,IAAIP,MAAM,GAAGA,MAAM,CAACO,MAAM,GAAGD,SAAU;IACvDE,OAAO,EAAER,MAAM,CAACQ,OAAQ;IAAAC,QAAA,EAEvBT,MAAM,CAACU;AAAI,GACR,CAAC;AAEX,CAAC,CAAC;AAEFb,YAAY,CAACc,WAAW,GAAG,cAAc;AAEzC;;;;;;;;;;AAUG;AACH,MAAMC,MAAM,gBAAmCd,sBAAK,CAACC,UAAU,CAC7D,CACE;AAAEc,EAAAA,EAAE,GAAG,IAAI;EAAEb,MAAM;EAAEI,SAAS;EAAEU,MAAM;EAAEC,KAAK;AAAEC,EAAAA,KAAK,GAAG,OAAO;EAAE,GAAGC;AAAK,CAAE,EAC1EhB,GAAuE,KACrE;AACF,EAAA,MAAMiB,WAAW,GAAGC,YAAM,CAAoB,IAA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,eAAgB;AAAChB,MAAAA,SAAS,EAAC,kBAAkB;AAAAK,MAAAA,QAAA,EAC/DM;AAAK,KACD,CACP,eAAAb,cAAA,CAACL,YAAY,EAAA;AAACG,MAAAA,MAAM,EAAEA;AAAO,KAAA,CAC/B;AAAA,GAAK,CAAC;AAEV,CAAC;AAGHY,MAAM,CAACD,WAAW,GAAG,QAAQ;;;;"}
1
+ {"version":3,"file":"Header.js","sources":["../../src/header/Header.tsx"],"sourcesContent":["import { clsx } from 'clsx';\n\nimport { AriaLabelProperty, CommonProps, Heading, LinkProps, Typography } from '../common';\nimport Button from '../button';\nimport Link from '../link';\nimport Title from '../title';\nimport React, { useEffect, useRef, FunctionComponent } from 'react';\n\ntype ActionProps = AriaLabelProperty & {\n text: string;\n onClick?: (event: React.MouseEvent) => void;\n};\n\ntype ButtonActionProps = ActionProps;\ntype LinkActionProps = ActionProps & LinkProps;\n\nexport interface HeaderProps extends CommonProps {\n /**\n * Optional prop to define the action for the header. If the `href` property\n * is provided, a `Link` will be rendered instead of a `Button`.\n */\n action?: ButtonActionProps | LinkActionProps;\n\n /**\n * Option prop to specify DOM render element of the title\n *\n * - When `as=\"legend\"`, the `Header` will render as a `<legend>` element.\n * **Note:** `<legend>` elements must be the first child of a `<fieldset>` to comply with HTML semantics.\n * If this condition is not met, a warning will be logged to the console.\n *\n * - Other valid values include standard heading tags (`h1` to `h6`) or `header`.\n */\n as?: Heading | 'legend' | 'header';\n\n /** Required prop to set the title of the Header. */\n title: string;\n\n /** Optional prop to specify the level of the Header */\n level?: 'section' | 'group';\n\n className?: string;\n testId?: string;\n}\n\n/**\n * Renders a header action which can be either a button or a link.\n *\n * @param {Object} props - The properties object.\n * @param {ButtonActionProps | LinkActionProps} props.action - The action object which can be either a button or a link.\n * @returns {JSX.Element} The rendered header action component.\n */\nconst HeaderAction = React.forwardRef<\n HTMLButtonElement | HTMLAnchorElement,\n { action: ButtonActionProps | LinkActionProps }\n>(({ action }, ref) => {\n return (\n <Link\n className=\"np-header__action-button\"\n aria-label={action['aria-label']}\n href={'href' in action ? action.href : undefined}\n target={'target' in action ? action.target : undefined}\n onClick={action.onClick}\n >\n {action.text}\n </Link>\n );\n});\n\nHeaderAction.displayName = 'HeaderAction';\n\n/**\n * @param {ButtonActionProps | LinkActionProps} [action] - Optional prop to specify the action button or link.\n * @param {Heading | 'legend'} [as='h5'] - Optional prop to override the heading element rendered for the title.\n * @param {string} title - Required prop to set the title of the section header.\n * @param {'group' | 'section'} [level='group'] - Optional prop to specify the level of the section header.\n * @param {string} [className]\n * @param {string} [testId]\n *\n * @see {@link Header } for further information.\n * @see {@link https://storybook.wise.design/?path=/docs/typography-header--docs|Storybook Wise Design}\n */\nconst Header: FunctionComponent<HeaderProps> = React.forwardRef(\n (\n { as = 'h5', action, className, testId, title, level = 'group', ...props },\n ref: React.Ref<HTMLDivElement | HTMLHeadingElement | HTMLLegendElement>,\n ) => {\n const internalRef = useRef<HTMLLegendElement>(null);\n const levelTypography =\n level === 'group' ? Typography.TITLE_GROUP : Typography.TITLE_SUBSECTION;\n const isLegendOrNoAction = !action || as === 'legend';\n const headerClasses = clsx('np-header', className, {\n 'np-header--group': level === 'group',\n 'np-header__title': isLegendOrNoAction,\n });\n\n const commonProps = {\n className: headerClasses,\n 'data-testid': testId,\n };\n\n useEffect(() => {\n if (as === 'legend' && internalRef.current) {\n const { parentElement } = internalRef.current;\n if (!parentElement || parentElement.tagName.toLowerCase() !== 'fieldset') {\n console.warn(\n 'Legends should be the first child in a fieldset, and this is not possible when including an action',\n );\n }\n }\n }, [as]);\n\n if (!action) {\n return (\n <Title ref={internalRef} as={as} type={levelTypography} {...commonProps} {...props}>\n {title}\n </Title>\n );\n }\n\n return (\n <div {...commonProps} {...props} ref={ref as React.Ref<HTMLDivElement>}>\n <Title as={as} type={levelTypography} className=\"np-header__title\">\n {title}\n </Title>\n <HeaderAction action={action} />\n </div>\n );\n },\n);\n\nHeader.displayName = 'Header';\n\nexport default Header;\n"],"names":["HeaderAction","React","forwardRef","action","ref","_jsx","Link","className","href","undefined","target","onClick","children","text","displayName","Header","as","testId","title","level","props","internalRef","useRef","levelTypography","Typography","TITLE_GROUP","TITLE_SUBSECTION","isLegendOrNoAction","headerClasses","clsx","commonProps","useEffect","current","parentElement","tagName","toLowerCase","console","warn","Title","type","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAMA,YAAY,gBAAGC,sBAAK,CAACC,UAAU,CAGnC,CAAC;AAAEC,EAAAA;AAAM,CAAE,EAAEC,GAAG,KAAI;EACpB,oBACEC,cAAA,CAACC,YAAI,EAAA;AACHC,IAAAA,SAAS,EAAC,0BAA0B;IACpC,YAAA,EAAYJ,MAAM,CAAC,YAAY,CAAE;IACjCK,IAAI,EAAE,MAAM,IAAIL,MAAM,GAAGA,MAAM,CAACK,IAAI,GAAGC,SAAU;IACjDC,MAAM,EAAE,QAAQ,IAAIP,MAAM,GAAGA,MAAM,CAACO,MAAM,GAAGD,SAAU;IACvDE,OAAO,EAAER,MAAM,CAACQ,OAAQ;IAAAC,QAAA,EAEvBT,MAAM,CAACU;AAAI,GACR,CAAC;AAEX,CAAC,CAAC;AAEFb,YAAY,CAACc,WAAW,GAAG,cAAc;AAEzC;;;;;;;;;;AAUG;AACH,MAAMC,MAAM,gBAAmCd,sBAAK,CAACC,UAAU,CAC7D,CACE;AAAEc,EAAAA,EAAE,GAAG,IAAI;EAAEb,MAAM;EAAEI,SAAS;EAAEU,MAAM;EAAEC,KAAK;AAAEC,EAAAA,KAAK,GAAG,OAAO;EAAE,GAAGC;AAAK,CAAE,EAC1EhB,GAAuE,KACrE;AACF,EAAA,MAAMiB,WAAW,GAAGC,YAAM,CAAoB,IAAI,CAAC;AACnD,EAAA,MAAMC,eAAe,GACnBJ,KAAK,KAAK,OAAO,GAAGK,qBAAU,CAACC,WAAW,GAAGD,qBAAU,CAACE,gBAAgB;AAC1E,EAAA,MAAMC,kBAAkB,GAAG,CAACxB,MAAM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,MAAAA,QAAA,EAC/DM;AAAK,KACD,CACP,eAAAb,cAAA,CAACL,YAAY,EAAA;AAACG,MAAAA,MAAM,EAAEA;AAAO,KAAA,CAC/B;AAAA,GAAK,CAAC;AAEV,CAAC;AAGHY,MAAM,CAACD,WAAW,GAAG,QAAQ;;;;"}
@@ -61,8 +61,10 @@ const Header = /*#__PURE__*/React__default.forwardRef(({
61
61
  }, ref) => {
62
62
  const internalRef = useRef(null);
63
63
  const levelTypography = level === 'group' ? Typography.TITLE_GROUP : Typography.TITLE_SUBSECTION;
64
+ const isLegendOrNoAction = !action || as === 'legend';
64
65
  const headerClasses = clsx('np-header', className, {
65
- 'np-header--group': level === 'group'
66
+ 'np-header--group': level === 'group',
67
+ 'np-header__title': isLegendOrNoAction
66
68
  });
67
69
  const commonProps = {
68
70
  className: headerClasses,
@@ -1 +1 @@
1
- {"version":3,"file":"Header.mjs","sources":["../../src/header/Header.tsx"],"sourcesContent":["import { clsx } from 'clsx';\n\nimport { AriaLabelProperty, CommonProps, Heading, LinkProps, Typography } from '../common';\nimport Link from '../link';\nimport Title from '../title';\nimport React, { useEffect, useRef, FunctionComponent } from 'react';\n\ntype ActionProps = AriaLabelProperty & {\n text: string;\n onClick?: (event: React.MouseEvent) => void;\n};\n\ntype ButtonActionProps = ActionProps;\ntype LinkActionProps = ActionProps & LinkProps;\n\nexport interface HeaderProps extends CommonProps {\n /**\n * Optional prop to define the action for the header. If the `href` property\n * is provided, a `Link` will be rendered instead of a `Button`.\n */\n action?: ButtonActionProps | LinkActionProps;\n\n /**\n * Option prop to specify DOM render element of the title\n *\n * - When `as=\"legend\"`, the `Header` will render as a `<legend>` element.\n * **Note:** `<legend>` elements must be the first child of a `<fieldset>` to comply with HTML semantics.\n * If this condition is not met, a warning will be logged to the console.\n *\n * - Other valid values include standard heading tags (`h1` to `h6`) or `header`.\n */\n as?: Heading | 'legend' | 'header';\n\n /** Required prop to set the title of the Header. */\n title: string;\n\n /** Optional prop to specify the level of the Header */\n level?: 'section' | 'group';\n\n className?: string;\n testId?: string;\n}\n\n/**\n * Renders a header action which can be either a button or a link.\n *\n * @param {Object} props - The properties object.\n * @param {ButtonActionProps | LinkActionProps} props.action - The action object which can be either a button or a link.\n * @returns {JSX.Element} The rendered header action component.\n */\nconst HeaderAction = React.forwardRef<\n HTMLButtonElement | HTMLAnchorElement,\n { action: ButtonActionProps | LinkActionProps }\n>(({ action }, ref) => {\n return (\n <Link\n className=\"np-header__action-button\"\n aria-label={action['aria-label']}\n href={'href' in action ? action.href : undefined}\n target={'target' in action ? action.target : undefined}\n onClick={action.onClick}\n >\n {action.text}\n </Link>\n );\n});\n\nHeaderAction.displayName = 'HeaderAction';\n\n/**\n * @param {ButtonActionProps | LinkActionProps} [action] - Optional prop to specify the action button or link.\n * @param {Heading | 'legend'} [as='h5'] - Optional prop to override the heading element rendered for the title.\n * @param {string} title - Required prop to set the title of the section header.\n * @param {'group' | 'section'} [level='group'] - Optional prop to specify the level of the section header.\n * @param {string} [className]\n * @param {string} [testId]\n *\n * @see {@link Header } for further information.\n * @see {@link https://storybook.wise.design/?path=/docs/typography-header--docs|Storybook Wise Design}\n */\nconst Header: FunctionComponent<HeaderProps> = React.forwardRef(\n (\n { as = 'h5', action, className, testId, title, level = 'group', ...props },\n ref: React.Ref<HTMLDivElement | HTMLHeadingElement | HTMLLegendElement>,\n ) => {\n const internalRef = useRef<HTMLLegendElement>(null);\n const levelTypography =\n level === 'group' ? Typography.TITLE_GROUP : Typography.TITLE_SUBSECTION;\n const headerClasses = clsx('np-header', className, {\n 'np-header--group': level === 'group',\n });\n\n const commonProps = {\n className: headerClasses,\n 'data-testid': testId,\n };\n\n useEffect(() => {\n if (as === 'legend' && internalRef.current) {\n const { parentElement } = internalRef.current;\n if (!parentElement || parentElement.tagName.toLowerCase() !== 'fieldset') {\n console.warn(\n 'Legends should be the first child in a fieldset, and this is not possible when including an action',\n );\n }\n }\n }, [as]);\n\n if (!action) {\n return (\n <Title ref={internalRef} as={as} type={levelTypography} {...commonProps} {...props}>\n {title}\n </Title>\n );\n }\n\n return (\n <div {...commonProps} {...props} ref={ref as React.Ref<HTMLDivElement>}>\n <Title as={as} type={levelTypography} className=\"np-header__title\">\n {title}\n </Title>\n <HeaderAction action={action} />\n </div>\n );\n },\n);\n\nHeader.displayName = 'Header';\n\nexport default Header;\n"],"names":["HeaderAction","React","forwardRef","action","ref","_jsx","Link","className","href","undefined","target","onClick","children","text","displayName","Header","as","testId","title","level","props","internalRef","useRef","levelTypography","Typography","TITLE_GROUP","TITLE_SUBSECTION","headerClasses","clsx","commonProps","useEffect","current","parentElement","tagName","toLowerCase","console","warn","Title","type","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAMA,YAAY,gBAAGC,cAAK,CAACC,UAAU,CAGnC,CAAC;AAAEC,EAAAA;AAAM,CAAE,EAAEC,GAAG,KAAI;EACpB,oBACEC,GAAA,CAACC,IAAI,EAAA;AACHC,IAAAA,SAAS,EAAC,0BAA0B;IACpC,YAAA,EAAYJ,MAAM,CAAC,YAAY,CAAE;IACjCK,IAAI,EAAE,MAAM,IAAIL,MAAM,GAAGA,MAAM,CAACK,IAAI,GAAGC,SAAU;IACjDC,MAAM,EAAE,QAAQ,IAAIP,MAAM,GAAGA,MAAM,CAACO,MAAM,GAAGD,SAAU;IACvDE,OAAO,EAAER,MAAM,CAACQ,OAAQ;IAAAC,QAAA,EAEvBT,MAAM,CAACU;AAAI,GACR,CAAC;AAEX,CAAC,CAAC;AAEFb,YAAY,CAACc,WAAW,GAAG,cAAc;AAEzC;;;;;;;;;;AAUG;AACH,MAAMC,MAAM,gBAAmCd,cAAK,CAACC,UAAU,CAC7D,CACE;AAAEc,EAAAA,EAAE,GAAG,IAAI;EAAEb,MAAM;EAAEI,SAAS;EAAEU,MAAM;EAAEC,KAAK;AAAEC,EAAAA,KAAK,GAAG,OAAO;EAAE,GAAGC;AAAK,CAAE,EAC1EhB,GAAuE,KACrE;AACF,EAAA,MA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,EAAG;AAACsB,MAAAA,IAAI,EAAEf,eAAgB;AAAChB,MAAAA,SAAS,EAAC,kBAAkB;AAAAK,MAAAA,QAAA,EAC/DM;AAAK,KACD,CACP,eAAAb,GAAA,CAACL,YAAY,EAAA;AAACG,MAAAA,MAAM,EAAEA;AAAO,KAAA,CAC/B;AAAA,GAAK,CAAC;AAEV,CAAC;AAGHY,MAAM,CAACD,WAAW,GAAG,QAAQ;;;;"}
1
+ {"version":3,"file":"Header.mjs","sources":["../../src/header/Header.tsx"],"sourcesContent":["import { clsx } from 'clsx';\n\nimport { AriaLabelProperty, CommonProps, Heading, LinkProps, Typography } from '../common';\nimport Button from '../button';\nimport Link from '../link';\nimport Title from '../title';\nimport React, { useEffect, useRef, FunctionComponent } from 'react';\n\ntype ActionProps = AriaLabelProperty & {\n text: string;\n onClick?: (event: React.MouseEvent) => void;\n};\n\ntype ButtonActionProps = ActionProps;\ntype LinkActionProps = ActionProps & LinkProps;\n\nexport interface HeaderProps extends CommonProps {\n /**\n * Optional prop to define the action for the header. If the `href` property\n * is provided, a `Link` will be rendered instead of a `Button`.\n */\n action?: ButtonActionProps | LinkActionProps;\n\n /**\n * Option prop to specify DOM render element of the title\n *\n * - When `as=\"legend\"`, the `Header` will render as a `<legend>` element.\n * **Note:** `<legend>` elements must be the first child of a `<fieldset>` to comply with HTML semantics.\n * If this condition is not met, a warning will be logged to the console.\n *\n * - Other valid values include standard heading tags (`h1` to `h6`) or `header`.\n */\n as?: Heading | 'legend' | 'header';\n\n /** Required prop to set the title of the Header. */\n title: string;\n\n /** Optional prop to specify the level of the Header */\n level?: 'section' | 'group';\n\n className?: string;\n testId?: string;\n}\n\n/**\n * Renders a header action which can be either a button or a link.\n *\n * @param {Object} props - The properties object.\n * @param {ButtonActionProps | LinkActionProps} props.action - The action object which can be either a button or a link.\n * @returns {JSX.Element} The rendered header action component.\n */\nconst HeaderAction = React.forwardRef<\n HTMLButtonElement | HTMLAnchorElement,\n { action: ButtonActionProps | LinkActionProps }\n>(({ action }, ref) => {\n return (\n <Link\n className=\"np-header__action-button\"\n aria-label={action['aria-label']}\n href={'href' in action ? action.href : undefined}\n target={'target' in action ? action.target : undefined}\n onClick={action.onClick}\n >\n {action.text}\n </Link>\n );\n});\n\nHeaderAction.displayName = 'HeaderAction';\n\n/**\n * @param {ButtonActionProps | LinkActionProps} [action] - Optional prop to specify the action button or link.\n * @param {Heading | 'legend'} [as='h5'] - Optional prop to override the heading element rendered for the title.\n * @param {string} title - Required prop to set the title of the section header.\n * @param {'group' | 'section'} [level='group'] - Optional prop to specify the level of the section header.\n * @param {string} [className]\n * @param {string} [testId]\n *\n * @see {@link Header } for further information.\n * @see {@link https://storybook.wise.design/?path=/docs/typography-header--docs|Storybook Wise Design}\n */\nconst Header: FunctionComponent<HeaderProps> = React.forwardRef(\n (\n { as = 'h5', action, className, testId, title, level = 'group', ...props },\n ref: React.Ref<HTMLDivElement | HTMLHeadingElement | HTMLLegendElement>,\n ) => {\n const internalRef = useRef<HTMLLegendElement>(null);\n const levelTypography =\n level === 'group' ? Typography.TITLE_GROUP : Typography.TITLE_SUBSECTION;\n const isLegendOrNoAction = !action || as === 'legend';\n const headerClasses = clsx('np-header', className, {\n 'np-header--group': level === 'group',\n 'np-header__title': isLegendOrNoAction,\n });\n\n const commonProps = {\n className: headerClasses,\n 'data-testid': testId,\n };\n\n useEffect(() => {\n if (as === 'legend' && internalRef.current) {\n const { parentElement } = internalRef.current;\n if (!parentElement || parentElement.tagName.toLowerCase() !== 'fieldset') {\n console.warn(\n 'Legends should be the first child in a fieldset, and this is not possible when including an action',\n );\n }\n }\n }, [as]);\n\n if (!action) {\n return (\n <Title ref={internalRef} as={as} type={levelTypography} {...commonProps} {...props}>\n {title}\n </Title>\n );\n }\n\n return (\n <div {...commonProps} {...props} ref={ref as React.Ref<HTMLDivElement>}>\n <Title as={as} type={levelTypography} className=\"np-header__title\">\n {title}\n </Title>\n <HeaderAction action={action} />\n </div>\n );\n },\n);\n\nHeader.displayName = 'Header';\n\nexport default Header;\n"],"names":["HeaderAction","React","forwardRef","action","ref","_jsx","Link","className","href","undefined","target","onClick","children","text","displayName","Header","as","testId","title","level","props","internalRef","useRef","levelTypography","Typography","TITLE_GROUP","TITLE_SUBSECTION","isLegendOrNoAction","headerClasses","clsx","commonProps","useEffect","current","parentElement","tagName","toLowerCase","console","warn","Title","type","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAMA,YAAY,gBAAGC,cAAK,CAACC,UAAU,CAGnC,CAAC;AAAEC,EAAAA;AAAM,CAAE,EAAEC,GAAG,KAAI;EACpB,oBACEC,GAAA,CAACC,IAAI,EAAA;AACHC,IAAAA,SAAS,EAAC,0BAA0B;IACpC,YAAA,EAAYJ,MAAM,CAAC,YAAY,CAAE;IACjCK,IAAI,EAAE,MAAM,IAAIL,MAAM,GAAGA,MAAM,CAACK,IAAI,GAAGC,SAAU;IACjDC,MAAM,EAAE,QAAQ,IAAIP,MAAM,GAAGA,MAAM,CAACO,MAAM,GAAGD,SAAU;IACvDE,OAAO,EAAER,MAAM,CAACQ,OAAQ;IAAAC,QAAA,EAEvBT,MAAM,CAACU;AAAI,GACR,CAAC;AAEX,CAAC,CAAC;AAEFb,YAAY,CAACc,WAAW,GAAG,cAAc;AAEzC;;;;;;;;;;AAUG;AACH,MAAMC,MAAM,gBAAmCd,cAAK,CAACC,UAAU,CAC7D,CACE;AAAEc,EAAAA,EAAE,GAAG,IAAI;EAAEb,MAAM;EAAEI,SAAS;EAAEU,MAAM;EAAEC,KAAK;AAAEC,EAAAA,KAAK,GAAG,OAAO;EAAE,GAAGC;AAAK,CAAE,EAC1EhB,GAAuE,KACrE;AACF,EAAA,MAAMiB,WAAW,GAAGC,MAAM,CAAoB,IAAI,CAAC;AACnD,EAAA,MAAMC,eAAe,GACnBJ,KAAK,KAAK,OAAO,GAAGK,UAAU,CAACC,WAAW,GAAGD,UAAU,CAACE,gBAAgB;AAC1E,EAAA,MAAMC,kBAA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,EAAC,kBAAkB;AAAAK,MAAAA,QAAA,EAC/DM;AAAK,KACD,CACP,eAAAb,GAAA,CAACL,YAAY,EAAA;AAACG,MAAAA,MAAM,EAAEA;AAAO,KAAA,CAC/B;AAAA,GAAK,CAAC;AAEV,CAAC;AAGHY,MAAM,CAACD,WAAW,GAAG,QAAQ;;;;"}
package/build/main.css CHANGED
@@ -2454,10 +2454,10 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2454
2454
  border-bottom: 1px solid rgba(0,0,0,0.10196);
2455
2455
  border-bottom: 1px solid var(--color-border-neutral);
2456
2456
  }
2457
- .np-header--group,
2458
- .np-header--group .np-header__title {
2457
+ .np-header__title {
2459
2458
  color: #5d7079;
2460
2459
  color: var(--color-content-secondary);
2460
+ margin: 0;
2461
2461
  }
2462
2462
  .np-header__action {
2463
2463
  margin: 0;
@@ -3228,12 +3228,6 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3228
3228
  outline-offset: var(--ring-outline-offset);
3229
3229
  outline-offset: -1px;
3230
3230
  }
3231
- .wds-list-item-interactive.wds-list-item-spotlight:not(.disabled):not(:disabled):hover {
3232
- background-color: var(--color-background-screen-hover);
3233
- }
3234
- .wds-list-item-interactive.wds-list-item-spotlight:not(.disabled):not(:disabled):active {
3235
- background-color: var(--color-background-screen-active);
3236
- }
3237
3231
  .wds-list-item-interactive.wds-list-item-spotlight:has(.wds-list-item-prompt:hover a, .wds-list-item-prompt:hover button):hover {
3238
3232
  background-color: transparent;
3239
3233
  background-color: initial;
@@ -3374,10 +3368,10 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3374
3368
  }
3375
3369
  }
3376
3370
  .wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):hover {
3377
- background-color: color-mix(in srgb, var(--color-background-neutral-hover) 25%, transparent);
3371
+ background-color: color-mix(in srgb, var(--color-background-neutral-hover) 35%, transparent);
3378
3372
  }
3379
3373
  .wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):active {
3380
- background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
3374
+ background-color: color-mix(in srgb, var(--color-background-neutral-active) 45%, transparent);
3381
3375
  }
3382
3376
  .wds-list-item .wds-list-item-spotlight__border {
3383
3377
  position: absolute;
@@ -20,10 +20,10 @@
20
20
  border-bottom: 1px solid rgba(0,0,0,0.10196);
21
21
  border-bottom: 1px solid var(--color-border-neutral);
22
22
  }
23
- .np-header--group,
24
- .np-header--group .np-header__title {
23
+ .np-header__title {
25
24
  color: #5d7079;
26
25
  color: var(--color-content-secondary);
26
+ margin: 0;
27
27
  }
28
28
  .np-header__action {
29
29
  margin: 0;
@@ -584,12 +584,6 @@
584
584
  outline-offset: var(--ring-outline-offset);
585
585
  outline-offset: -1px;
586
586
  }
587
- .wds-list-item-interactive.wds-list-item-spotlight:not(.disabled):not(:disabled):hover {
588
- background-color: var(--color-background-screen-hover);
589
- }
590
- .wds-list-item-interactive.wds-list-item-spotlight:not(.disabled):not(:disabled):active {
591
- background-color: var(--color-background-screen-active);
592
- }
593
587
  .wds-list-item-interactive.wds-list-item-spotlight:has(.wds-list-item-prompt:hover a, .wds-list-item-prompt:hover button):hover {
594
588
  background-color: transparent;
595
589
  background-color: initial;
@@ -730,10 +724,10 @@
730
724
  }
731
725
  }
732
726
  .wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):hover {
733
- background-color: color-mix(in srgb, var(--color-background-neutral-hover) 25%, transparent);
727
+ background-color: color-mix(in srgb, var(--color-background-neutral-hover) 35%, transparent);
734
728
  }
735
729
  .wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):active {
736
- background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
730
+ background-color: color-mix(in srgb, var(--color-background-neutral-active) 45%, transparent);
737
731
  }
738
732
  .wds-list-item .wds-list-item-spotlight__border {
739
733
  position: absolute;
@@ -2454,10 +2454,10 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2454
2454
  border-bottom: 1px solid rgba(0,0,0,0.10196);
2455
2455
  border-bottom: 1px solid var(--color-border-neutral);
2456
2456
  }
2457
- .np-header--group,
2458
- .np-header--group .np-header__title {
2457
+ .np-header__title {
2459
2458
  color: #5d7079;
2460
2459
  color: var(--color-content-secondary);
2460
+ margin: 0;
2461
2461
  }
2462
2462
  .np-header__action {
2463
2463
  margin: 0;
@@ -3228,12 +3228,6 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3228
3228
  outline-offset: var(--ring-outline-offset);
3229
3229
  outline-offset: -1px;
3230
3230
  }
3231
- .wds-list-item-interactive.wds-list-item-spotlight:not(.disabled):not(:disabled):hover {
3232
- background-color: var(--color-background-screen-hover);
3233
- }
3234
- .wds-list-item-interactive.wds-list-item-spotlight:not(.disabled):not(:disabled):active {
3235
- background-color: var(--color-background-screen-active);
3236
- }
3237
3231
  .wds-list-item-interactive.wds-list-item-spotlight:has(.wds-list-item-prompt:hover a, .wds-list-item-prompt:hover button):hover {
3238
3232
  background-color: transparent;
3239
3233
  background-color: initial;
@@ -3374,10 +3368,10 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3374
3368
  }
3375
3369
  }
3376
3370
  .wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):hover {
3377
- background-color: color-mix(in srgb, var(--color-background-neutral-hover) 25%, transparent);
3371
+ background-color: color-mix(in srgb, var(--color-background-neutral-hover) 35%, transparent);
3378
3372
  }
3379
3373
  .wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):active {
3380
- background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
3374
+ background-color: color-mix(in srgb, var(--color-background-neutral-active) 45%, transparent);
3381
3375
  }
3382
3376
  .wds-list-item .wds-list-item-spotlight__border {
3383
3377
  position: absolute;
@@ -1 +1 @@
1
- {"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../src/header/Header.t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K,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;CAC7C,CAAC;AAEF,KAAK,iBAAiB,GAAG,WAAW,CAAC;AACrC,KAAK,eAAe,GAAG,WAAW,GAAG,SAAS,CAAC;AAE/C,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C;;;OAGG;IACH,MAAM,CAAC,EAAE,iBAAiB,GAAG,eAAe,CAAC;IAE7C;;;;;;;;OAQG;IACH,EAAE,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAEnC,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IAEd,uDAAuD;IACvD,KAAK,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAE5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA4BD;;;;;;;;;;GAUG;AACH,QAAA,MAAM,MAAM,EAAE,iBAAiB,CAAC,WAAW,CA+C1C,CAAC;AAIF,eAAe,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "0.0.0-experimental-91e668a",
3
+ "version": "0.0.0-experimental-3232842",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -20,10 +20,10 @@
20
20
  border-bottom: 1px solid rgba(0,0,0,0.10196);
21
21
  border-bottom: 1px solid var(--color-border-neutral);
22
22
  }
23
- .np-header--group,
24
- .np-header--group .np-header__title {
23
+ .np-header__title {
25
24
  color: #5d7079;
26
25
  color: var(--color-content-secondary);
26
+ margin: 0;
27
27
  }
28
28
  .np-header__action {
29
29
  margin: 0;
@@ -11,11 +11,11 @@
11
11
  &--group {
12
12
  align-items: flex-end;
13
13
  border-bottom: 1px solid var(--color-border-neutral);
14
+ }
14
15
 
15
- &,
16
- .np-header__title{
17
- color: var(--color-content-secondary);
18
- }
16
+ &__title {
17
+ color: var(--color-content-secondary);
18
+ margin: 0;
19
19
  }
20
20
 
21
21
  &__action {
@@ -1,5 +1,6 @@
1
1
  import { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import Header, { HeaderProps } from './Header';
3
+ import { storyConfig } from '../test-utils';
3
4
 
4
5
  const withContainer = (Story: any) => (
5
6
  <div style={{ display: 'flex', justifyContent: 'center' }}>
@@ -27,6 +28,41 @@ const renderHeader = (args: HeaderProps) => {
27
28
  return <Header {...args} />;
28
29
  };
29
30
 
31
+ /**
32
+ * Helper to generate variants for `AllVariants` story.
33
+ */
34
+ const renderVariants = () => (
35
+ <div
36
+ className="header-variants"
37
+ style={{ display: 'flex', flexWrap: 'wrap', gap: '16px', maxWidth: '1200px' }}
38
+ >
39
+ {(['h1', 'h2', 'h3', 'legend'] as const).map((as) => (
40
+ <Header key={as} as={as} title={`Header as ${as}`} />
41
+ ))}
42
+ {(['section', 'group'] as const).map((level) => (
43
+ <Header key={level} level={level} title={`Header level ${level}`} />
44
+ ))}
45
+ <Header
46
+ as="h2"
47
+ title="Header with Action"
48
+ action={{
49
+ 'aria-label': 'Action',
50
+ text: 'Action',
51
+ onClick: () => alert('Action clicked!'),
52
+ }}
53
+ />
54
+ <Header
55
+ as="h2"
56
+ title="Header with link"
57
+ action={{
58
+ 'aria-label': 'Action',
59
+ text: 'Action',
60
+ href: 'https://wise.com',
61
+ }}
62
+ />
63
+ </div>
64
+ );
65
+
30
66
  /**
31
67
  * The stories below document the `Header` component, which is used to structure content and convey hierarchy. <br />
32
68
  * For more details, refer to the [design documentation](https://wise.design/components/section-header).
@@ -50,7 +86,7 @@ const meta: Meta<typeof Header> = {
50
86
  as: {
51
87
  type: {
52
88
  name: 'enum',
53
- value: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'legend'],
89
+ value: ['h1', 'h2', 'h3', 'legend'],
54
90
  },
55
91
  table: {
56
92
  type: {
@@ -155,3 +191,17 @@ export const SectionLevel: Story = {
155
191
  },
156
192
  argTypes: hideControls(['action', 'as', 'className', 'title', 'testId']),
157
193
  };
194
+
195
+ /**
196
+ * Displays all variants of the `Header` component, including different levels, tags, and actions.
197
+ */
198
+ export const AllVariants = storyConfig(
199
+ {
200
+ tags: ['!autodocs'],
201
+ parameters: {
202
+ padding: '0',
203
+ },
204
+ render: renderVariants,
205
+ },
206
+ { variants: ['default', 'dark', 'bright-green', 'forest-green', 'rtl'] },
207
+ );
@@ -1,6 +1,7 @@
1
1
  import { clsx } from 'clsx';
2
2
 
3
3
  import { AriaLabelProperty, CommonProps, Heading, LinkProps, Typography } from '../common';
4
+ import Button from '../button';
4
5
  import Link from '../link';
5
6
  import Title from '../title';
6
7
  import React, { useEffect, useRef, FunctionComponent } from 'react';
@@ -86,8 +87,10 @@ const Header: FunctionComponent<HeaderProps> = React.forwardRef(
86
87
  const internalRef = useRef<HTMLLegendElement>(null);
87
88
  const levelTypography =
88
89
  level === 'group' ? Typography.TITLE_GROUP : Typography.TITLE_SUBSECTION;
90
+ const isLegendOrNoAction = !action || as === 'legend';
89
91
  const headerClasses = clsx('np-header', className, {
90
92
  'np-header--group': level === 'group',
93
+ 'np-header__title': isLegendOrNoAction,
91
94
  });
92
95
 
93
96
  const commonProps = {
@@ -584,12 +584,6 @@
584
584
  outline-offset: var(--ring-outline-offset);
585
585
  outline-offset: -1px;
586
586
  }
587
- .wds-list-item-interactive.wds-list-item-spotlight:not(.disabled):not(:disabled):hover {
588
- background-color: var(--color-background-screen-hover);
589
- }
590
- .wds-list-item-interactive.wds-list-item-spotlight:not(.disabled):not(:disabled):active {
591
- background-color: var(--color-background-screen-active);
592
- }
593
587
  .wds-list-item-interactive.wds-list-item-spotlight:has(.wds-list-item-prompt:hover a, .wds-list-item-prompt:hover button):hover {
594
588
  background-color: transparent;
595
589
  background-color: initial;
@@ -730,10 +724,10 @@
730
724
  }
731
725
  }
732
726
  .wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):hover {
733
- background-color: color-mix(in srgb, var(--color-background-neutral-hover) 25%, transparent);
727
+ background-color: color-mix(in srgb, var(--color-background-neutral-hover) 35%, transparent);
734
728
  }
735
729
  .wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):active {
736
- background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
730
+ background-color: color-mix(in srgb, var(--color-background-neutral-active) 45%, transparent);
737
731
  }
738
732
  .wds-list-item .wds-list-item-spotlight__border {
739
733
  position: absolute;
@@ -80,16 +80,6 @@
80
80
  outline-offset: -1px;
81
81
  }
82
82
 
83
- &:not(.disabled, :disabled) {
84
- &:hover {
85
- background-color: var(--color-background-screen-hover);
86
- }
87
-
88
- &:active {
89
- background-color: var(--color-background-screen-active);
90
- }
91
- }
92
-
93
83
  &:has(.wds-list-item-prompt:hover a, .wds-list-item-prompt:hover button) {
94
84
  &:hover {
95
85
  background-color: unset;
@@ -236,32 +226,36 @@
236
226
  }
237
227
  }
238
228
 
239
-
240
-
241
229
  &-spotlight {
242
230
  padding-left: var(--size-12);
243
231
  padding-right: var(--size-12);
244
232
 
245
233
  &-active {
246
234
  background-color: var(--color-background-neutral);
247
- &:not(.disabled, :disabled):hover {
235
+ &:not(.disabled, :disabled) {
236
+ &:hover {
248
237
  background-color: var(--color-background-neutral-hover);
249
- }
250
- &:not(.disabled, :disabled):active {
238
+ }
239
+ &:active {
251
240
  background-color: var(--color-background-neutral-active);
241
+ }
252
242
  }
253
243
  }
254
244
 
255
245
  &-inactive {
256
- background-color: color-mix(in srgb, var(--color-background-neutral) 25%, transparent);
257
-
258
- &:not(.disabled, :disabled):hover {
259
- background-color: color-mix(in srgb, var(--color-background-neutral-hover) 25%, transparent);
260
- }
261
- &:not(.disabled, :disabled):active {
262
- background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
246
+ background-color: color-mix(in srgb, var(--color-background-neutral) 25%, transparent);
247
+
248
+ &:not(.disabled, :disabled) {
249
+ &:hover {
250
+ background-color: color-mix(in srgb, var(--color-background-neutral-hover) 35%, transparent);
251
+ }
252
+ &:active {
253
+ background-color: color-mix(in srgb, var(--color-background-neutral-active) 45%, transparent);
254
+ }
263
255
  }
264
256
  }
257
+
258
+
265
259
  }
266
260
 
267
261
  .wds-list-item-spotlight__border{
package/src/main.css CHANGED
@@ -2454,10 +2454,10 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2454
2454
  border-bottom: 1px solid rgba(0,0,0,0.10196);
2455
2455
  border-bottom: 1px solid var(--color-border-neutral);
2456
2456
  }
2457
- .np-header--group,
2458
- .np-header--group .np-header__title {
2457
+ .np-header__title {
2459
2458
  color: #5d7079;
2460
2459
  color: var(--color-content-secondary);
2460
+ margin: 0;
2461
2461
  }
2462
2462
  .np-header__action {
2463
2463
  margin: 0;
@@ -3228,12 +3228,6 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3228
3228
  outline-offset: var(--ring-outline-offset);
3229
3229
  outline-offset: -1px;
3230
3230
  }
3231
- .wds-list-item-interactive.wds-list-item-spotlight:not(.disabled):not(:disabled):hover {
3232
- background-color: var(--color-background-screen-hover);
3233
- }
3234
- .wds-list-item-interactive.wds-list-item-spotlight:not(.disabled):not(:disabled):active {
3235
- background-color: var(--color-background-screen-active);
3236
- }
3237
3231
  .wds-list-item-interactive.wds-list-item-spotlight:has(.wds-list-item-prompt:hover a, .wds-list-item-prompt:hover button):hover {
3238
3232
  background-color: transparent;
3239
3233
  background-color: initial;
@@ -3374,10 +3368,10 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3374
3368
  }
3375
3369
  }
3376
3370
  .wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):hover {
3377
- background-color: color-mix(in srgb, var(--color-background-neutral-hover) 25%, transparent);
3371
+ background-color: color-mix(in srgb, var(--color-background-neutral-hover) 35%, transparent);
3378
3372
  }
3379
3373
  .wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):active {
3380
- background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
3374
+ background-color: color-mix(in srgb, var(--color-background-neutral-active) 45%, transparent);
3381
3375
  }
3382
3376
  .wds-list-item .wds-list-item-spotlight__border {
3383
3377
  position: absolute;
@@ -1,103 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react-webpack5';
2
- import Header, { type HeaderProps } from './Header';
3
- import { storyConfig } from '../test-utils';
4
-
5
- const meta: Meta<typeof Header> = {
6
- component: Header,
7
- tags: ['!autodocs'],
8
- title: 'Typography/Header/tests',
9
- };
10
- export default meta;
11
- type Story = StoryObj<HeaderProps>;
12
-
13
- const TestComponent = () => (
14
- <div
15
- className="p-a-4 text-xs-center font-weight-bold"
16
- style={{
17
- backgroundImage: `repeating-linear-gradient(
18
- -45deg, var(--color-background-neutral),
19
- var(--color-background-neutral) 10px,
20
- transparent 10px,
21
- transparent 20px
22
- )`,
23
- }}
24
- >
25
- Placeholder component
26
- </div>
27
- );
28
-
29
- const generateLevelStory = (level: HeaderProps['level'], withAction = false) => {
30
- return {
31
- render: () => {
32
- return (
33
- <>
34
- {(['legend', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as HeaderProps['as'][]).map((tag) => {
35
- const Wrapper = tag === 'legend' ? 'fieldset' : 'section';
36
-
37
- return (
38
- <Wrapper key={tag}>
39
- <Header
40
- as={tag}
41
- level={level}
42
- title={`Showcasing ${level} level with tag ${tag}`}
43
- action={withAction ? { text: 'Action', href: '#target' } : undefined}
44
- />
45
- <TestComponent />
46
- </Wrapper>
47
- );
48
- })}
49
- </>
50
- );
51
- },
52
- };
53
- };
54
-
55
- /**
56
- * Helper to generate variants for `AllVariants` story.
57
- */
58
- const renderVariants = () => (
59
- <div
60
- className="header-variants"
61
- style={{ display: 'flex', flexWrap: 'wrap', gap: '16px', maxWidth: '1200px' }}
62
- >
63
- {(['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'legend'] as const).map((as) => (
64
- <Header key={as} as={as} title={`Header as ${as}`} />
65
- ))}
66
- {(['section', 'group'] as const).map((level) => (
67
- <Header key={level} level={level} title={`Header level ${level}`} />
68
- ))}
69
- <Header
70
- as="h2"
71
- title="Header with Action"
72
- action={{
73
- 'aria-label': 'Action',
74
- text: 'Action',
75
- onClick: () => alert('Action clicked!'),
76
- }}
77
- />
78
- <Header
79
- as="h2"
80
- title="Header with link"
81
- action={{
82
- 'aria-label': 'Action',
83
- text: 'Action',
84
- href: 'https://wise.com',
85
- }}
86
- />
87
- </div>
88
- );
89
-
90
- export const GroupTrailingSpace: Story = generateLevelStory('group');
91
- export const GroupTrailingSpaceWithAction: Story = generateLevelStory('group', true);
92
- export const SectionTrailingSpace: Story = generateLevelStory('section');
93
- export const SectionTrailingSpaceWithAction: Story = generateLevelStory('section', true);
94
-
95
- export const AllVariants = storyConfig(
96
- {
97
- parameters: {
98
- padding: '0',
99
- },
100
- render: renderVariants,
101
- },
102
- { variants: ['default', 'dark', 'bright-green', 'forest-green', 'rtl'] },
103
- );