From 340f917ae60082f246c1ac4201408bf32fa4741f Mon Sep 17 00:00:00 2001 From: niftea <73510936+niftea@users.noreply.github.com> Date: Wed, 8 Jan 2025 09:07:50 -0800 Subject: [PATCH] feat: Add new InformationHighlight component to Preview (#3015) Fixes: #1175, #2483 Resolves: The need for an Information Highlight component. Moves the existing Information Highlight out of `modules/docs` and into `modules/preview-react`. Updates the existing design of Information Highlight to match the most recent specs and adding a `high` and `low` emphasis options. Updates `Hyperlink` to use new CSS Styling Utilities and tokens. [category:Components] Release Note: Added new component `InformationHighlight`, to the `preview` package. Refactored `Hyperlink` to use new CSS Utilities and tokens. Co-authored-by: Arianna Malakis --- .../component/InformationHighlight.spec.tsx | 22 ++++ modules/docs/index.ts | 1 - .../docs/lib/InformationHighlight/Base.tsx | 12 -- .../docs/lib/InformationHighlight/Body.tsx | 21 ---- .../docs/lib/InformationHighlight/Heading.tsx | 20 --- .../docs/lib/InformationHighlight/Icon.tsx | 65 ---------- .../docs/lib/InformationHighlight/Link.tsx | 20 --- .../docs/lib/InformationHighlight/index.tsx | 62 --------- .../InformationHighlight/LICENSE | 51 ++++++++ .../InformationHighlight/README.md | 10 ++ .../InformationHighlight/index.tsx | 5 + .../lib/InformationHighlight.tsx | 118 ++++++++++++++++++ .../hooks/useInformationHighlightModel.ts} | 6 +- .../InformationHighlight/lib/parts/Body.tsx | 29 +++++ .../lib/parts/Heading.tsx | 35 ++++++ .../InformationHighlight/lib/parts/Icon.tsx | 30 +++++ .../InformationHighlight/lib/parts/Link.tsx | 30 +++++ .../spec/InformationHighlight.spec.tsx | 21 ++++ .../stories/InformationHighlight.mdx | 110 ++++++++++++++++ .../stories/InformationHighlight.stories.ts | 51 ++++++++ .../stories/examples/Basic.tsx | 18 +++ .../stories/examples/Body.tsx | 13 ++ .../stories/examples/Caution.tsx | 27 ++++ .../stories/examples/Critical.tsx | 33 +++++ .../stories/examples/CustomIconCritical.tsx | 28 +++++ .../stories/examples/Heading.tsx | 11 ++ .../stories/examples/Informational.tsx | 27 ++++ .../stories/examples/RTL.tsx | 42 +++++++ .../stories/tsconfig.json | 3 + .../visual_testing/testing.stories.tsx | 85 +++++++++++++ modules/preview-react/index.ts | 1 + modules/react/button/lib/Hyperlink.tsx | 84 ++++++------- modules/react/tokens/stories/Tokens.mdx | 3 +- 33 files changed, 844 insertions(+), 250 deletions(-) create mode 100644 cypress/component/InformationHighlight.spec.tsx delete mode 100644 modules/docs/lib/InformationHighlight/Base.tsx delete mode 100644 modules/docs/lib/InformationHighlight/Body.tsx delete mode 100644 modules/docs/lib/InformationHighlight/Heading.tsx delete mode 100644 modules/docs/lib/InformationHighlight/Icon.tsx delete mode 100644 modules/docs/lib/InformationHighlight/Link.tsx delete mode 100644 modules/docs/lib/InformationHighlight/index.tsx create mode 100644 modules/preview-react/InformationHighlight/LICENSE create mode 100644 modules/preview-react/InformationHighlight/README.md create mode 100644 modules/preview-react/InformationHighlight/index.tsx create mode 100644 modules/preview-react/InformationHighlight/lib/InformationHighlight.tsx rename modules/{docs/lib/InformationHighlight/modelHook.ts => preview-react/InformationHighlight/lib/hooks/useInformationHighlightModel.ts} (63%) create mode 100644 modules/preview-react/InformationHighlight/lib/parts/Body.tsx create mode 100644 modules/preview-react/InformationHighlight/lib/parts/Heading.tsx create mode 100644 modules/preview-react/InformationHighlight/lib/parts/Icon.tsx create mode 100644 modules/preview-react/InformationHighlight/lib/parts/Link.tsx create mode 100644 modules/preview-react/InformationHighlight/spec/InformationHighlight.spec.tsx create mode 100644 modules/preview-react/InformationHighlight/stories/InformationHighlight.mdx create mode 100644 modules/preview-react/InformationHighlight/stories/InformationHighlight.stories.ts create mode 100644 modules/preview-react/InformationHighlight/stories/examples/Basic.tsx create mode 100644 modules/preview-react/InformationHighlight/stories/examples/Body.tsx create mode 100644 modules/preview-react/InformationHighlight/stories/examples/Caution.tsx create mode 100644 modules/preview-react/InformationHighlight/stories/examples/Critical.tsx create mode 100644 modules/preview-react/InformationHighlight/stories/examples/CustomIconCritical.tsx create mode 100644 modules/preview-react/InformationHighlight/stories/examples/Heading.tsx create mode 100644 modules/preview-react/InformationHighlight/stories/examples/Informational.tsx create mode 100644 modules/preview-react/InformationHighlight/stories/examples/RTL.tsx create mode 100644 modules/preview-react/InformationHighlight/stories/tsconfig.json create mode 100644 modules/preview-react/InformationHighlight/stories/visual_testing/testing.stories.tsx diff --git a/cypress/component/InformationHighlight.spec.tsx b/cypress/component/InformationHighlight.spec.tsx new file mode 100644 index 0000000000..9ca2a7672e --- /dev/null +++ b/cypress/component/InformationHighlight.spec.tsx @@ -0,0 +1,22 @@ +import * as React from 'react'; +import {Informational} from '../../modules/preview-react/InformationHighlight/stories/examples/Informational'; +import {Caution} from '../../modules/preview-react/InformationHighlight/stories/examples/Caution'; +import {Critical} from '../../modules/preview-react/InformationHighlight/stories/examples/Critical'; + +describe('Information Highlight', () => { + [Informational, Caution, Critical].forEach(Example => { + context(`${Example.name} Example`, () => { + beforeEach(() => { + cy.mount(); + }); + + it('should pass axe checks', () => { + cy.checkA11y(); + }); + + it('should have an element with a role of "heading"', () => { + cy.findAllByRole('heading').should('be.visible'); + }); + }); + }); +}); diff --git a/modules/docs/index.ts b/modules/docs/index.ts index eca7f2c6ab..44a1eefb79 100644 --- a/modules/docs/index.ts +++ b/modules/docs/index.ts @@ -1,6 +1,5 @@ export {ExampleCodeBlock} from './lib/ExampleCodeBlock'; export * from './lib/specs'; -export * from './lib/InformationHighlight'; export * from './lib/Specifications'; export * from './lib/StylePropsTable'; export * from './lib/docs'; diff --git a/modules/docs/lib/InformationHighlight/Base.tsx b/modules/docs/lib/InformationHighlight/Base.tsx deleted file mode 100644 index 6e5a4445cc..0000000000 --- a/modules/docs/lib/InformationHighlight/Base.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import * as React from 'react'; -import {createComponent} from '@workday/canvas-kit-react/common'; -import {CSProps, handleCsProp} from '@workday/canvas-kit-styling'; - -export interface BaseProps extends CSProps {} - -export const Base = createComponent('div')({ - displayName: 'Base', - Component: (props: BaseProps, ref, Element) => { - return ; - }, -}); diff --git a/modules/docs/lib/InformationHighlight/Body.tsx b/modules/docs/lib/InformationHighlight/Body.tsx deleted file mode 100644 index 323781d143..0000000000 --- a/modules/docs/lib/InformationHighlight/Body.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import * as React from 'react'; -import {createComponent} from '@workday/canvas-kit-react/common'; -import {createStyles} from '@workday/canvas-kit-styling'; -import {base, system} from '@workday/canvas-tokens-web'; - -import {Base} from './Base'; - -const bodyStyles = createStyles({ - ...system.type.subtext.large, - color: base.blackPepper300, - gridColumn: '2', - fontWeight: 400, // This is here to keep createStyle types from being angry - margin: 0, -}); - -export const Body = createComponent('p')({ - displayName: 'Body', - Component: (props, ref, Element) => { - return ; - }, -}); diff --git a/modules/docs/lib/InformationHighlight/Heading.tsx b/modules/docs/lib/InformationHighlight/Heading.tsx deleted file mode 100644 index f61307e234..0000000000 --- a/modules/docs/lib/InformationHighlight/Heading.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import * as React from 'react'; -import {createComponent} from '@workday/canvas-kit-react/common'; -import {createStyles} from '@workday/canvas-kit-styling'; -import {base, system} from '@workday/canvas-tokens-web'; - -import {Base} from './Base'; - -const headingStyles = createStyles({ - ...system.type.body.small, - color: base.blackPepper400, - gridColumn: '2', - fontWeight: 700, // should use system.fontWeight.bold -}); - -export const Heading = createComponent('div')({ - displayName: 'Heading', - Component: (props, ref, Element) => { - return ; - }, -}); diff --git a/modules/docs/lib/InformationHighlight/Icon.tsx b/modules/docs/lib/InformationHighlight/Icon.tsx deleted file mode 100644 index 354abb145f..0000000000 --- a/modules/docs/lib/InformationHighlight/Icon.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import * as React from 'react'; -import {SystemIcon, SystemIconProps} from '@workday/canvas-kit-react/icon'; -import {createSubcomponent} from '@workday/canvas-kit-react/common'; - -import {cssVar} from '@workday/canvas-kit-styling'; -import { - infoIcon, - exclamationCircleIcon, - exclamationTriangleIcon, -} from '@workday/canvas-system-icons-web'; -import {base} from '@workday/canvas-tokens-web'; -import {useInformationHighlightModel} from './modelHook'; - -type Variant = 'emphasis' | 'caution' | 'attention'; - -const iconStyles = { - emphasis: { - accent: cssVar(base.blueberry400), - fill: cssVar(base.blueberry400), - background: 'none', - accentHover: cssVar(base.blueberry400), - fillHover: cssVar(base.blueberry400), - backgroundHover: 'none', - }, - caution: { - accent: cssVar(base.blackPepper400), - fill: cssVar(base.blackPepper400), - background: 'none', - accentHover: cssVar(base.blackPepper400), - fillHover: cssVar(base.blackPepper400), - backgroundHover: 'none', - }, - attention: { - accent: cssVar(base.cinnamon500), - fill: cssVar(base.cinnamon500), - background: 'none', - accentHover: cssVar(base.cinnamon500), - fillHover: cssVar(base.cinnamon500), - backgroundHover: 'none', - }, -}; - -export interface IconProps extends SystemIconProps { - variant: Variant; -} - -const defaultIcons = { - emphasis: infoIcon, - caution: exclamationTriangleIcon, - attention: exclamationCircleIcon, -}; - -export const Icon = createSubcomponent('span')({ - displayName: 'Icon', - modelHook: useInformationHighlightModel, -})(({icon, ...props}: IconProps, Element, model) => { - return ( - - ); -}); diff --git a/modules/docs/lib/InformationHighlight/Link.tsx b/modules/docs/lib/InformationHighlight/Link.tsx deleted file mode 100644 index 8062d39064..0000000000 --- a/modules/docs/lib/InformationHighlight/Link.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import * as React from 'react'; -import {ExternalHyperlink} from '@workday/canvas-kit-react/button'; -import {createComponent} from '@workday/canvas-kit-react/common'; -import {createStyles, cssVar} from '@workday/canvas-kit-styling'; -import {base, system} from '@workday/canvas-tokens-web'; - -const linkStyles = createStyles({ - ...system.type.subtext.large, - gridColumn: '2', - justifySelf: 'start', - color: `${cssVar(base.blueberry500)} !important`, - fontWeight: 500, // should use system.fontWeight.bold -}); - -export const Link = createComponent('div')({ - displayName: 'Link', - Component: (props, ref, Element) => { - return ; - }, -}); diff --git a/modules/docs/lib/InformationHighlight/index.tsx b/modules/docs/lib/InformationHighlight/index.tsx deleted file mode 100644 index dad24f415c..0000000000 --- a/modules/docs/lib/InformationHighlight/index.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import * as React from 'react'; -import {createContainer} from '@workday/canvas-kit-react/common'; -import {createModifiers, createStyles, cssVar} from '@workday/canvas-kit-styling'; -import {base, system} from '@workday/canvas-tokens-web'; - -import {Base, BaseProps} from './Base'; -import {Heading} from './Heading'; -import {Body} from './Body'; -import {Icon} from './Icon'; -import {Link} from './Link'; -import {useInformationHighlightModel} from './modelHook'; - -type Variant = 'emphasis' | 'caution' | 'attention'; - -interface InformationHighlightProps extends BaseProps { - variant?: Variant; -} - -const containerStyles = createStyles({ - backgroundColor: base.soap100, - display: 'grid', - gridTemplateColumns: 'min-content', - columnGap: system.space.x4, - rowGap: system.space.x2, - padding: system.space.x4, - borderRadius: system.shape.x1, -}); - -const containerModifiers = createModifiers({ - variant: { - emphasis: createStyles({ - borderInlineStart: `solid ${cssVar(system.space.x1)} ${cssVar(base.blueberry400)}`, - }), - caution: createStyles({ - borderInlineStart: `solid ${cssVar(system.space.x1)} ${cssVar( - base.cantaloupe400 - )}`, - }), - attention: createStyles({ - borderInlineStart: `solid ${cssVar(system.space.x1)} ${cssVar(base.cinnamon500)}`, - }), - }, -}); - -export const InformationHighlight = createContainer('section')({ - displayName: 'InformationHighlight', - modelHook: useInformationHighlightModel, - subComponents: { - Icon: Icon, - Heading: Heading, - Body: Body, - Link: Link, - }, -})((props: InformationHighlightProps, Element, model) => { - return ( - - ); -}); diff --git a/modules/preview-react/InformationHighlight/LICENSE b/modules/preview-react/InformationHighlight/LICENSE new file mode 100644 index 0000000000..5bcbbab3b9 --- /dev/null +++ b/modules/preview-react/InformationHighlight/LICENSE @@ -0,0 +1,51 @@ +Apache License, Version 2.0 Apache License Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. +You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: +You must give any other recipients of the Work or Derivative Works a copy of this License; and You must cause any modified files to carry prominent notices stating that You changed the files; and You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. +Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. +This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. +Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. +In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. +While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +©2020. Workday, Inc. All rights reserved. Workday and the Workday logo are registered trademarks of Workday, Inc. All other brand and product names are trademarks or registered trademarks of their respective holders. + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/modules/preview-react/InformationHighlight/README.md b/modules/preview-react/InformationHighlight/README.md new file mode 100644 index 0000000000..9618aad06c --- /dev/null +++ b/modules/preview-react/InformationHighlight/README.md @@ -0,0 +1,10 @@ +# Canvas Kit Information Highlight + + + PREVIEW: Beta + This component is work in progress and currently in prerelease. + +A information highlight component to highlight and prioritize content + +View the [documentation for Information Highlight](https://workday.github.io/canvas-kit/?path=/docs/preview-information-highlight--docs) +on Storybook. diff --git a/modules/preview-react/InformationHighlight/index.tsx b/modules/preview-react/InformationHighlight/index.tsx new file mode 100644 index 0000000000..f759049a7b --- /dev/null +++ b/modules/preview-react/InformationHighlight/index.tsx @@ -0,0 +1,5 @@ +export * from './lib/InformationHighlight'; +export * from './lib/parts/Body'; +export * from './lib/parts/Heading'; +export * from './lib/parts/Icon'; +export * from './lib/parts/Link'; diff --git a/modules/preview-react/InformationHighlight/lib/InformationHighlight.tsx b/modules/preview-react/InformationHighlight/lib/InformationHighlight.tsx new file mode 100644 index 0000000000..a75bdb7b94 --- /dev/null +++ b/modules/preview-react/InformationHighlight/lib/InformationHighlight.tsx @@ -0,0 +1,118 @@ +import * as React from 'react'; +import {createContainer} from '@workday/canvas-kit-react/common'; +import {cssVar, createStencil, handleCsProp, CSProps} from '@workday/canvas-kit-styling'; +import {base, system} from '@workday/canvas-tokens-web'; + +import {InformationHighlightHeading} from './parts/Heading'; +import {Body} from './parts/Body'; +import {Icon} from './parts/Icon'; +import {Link} from './parts/Link'; +import {useInformationHighlightModel} from './hooks/useInformationHighlightModel'; +import {systemIconStencil} from '@workday/canvas-kit-react/icon'; + +interface InformationHighlightProps extends CSProps {} + +export const informationHighlightStencil = createStencil({ + base: { + display: 'grid', + gridTemplateColumns: 'min-content', + columnGap: system.space.x4, + rowGap: system.space.x2, + padding: system.space.x4, + borderRadius: system.shape.x1, + }, + modifiers: { + informational: { + low: { + borderInlineStart: `solid ${cssVar(system.space.x1)} ${cssVar( + system.color.bg.primary.default + )}`, + backgroundColor: system.color.bg.alt.soft, + '& [data-part="information-highlight-icon"]': { + [systemIconStencil.vars.accentColor]: system.color.bg.primary.default, + [systemIconStencil.vars.color]: system.color.bg.primary.default, + [systemIconStencil.vars.backgroundColor]: 'none', + }, + }, + high: { + borderInlineStart: `solid ${cssVar(system.space.x1)} ${cssVar( + system.color.bg.primary.default + )}`, + backgroundColor: base.blueberry100, + '& [data-part="information-highlight-icon"]': { + [systemIconStencil.vars.accentColor]: system.color.icon.inverse, + [systemIconStencil.vars.color]: system.color.bg.primary.default, + [systemIconStencil.vars.backgroundColor]: system.color.bg.primary.default, + }, + }, + }, + caution: { + low: { + borderInlineStart: `solid ${cssVar(system.space.x1)} ${cssVar( + system.color.border.caution.default + )}`, + backgroundColor: system.color.bg.alt.soft, + '& [data-part="information-highlight-icon"]': { + [systemIconStencil.vars.accentColor]: system.color.fg.contrast.default, + [systemIconStencil.vars.color]: system.color.fg.contrast.default, + [systemIconStencil.vars.backgroundColor]: 'none', + }, + }, + high: { + borderInlineStart: `solid ${cssVar(system.space.x1)} ${cssVar( + system.color.border.caution.default + )}`, + backgroundColor: base.sourLemon100, + '& [data-part="information-highlight-icon"]': { + [systemIconStencil.vars.accentColor]: system.color.icon.inverse, + [systemIconStencil.vars.color]: system.color.fg.contrast.default, + [systemIconStencil.vars.backgroundColor]: system.color.fg.contrast.default, + }, + }, + }, + critical: { + low: { + borderInlineStart: `solid ${cssVar(system.space.x1)} ${cssVar( + system.color.border.critical.default + )}`, + backgroundColor: system.color.bg.alt.soft, + '& [data-part="information-highlight-icon"]': { + [systemIconStencil.vars.accentColor]: system.color.bg.critical.default, + [systemIconStencil.vars.color]: system.color.bg.critical.default, + [systemIconStencil.vars.backgroundColor]: 'none', + }, + }, + high: { + borderInlineStart: `solid ${cssVar(system.space.x1)} ${cssVar( + system.color.border.critical.default + )}`, + backgroundColor: base.peach100, + '& [data-part="information-highlight-icon"]': { + [systemIconStencil.vars.accentColor]: system.color.icon.inverse, + [systemIconStencil.vars.color]: system.color.bg.critical.default, + [systemIconStencil.vars.backgroundColor]: system.color.bg.critical.default, + }, + }, + }, + }, +}); + +export const InformationHighlight = createContainer('section')({ + displayName: 'InformationHighlight', + modelHook: useInformationHighlightModel, + subComponents: { + Icon: Icon, + Heading: InformationHighlightHeading, + Body: Body, + Link: Link, + }, +})(({...elemProps}: InformationHighlightProps, Element, model) => { + return ( + + ); +}); diff --git a/modules/docs/lib/InformationHighlight/modelHook.ts b/modules/preview-react/InformationHighlight/lib/hooks/useInformationHighlightModel.ts similarity index 63% rename from modules/docs/lib/InformationHighlight/modelHook.ts rename to modules/preview-react/InformationHighlight/lib/hooks/useInformationHighlightModel.ts index cf5dca0955..37425b9c8f 100644 --- a/modules/docs/lib/InformationHighlight/modelHook.ts +++ b/modules/preview-react/InformationHighlight/lib/hooks/useInformationHighlightModel.ts @@ -1,15 +1,15 @@ import {createModelHook} from '@workday/canvas-kit-react/common'; -export type Variant = 'emphasis' | 'caution' | 'attention'; - export const useInformationHighlightModel = createModelHook({ defaultConfig: { - variant: 'emphasis' as Variant, + variant: 'informational' as 'informational' | 'caution' | 'critical', + emphasis: 'low' as 'low' | 'high', }, })(config => { return { state: { variant: config.variant, + emphasis: config.emphasis, }, events: {}, }; diff --git a/modules/preview-react/InformationHighlight/lib/parts/Body.tsx b/modules/preview-react/InformationHighlight/lib/parts/Body.tsx new file mode 100644 index 0000000000..c327a10e82 --- /dev/null +++ b/modules/preview-react/InformationHighlight/lib/parts/Body.tsx @@ -0,0 +1,29 @@ +import * as React from 'react'; +import {createComponent, ExtractProps} from '@workday/canvas-kit-react/common'; +import {createStencil, cssVar, handleCsProp} from '@workday/canvas-kit-styling'; +import {system} from '@workday/canvas-tokens-web'; +import {Text} from '@workday/canvas-kit-react/text'; + +const informationHighlightBodyStencil = createStencil({ + base: () => { + return { + ...system.type.subtext.large, + color: system.color.text.strong, + gridColumn: '2', + margin: `0 0 ${cssVar(system.space.x2)} 0`, + }; + }, +}); + +export const Body = createComponent('p')({ + displayName: 'Body', + Component: ({...elemProps}: ExtractProps, ref, Element) => { + return ( + + ); + }, +}); diff --git a/modules/preview-react/InformationHighlight/lib/parts/Heading.tsx b/modules/preview-react/InformationHighlight/lib/parts/Heading.tsx new file mode 100644 index 0000000000..9c78a7ee28 --- /dev/null +++ b/modules/preview-react/InformationHighlight/lib/parts/Heading.tsx @@ -0,0 +1,35 @@ +import * as React from 'react'; +import {createComponent, ExtractProps} from '@workday/canvas-kit-react/common'; +import {createStencil, handleCsProp} from '@workday/canvas-kit-styling'; +import {system} from '@workday/canvas-tokens-web'; +import {Heading} from '@workday/canvas-kit-react/text'; + +const informationHighlightHeadingStencil = createStencil({ + base: () => { + return { + ...system.type.body.small, + color: system.color.text.strong, + gridColumn: '2', + fontWeight: system.fontWeight.bold, + marginTop: system.space.zero, + marginBottom: system.space.zero, + }; + }, +}); + +export interface InformationHighlightHeadingProps + extends Partial> {} + +export const InformationHighlightHeading = createComponent('h3')({ + displayName: 'Heading', + Component: ({size = 'small', ...elemProps}: InformationHighlightHeadingProps, ref, Element) => { + return ( + + ); + }, +}); diff --git a/modules/preview-react/InformationHighlight/lib/parts/Icon.tsx b/modules/preview-react/InformationHighlight/lib/parts/Icon.tsx new file mode 100644 index 0000000000..5ccd987096 --- /dev/null +++ b/modules/preview-react/InformationHighlight/lib/parts/Icon.tsx @@ -0,0 +1,30 @@ +import * as React from 'react'; +import {SystemIcon} from '@workday/canvas-kit-react/icon'; +import {createSubcomponent, ExtractProps} from '@workday/canvas-kit-react/common'; +import { + infoIcon, + exclamationCircleIcon, + exclamationTriangleIcon, +} from '@workday/canvas-system-icons-web'; +import {useInformationHighlightModel} from '../hooks/useInformationHighlightModel'; + +export interface IconProps extends Partial> {} +const defaultIcons = { + informational: infoIcon, + caution: exclamationTriangleIcon, + critical: exclamationCircleIcon, +}; + +export const Icon = createSubcomponent('span')({ + displayName: 'Icon', + modelHook: useInformationHighlightModel, +})(({icon, ...props}: IconProps, Element, model) => { + return ( + + ); +}); diff --git a/modules/preview-react/InformationHighlight/lib/parts/Link.tsx b/modules/preview-react/InformationHighlight/lib/parts/Link.tsx new file mode 100644 index 0000000000..bf7edd0899 --- /dev/null +++ b/modules/preview-react/InformationHighlight/lib/parts/Link.tsx @@ -0,0 +1,30 @@ +import * as React from 'react'; +import {Hyperlink} from '@workday/canvas-kit-react/button'; +import {createComponent, ExtractProps} from '@workday/canvas-kit-react/common'; +import {createStencil, handleCsProp} from '@workday/canvas-kit-styling'; +import {system} from '@workday/canvas-tokens-web'; + +const informationHighlightLinkStencil = createStencil({ + base: () => { + return { + ...system.type.subtext.large, + gridColumn: '2', + justifySelf: 'start', + color: system.color.text.strong, + fontWeight: system.fontWeight.bold, + }; + }, +}); + +export const Link = createComponent('a')({ + displayName: 'Link', + Component: ({...elemProps}: ExtractProps, ref, Element) => { + return ( + + ); + }, +}); diff --git a/modules/preview-react/InformationHighlight/spec/InformationHighlight.spec.tsx b/modules/preview-react/InformationHighlight/spec/InformationHighlight.spec.tsx new file mode 100644 index 0000000000..84ddc4c1ee --- /dev/null +++ b/modules/preview-react/InformationHighlight/spec/InformationHighlight.spec.tsx @@ -0,0 +1,21 @@ +/** + * @jest-environment node + */ +import React from 'react'; +import {renderToString} from 'react-dom/server'; +import {infoIcon} from '@workday/canvas-system-icons-web'; +import {InformationHighlight} from '../'; + +describe('InformationHighlight', () => { + it('should render on a server without crashing', () => { + const ssrRender = () => + renderToString( + + + Content + Content + + ); + expect(ssrRender).not.toThrow(); + }); +}); diff --git a/modules/preview-react/InformationHighlight/stories/InformationHighlight.mdx b/modules/preview-react/InformationHighlight/stories/InformationHighlight.mdx new file mode 100644 index 0000000000..307bb01193 --- /dev/null +++ b/modules/preview-react/InformationHighlight/stories/InformationHighlight.mdx @@ -0,0 +1,110 @@ +import { + ExampleCodeBlock, + SymbolDoc, + Specifications, +} from '@workday/canvas-kit-docs'; + +import * as InformationHighlight from './InformationHighlight.stories.ts'; +import { Basic } from './examples/Basic'; +import {Body} from './examples/Body'; +import {Heading} from './examples/Heading'; +import {Informational} from './examples/Informational'; +import {Caution} from './examples/Caution'; +import {Critical} from './examples/Critical'; +import {IconCritical} from './examples/CustomIconCritical'; +import {RTL} from './examples/RTL'; + + + +# Canvas Kit Information Highlight + +A container to call out important information on a page or a section of a page that the user should be aware of. + +## Installation + +```sh +yarn add @workday/canvas-kit-preview-react +``` + +## Usage + +`InformationHighlight` should be used to call out important information to the user and are paired with a meaningful + icon and color to differentiate information type. It should not be removed from the interface until some system or admin level action has been taken to do so. + +You can use an `InformationHighlight` to: +- Prevent unwanted consequences from destructive actions +- Reassure users in their next steps +- Provide detail into information on the page +- Show changes in page content + +### When to Consider Something Else +- Consider a [Banner](https://workday.github.io/canvas-kit/?path=/docs/components-indicators-banner--docs) if the message is about system-wide errors or alerts, or if the message appears in response to user action. +- Consider a [Dialog](https://workday.github.io/canvas-kit/?path=/docs/components-popups-dialog--docs) if the message is critical and requires user action or decision before proceeding +- Consider a [Toast](https://workday.github.io/canvas-kit/?path=/docs/components-popups-toast--docs) if the message is timely, such as communicating updates on the process of an application. +### Basic Example + + + +## Variants +`InformationHighlight` has three variants and each `variant` has two types of `emphasis`. + + +Variants: `informational`, `caution`, `critical` + +Emphasis: `low`, `high` + + +The variants have different icons and colors to convey severity and the emphasis changes the background color to have a + lower or higher contrast. If no `variant` or `emphasis` is selected the layout will default to + `Variant: informational, Emphasis: low`. + + +The following examples will show the `low` and `high` emphasis of the three variants. +`low` Emphasis will be shown first and should be used when there is other more important information on the page. +`high` Emphasis will be shown second, and should be used when the highlight is not competing with other, more important information. + +### Informational +The informational variant is for _nice to have_ information, such as related features or opportunities. + + +### Caution +The caution variant is for _important to know_ information, such as the potential consequences of specific actions. + + + + +### Critical +The critical variant is for _must know_ information that could otherwise cause failure if the user is unaware + + + + +### RTL Example + Information Highlight also supports RTL Languages. To enable RTL, add a custom theme with direction set to 'ContentDirection.RTL' + + +## Partial and Custom Information Highlights + +`InformationHighlight` can use custom icons or be designed to only use some of its components. + +### Custom Icon: Critical + + +### Body Only Example + + +### Heading Only Example + + +### Accessible Use of the `as` Prop +Like many of our components, `InformationHighlight` and it's subcomponents accept an `as` prop, which lets you change +the underlying semantic element. For `InformationHighlight.Heading`, you can change the heading level if you were +needing to define a different level of importance. This should be done with caution to ensure the best accessibility. + +## Component API + + + +## Specifications + + diff --git a/modules/preview-react/InformationHighlight/stories/InformationHighlight.stories.ts b/modules/preview-react/InformationHighlight/stories/InformationHighlight.stories.ts new file mode 100644 index 0000000000..0b27f7425b --- /dev/null +++ b/modules/preview-react/InformationHighlight/stories/InformationHighlight.stories.ts @@ -0,0 +1,51 @@ +import {Meta, StoryObj} from '@storybook/react'; + +import mdxDoc from './InformationHighlight.mdx'; + +import {InformationHighlight} from '@workday/canvas-kit-preview-react/InformationHighlight'; +import {Basic as BasicExample} from './examples/Basic'; +import {Body as BodyExample} from './examples/Body'; +import {Heading as HeadingExample} from './examples/Heading'; +import {Critical as CriticalExamples} from './examples/Critical'; +import {Caution as CautionExamples} from './examples/Caution'; +import {Informational as InformationalExamples} from './examples/Informational'; +import {IconCritical as IconCriticalExamples} from './examples/CustomIconCritical'; +import {RTL as RTLExample} from './examples/RTL'; + +export default { + title: 'Preview/Information Highlight', + component: InformationHighlight, + tags: ['autodocs'], + parameters: { + docs: { + page: mdxDoc, + }, + }, +} as Meta; + +type Story = StoryObj; + +export const Basic: Story = { + render: BasicExample, +}; +export const Body: Story = { + render: BodyExample, +}; +export const Heading: Story = { + render: HeadingExample, +}; +export const Critical: Story = { + render: CriticalExamples, +}; +export const Caution: Story = { + render: CautionExamples, +}; +export const Informational: Story = { + render: InformationalExamples, +}; +export const IconCritical: Story = { + render: IconCriticalExamples, +}; +export const RTL: Story = { + render: RTLExample, +}; diff --git a/modules/preview-react/InformationHighlight/stories/examples/Basic.tsx b/modules/preview-react/InformationHighlight/stories/examples/Basic.tsx new file mode 100644 index 0000000000..22f13118e6 --- /dev/null +++ b/modules/preview-react/InformationHighlight/stories/examples/Basic.tsx @@ -0,0 +1,18 @@ +import React from 'react'; + +import {InformationHighlight} from '@workday/canvas-kit-preview-react/InformationHighlight'; + +export const Basic = () => { + return ( + + + Information Highlight + + {' '} + This is what an information highlight would look like with with the default settings and + every field filled in{' '} + + View the Docs + + ); +}; diff --git a/modules/preview-react/InformationHighlight/stories/examples/Body.tsx b/modules/preview-react/InformationHighlight/stories/examples/Body.tsx new file mode 100644 index 0000000000..3ee4be5b01 --- /dev/null +++ b/modules/preview-react/InformationHighlight/stories/examples/Body.tsx @@ -0,0 +1,13 @@ +import React from 'react'; + +import {InformationHighlight} from '@workday/canvas-kit-preview-react/InformationHighlight'; + +export const Body = () => { + return ( + + + Only the body of an information highlight + + + ); +}; diff --git a/modules/preview-react/InformationHighlight/stories/examples/Caution.tsx b/modules/preview-react/InformationHighlight/stories/examples/Caution.tsx new file mode 100644 index 0000000000..f3d83daabf --- /dev/null +++ b/modules/preview-react/InformationHighlight/stories/examples/Caution.tsx @@ -0,0 +1,27 @@ +import React from 'react'; +import {Flex} from '@workday/canvas-kit-react/layout'; +import {InformationHighlight} from '@workday/canvas-kit-preview-react/InformationHighlight'; +import {system} from '@workday/canvas-tokens-web'; + +export const Caution = () => { + return ( + + + + Caution: Highlight Something + + If you select the link below, nothing will happen + + View the Docs + + + + Caution: Highlight Something + + If you select the link below, nothing will happen + + View the Docs + + + ); +}; diff --git a/modules/preview-react/InformationHighlight/stories/examples/Critical.tsx b/modules/preview-react/InformationHighlight/stories/examples/Critical.tsx new file mode 100644 index 0000000000..95bfd1d70a --- /dev/null +++ b/modules/preview-react/InformationHighlight/stories/examples/Critical.tsx @@ -0,0 +1,33 @@ +import React from 'react'; +import {Flex} from '@workday/canvas-kit-react/layout'; +import {InformationHighlight} from '@workday/canvas-kit-preview-react/InformationHighlight'; +import {system} from '@workday/canvas-tokens-web'; + +export const Critical = () => { + return ( + + + + + {' '} + Attention! Highlight Something{' '} + + + If you select the link below it will just reroute you back to this page + + View the Docs + + + + + {' '} + Attention! Highlight Something{' '} + + + If you select the link below it will just reroute you back to this page + + View the Docs + + + ); +}; diff --git a/modules/preview-react/InformationHighlight/stories/examples/CustomIconCritical.tsx b/modules/preview-react/InformationHighlight/stories/examples/CustomIconCritical.tsx new file mode 100644 index 0000000000..cf7f10194f --- /dev/null +++ b/modules/preview-react/InformationHighlight/stories/examples/CustomIconCritical.tsx @@ -0,0 +1,28 @@ +import React from 'react'; +import {InformationHighlight} from '@workday/canvas-kit-preview-react/InformationHighlight'; +import {chartIcon} from '@workday/canvas-system-icons-web'; +import {Flex} from '@workday/canvas-kit-react/layout'; +import {system} from '@workday/canvas-tokens-web'; + +export const IconCritical = () => { + return ( + + + + Attention! Custom Highlight + + A custom Icon can be added to the Information Highlight component + + View the Docs + + + + Attention! Custom Highlight + + A custom Icon can be added to the Information Highlight component + + View the Docs + + + ); +}; diff --git a/modules/preview-react/InformationHighlight/stories/examples/Heading.tsx b/modules/preview-react/InformationHighlight/stories/examples/Heading.tsx new file mode 100644 index 0000000000..d06158a8cb --- /dev/null +++ b/modules/preview-react/InformationHighlight/stories/examples/Heading.tsx @@ -0,0 +1,11 @@ +import React from 'react'; + +import {InformationHighlight} from '@workday/canvas-kit-preview-react/InformationHighlight'; + +export const Heading = () => { + return ( + + Only Heading + + ); +}; diff --git a/modules/preview-react/InformationHighlight/stories/examples/Informational.tsx b/modules/preview-react/InformationHighlight/stories/examples/Informational.tsx new file mode 100644 index 0000000000..6cbe7c8526 --- /dev/null +++ b/modules/preview-react/InformationHighlight/stories/examples/Informational.tsx @@ -0,0 +1,27 @@ +import React from 'react'; +import {Flex} from '@workday/canvas-kit-react/layout'; +import {InformationHighlight} from '@workday/canvas-kit-preview-react/InformationHighlight'; +import {system} from '@workday/canvas-tokens-web'; + +export const Informational = () => { + return ( + + + + Informational Highlight + + If you select the link below it will just reroute you back to this page + + View the Docs + + + + Informational Highlight + + If you select the link below it will just reroute you back to this page + + View the Docs + + + ); +}; diff --git a/modules/preview-react/InformationHighlight/stories/examples/RTL.tsx b/modules/preview-react/InformationHighlight/stories/examples/RTL.tsx new file mode 100644 index 0000000000..7f9e949e0d --- /dev/null +++ b/modules/preview-react/InformationHighlight/stories/examples/RTL.tsx @@ -0,0 +1,42 @@ +import React from 'react'; +import {Flex} from '@workday/canvas-kit-react/layout'; +import {InformationHighlight} from '@workday/canvas-kit-preview-react/InformationHighlight'; +import {CanvasProvider, ContentDirection} from '@workday/canvas-kit-react/common'; +import {system} from '@workday/canvas-tokens-web'; +export const RTL = () => { + const theme = { + canvas: { + direction: ContentDirection.RTL, + }, + }; + return ( + + + + + + {' '} + انتباه! من اليمين إلى اليسار{' '} + + + نحن ندعم اللغات من اليمين إلى اليسار + + وثائق + + + + + + + {' '} + انتباه! من اليمين إلى اليسار{' '} + + + نحن ندعم اللغات من اليمين إلى اليسار + + وثائق + + + + ); +}; diff --git a/modules/preview-react/InformationHighlight/stories/tsconfig.json b/modules/preview-react/InformationHighlight/stories/tsconfig.json new file mode 100644 index 0000000000..4fb6aa9472 --- /dev/null +++ b/modules/preview-react/InformationHighlight/stories/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "../../../../tsconfig.stories.json" +} diff --git a/modules/preview-react/InformationHighlight/stories/visual_testing/testing.stories.tsx b/modules/preview-react/InformationHighlight/stories/visual_testing/testing.stories.tsx new file mode 100644 index 0000000000..fedbdc82b4 --- /dev/null +++ b/modules/preview-react/InformationHighlight/stories/visual_testing/testing.stories.tsx @@ -0,0 +1,85 @@ +import React from 'react'; + +import {StaticStates, ComponentStatesTable} from '@workday/canvas-kit-react/testing'; +import {InformationHighlight} from '@workday/canvas-kit-preview-react/InformationHighlight'; + +export default { + title: 'Testing/Preview/Information Highlight', + component: InformationHighlight, + parameters: { + chromatic: { + disable: false, + }, + }, +}; + +export const InformationHighlightStates = () => { + return ( + + + {props => { + const {variant, heading, body, link, emphasis} = props; + return ( + + + {heading && Lorem ipsum} + {body && ( + + {' '} + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor + incididunt ut labore et dolore magna aliqua.{' '} + + )} + {link && Link} + + ); + }} + + + ); +}; diff --git a/modules/preview-react/index.ts b/modules/preview-react/index.ts index 4118db6d52..fce5bbc420 100644 --- a/modules/preview-react/index.ts +++ b/modules/preview-react/index.ts @@ -11,3 +11,4 @@ export * from './side-panel'; export * from './status-indicator'; export * from './text-area'; export * from './text-input'; +export * from './InformationHighlight'; diff --git a/modules/react/button/lib/Hyperlink.tsx b/modules/react/button/lib/Hyperlink.tsx index cde1199436..e3e9233bbc 100644 --- a/modules/react/button/lib/Hyperlink.tsx +++ b/modules/react/button/lib/Hyperlink.tsx @@ -1,8 +1,9 @@ import * as React from 'react'; -import {borderRadius, colors, type} from '@workday/canvas-kit-react/tokens'; -import {styled, createComponent, StyledType} from '@workday/canvas-kit-react/common'; +import {createComponent} from '@workday/canvas-kit-react/common'; +import {createStencil, CSProps, cssVar, handleCsProp} from '@workday/canvas-kit-styling'; +import {system} from '@workday/canvas-tokens-web'; -export interface HyperlinkProps { +export interface HyperlinkProps extends CSProps { /** * sets modifier styles for Hyperlink * - `inverse`: sets the color to frenchVanilla100 and updates hover, focus, and active pseudo-classes @@ -15,56 +16,49 @@ export interface HyperlinkProps { children?: React.ReactNode; } -const variantStyles = { - inverse: { - color: colors.frenchVanilla100, - '&:hover': { - color: colors.frenchVanilla100, - background: 'rgba(255, 255, 255, 0.1)', - }, - '&:focus': { - boxShadow: `0 0 0 2px ${colors.frenchVanilla100}`, - }, - '&:active': { - color: colors.blueberry600, - background: colors.soap200, - }, - }, -}; - -const anchorVariants = (props: HyperlinkProps) => { - if (props.variant === 'inverse') { - return variantStyles.inverse; - } - return {}; -}; - -const Anchor = styled('a')( - { - fontFamily: type.properties.fontFamilies.default, +const hyperlinkStencil = createStencil({ + base: { + fontFamily: system.fontFamily.default, textDecoration: 'underline', - color: colors.blueberry400, + color: system.color.text.primary.default, cursor: 'pointer', - borderRadius: borderRadius.s, + borderRadius: system.shape.half, display: 'inline-block', padding: '0 2px', margin: '0 -2px', transition: 'color 0.15s,background-color 0.15s', - '&:hover': { - color: colors.blueberry500, - background: colors.soap200, + '&:hover, &.hover': { + color: system.color.text.primary.strong, + background: system.color.bg.alt.soft, }, - '&:focus': { - boxShadow: `0 0 0 2px ${colors.blueberry400}`, + '&:focus, &.focus, &:focus-visible': { + boxShadow: `0 0 0 2px ${cssVar(system.color.bg.primary.default)}`, outline: 'none', }, - '&:active': { - color: colors.blueberry600, - background: colors.soap300, + '&:active, &.active': { + color: system.color.text.primary.stronger, + background: system.color.bg.alt.default, + }, + }, + modifiers: { + variant: { + inverse: { + color: system.color.text.inverse, + '&:hover, &.hover': { + color: system.color.text.inverse, + background: 'rgba(255, 255, 255, 0.1)', + }, + '&:focus, &.focus, &:focus-visible': { + boxShadow: `0 0 0 2px ${cssVar(system.color.text.inverse)}`, + }, + '&:active, &.active': { + color: system.color.text.primary.stronger, + background: system.color.bg.alt.soft, + }, + }, }, }, - anchorVariants -); +}); /** * `Hyperlink`s should be used when you want to navigate away from the current page or to an anchor @@ -72,9 +66,9 @@ const Anchor = styled('a')( */ export const Hyperlink = createComponent('a')({ displayName: 'Hyperlink', - Component: ({children, ...elemProps}: HyperlinkProps, ref, Element) => ( - + Component: ({children, variant, ...elemProps}: HyperlinkProps, ref, Element) => ( + {children} - + ), }); diff --git a/modules/react/tokens/stories/Tokens.mdx b/modules/react/tokens/stories/Tokens.mdx index fc0bf80d60..cae51140ff 100644 --- a/modules/react/tokens/stories/Tokens.mdx +++ b/modules/react/tokens/stories/Tokens.mdx @@ -1,4 +1,5 @@ -import {ExampleCodeBlock, InformationHighlight} from '@workday/canvas-kit-docs'; +import {ExampleCodeBlock} from '@workday/canvas-kit-docs'; +import {InformationHighlight} from '@workday/canvas-kit-preview-react/InformationHighlight'; import * as TokenStories from './Tokens.stories'; import {BorderRadius, Space, Depth, Colors, Type} from './examples/Tokens'; import {Overview} from './examples/Overview';