diff --git a/modules/preview-react/InformationHighlight/lib/InformationHighlight.tsx b/modules/preview-react/InformationHighlight/lib/InformationHighlight.tsx index 06dde05e36..a810388d9e 100644 --- a/modules/preview-react/InformationHighlight/lib/InformationHighlight.tsx +++ b/modules/preview-react/InformationHighlight/lib/InformationHighlight.tsx @@ -1,19 +1,15 @@ import * as React from 'react'; import {createContainer} from '@workday/canvas-kit-react/common'; -import {cssVar, createStencil} from '@workday/canvas-kit-styling'; +import {cssVar, createStencil, handleCsProp, CSProps} from '@workday/canvas-kit-styling'; import {base, system} from '@workday/canvas-tokens-web'; -import {Base, BaseProps} from './parts/Base'; -import {Heading} from './parts/Heading'; +import {InformationHighlightHeading} from './parts/Heading'; import {Body} from './parts/Body'; import {Icon} from './parts/Icon'; import {Link} from './parts/Link'; -import {useInformationHighlightModel, Variant, Emphasis} from './hooks/modelHook'; +import {useInformationHighlightModel} from './hooks/useInformationHighlightModel'; -interface InformationHighlightProps extends BaseProps { - variant?: Variant; - emphasis?: Emphasis; -} +interface InformationHighlightProps extends CSProps {} const informationHighlightStencil = createStencil({ base: { @@ -63,16 +59,17 @@ export const InformationHighlight = createContainer('section')({ modelHook: useInformationHighlightModel, subComponents: { Icon: Icon, - Heading: Heading, + Heading: InformationHighlightHeading, Body: Body, Link: Link, }, -})((props: InformationHighlightProps, Element, model) => { +})(({...elemProps}: InformationHighlightProps, Element, model) => { return ( - ); }); diff --git a/modules/preview-react/InformationHighlight/lib/hooks/modelHook.ts b/modules/preview-react/InformationHighlight/lib/hooks/useInformationHighlightModel.ts similarity index 100% rename from modules/preview-react/InformationHighlight/lib/hooks/modelHook.ts rename to modules/preview-react/InformationHighlight/lib/hooks/useInformationHighlightModel.ts diff --git a/modules/preview-react/InformationHighlight/lib/parts/Base.tsx b/modules/preview-react/InformationHighlight/lib/parts/Base.tsx deleted file mode 100644 index 6e5a4445cc..0000000000 --- a/modules/preview-react/InformationHighlight/lib/parts/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/preview-react/InformationHighlight/lib/parts/Body.tsx b/modules/preview-react/InformationHighlight/lib/parts/Body.tsx index 323781d143..bfcc8b94fb 100644 --- a/modules/preview-react/InformationHighlight/lib/parts/Body.tsx +++ b/modules/preview-react/InformationHighlight/lib/parts/Body.tsx @@ -1,21 +1,19 @@ import * as React from 'react'; -import {createComponent} from '@workday/canvas-kit-react/common'; -import {createStyles} from '@workday/canvas-kit-styling'; +import {createComponent, ExtractProps} from '@workday/canvas-kit-react/common'; +import {createStyles, handleCsProp} from '@workday/canvas-kit-styling'; import {base, system} from '@workday/canvas-tokens-web'; - -import {Base} from './Base'; +import {Text} from '@workday/canvas-kit-react/text'; 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 ; + 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 index cb40550395..e29e2a5f1e 100644 --- a/modules/preview-react/InformationHighlight/lib/parts/Heading.tsx +++ b/modules/preview-react/InformationHighlight/lib/parts/Heading.tsx @@ -1,9 +1,8 @@ import * as React from 'react'; -import {createComponent} from '@workday/canvas-kit-react/common'; -import {createStyles} from '@workday/canvas-kit-styling'; +import {createComponent, ExtractProps} from '@workday/canvas-kit-react/common'; +import {createStyles, handleCsProp} from '@workday/canvas-kit-styling'; import {base, system} from '@workday/canvas-tokens-web'; - -import {Base} from './Base'; +import {Heading, TypeLevelProps} from '@workday/canvas-kit-react/text'; const headingStyles = createStyles({ ...system.type.body.small, @@ -14,9 +13,16 @@ const headingStyles = createStyles({ marginBottom: system.space.zero, }); -export const Heading = createComponent('h3')({ +export interface InformationHighlightHeadingProps + extends Omit>, 'size'> { + size?: TypeLevelProps['size']; +} + +export const InformationHighlightHeading = createComponent('h3')({ displayName: 'Heading', - Component: (props, ref, Element) => { - return ; + 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 index 5094d02f1d..00d23ec102 100644 --- a/modules/preview-react/InformationHighlight/lib/parts/Icon.tsx +++ b/modules/preview-react/InformationHighlight/lib/parts/Icon.tsx @@ -1,57 +1,61 @@ import * as React from 'react'; import {SystemIcon, SystemIconProps, systemIconStencil} from '@workday/canvas-kit-react/icon'; import {createSubcomponent, ExtractProps} from '@workday/canvas-kit-react/common'; -import {cssVar} from '@workday/canvas-kit-styling'; +import {createStencil, handleCsProp} 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 '../hooks/modelHook'; +import {useInformationHighlightModel} from '../hooks/useInformationHighlightModel'; export interface IconProps extends Omit>, 'icon'> { icon?: SystemIconProps['icon']; } -const iconStyles = { - informational: { - low: systemIconStencil({ - accentColor: cssVar(base.blueberry400), - color: cssVar(base.blueberry400), - backgroundColor: 'none', - }), - high: systemIconStencil({ - accentColor: cssVar(base.frenchVanilla100), - color: cssVar(base.blueberry400), - backgroundColor: cssVar(base.blueberry400), - }), +const informationIconStencil = createStencil({ + extends: systemIconStencil, + base: {}, + modifiers: { + informational: { + low: { + [systemIconStencil.vars.accentColor]: base.blueberry400, + [systemIconStencil.vars.color]: base.blueberry400, + [systemIconStencil.vars.backgroundColor]: 'none', + }, + high: { + [systemIconStencil.vars.accentColor]: base.frenchVanilla100, + [systemIconStencil.vars.color]: base.blueberry400, + [systemIconStencil.vars.backgroundColor]: base.blueberry400, + }, + }, + caution: { + low: { + [systemIconStencil.vars.accentColor]: base.blackPepper400, + [systemIconStencil.vars.color]: base.blackPepper400, + [systemIconStencil.vars.backgroundColor]: 'none', + }, + high: { + [systemIconStencil.vars.accentColor]: base.frenchVanilla100, + [systemIconStencil.vars.color]: base.blackPepper400, + [systemIconStencil.vars.backgroundColor]: base.blackPepper400, + }, + }, + critical: { + low: { + [systemIconStencil.vars.accentColor]: base.cinnamon500, + [systemIconStencil.vars.color]: base.cinnamon500, + [systemIconStencil.vars.backgroundColor]: 'none', + }, + high: { + [systemIconStencil.vars.accentColor]: base.frenchVanilla100, + [systemIconStencil.vars.color]: base.cinnamon500, + [systemIconStencil.vars.backgroundColor]: base.cinnamon500, + }, + }, }, - caution: { - low: systemIconStencil({ - accentColor: cssVar(base.blackPepper400), - color: cssVar(base.blackPepper400), - backgroundColor: 'none', - }), - high: systemIconStencil({ - accentColor: cssVar(base.frenchVanilla100), - color: cssVar(base.blackPepper400), - backgroundColor: cssVar(base.blackPepper400), - }), - }, - critical: { - low: systemIconStencil({ - accentColor: cssVar(base.cinnamon500), - color: cssVar(base.cinnamon500), - backgroundColor: 'none', - }), - high: systemIconStencil({ - accentColor: cssVar(base.frenchVanilla100), - color: cssVar(base.cinnamon500), - backgroundColor: cssVar(base.cinnamon500), - }), - }, -}; +}); const defaultIcons = { informational: infoIcon, @@ -67,8 +71,10 @@ export const Icon = createSubcomponent('span')({ ); }); diff --git a/modules/preview-react/InformationHighlight/stories/InformationHighlight.mdx b/modules/preview-react/InformationHighlight/stories/InformationHighlight.mdx index 2e3e9dd9f7..7bbbb54ba5 100644 --- a/modules/preview-react/InformationHighlight/stories/InformationHighlight.mdx +++ b/modules/preview-react/InformationHighlight/stories/InformationHighlight.mdx @@ -104,7 +104,7 @@ needing to define a different level of importance. This should be done with caut ## Component API - + ## Specifications diff --git a/modules/preview-react/InformationHighlight/stories/visual_testing/testing.stories.tsx b/modules/preview-react/InformationHighlight/stories/visual_testing/testing.stories.tsx index 0c073579ec..0eebdf431e 100644 --- a/modules/preview-react/InformationHighlight/stories/visual_testing/testing.stories.tsx +++ b/modules/preview-react/InformationHighlight/stories/visual_testing/testing.stories.tsx @@ -66,7 +66,7 @@ export const InformationHighlightStates = () => { const {variant, heading, body, button, emphasis} = props; return ( - + {heading && Lorem ipsum} {body && (