From 32a8cba4d464b6c3d7c8ec4941d4697cb55d1526 Mon Sep 17 00:00:00 2001 From: Jon Q Date: Fri, 29 Jan 2021 10:00:06 -0500 Subject: [PATCH 1/8] Add Elevation component --- docs/manifest.json | 6 + packages/components/src/elevation/README.md | 70 ++++ .../src/elevation/elevation-styles.js | 13 + .../components/src/elevation/elevation.js | 47 +++ packages/components/src/elevation/index.js | 2 + .../components/src/elevation/stories/index.js | 31 ++ .../test/__snapshots__/index.js.snap | 359 ++++++++++++++++++ .../components/src/elevation/test/index.js | 51 +++ packages/components/src/elevation/types.ts | 48 +++ .../components/src/elevation/use-elevation.js | 99 +++++ packages/components/src/index.js | 1 + 11 files changed, 727 insertions(+) create mode 100644 packages/components/src/elevation/README.md create mode 100644 packages/components/src/elevation/elevation-styles.js create mode 100644 packages/components/src/elevation/elevation.js create mode 100644 packages/components/src/elevation/index.js create mode 100644 packages/components/src/elevation/stories/index.js create mode 100644 packages/components/src/elevation/test/__snapshots__/index.js.snap create mode 100644 packages/components/src/elevation/test/index.js create mode 100644 packages/components/src/elevation/types.ts create mode 100644 packages/components/src/elevation/use-elevation.js diff --git a/docs/manifest.json b/docs/manifest.json index e571ec2b03ea88..6cc3964517b5c5 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -917,6 +917,12 @@ "markdown_source": "../packages/components/src/dropdown/README.md", "parent": "components" }, + { + "title": "Elevation", + "slug": "elevation", + "markdown_source": "../packages/components/src/elevation/README.md", + "parent": "components" + }, { "title": "ExternalLink", "slug": "external-link", diff --git a/packages/components/src/elevation/README.md b/packages/components/src/elevation/README.md new file mode 100644 index 00000000000000..777cec0c654c9a --- /dev/null +++ b/packages/components/src/elevation/README.md @@ -0,0 +1,70 @@ +# Elevation + +`Elevation` is a core component that renders shadow, using the component system's shadow system. + +## Usage + +The shadow effect is generated using the `value` prop. + +```jsx live +import { + __experimentalElevation as Elevation, + __experimetnalSurface as Surface, + __experimetnalText as Text, + __experimetnalView as View, +} from '@wp-g2/components'; + +function Example() { + return ( + + Elevation + + + ); +} +``` + +## Props + +##### active + +**Type**: `boolean` + +Renders the active (interaction) shadow value. + +##### borderRadius + +**Type**: `string`,`number` + +Renders the border-radius of the shadow. + +##### focus + +**Type**: `boolean` + +Renders the focus (interaction) shadow value. + +##### hover + +**Type**: `boolean` + +Renders the hover (interaction) shadow value. + +##### isInteractive + +**Type**: `boolean` + +Determines if hover, active, and focus shadow values should be automatically calculated and rendered. + +##### offset + +**Type**: `number` + +Dimensional offsets (margin) for the shadow. + +##### value + +**Type**: `number` + +Size of the shadow, based on the Style system's elevation system. The `value` determines the strength of the shadow, which sense of depth. +In the example below, `isInteractive` is activated to give a better sense of depth. diff --git a/packages/components/src/elevation/elevation-styles.js b/packages/components/src/elevation/elevation-styles.js new file mode 100644 index 00000000000000..398a015cc30901 --- /dev/null +++ b/packages/components/src/elevation/elevation-styles.js @@ -0,0 +1,13 @@ +/** + * External dependencies + */ +import { css } from '@wp-g2/styles'; + +export const Elevation = css` + background: transparent; + display: block; + margin: 0 !important; + pointer-events: none; + position: absolute; + will-change: box-shadow; +`; diff --git a/packages/components/src/elevation/elevation.js b/packages/components/src/elevation/elevation.js new file mode 100644 index 00000000000000..607dcc2e66a7a4 --- /dev/null +++ b/packages/components/src/elevation/elevation.js @@ -0,0 +1,47 @@ +/** + * External dependencies + */ +import { contextConnect } from '@wp-g2/context'; + +/** + * Internal dependencies + */ +import View from '../view'; +import { useElevation } from './use-elevation'; + +/** + * + * @param {import('@wp-g2/create-styles').ViewOwnProps<'div', import('./types').Props>} props + * @param {import('react').Ref} forwardedRef + */ +function Elevation( props, forwardedRef ) { + const otherProps = useElevation( props ); + + return ; +} + +/** + * `Elevation` is a core component that renders shadow, using the library's shadow system. + * + * The shadow effect is generated using the `value` prop. + * + * @example + * ```jsx + * import { Elevation, Surface, Text, View } from `@wp-g2/components` + * import { ui } from `@wp-g2/styles` + * + * function Example() { + * return ( + * + * + * Into The Unknown + * + * + * + * ); + * } + * ``` + */ +const ConnectedElevation = contextConnect( Elevation, 'Elevation' ); + +export default ConnectedElevation; diff --git a/packages/components/src/elevation/index.js b/packages/components/src/elevation/index.js new file mode 100644 index 00000000000000..0c1b665437e65c --- /dev/null +++ b/packages/components/src/elevation/index.js @@ -0,0 +1,2 @@ +export { default } from './elevation'; +export * from './use-elevation'; diff --git a/packages/components/src/elevation/stories/index.js b/packages/components/src/elevation/stories/index.js new file mode 100644 index 00000000000000..09cfd7e55c4006 --- /dev/null +++ b/packages/components/src/elevation/stories/index.js @@ -0,0 +1,31 @@ +/** + * External dependencies + */ +import { number } from '@storybook/addon-knobs'; +/** + * Internal dependencies + */ +import Elevation from '../index'; +import View from '../../view'; + +export default { + component: Elevation, + title: 'Components/Elevation', +}; + +export const _default = () => { + const value = number( 'value', 5 ); + + return ( + + + + ); +}; diff --git a/packages/components/src/elevation/test/__snapshots__/index.js.snap b/packages/components/src/elevation/test/__snapshots__/index.js.snap new file mode 100644 index 00000000000000..a04ca4976d3cda --- /dev/null +++ b/packages/components/src/elevation/test/__snapshots__/index.js.snap @@ -0,0 +1,359 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`props should render active 1`] = ` +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-sizing: border-box; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; + font-family: var(--wp-g2-font-family); + font-size: 13px; + font-size: var(--wp-g2-font-size); + font-weight: normal; + font-weight: var(--wp-g2-font-weight); + margin: 0; + background: transparent; + display: block; + margin: 0 !important; + pointer-events: none; + position: absolute; + will-change: box-shadow; + border-radius: inherit; + bottom: 0; + box-shadow: 0 7px 14px 0 rgba(0 ,0,0,0.35); + opacity: 1; + opacity: var(--wp-g2-elevation-intensity); + left: 0; + right: 0; + top: 0; + -webkit-transition: box-shadow 200ms cubic-bezier(0.08, 0.52, 0.52, 1); + -webkit-transition: box-shadow var(--wp-g2-transition-duration) var(--wp-g2-transition-timing-function); + transition: box-shadow 200ms cubic-bezier(0.08, 0.52, 0.52, 1); + transition: box-shadow var(--wp-g2-transition-duration) var(--wp-g2-transition-timing-function); +} + +@media (prefers-reduced-motion) { + .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none !important; + transition: none !important; + } +} + +[data-system-ui-reduced-motion-mode="true"] .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none !important; + transition: none !important; +} + +*:hover > .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-shadow: 0 14px 28px 0 rgba(0 ,0,0,0.7); +} + +*:active > .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-shadow: 0 5px 10px 0 rgba(0 ,0,0,0.25); +} + +*:focus > .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-shadow: 0 false 0px 0 rgba(0 ,0,0,0); +} + +
+`; + +exports[`props should render correctly 1`] = ` +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-sizing: border-box; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; + font-family: var(--wp-g2-font-family); + font-size: 13px; + font-size: var(--wp-g2-font-size); + font-weight: normal; + font-weight: var(--wp-g2-font-weight); + margin: 0; + background: transparent; + display: block; + margin: 0 !important; + pointer-events: none; + position: absolute; + will-change: box-shadow; + border-radius: inherit; + bottom: 0; + box-shadow: 0 0px 0px 0 rgba(0 ,0,0,0); + opacity: 1; + opacity: var(--wp-g2-elevation-intensity); + left: 0; + right: 0; + top: 0; + -webkit-transition: box-shadow 200ms cubic-bezier(0.08, 0.52, 0.52, 1); + -webkit-transition: box-shadow var(--wp-g2-transition-duration) var(--wp-g2-transition-timing-function); + transition: box-shadow 200ms cubic-bezier(0.08, 0.52, 0.52, 1); + transition: box-shadow var(--wp-g2-transition-duration) var(--wp-g2-transition-timing-function); +} + +@media (prefers-reduced-motion) { + .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none !important; + transition: none !important; + } +} + +[data-system-ui-reduced-motion-mode="true"] .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none !important; + transition: none !important; +} + +*:focus > .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-shadow: 0 false 0px 0 rgba(0 ,0,0,0); +} + +
+`; + +exports[`props should render hover 1`] = ` +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-sizing: border-box; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; + font-family: var(--wp-g2-font-family); + font-size: 13px; + font-size: var(--wp-g2-font-size); + font-weight: normal; + font-weight: var(--wp-g2-font-weight); + margin: 0; + background: transparent; + display: block; + margin: 0 !important; + pointer-events: none; + position: absolute; + will-change: box-shadow; + border-radius: inherit; + bottom: 0; + box-shadow: 0 7px 14px 0 rgba(0 ,0,0,0.35); + opacity: 1; + opacity: var(--wp-g2-elevation-intensity); + left: 0; + right: 0; + top: 0; + -webkit-transition: box-shadow 200ms cubic-bezier(0.08, 0.52, 0.52, 1); + -webkit-transition: box-shadow var(--wp-g2-transition-duration) var(--wp-g2-transition-timing-function); + transition: box-shadow 200ms cubic-bezier(0.08, 0.52, 0.52, 1); + transition: box-shadow var(--wp-g2-transition-duration) var(--wp-g2-transition-timing-function); +} + +@media (prefers-reduced-motion) { + .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none !important; + transition: none !important; + } +} + +[data-system-ui-reduced-motion-mode="true"] .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none !important; + transition: none !important; +} + +*:hover > .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-shadow: 0 14px 28px 0 rgba(0 ,0,0,0.7); +} + +*:focus > .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-shadow: 0 false 0px 0 rgba(0 ,0,0,0); +} + +
+`; + +exports[`props should render isInteractive 1`] = ` +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-sizing: border-box; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; + font-family: var(--wp-g2-font-family); + font-size: 13px; + font-size: var(--wp-g2-font-size); + font-weight: normal; + font-weight: var(--wp-g2-font-weight); + margin: 0; + background: transparent; + display: block; + margin: 0 !important; + pointer-events: none; + position: absolute; + will-change: box-shadow; + border-radius: inherit; + bottom: 0; + box-shadow: 0 0px 0px 0 rgba(0 ,0,0,0); + opacity: 1; + opacity: var(--wp-g2-elevation-intensity); + left: 0; + right: 0; + top: 0; + -webkit-transition: box-shadow 200ms cubic-bezier(0.08, 0.52, 0.52, 1); + -webkit-transition: box-shadow var(--wp-g2-transition-duration) var(--wp-g2-transition-timing-function); + transition: box-shadow 200ms cubic-bezier(0.08, 0.52, 0.52, 1); + transition: box-shadow var(--wp-g2-transition-duration) var(--wp-g2-transition-timing-function); +} + +@media (prefers-reduced-motion) { + .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none !important; + transition: none !important; + } +} + +[data-system-ui-reduced-motion-mode="true"] .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none !important; + transition: none !important; +} + +*:hover > .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-shadow: 0 0px 0px 0 rgba(0 ,0,0,0); +} + +*:active > .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-shadow: 0 0px 0px 0 rgba(0 ,0,0,0); +} + +*:focus > .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-shadow: 0 false 0px 0 rgba(0 ,0,0,0); +} + +
+`; + +exports[`props should render offset 1`] = ` +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-sizing: border-box; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; + font-family: var(--wp-g2-font-family); + font-size: 13px; + font-size: var(--wp-g2-font-size); + font-weight: normal; + font-weight: var(--wp-g2-font-weight); + margin: 0; + background: transparent; + display: block; + margin: 0 !important; + pointer-events: none; + position: absolute; + will-change: box-shadow; + border-radius: inherit; + bottom: -2px; + box-shadow: 0 7px 14px 0 rgba(0 ,0,0,0.35); + opacity: 1; + opacity: var(--wp-g2-elevation-intensity); + left: -2px; + right: -2px; + top: -2px; + -webkit-transition: box-shadow 200ms cubic-bezier(0.08, 0.52, 0.52, 1); + -webkit-transition: box-shadow var(--wp-g2-transition-duration) var(--wp-g2-transition-timing-function); + transition: box-shadow 200ms cubic-bezier(0.08, 0.52, 0.52, 1); + transition: box-shadow var(--wp-g2-transition-duration) var(--wp-g2-transition-timing-function); +} + +@media (prefers-reduced-motion) { + .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none !important; + transition: none !important; + } +} + +[data-system-ui-reduced-motion-mode="true"] .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none !important; + transition: none !important; +} + +*:hover > .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-shadow: 0 14px 28px 0 rgba(0 ,0,0,0.7); +} + +*:active > .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-shadow: 0 5px 10px 0 rgba(0 ,0,0,0.25); +} + +*:focus > .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-shadow: 0 false 0px 0 rgba(0 ,0,0,0); +} + +
+`; + +exports[`props should render value 1`] = ` +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-sizing: border-box; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; + font-family: var(--wp-g2-font-family); + font-size: 13px; + font-size: var(--wp-g2-font-size); + font-weight: normal; + font-weight: var(--wp-g2-font-weight); + margin: 0; + background: transparent; + display: block; + margin: 0 !important; + pointer-events: none; + position: absolute; + will-change: box-shadow; + border-radius: inherit; + bottom: 0; + box-shadow: 0 7px 14px 0 rgba(0 ,0,0,0.35); + opacity: 1; + opacity: var(--wp-g2-elevation-intensity); + left: 0; + right: 0; + top: 0; + -webkit-transition: box-shadow 200ms cubic-bezier(0.08, 0.52, 0.52, 1); + -webkit-transition: box-shadow var(--wp-g2-transition-duration) var(--wp-g2-transition-timing-function); + transition: box-shadow 200ms cubic-bezier(0.08, 0.52, 0.52, 1); + transition: box-shadow var(--wp-g2-transition-duration) var(--wp-g2-transition-timing-function); +} + +@media (prefers-reduced-motion) { + .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none !important; + transition: none !important; + } +} + +[data-system-ui-reduced-motion-mode="true"] .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none !important; + transition: none !important; +} + +*:focus > .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-shadow: 0 false 0px 0 rgba(0 ,0,0,0); +} + +
+`; diff --git a/packages/components/src/elevation/test/index.js b/packages/components/src/elevation/test/index.js new file mode 100644 index 00000000000000..1e739022a7c396 --- /dev/null +++ b/packages/components/src/elevation/test/index.js @@ -0,0 +1,51 @@ +/** + * External dependencies + */ +import { render } from '@testing-library/react'; + +/** + * Internal dependencies + */ +import Elevation from '../index'; + +describe( 'props', () => { + test( 'should render correctly', () => { + const { container } = render( ); + + expect( container.firstChild ).toMatchSnapshot(); + } ); + + test( 'should render isInteractive', () => { + const { container } = render( ); + + expect( container.firstChild ).toMatchSnapshot(); + } ); + + test( 'should render value', () => { + const { container } = render( ); + + expect( container.firstChild ).toMatchSnapshot(); + } ); + + test( 'should render hover', () => { + const { container } = render( ); + + expect( container.firstChild ).toMatchSnapshot(); + } ); + + test( 'should render active', () => { + const { container } = render( + + ); + + expect( container.firstChild ).toMatchSnapshot(); + } ); + + test( 'should render offset', () => { + const { container } = render( + + ); + + expect( container.firstChild ).toMatchSnapshot(); + } ); +} ); diff --git a/packages/components/src/elevation/types.ts b/packages/components/src/elevation/types.ts new file mode 100644 index 00000000000000..cdbabfaf1e6fda --- /dev/null +++ b/packages/components/src/elevation/types.ts @@ -0,0 +1,48 @@ +export type Props = { + /** + * Renders the active (interaction) shadow value. + */ + active?: boolean; + /** + * Renders the border-radius of the shadow. + */ + borderRadius?: number | string; + /** + * Renders the focus (interaction) shadow value. + */ + focus?: boolean; + /** + * Renders the hover (interaction) shadow value. + */ + hover?: boolean; + /** + * Determines if hover, active, and focus shadow values should be automatically calculated and rendered. + */ + isInteractive?: boolean; + /** + * Dimensional offsets (margin) for the shadow. + */ + offset?: number; + /** + * Size of the shadow, based on the Style system's elevation system. The `value` determines the strength of the shadow, which sense of depth. + * In the example below, `isInteractive` is activated to give a better sense of depth. + * + * @example + * ```jsx + * import { Elevation, Surface, Text, View } from `@wp-g2/components` + * import { ui } from `@wp-g2/styles` + * + * function Example() { + * return ( + * + * + * Into The Unknown + * + * + * + * ) + * } + * ``` + */ + value?: number; +}; diff --git a/packages/components/src/elevation/use-elevation.js b/packages/components/src/elevation/use-elevation.js new file mode 100644 index 00000000000000..a90834a0f85e71 --- /dev/null +++ b/packages/components/src/elevation/use-elevation.js @@ -0,0 +1,99 @@ +/** + * External dependencies + */ +import { useContextSystem } from '@wp-g2/context'; +import { css, cx, getBoxShadow, ui } from '@wp-g2/styles'; +import { is } from '@wp-g2/utils'; + +/** + * WordPress dependencies + */ +import { useMemo } from '@wordpress/element'; + +/** + * Internal dependencies + */ +import * as styles from './elevation-styles'; + +/** + * @param {import('@wp-g2/create-styles').ViewOwnProps} props + */ +export function useElevation( props ) { + const { + active, + borderRadius = 'inherit', + className, + focus = false, + hover = false, + isInteractive = false, + offset = 0, + value = 0, + ...otherProps + } = useContextSystem( props, 'Elevation' ); + + const classes = useMemo( () => { + let hoverValue = !! hover ? hover : value * 2; + let activeValue = !! active ? hover : value / 2; + + if ( ! isInteractive ) { + hoverValue = !! hover ? hover : undefined; + activeValue = !! active ? active : undefined; + } + + const transition = `box-shadow ${ ui.get( + 'transitionDuration' + ) } ${ ui.get( 'transitionTimingFunction' ) }`; + + const sx = {}; + + sx.Base = css( { + borderRadius, + bottom: offset, + boxShadow: getBoxShadow( value ), + opacity: ui.get( 'elevationIntensity' ), + left: offset, + right: offset, + top: offset, + transition, + } ); + + sx.hover = css` + *:hover > & { + box-shadow: ${ getBoxShadow( hoverValue ) }; + } + `; + + sx.active = css` + *:active > & { + box-shadow: ${ getBoxShadow( activeValue ) }; + } + `; + + sx.focus = css` + *:focus > & { + box-shadow: ${ getBoxShadow( focus ) }; + } + `; + + return cx( + styles.Elevation, + sx.Elevation, + sx.Base, + is.defined( hoverValue ) && sx.hover, + is.defined( activeValue ) && sx.active, + is.defined( focus ) && sx.focus, + className + ); + }, [ + active, + borderRadius, + className, + focus, + hover, + isInteractive, + offset, + value, + ] ); + + return { ...otherProps, className: classes }; +} diff --git a/packages/components/src/index.js b/packages/components/src/index.js index 0c67e9330f035e..c1dcac041f2ce1 100644 --- a/packages/components/src/index.js +++ b/packages/components/src/index.js @@ -59,6 +59,7 @@ export { } from './drop-zone/provider'; export { default as Dropdown } from './dropdown'; export { default as DropdownMenu } from './dropdown-menu'; +export { default as __experimentalElevation } from './elevation'; export { default as ExternalLink } from './external-link'; export { default as Flex } from './flex'; export { default as FlexBlock } from './flex/block'; From c1a48469be424c16b4067461e68048b5d2c8944a Mon Sep 17 00:00:00 2001 From: Jon Q Date: Fri, 29 Jan 2021 10:08:14 -0500 Subject: [PATCH 2/8] Add aria-hidden to the Elevation element --- packages/components/src/elevation/elevation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/src/elevation/elevation.js b/packages/components/src/elevation/elevation.js index 607dcc2e66a7a4..862b2d21577e68 100644 --- a/packages/components/src/elevation/elevation.js +++ b/packages/components/src/elevation/elevation.js @@ -17,7 +17,7 @@ import { useElevation } from './use-elevation'; function Elevation( props, forwardedRef ) { const otherProps = useElevation( props ); - return ; + return ; } /** From b31f9e9b4ea230a57c64ce14bca129b7b4780b9d Mon Sep 17 00:00:00 2001 From: Jon Q Date: Fri, 29 Jan 2021 10:09:46 -0500 Subject: [PATCH 3/8] Update type for borderRadius --- packages/components/src/elevation/types.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/components/src/elevation/types.ts b/packages/components/src/elevation/types.ts index cdbabfaf1e6fda..351f36da906d3a 100644 --- a/packages/components/src/elevation/types.ts +++ b/packages/components/src/elevation/types.ts @@ -1,3 +1,5 @@ +import { CSSProperties } from 'react'; + export type Props = { /** * Renders the active (interaction) shadow value. @@ -6,7 +8,7 @@ export type Props = { /** * Renders the border-radius of the shadow. */ - borderRadius?: number | string; + borderRadius?: CSSProperties[ 'borderRadius' ]; /** * Renders the focus (interaction) shadow value. */ From d9408225d0afd1df8d129ea53f8c2a3808e38d0b Mon Sep 17 00:00:00 2001 From: Jon Q Date: Fri, 29 Jan 2021 10:47:08 -0500 Subject: [PATCH 4/8] Update snapshot tests --- .../src/elevation/test/__snapshots__/index.js.snap | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/components/src/elevation/test/__snapshots__/index.js.snap b/packages/components/src/elevation/test/__snapshots__/index.js.snap index a04ca4976d3cda..c7741b6e5472a3 100644 --- a/packages/components/src/elevation/test/__snapshots__/index.js.snap +++ b/packages/components/src/elevation/test/__snapshots__/index.js.snap @@ -57,6 +57,7 @@ exports[`props should render active 1`] = ` }