Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Merge prerelease into master #14

Closed
wants to merge 73 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
985ae6a
feat: Set initial v10 codemod (#2239)
RayRedGoose May 30, 2023
53027e4
chore: Adding v10 upgrade guide (#2237)
jaclynjessup May 30, 2023
83a1440
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jun 1, 2023
7202c69
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jun 5, 2023
7fc0c57
feat!: Update space and depth tokens to rem (#2229)
josh-bagwell Jun 7, 2023
aec7d64
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jun 7, 2023
b06a0d5
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jun 12, 2023
18304e0
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jun 14, 2023
4573a44
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jun 15, 2023
356ee5e
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jun 15, 2023
7da0817
feat!: Remove Menu Preview (#2247)
josh-bagwell Jun 16, 2023
a26561e
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jun 16, 2023
75816f9
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jun 20, 2023
6e5c322
chore: Merge prerelease/minor into prerelease/major
alanbsmith Jun 26, 2023
4ec538c
chore: Merge prerelease/minor into prerelease/major
alanbsmith Jun 27, 2023
7555f64
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jun 27, 2023
f3487a7
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jun 29, 2023
4506f90
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jun 30, 2023
93f3772
chore: Merge prerelease/minor into prerelease/major
alanbsmith Jul 5, 2023
30d68d5
chore: Merge prerelease/minor into prerelease/major
alanbsmith Jul 7, 2023
a465584
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jul 7, 2023
41a9665
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jul 12, 2023
596994f
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jul 14, 2023
373c850
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jul 17, 2023
5080d15
chore: Merge prerelease/minor into prerelease/major
RayRedGoose Jul 20, 2023
1c38e81
chore: Merge prerelease/minor into prerelease/major (#2290)
alanbsmith Jul 20, 2023
9db7ae0
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jul 21, 2023
4549883
fix: Changing ARIA role to switch (#2292)
williamjstanton Jul 25, 2023
a669b80
chore: Merge prerelease/minor into prerelease/major
alanbsmith Jul 25, 2023
fe2117c
chore: Merge master into prerelease/minor [skip release]
alanbsmith Jul 27, 2023
f6b5f68
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jul 27, 2023
390ff57
chore: Merge master into prerelease/minor [skip release]
alanbsmith Jul 31, 2023
f5f8029
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Jul 31, 2023
1da70c9
chore: Merge master into prerelease/minor [skip release]
alanbsmith Aug 1, 2023
6592182
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Aug 1, 2023
c15a57c
chore: Merge master into prerelease/minor [skip release]
alanbsmith Aug 3, 2023
7b5e469
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Aug 3, 2023
7315bf0
chore: Merge master into prerelease/minor [skip release]
alanbsmith Aug 4, 2023
c656da6
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Aug 4, 2023
21566dd
chore: Merge master into prerelease/minor [skip release]
alanbsmith Aug 11, 2023
3ed0427
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Aug 11, 2023
273983b
chore: Merge master into prerelease/minor [skip release]
alanbsmith Aug 14, 2023
de780dd
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Aug 14, 2023
d00b99d
chore: Merge master into prerelease/minor [skip release]
alanbsmith Aug 24, 2023
0c9dc97
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Aug 24, 2023
944984a
chore: Merge master into prerelease/minor [skip release]
alanbsmith Aug 29, 2023
2143ce9
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Aug 29, 2023
0e6cc2e
chore: Merge master into prerelease/minor [skip release]
alanbsmith Aug 29, 2023
7ce7df0
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Aug 29, 2023
81c6c52
chore: Merge master into prerelease/minor [skip release]
alanbsmith Sep 6, 2023
be97c81
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Sep 6, 2023
c78bbce
chore: Merge master into prerelease/minor [skip release]
alanbsmith Sep 6, 2023
b0ece1d
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Sep 6, 2023
9a26501
refactor!: Removing aria attributes from Banner component (#2318)
williamjstanton Sep 12, 2023
06bda48
fix: Revert removal of Menu in Preview (#2335)
mannycarrera4 Sep 12, 2023
84c8363
chore: Merge master into prerelease/minor [skip release]
NicholasBoll Sep 15, 2023
9de5c3f
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Sep 15, 2023
a07a3ad
feat: Deprecate InputIconContainer (#2332)
dgubko Sep 18, 2023
5cdfe90
chore: Merge master into prerelease/minor [skip release]
alanbsmith Sep 18, 2023
9c5d040
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Sep 18, 2023
d9bfbcf
chore: Merge master into prerelease/minor [skip release]
alanbsmith Sep 20, 2023
c98487a
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Sep 20, 2023
a7a2138
feat: Deprecated Table in Main (#2344)
thunguyen19 Sep 25, 2023
9faea89
chore: Merge master into prerelease/minor [skip release]
alanbsmith Sep 25, 2023
04d2d5d
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Sep 25, 2023
32899ba
chore: Merge master into prerelease/minor [skip release]
alanbsmith Sep 26, 2023
aa37751
chore: Merge prerelease/minor into prerelease/major
Sep 28, 2023
7ab3d66
chore: Merge prerelease/minor into prerelease/major (#2346)
alanbsmith Sep 28, 2023
c471783
chore: Merge master into prerelease/minor [skip release]
alanbsmith Oct 2, 2023
b665fba
chore: Merge prerelease/minor into prerelease/major [skip release]
alanbsmith Oct 2, 2023
db9cd15
adding selectable rows example
williamjstanton Oct 4, 2023
7173ff6
Update Table.stories.mdx
williamjstanton Oct 4, 2023
6f2506c
Merge pull request #13 from williamjstanton/william-selectable-rows
williamjstanton Oct 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions cypress/integration/Banner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,6 @@ describe('Banner', () => {
it('should have an element with a role of "button"', () => {
cy.findByRole('button').should('be.visible');
});

it('should have an "aria-labelledby" that matches the action', () => {
cy.findByRole('button').then($button => {
const id = $button.attr('aria-labelledby');
cy.findByText('View All').should('have.attr', 'id', id);
});
});

it('should have an "aria-describedby" that matches the label', () => {
cy.findByRole('button').then($button => {
const id = $button.attr('aria-describedby');
cy.findByText('3 Errors').should('have.attr', 'id', id);
});
});
});
});
});
2 changes: 1 addition & 1 deletion cypress/integration/Switch.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as h from '../helpers';

const getSwitch = () => {
return cy.findByRole('checkbox');
return cy.findByRole('switch');
};

describe('Switch', () => {
Expand Down
7 changes: 7 additions & 0 deletions modules/codemod/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ const {_: commands, path, ignoreConfig, ignorePattern, verbose} = require('yargs
describe: chalk.gray('The path to execute the transform in (recursively).'),
});
})
.command('v10 [path]', chalk.gray('Canvas Kit v9 > v10 upgrade transform'), yargs => {
yargs.positional('path', {
type: 'string',
default: '.',
describe: chalk.gray('The path to execute the transform in (recursively).'),
});
})
.demandCommand(1, chalk.red.bold('You must provide a transform to apply.'))
.strictCommands()
.fail((msg, err, yargs) => {
Expand Down
10 changes: 10 additions & 0 deletions modules/codemod/lib/v10/example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {API, FileInfo, Options} from 'jscodeshift';

export default function transformer(file: FileInfo, api: API, options: Options) {
const j = api.jscodeshift;
const root = j(file.source);

// codemode goes here ...

return root.toSource();
}
14 changes: 14 additions & 0 deletions modules/codemod/lib/v10/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {Transform} from 'jscodeshift';
import example from './example';

const transform: Transform = (file, api, options) => {
// These will run in order. If your transform depends on others, place yours after dependent transforms
const fixes = [
// add codemods here
example,
];

return fixes.reduce((source, fix) => fix({...file, source}, api, options) as string, file.source);
};

export default transform;
18 changes: 18 additions & 0 deletions modules/codemod/lib/v10/spec/example.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {expectTransformFactory} from './expectTransformFactory';
import transform from '../example';
import {stripIndent} from 'common-tags';

const expectTransform = expectTransformFactory(transform);

describe('Example', () => {
it('should ignore non-canvas-kit imports', () => {
const input = stripIndent`
import Example from '@workday/some-other-library'
`;
const expected = stripIndent`
import Example from '@workday/some-other-library'
`;

expectTransform(input, expected);
});
});
9 changes: 9 additions & 0 deletions modules/codemod/lib/v10/spec/expectTransformFactory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {runInlineTest} from 'jscodeshift/dist/testUtils';

export const expectTransformFactory = (fn: Function) => (
input: string,
expected: string,
options?: Record<string, any>
) => {
return runInlineTest(fn, options, {source: input}, expected, {parser: 'tsx'});
};
166 changes: 166 additions & 0 deletions modules/docs/mdx/10.0-UPGRADE_GUIDE.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
import {Meta} from '@storybook/addon-docs';

<Meta title="Guides/Upgrade Guides/v10.0" />

# Canvas Kit 10.0 Upgrade Guide

This guide contains an overview of the changes in Canvas Kit v10. Please
[reach out](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you have
any questions.

- [Codemod](#codemod)
- [Removals](#removals)
- [useBanner](#useBanner)
- [Deprecations](#deprecations)
- [InputIconContainer](#input-icon-container)
- [Table](#table)
- [Token Updates](#token-updates)
- [Space and Depth](#space-and-depth)
- [Component Updates](#component-updates)
- [Glossary](#glossary)
- [Main](#main)
- [Preview](#preview)
- [Labs](#labs)

## Codemod

Please use our [codemod package](https://github.com/Workday/canvas-kit/tree/master/modules/codemod)
to automatically update your code to work with most of the breaking changes in v10.

```sh
> npx @workday/canvas-kit-codemod v10 [path]
```

Alternatively, if you're unable to run the codemod successfully using `npx`, you can install the
codemod package as a dev dependency, run it with `yarn`, and then remove the package after you're
finished.

```sh
> yarn add @workday/canvas-kit-codemod --dev
> yarn canvas-kit-codemod v10 [path]
> yarn remove @workday/canvas-kit-codemod
```

> The codemod only works on `.js`, `.jsx`, `.ts`, and `.tsx` files. You'll need to manually edit
> other file types (`.json`, `.mdx`, `.md`, etc.). You may need to run your linter after executing
> the codemod, as its resulting formatting (spacing, quotes, etc.) may not match your project
> conventions.

The codemod will handle _most_ but _not all_ of the breaking changes in 10. **Breaking changes
handled by the codemod are marked with 🤖 in the Upgrade Guide.**

**Please verify all changes made by the codemod.** As a safety precaution, we recommend committing
the changes from the codemod as a single isolated commit (separate from other changes) so you can
roll back more easily if necessary.

## Removals

Removals are deletions from our codebase and you can no longer consume this component. We've either
promoted or replaced a component or utility.

## useBanner

We have removed the `useBanner` hook, the only function of which was to add `aria-labelledby` and
`aria-describedby` references to the text inside of the Banner. This was not required for accessibility,
and browsers can compute the name of the Banner from the text given inside.

## Deprecations

### Input Icon Container

We've deprecated `InputIconContainer` from [Main](#main) because it doesn't handle
bidirectionality or icons at the start of an input. Please consider using [`InputGroup`](https://workday.github.io/canvas-kit/?path=/story/components-inputs-text-input--icons) instead.

### Table

We've deprecated `Table` and `TableRow` as well as all of their exported members. Please consider using [`Table in Preview`](https://workday.github.io/canvas-kit/?path=/docs/preview-table--basic) instead.

## Token Updates

### Space and Depth

**PR:** [#2229](https://github.com/Workday/canvas-kit/pull/2229)

In v10, we have updated our `space` and `depth` token values from `px` to `rem`. This is based on
the default browser font size which is `16px`.

These updates just mean that we have moved the values from `px` to `rem`. The values have been
updated on a 1:1 basis. None of the base value have changed, just the unit.

Below is a table to show what each token value is, what is corresponds too and what the new `rem`
value is in `px`:

| px Value | rem Value | space Token |
| -------- | --------- | ----------- |
| 0 | 0 | zero |
| 4px | 0.25rem | xxxs |
| 8px | 0.5rem | xxs |
| 12px | 0.75rem | xs |
| 16px | 1rem | s |
| 24px | 1.5rem | m |
| 32px | 2rem | l |
| 40px | 2.5rem | xl |
| 64px | 4rem | xxl |
| 80px | 5rem | xxxl |

You can convert a `px` value to a `rem` value by dividing your `px` value by `16`(if your default
browser font size hasn't been updated, the value will be `16`).

For example:

| Equation | rem Value |
| ----------- | --------- |
| `16px/16px` | `1rem` |
| `32px/16px` | `2rem` |
| `8px/16px` | `0.5rem` |

#### Why Did We Make This Change?

We wanted to move away from absolute units in tokens to relative units for better accessibility and
adaptability to different viewport/screen sizes. If a user changes their default browser font size,
these sizes should change along with it. Since `px` are a fixed unit and do not scale, utilizing
`rem` will allow these tokens to scale with a new default font size.

## Component Updates

## Glossary

### Main

Our Main package of Canvas Kit tokens, components, and utilities at `@workday/canvas-kit-react` has
undergone a full design and a11y review and is approved for use in product.

Breaking changes to code in Main will only occur during major version updates and will always be
communicated in advance and accompanied by migration strategies.

---

### Preview

Our Preview package of Canvas Kit tokens, components, and utilities at
`@workday/canvas-kit-preview-react` has undergone a full design and a11y review and is approved for
use in product, but may not be up to the high code standards upheld in the [Main](#main) package.
Preview is analagous to code in beta.

Breaking changes are unlikely, but possible, and can be deployed to Preview at any time without
triggering a major version update, though such changes will be communicated in advance and
accompanied by migration strategies.

Generally speaking, our goal is to eventually promote code from Preview to [Main](#main).
Occasionally, a component with the same name will exist in both [Main](#main) and Preview (for
example, see Segmented Control in [Preview](/components/buttons/segmented-control/) and
[Main](https://d2krrudi3mmzzw.cloudfront.net/v8/?path=/docs/components-buttons-segmented-control--basic)).
In these cases, Preview serves as a staging ground for an improved version of the component with a
different API. The component in [Main](#main) will eventually be replaced with the one in Preview.

---

### Labs

Our Labs package of Canvas Kit tokens, components, and utilities at `@workday/canvas-kit-labs-react`
has **not** undergone a full design and a11y review. Labs serves as an incubator space for new and
experimental code and is analagous to code in alpha.

Breaking changes can be deployed to Labs at any time without triggering a major version update and
may not be subject to the same rigor in communcation and migration strategies reserved for breaking
changes in [Preview](#preview) and [Main](#main).
22 changes: 11 additions & 11 deletions modules/labs-react/combobox/spec/Combobox.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import {Combobox, ComboboxProps} from '../lib/Combobox';
import {DeprecatedMenuItem} from '@workday/canvas-kit-preview-react/menu';
import {StyledMenuItem} from '@workday/canvas-kit-react/menu';
import {TextInput} from '@workday/canvas-kit-react/text-input';
import {render, fireEvent} from '@testing-library/react';

Expand All @@ -13,7 +13,7 @@ describe('Combobox', () => {

beforeEach(() => {
defaultProps = {
autocompleteItems: [<DeprecatedMenuItem />, <DeprecatedMenuItem />],
autocompleteItems: [<StyledMenuItem />, <StyledMenuItem />],
children: <TextInput placeholder={placeholderText} />,
};
});
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('Combobox', () => {
it('should render correct status text', () => {
const screen = renderCombobox({
...defaultProps,
autocompleteItems: [<DeprecatedMenuItem />, <DeprecatedMenuItem />],
autocompleteItems: [<StyledMenuItem />, <StyledMenuItem />],
getStatusText(listCount: number) {
return `Item count: ${listCount}`;
},
Expand All @@ -113,7 +113,7 @@ describe('Combobox', () => {

test('Call callback function when enter is pressed', async () => {
const menuText = 'menuText';
const autocompleteItems = [<DeprecatedMenuItem onClick={cb}>{menuText}</DeprecatedMenuItem>];
const autocompleteItems = [<StyledMenuItem onClick={cb}>{menuText}</StyledMenuItem>];
const {findByRole} = renderCombobox({
...defaultProps,
autocompleteItems,
Expand All @@ -132,9 +132,9 @@ describe('Combobox', () => {
test('Call callback function when list item is clicked', async () => {
const menuText = 'menuText';
const autocompleteItems = [
<DeprecatedMenuItem onClick={cb}>
<StyledMenuItem onClick={cb}>
<span>{menuText}</span>
</DeprecatedMenuItem>,
</StyledMenuItem>,
];
const {findByRole, findByText} = renderCombobox({
...defaultProps,
Expand All @@ -152,9 +152,9 @@ describe('Combobox', () => {
const menuText = 'menuText';
const id = 'my-id';
const autocompleteItems = [
<DeprecatedMenuItem isDisabled={true} onClick={cb}>
<StyledMenuItem isDisabled={true} onClick={cb}>
{menuText}
</DeprecatedMenuItem>,
</StyledMenuItem>,
];
const {findByRole} = renderCombobox({
...defaultProps,
Expand All @@ -176,7 +176,7 @@ describe('Combobox', () => {
test('Do not call callback function when meta key is pressed', async () => {
const menuText = 'menuText';
const id = 'my-id';
const autocompleteItems = [<DeprecatedMenuItem onClick={cb}>{menuText}</DeprecatedMenuItem>];
const autocompleteItems = [<StyledMenuItem onClick={cb}>{menuText}</StyledMenuItem>];
const {findByRole} = renderCombobox({
...defaultProps,
autocompleteItems,
Expand Down Expand Up @@ -233,9 +233,9 @@ describe('Combobox', () => {
test('Do not call blur function when clicking on disabled menu item', async () => {
const menuText = 'menuText';
const autocompleteItems = [
<DeprecatedMenuItem isDisabled={true} onClick={cb}>
<StyledMenuItem disabled onClick={cb}>
{menuText}
</DeprecatedMenuItem>,
</StyledMenuItem>,
];
const {findByRole, findByText} = renderCombobox({
...defaultProps,
Expand Down
4 changes: 2 additions & 2 deletions modules/labs-react/combobox/spec/SSR.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import React from 'react';
import {renderToString} from 'react-dom/server';
import {Combobox} from '../lib/Combobox';
import {DeprecatedMenuItem} from '@workday/canvas-kit-preview-react/menu';
import {StyledMenuItem} from '@workday/canvas-kit-react/menu';
import {TextInput} from '@workday/canvas-kit-react/text-input';

describe('InputProvider', () => {
it('should render on a server without crashing', () => {
const autocompleteItems = [<DeprecatedMenuItem>test</DeprecatedMenuItem>];
const autocompleteItems = [<StyledMenuItem>test</StyledMenuItem>];
const ssrRender = () =>
renderToString(
<Combobox autocompleteItems={autocompleteItems}>
Expand Down
14 changes: 7 additions & 7 deletions modules/labs-react/combobox/stories/stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import {
ComboBoxMenuItemGroup,
} from '@workday/canvas-kit-labs-react/combobox';
import {FormField} from '@workday/canvas-kit-react/form-field';
import {DeprecatedMenuItem, DeprecatedMenuItemProps} from '@workday/canvas-kit-preview-react/menu';
import {StyledMenuItem, MenuItemProps} from '@workday/canvas-kit-react/menu';
import {TextInput} from '@workday/canvas-kit-react/text-input';
import {CanvasProvider, ContentDirection} from '@workday/canvas-kit-react/common';

const autocompleteResult = (
textModifier: number,
isDisabled: boolean
): ReactElement<DeprecatedMenuItemProps> => (
<DeprecatedMenuItem isDisabled={isDisabled}>
disabled: boolean
): ReactElement<MenuItemProps> => (
<StyledMenuItem isDisabled={disabled}>
Result{' '}
<span>
num<span>ber</span>
</span>{' '}
{textModifier}
</DeprecatedMenuItem>
</StyledMenuItem>
);

const simpleAutoComplete = (count: number, showDisabledItems, total = 5) =>
Expand All @@ -35,9 +35,9 @@ const groupOfResults = (
groupHeading: ReactNode = 'Group'
): ComboBoxMenuItemGroup => ({
header: (
<DeprecatedMenuItem>
<StyledMenuItem>
<strong>{groupHeading}</strong>
</DeprecatedMenuItem>
</StyledMenuItem>
),
items: simpleAutoComplete(count, showDisabledItems, 10),
});
Expand Down
Loading
Loading