diff --git a/src/components/AppNotification/AppNotification.stories.tsx b/src/components/AppNotification/AppNotification.stories.tsx index 6422a7739..5ff5f2a8f 100644 --- a/src/components/AppNotification/AppNotification.stories.tsx +++ b/src/components/AppNotification/AppNotification.stories.tsx @@ -6,6 +6,8 @@ import React from 'react'; import { AppNotification } from './AppNotification'; import { ButtonV2 as Button } from '../Button'; import { ButtonGroupV2 as ButtonGroup } from '../ButtonGroup'; +import { LinkV2 as Link } from '../Link'; +import Text from '../Text'; export default { title: 'Components/V2/AppNotification', @@ -52,6 +54,20 @@ export const WithControls: StoryObj = { }, }; +export const WithLinkInSubtitle: StoryObj = { + args: { + subTitle: ( + + Some text with a{' '} + + link + {' '} + in. + + ), + }, +}; + export const LightColor: StoryObj = { args: { color: 'light', diff --git a/src/components/AppNotification/__snapshots__/AppNotification.test.ts.snap b/src/components/AppNotification/__snapshots__/AppNotification.test.ts.snap index e47f7b700..b3557c221 100644 --- a/src/components/AppNotification/__snapshots__/AppNotification.test.ts.snap +++ b/src/components/AppNotification/__snapshots__/AppNotification.test.ts.snap @@ -282,3 +282,43 @@ exports[` WithDismissAndControls story renders snapshot 1`] = `; + +exports[` WithLinkInSubtitle story renders snapshot 1`] = ` +
+
+
+
+ This is an AppNotification title +
+

+ + Some text with a + + + link + + + in. + +

+
+
+
+
+`; diff --git a/src/components/Link/Link-v2.module.css b/src/components/Link/Link-v2.module.css index cf66ad809..1502470d5 100644 --- a/src/components/Link/Link-v2.module.css +++ b/src/components/Link/Link-v2.module.css @@ -8,7 +8,6 @@ */ .link { - color: var(--eds-theme-color-text-utility-default-primary); display: inline; /* TODO: verify the way to sync type tokens and one-off treatments */ @@ -17,7 +16,7 @@ } /** - * Sub-components + * Sub-components (only should apply to standalone links */ .link__icon { padding-left: 0.25rem; @@ -37,6 +36,15 @@ .link--context-standalone { display: block; + &.link--emphasis-default { + color: var(--eds-theme-color-text-utility-default-primary); + } + + &.link--emphasis-low { + color: var(--eds-theme-color-text-utility-default-primary); + text-decoration: none; + } + /** * Sizes - using the presets for type ramp matching body-* */ @@ -64,31 +72,25 @@ /** * Emphasis */ -.link--emphasis-high { - color: var(--eds-theme-color-text-utility-interactive-secondary); +.link--emphasis-default { + color: inherit; } -.link--emphasis-low { - color: var(--eds-theme-color-text-utility-default-primary); - text-decoration: none; +.link--emphasis-high { + color: var(--eds-theme-color-text-utility-interactive-secondary); } /** - * Variants + * Inverse variant */ -.link.link--variant-inverse { - color: var(--eds-theme-color-text-utility-inverse); - - &:active, - &:visited { +.link.link--variant-inverse:hover, +.link.link--variant-inverse:active { color: var(--eds-theme-color-text-utility-inverse); - } } /** * States */ - .link:hover { color: var(--eds-theme-color-text-utility-interactive-secondary-hover); } diff --git a/src/components/Link/Link-v2.stories.tsx b/src/components/Link/Link-v2.stories.tsx index 64d3102d3..fff8ed9c4 100644 --- a/src/components/Link/Link-v2.stories.tsx +++ b/src/components/Link/Link-v2.stories.tsx @@ -12,16 +12,22 @@ export default { args: { children: 'Link', size: 'lg', - href: 'https://go.czi.team/eds', + href: 'http://example.org/', // stop link from navigating to another page so we can click the link for testing onClick: (event: any) => event.preventDefault(), }, + decorators: [ + (Story) =>
{Story()}
, + ], } as Meta; type Args = React.ComponentProps; export const Default: StoryObj = {}; +/** + * When using context, you can specify a trailing icon for the link. + */ export const LinkWithChevron: StoryObj = { args: { children: 'Default', @@ -30,6 +36,9 @@ export const LinkWithChevron: StoryObj = { }, }; +/** + * When using context, you can specify a trailing icon for the link. When using the open icon, make sure that a new tab/window is opened. + */ export const LinkWithOpenIcon: StoryObj = { args: { children: 'Default', @@ -38,6 +47,9 @@ export const LinkWithOpenIcon: StoryObj = { }, }; +/** + * You can add formatting to the link if needed. + */ export const LinkWithFormattedChildren: StoryObj = { args: { children: emphasized link, @@ -46,6 +58,9 @@ export const LinkWithFormattedChildren: StoryObj = { }, }; +/** + * Standalone links can have additional emphasis or minimized emphasis applied. + */ export const Emphasis: StoryObj = { args: { size: 'md', @@ -78,7 +93,7 @@ export const Inverse: StoryObj = { // TODO: find a cleaner way to decorate with unavailable tokens using parameters:backgounds: decorators: [ (Story) => ( -
+
{Story()}
), @@ -86,18 +101,46 @@ export const Inverse: StoryObj = { }; export const LinkInParagraphContext: StoryObj = { - render: ( - args: React.JSX.IntrinsicAttributes & - (LinkV2Props & React.RefAttributes), - ) => ( + render: (args) => ( +
+ Lorem ipsum dolor sit amet,{' '} + + consectetur adipiscing elit + + . Morbi porta at ante quis molestie. Nam scelerisque id diam at iaculis. + Nullam sit amet iaculis erat. Nulla id tellus ante.{' '} + + Aliquam pellentesque ipsum sagittis, commodo neque at, ornare est. + Maecenas a malesuada sem, vitae euismod erat. Nullam molestie nunc non + dui dignissim fermentum. + {' '} + Aliquam id volutpat nulla, sed auctor orci. Fusce cursus leo nisi. Fusce + vehicula vitae nisl nec ultricies. Cras ut enim nec magna semper egestas. + Sed sed quam id nisl bibendum convallis. Proin suscipit, odio{' '} + + vel pulvinar + {' '} + euismod, risus eros ullamcorper lectus, non blandit nulla dui eget massa. +
+ ), +}; + +/** + * Links will inherit the color from the surrounding text color definition (default emphasis, inline links) + */ +export const InheritColor: StoryObj = { + args: { + children: 'Inheriting', + }, + render: (args) => (
Lorem ipsum dolor sit amet,{' '} - + consectetur adipiscing elit . Morbi porta at ante quis molestie. Nam scelerisque id diam at iaculis. Nullam sit amet iaculis erat. Nulla id tellus ante.{' '} - + Aliquam pellentesque ipsum sagittis, commodo neque at, ornare est. Maecenas a malesuada sem, vitae euismod erat. Nullam molestie nunc non dui dignissim fermentum. @@ -105,16 +148,21 @@ export const LinkInParagraphContext: StoryObj = { Aliquam id volutpat nulla, sed auctor orci. Fusce cursus leo nisi. Fusce vehicula vitae nisl nec ultricies. Cras ut enim nec magna semper egestas. Sed sed quam id nisl bibendum convallis. Proin suscipit, odio{' '} - + vel pulvinar {' '} euismod, risus eros ullamcorper lectus, non blandit nulla dui eget massa.
), + decorators: [ + (Story) =>
{Story()}
, + ], }; -// Here, we introduce a special type extension to LinkProps, then use it in a -// composed component, to demonstrate the ability to offer custom props to a component +/** + * Here, we introduce a special type extension to LinkProps, then use it in a + * composed component, to demonstrate the ability to offer custom props to a component + */ type ExtendArgs = LinkV2Props<{ to: string }>; function ExtendedLink(args: ExtendArgs) { return ( @@ -150,7 +198,11 @@ export const UsingExtendedLink: StoryObj = { render: (args) => (
Lorem ipsum dolor sit amet,{' '} - + consectetur adipiscing elit . Morbi porta at ante quis molestie. Nam scelerisque id diam at iaculis. diff --git a/src/components/Link/Link-v2.tsx b/src/components/Link/Link-v2.tsx index 9f832daa6..5dd55bb47 100644 --- a/src/components/Link/Link-v2.tsx +++ b/src/components/Link/Link-v2.tsx @@ -79,6 +79,8 @@ export const Link = forwardRef( const iconSize = size && (['xl', 'lg'].includes(size) ? '1.5rem' : '1rem'); + // TODO-AH: Inline links cannot be lowEmphasis (add runtime warning) + // TODO-AH: chevron-right only allowr when lowEmphasis is used (add runtime warning) return ( {children} diff --git a/src/components/Link/__snapshots__/Link-v2.test.tsx.snap b/src/components/Link/__snapshots__/Link-v2.test.tsx.snap index 5dcf92a09..7ed75ebcf 100644 --- a/src/components/Link/__snapshots__/Link-v2.test.tsx.snap +++ b/src/components/Link/__snapshots__/Link-v2.test.tsx.snap @@ -1,166 +1,238 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[` Default story renders snapshot 1`] = ` - - Link - -`; - -exports[` Emphasis story renders snapshot 1`] = ` -
- - Default Emphasis - - High Emphasis + Link - +`; + +exports[` Emphasis story renders snapshot 1`] = ` + +`; + +exports[` InheritColor story renders snapshot 1`] = ` +
+
- Low Emphasis - +
+ Lorem ipsum dolor sit amet, + + + consectetur adipiscing elit + + . Morbi porta at ante quis molestie. Nam scelerisque id diam at iaculis. Nullam sit amet iaculis erat. Nulla id tellus ante. + + + Aliquam pellentesque ipsum sagittis, commodo neque at, ornare est. Maecenas a malesuada sem, vitae euismod erat. Nullam molestie nunc non dui dignissim fermentum. + + + Aliquam id volutpat nulla, sed auctor orci. Fusce cursus leo nisi. Fusce vehicula vitae nisl nec ultricies. Cras ut enim nec magna semper egestas. Sed sed quam id nisl bibendum convallis. Proin suscipit, odio + + + vel pulvinar + + + euismod, risus eros ullamcorper lectus, non blandit nulla dui eget massa. +
+
`; exports[` Inverse story renders snapshot 1`] = `
`; exports[` LinkInParagraphContext story renders snapshot 1`] = ` -
- Lorem ipsum dolor sit amet, - - - consectetur adipiscing elit - - . Morbi porta at ante quis molestie. Nam scelerisque id diam at iaculis. Nullam sit amet iaculis erat. Nulla id tellus ante. - - - Aliquam pellentesque ipsum sagittis, commodo neque at, ornare est. Maecenas a malesuada sem, vitae euismod erat. Nullam molestie nunc non dui dignissim fermentum. - - - Aliquam id volutpat nulla, sed auctor orci. Fusce cursus leo nisi. Fusce vehicula vitae nisl nec ultricies. Cras ut enim nec magna semper egestas. Sed sed quam id nisl bibendum convallis. Proin suscipit, odio - - - vel pulvinar - - - euismod, risus eros ullamcorper lectus, non blandit nulla dui eget massa. +
+
+ Lorem ipsum dolor sit amet, + + + consectetur adipiscing elit + + . Morbi porta at ante quis molestie. Nam scelerisque id diam at iaculis. Nullam sit amet iaculis erat. Nulla id tellus ante. + + + Aliquam pellentesque ipsum sagittis, commodo neque at, ornare est. Maecenas a malesuada sem, vitae euismod erat. Nullam molestie nunc non dui dignissim fermentum. + + + Aliquam id volutpat nulla, sed auctor orci. Fusce cursus leo nisi. Fusce vehicula vitae nisl nec ultricies. Cras ut enim nec magna semper egestas. Sed sed quam id nisl bibendum convallis. Proin suscipit, odio + + + vel pulvinar + + + euismod, risus eros ullamcorper lectus, non blandit nulla dui eget massa. +
`; exports[` LinkWithChevron story renders snapshot 1`] = ` - - Default - - + Default + + +
`; exports[` LinkWithFormattedChildren story renders snapshot 1`] = ` - - - emphasized link - - - + + emphasized link + + + +
`; exports[` LinkWithOpenIcon story renders snapshot 1`] = ` - - Default - - + Default + + +
`; exports[` UsingExtendedLink story renders snapshot 1`] = ` -
- Lorem ipsum dolor sit amet, - - - consectetur adipiscing elit - - . Morbi porta at ante quis molestie. Nam scelerisque id diam at iaculis. Nullam sit amet iaculis erat. Nulla id tellus ante. - +
+
+ Lorem ipsum dolor sit amet, + + + consectetur adipiscing elit + + . Morbi porta at ante quis molestie. Nam scelerisque id diam at iaculis. Nullam sit amet iaculis erat. Nulla id tellus ante. + +
`;