= React.createRef();
- const {findByRole} = render();
- expect(await findByRole(selectButtonRole)).toEqual(ref.current);
- });
- });
-
- describe('when an option with a different value than the current value of the select is clicked', () => {
- it('should call the onChange callback', () => {
- const {getAllByRole, getByRole} = render();
- fireEvent.click(getByRole(selectButtonRole));
- fireEvent.click(getAllByRole(optionRole)[1]);
- expect(cb).toHaveBeenCalledTimes(1);
- });
- });
-});
diff --git a/modules/preview-react/select/spec/tsconfig.json b/modules/preview-react/select/spec/tsconfig.json
deleted file mode 100644
index e7f236e49a..0000000000
--- a/modules/preview-react/select/spec/tsconfig.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "extends": "../../../../tsconfig.spec.json"
-}
diff --git a/modules/preview-react/select/stories/stories.tsx b/modules/preview-react/select/stories/stories.tsx
deleted file mode 100644
index 7ee8e0992c..0000000000
--- a/modules/preview-react/select/stories/stories.tsx
+++ /dev/null
@@ -1,242 +0,0 @@
-import * as React from 'react';
-import {storiesOf} from '@storybook/react';
-import {controlComponent} from '../../../../utils/storybook';
-import {SystemIcon} from '@workday/canvas-kit-react/icon';
-import {
- activityStreamIcon,
- avatarIcon,
- uploadCloudIcon,
- userIcon,
-} from '@workday/canvas-system-icons-web';
-import {colors, typeColors} from '@workday/canvas-kit-react/tokens';
-import {FormField} from '@workday/canvas-kit-react/form-field';
-import {
- Select,
- RenderOptionFunction,
- RenderSelectedFunction,
-} from '@workday/canvas-kit-preview-react/select';
-
-const hintText = 'Helpful text goes here.';
-const hintId = 'error-desc-id';
-
-export const options = [
- {label: 'E-mail', value: 'email-1234'},
- {label: 'Phone', value: 'phone'},
- {label: 'Fax (disabled)', value: 'fax', disabled: true},
- {label: 'Mail', value: 'mail'},
- {label: 'Mobile Phone', value: 'mobile_phone'},
- {
- label: 'The Ontologically Anthropocentric Sensory Immersive Simulation',
- value: 'oasis',
- },
-];
-
-export const simpleOptions = ['California', 'Florida', 'New York', 'Pennsylvania', 'Texas'];
-
-export const manyOptions = [
- {label: 'Atlanta (United States)', value: 'atlanta'},
- {label: 'Amsterdam (Europe)', value: 'amsterdam'},
- {label: 'Austin (United States)', value: 'austin'},
- {label: 'Beaverton (United States)', value: 'beaverton'},
- {label: 'Belfast (Europe)', value: 'belfast'},
- {label: 'Berlin (Europe)', value: 'berlin'},
- {label: 'Boston (United States)', value: 'boston'},
- {label: 'Boulder (United States)', value: 'boulder'},
- {label: 'Chicago (United States)', value: 'chicago'},
- {label: 'Dallas (United States)', value: 'dallas'},
- {label: 'Denver (United States)', value: 'denver'},
- {label: 'Dublin (Europe)', value: 'dublin'},
- {label: 'Irvine (United States)', value: 'irvine'},
- {label: 'Minneapolis (United States)', value: 'minneapolis'},
- {label: 'New York (United States)', value: 'new-york'},
- {label: 'Orlando (United States)', value: 'orlando'},
- {label: 'Palo Alto (United States)', value: 'palo-alto'},
- {label: 'Philadelphia (United States)', value: 'philadelphia'},
- {label: 'Pleasanton (United States)', value: 'pleasanton'},
- {label: 'Raleigh (United States)', value: 'raleigh'},
- {label: 'San Francisco (United States)', value: 'san-francisco'},
- {label: 'San Mateo (United States)', value: 'san-mateo'},
- {label: 'Stockholm (Europe)', value: 'stockholm'},
- {
- label: 'The Ontologically Anthropocentric Sensory Immersive Simulation (Virtual Reality)',
- value: 'oasis',
- },
- {label: 'Toronto (Canada)', value: 'toronto'},
- {label: 'Victoria (Canada)', value: 'victoria'},
- {label: 'Vienna (Europe)', value: 'vienna'},
- {label: 'Warsaw (Europe)', value: 'warsaw'},
- {label: 'Washington, DC (United States)', value: 'washington-dc'},
- {label: 'Zurich (Europe)', value: 'zurich'},
-];
-
-export const customOptions = [
- {value: 'Activity Stream', data: {icon: activityStreamIcon}},
- {value: 'Avatar', data: {icon: avatarIcon}},
- {value: 'Upload Cloud', data: {icon: uploadCloudIcon}},
- {value: 'User', data: {icon: userIcon}},
-];
-
-export const customRenderOption: RenderOptionFunction = option => {
- const iconColor = option.focused ? typeColors.inverse : colors.blackPepper100;
- return (
-
- );
-};
-
-export const customRenderSelected: RenderSelectedFunction = option => {
- const iconColor = colors.blackPepper100;
- return (
-
- );
-};
-
-storiesOf('Preview/Select/Top Label', module)
- .addParameters({component: Select})
- .addParameters({ReadmePath: 'preview-react/select'})
- .add('Default', () => (
-
- {controlComponent()}
-
- ))
- .add('Default with Simple Options (Strings)', () => (
-
- {controlComponent()}
-
- ))
- .add('Default with Custom Options Data', () => (
-
- {controlComponent(
-
- )}
-
- ))
- .add('Scrollable', () => (
-
- {controlComponent()}
-
- ))
- .add('Disabled', () => (
-
- {controlComponent()}
-
- ))
- .add('Alert', () => (
-
- {controlComponent()}
-
- ))
- .add('Error', () => (
-
- {controlComponent()}
-
- ))
- .add('Grow', () => (
-
- {controlComponent()}
-
- ));
-
-storiesOf('Preview/Select/Left Label', module)
- .addParameters({component: Select})
- .addParameters({ReadmePath: 'preview-react/select'})
- .add('Default', () => (
-
- {controlComponent()}
-
- ))
- .add('Default with Simple Options (Strings)', () => (
-
- {controlComponent()}
-
- ))
- .add('Default with Custom Options Data', () => (
-
- {controlComponent(
-
- )}
-
- ))
- .add('Scrollable', () => (
-
- {controlComponent()}
-
- ))
- .add('Disabled', () => (
-
- {controlComponent()}
-
- ))
- .add('Alert', () => (
-
- {controlComponent()}
-
- ))
- .add('Error', () => (
-
- {controlComponent()}
-
- ))
- .add('Grow', () => (
-
- {controlComponent()}
-
- ));
diff --git a/modules/preview-react/select/stories/stories_CypressTesting.tsx b/modules/preview-react/select/stories/stories_CypressTesting.tsx
deleted file mode 100644
index 57344672f8..0000000000
--- a/modules/preview-react/select/stories/stories_CypressTesting.tsx
+++ /dev/null
@@ -1,248 +0,0 @@
-import * as React from 'react';
-import {controlComponent} from '../../../../utils/storybook';
-
-import {colors} from '@workday/canvas-kit-react/tokens';
-import {PrimaryButton} from '@workday/canvas-kit-react/button';
-import {FormField} from '@workday/canvas-kit-react/form-field';
-
-import {Select} from '../lib/Select';
-
-import {manyOptions, options} from './stories';
-import {Modal} from '@workday/canvas-kit-react/modal';
-import {Flex} from '@workday/canvas-kit-react/layout';
-
-export default {
- title: 'Testing/Preview/Select/Cypress',
- component: Select,
-};
-
-const disabledOptions = [
- {label: 'Carrier Pigeon', value: 'pigeon', disabled: true},
- {label: 'E-mail', value: 'email'},
- {label: 'Phone', value: 'phone'},
- {label: 'Fax', value: 'fax', disabled: true},
- {label: 'Mail', value: 'mail'},
- {label: 'Mobile Phone', value: 'mobile_phone'},
- {label: 'Telegram', value: 'telegram', disabled: true},
-];
-
-const Container = ({children, style = {}, ...elemProps}) => {
- return (
-
- {children}
-
- );
-};
-
-const SelectModal = () => {
- return (
-
- Show Modal
-
-
-
- Modal with Select
-
- The menu for this Select should break out of the Modal.
-
- {controlComponent()}
-
-
- Submit
- Cancel
-
-
-
-
-
- );
-};
-
-const BlurTest = () => {
- const [clicked, setClicked] = React.useState(false);
-
- const handleButtonBlur = () => {
- // Setting clicked updates the state of BlurTest which in turn causes
- // the contained Select to re-render
- setClicked(false);
- };
-
- const handleButtonClick = () => {
- setClicked(true);
- };
-
- return (
- <>
- Empty filler (scroll down)
- Blur Test
-
- The following test checks against a timing issue where focus could be applied to the Select
- Menu before it's been properly positioned, causing the browser to scroll to the top of the
- page when clicking the Select Button to activate its Menu.
-
- Context
-
- The Select component consists of a Button (the collapsed form of the Select) and a Menu (the
- dropdown menu displayed when you click on the Button or activate it using assistive
- technology). The Menu has two important characteristics:
-
-
- - DOM focus is applied to the Menu when it's visible.
- -
- The Menu is portalled to another location in the DOM outside the DOM hierarchy of the
- Select component (to enable it to break outside of Modals, for example). Because the Menu
- is located some distance (DOM-wise) away from it's corresponding Button, it needs to be
- positioned so that it's visually attached to its Button.
-
-
-
- Focusing the Menu before it's been properly positioned next to the Button will cause the
- browser to scroll to the wrong location (where the Menu was before it was
- positioned next to the button -- this is generally the top of the page).
-
- Test
-
- The following test creates a scenario where such a timing issue could potentially occur:
-
-
- - The page is long (requires scrolling).
- -
- There's a button and a Select near the bottom of the page. The button has a blur handler
- which triggers a re-render of the Select.
-
- - You click on the button to give it focus.
- -
- You then click on the Select. This activates the Menu and immediately triggers the blur
- handler for the button (which re-renders the Select).
-
-
-
- This creates a tricky situation where we could potentially assign focus to the Menu before
- it's been positioned since we're re-rendering the Menu immediately after it's been
- activated. If we assign focus too soon, the page will scroll to the top and you'll need to
- scroll back down to access the Menu you just activated.
-
-
- To run the test, click on the "Click me first!" button, and then click directly on the
- Select below it (directly on the Select itself, not the label).{' '}
- No scrolling should occur when the Select is clicked.
-
-
-
- {controlComponent()}
-
- >
- );
-};
-
-export const AccessibilityTest = () => (
-
-
-
- This Select has its aria-required prop set to true. When its listbox menu
- is opened, we expect aria-required to be set to "true" for the listbox.
-
-
- {controlComponent(
-
- )}
-
-
- This Select has its required prop set to true. Again, when its listbox menu
- is opened, we expect aria-required to be set to "true" for the listbox.
-
-
- {controlComponent()}
-
-
-
-);
-
-export const DisabledOptionsTest = () => (
-
-
- Disabled options may not be assistively focused using the keyboard.
-
- {controlComponent()}
-
-
-
-);
-
-export const PortalTest = () => (
-
-
-
- All gray-bordered containers on this page have their overflow set to hidden. Menus are
- rendered using portals and should break out of their containers.
-
-
- {controlComponent()}
-
-
- Menus for Select with grow set to true should resize automatically as the Select grows.
- Activate this menu and resize the window to see the menu grow to match the width of the
- Select.
-
-
- {controlComponent()}
-
-
-
-
- Menus should flip upwards automatically if there isn't enough space in the viewport for them
- to extend downwards. As you scroll down and space becomes available, the Menu will flip back
- downwards.
-
-
- {controlComponent()}
-
-
- {controlComponent()}
-
-
-
- Menus should behave the same with left-labeled FormFields.
-
- {controlComponent()}
-
-
- {controlComponent()}
-
-
-
- Menus should break out of Modals.
-
-
-
-
-
-
-);
diff --git a/modules/preview-react/select/stories/stories_visualTesting.tsx b/modules/preview-react/select/stories/stories_visualTesting.tsx
deleted file mode 100644
index da85f102b9..0000000000
--- a/modules/preview-react/select/stories/stories_visualTesting.tsx
+++ /dev/null
@@ -1,172 +0,0 @@
-import * as React from 'react';
-import {
- ComponentStatesTable,
- permutateProps,
- StaticStates,
-} from '@workday/canvas-kit-react/testing';
-import {withSnapshotsEnabled, customColorTheme} from '../../../../utils/storybook';
-
-import {Select} from '../lib/Select';
-import {SelectBase} from '../lib/SelectBase';
-import {SelectOption} from '../lib/SelectOption';
-
-import {options} from './stories';
-
-const normalizedOptions = options.map(option => {
- return {
- data: {},
- disabled: option.disabled || false,
- id: option.value,
- label: option.label || option.value,
- value: option.value,
- };
-});
-
-export default withSnapshotsEnabled({
- title: 'Testing/Preview/Select',
- component: Select,
-});
-
-export const SelectStates = () => (
-
- {
- if (props.disabled && !['', 'hover'].includes(props.className)) {
- return false;
- }
- return true;
- }
- )}
- >
- {props => (
-
-
-);
-
-export const SelectStatesMenuOn = () => (
-
-
- {props => {
- const buttonRef = React.createRef();
- return (
-
- {}} // eslint-disable-line no-empty-function
- options={normalizedOptions}
- focusedOptionIndex={1}
- menuVisibility="opened"
- shouldMenuAutoFlip={false}
- shouldMenuAutoFocus={false}
- />
-
- );
- }}
-
-
-);
-
-export const SelectStatesOption = () => (
-
- {[
- {
- label: 'Disabled States',
- columnProps: [
- {label: 'Default', props: {}},
- {label: 'Hover', props: {className: 'hover'}},
- ],
- rowProps: [{label: 'Disabled', props: {'aria-disabled': true}}],
- },
- {
- label: 'Interaction States',
- columnProps: [
- {label: 'Default', props: {}},
- {label: 'Hover', props: {className: 'hover'}},
- {label: 'Active', props: {className: 'active'}},
- {label: 'Active Hover', props: {className: 'active hover'}},
- ],
- rowProps: [
- {label: 'Default', props: {}},
- {label: 'Assistive-Focus', props: {focused: true}},
- {label: 'Selected', props: {'aria-selected': true}},
- {label: 'Assistive-Focus Selected', props: {'aria-selected': true, focused: true}},
- ],
- },
- ].map(statesTable => (
-
-
{statesTable.label}
-
-
- {props => (
-
- )}
-
-
-
- ))}
-
-);
-
-const themedParameters = {
- canvasProviderDecorator: {
- theme: customColorTheme,
- },
-};
-
-export const SelectThemedStates = () => ;
-export const SelectThemedStatesMenuOn = () => ;
-export const SelectThemedStatesOption = () => ;
-
-SelectThemedStates.parameters = themedParameters;
-SelectThemedStatesMenuOn.parameters = themedParameters;
-SelectThemedStatesOption.parameters = themedParameters;
diff --git a/modules/preview-react/select/stories/tsconfig.json b/modules/preview-react/select/stories/tsconfig.json
deleted file mode 100644
index 4fb6aa9472..0000000000
--- a/modules/preview-react/select/stories/tsconfig.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "extends": "../../../../tsconfig.stories.json"
-}
diff --git a/modules/react/_examples/stories/examples/GlobalHeader.tsx b/modules/react/_examples/stories/examples/GlobalHeader.tsx
index 2519a65018..4190644e66 100644
--- a/modules/react/_examples/stories/examples/GlobalHeader.tsx
+++ b/modules/react/_examples/stories/examples/GlobalHeader.tsx
@@ -31,7 +31,7 @@ export const Basic = () => (
-
+
);
diff --git a/modules/react/avatar/README.md b/modules/react/avatar/README.md
index 6de1f0f22c..17674166d2 100644
--- a/modules/react/avatar/README.md
+++ b/modules/react/avatar/README.md
@@ -8,48 +8,6 @@ A component showing a user's photo with a circular crop.
yarn add @workday/canvas-kit-react
```
-## Usage
-
-```tsx
-import * as React from 'react';
-import {Avatar, AvatarVariant} from '@workday/canvas-kit-react/avatar';
-
-// Basic button with click handler
-
-
-// Rendering as a div instead of a button
-
-
-// Using static properties on Avatar
-
-
-// Using AvatarVariant import directly
-
-```
-
-## Static Properties
-
-#### `variant: AvatarVariant`
-
-```tsx
-
-```
-
----
-
-#### `Size: SystemIconCircleSize | number`
-
-```tsx
-
-
-// Custom Size.
-// Note: Please use the predefined sizes as it works nicely with the Canvas Design System
-
-```
-
## Component Props
### Required
@@ -58,39 +16,39 @@ import {Avatar, AvatarVariant} from '@workday/canvas-kit-react/avatar';
### Optional
-#### `variant: AvatarVariant`
+#### `variant: "light" | "dark"`
> The variant of the avatar if using a default image.
-Default: `AvatarVariant.Light`
+Default: "light"
-| Variant | Description |
+| String | Description |
| ------- | -------------------------------- |
-| `Light` | Light grey background, dark icon |
-| `Dark` | Dark blue background, white icon |
+| "light" | Light grey background, dark icon |
+| "dark" | Dark blue background, white icon |
---
-#### `size: SystemIconCircleSize | number`
+#### `size: "extraSmall" | "small" | "medium" | "large" | "extraLarge" | "extraExtraLarge" | (string & {})`
-> The diameter of the avatar in pixels
+> The diameter of the avatar in pixels. Can be given custom size as a string in either px or rem.
-Default: `Avatar.Size.m`
+Default: "medium"
-| Name | Size (px) |
-| ----- | --------- |
-| `xs` | 16 |
-| `s` | 24 |
-| `m` | 32 |
-| `l` | 40 |
-| `xl` | 64 |
-| `xxl` | 120 |
+| Name | Size (px) |
+| ----------------- | --------- |
+| "extraSmall" | 16 |
+| "small" | 24 |
+| "medium" | 32 |
+| "large" | 40 |
+| "extraLarge" | 64 |
+| "extraExtraLarge" | 120 |
---
#### `altText: string`
-> Text describing what the avatar is showing.
+> The alt text of the Avatar image. This prop is also used for the aria-label.
---
@@ -100,6 +58,15 @@ Default: `Avatar.Size.m`
---
+
+---
+
+#### `objectFit?: "contain" | "cover" | "fill" | "none" | "scale-down" | "-moz-initial" | "inherit" | "initial" | "revert" | "unset"`
+
+> An objectFit property that can customize how to resize your image to fit its container.
+
+---
+
#### `ref: React.Ref`
> A ref to the underlying `