@workday/canvas-kit-docs 9.0.0-alpha.317-next.3 → 9.0.0-alpha.320-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mdx/MAINTAINING.mdx +117 -1
- package/dist/mdx/react/card/card.mdx +6 -0
- package/package.json +3 -3
package/dist/mdx/MAINTAINING.mdx
CHANGED
|
@@ -25,6 +25,8 @@ Kit!
|
|
|
25
25
|
- [Minor Releases](#minor-releases)
|
|
26
26
|
- [Major Releases](#major-releases)
|
|
27
27
|
- [Canary Releases](#canary-releases)
|
|
28
|
+
- [Codemods](#codemods)
|
|
29
|
+
- [Add a New Codemod](#add-a-new-codemod)
|
|
28
30
|
|
|
29
31
|
## Branches
|
|
30
32
|
|
|
@@ -263,4 +265,118 @@ Canary releases on the `prerelease/major` branch go out automatically once the p
|
|
|
263
265
|
merged. The major version will be appended with `-alpha.{build-number}-next.{commit-count}`, where
|
|
264
266
|
`build-number` is the GitHub build identifier, and `commit-count` is the number of commits since the
|
|
265
267
|
last release tag. So for example, a V8 canary would look something like this:
|
|
266
|
-
`8.0.0-alpha.127-next.4`.
|
|
268
|
+
`8.0.0-alpha.127-next.4`.
|
|
269
|
+
|
|
270
|
+
## Codemods
|
|
271
|
+
|
|
272
|
+
We use codemods to reduce friction for consumers as they make changes and do upgrades. Codemods are
|
|
273
|
+
accompany major version releases since v5, and can also be released in minor releases if users want to apply some changes sooner.
|
|
274
|
+
|
|
275
|
+
### Add a New Codemod
|
|
276
|
+
|
|
277
|
+
Adding a new codemod is pretty straightforward, but this guide will make sure you don't miss any steps
|
|
278
|
+
along the way.
|
|
279
|
+
|
|
280
|
+
First, you need to add a new command to the root CLI. For this example, we'll pretend you're adding
|
|
281
|
+
a new v10 codemod.
|
|
282
|
+
|
|
283
|
+
#### Initial Setup
|
|
284
|
+
|
|
285
|
+
```js
|
|
286
|
+
// modules/codemod/lib/index.js
|
|
287
|
+
.command('v10 [path]', chalk.gray('Canvas Kit v9 > v10 upgrade transform'), yargs => {
|
|
288
|
+
yargs.positional('path', {
|
|
289
|
+
type: 'string',
|
|
290
|
+
default: '.',
|
|
291
|
+
describe: chalk.gray('The path to execute the transform in (recursively).'),
|
|
292
|
+
});
|
|
293
|
+
})
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Next, you'll want to add new v10 files and directories.
|
|
297
|
+
|
|
298
|
+
```sh
|
|
299
|
+
# add code and spec directories
|
|
300
|
+
mkdir modules/codemod/v10 modules/codemod/spec
|
|
301
|
+
# add code files
|
|
302
|
+
touch modules/codemod/v10/index.ts modules/codemod/v10/__example__.ts
|
|
303
|
+
## add spec files
|
|
304
|
+
touch modules/codemod/v10/spec/__example__.spec.ts modules/codemod/v10/spec/expectTransformFactory.spec.ts
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
#### Add the Codemod
|
|
308
|
+
|
|
309
|
+
Now you can add your first (placeholder) codemod.
|
|
310
|
+
|
|
311
|
+
```ts
|
|
312
|
+
// modules/codemod/v10/__example__.ts
|
|
313
|
+
import {Transform} from 'jscodeshift';
|
|
314
|
+
|
|
315
|
+
// placeholder codemod
|
|
316
|
+
const transform: Transform = (file, api) => {
|
|
317
|
+
const j = api.jscodeshift;
|
|
318
|
+
|
|
319
|
+
const root = j(file.source);
|
|
320
|
+
return root.toSource();
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
export default transform;
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
And add a codemod runner:
|
|
327
|
+
|
|
328
|
+
```ts
|
|
329
|
+
// modules/codemod/v10/index.ts
|
|
330
|
+
import {Transform} from 'jscodeshift';
|
|
331
|
+
|
|
332
|
+
// TODO: Remove this
|
|
333
|
+
import placeholderCodemod from './__example__';
|
|
334
|
+
|
|
335
|
+
const transform: Transform = (file, api, options) => {
|
|
336
|
+
// These will run in order. If your transform depends on others, place yours after dependent transforms
|
|
337
|
+
const fixes = [
|
|
338
|
+
// TODO: Remove this
|
|
339
|
+
placeholderCodemod,
|
|
340
|
+
// add codemods here
|
|
341
|
+
];
|
|
342
|
+
return fixes.reduce((source, fix) => fix({...file, source}, api, options) as string, file.source);
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
export default transform;
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
#### Add Tests
|
|
349
|
+
|
|
350
|
+
Now you're ready to add your tests. First, we'll add this test factory to make your tests easier to
|
|
351
|
+
write.
|
|
352
|
+
|
|
353
|
+
```ts
|
|
354
|
+
// modules/codemod/v10/spec/expectTransformFactory.spec.ts
|
|
355
|
+
import {runInlineTest} from 'jscodeshift/dist/testUtils';
|
|
356
|
+
|
|
357
|
+
export const expectTransformFactory = (fn: Function) => (
|
|
358
|
+
input: string,
|
|
359
|
+
expected: string,
|
|
360
|
+
options?: Record<string, any>
|
|
361
|
+
) => {
|
|
362
|
+
return runInlineTest(fn, options, {source: input}, expected, {parser: 'tsx'});
|
|
363
|
+
};
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
```ts
|
|
367
|
+
// modules/codemod/v10/spec/__example__.spec.ts
|
|
368
|
+
import {expectTransformFactory} from './expectTransformFactory';
|
|
369
|
+
import transform from '../__remove_this__';
|
|
370
|
+
|
|
371
|
+
const expectTransform = expectTransformFactory(transform);
|
|
372
|
+
|
|
373
|
+
describe('Example Codemod', () => {
|
|
374
|
+
it('should not modify the code', () => {
|
|
375
|
+
const input = "const foo = 'bar';";
|
|
376
|
+
const expected = "const foo = 'bar';";
|
|
377
|
+
expectTransform(input, expected);
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
And that's it! You're done. Stage your changes, commit, and push up a PR.
|
|
@@ -59,6 +59,12 @@ Here's an example of a `Card` with a reduced padding of `xs`.
|
|
|
59
59
|
wraps a non-semantic `div` element. The element can be replaced using the `as` prop, or a `role` or
|
|
60
60
|
other `aria-*` attributes can be added to give `Card` semantic meaning.
|
|
61
61
|
|
|
62
|
+
Changing the `Card` container to certain semantic elements will put accessibility at risk. For
|
|
63
|
+
example, using the `as` prop to change the cards to buttons will flatten the content in the card.
|
|
64
|
+
Headings, calls to action, etc. will not function as expected for users with disabilities. Semantic
|
|
65
|
+
container elements like `<section>`, or using `<li>` grouped together in a common `<ul>` can be a
|
|
66
|
+
useful way to elevate the accessibility of your design.
|
|
67
|
+
|
|
62
68
|
#### Props
|
|
63
69
|
|
|
64
70
|
Undocumented props are spread to the outermost element rendered by `Card`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.320-next.3+7d3b3e9b",
|
|
4
4
|
"description": "Documentation components of Canvas Kit components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@storybook/csf": "0.0.1",
|
|
45
|
-
"@workday/canvas-kit-react": "^9.0.0-alpha.
|
|
45
|
+
"@workday/canvas-kit-react": "^9.0.0-alpha.320-next.3+7d3b3e9b",
|
|
46
46
|
"@workday/canvas-system-icons-web": "^3.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"mkdirp": "^1.0.3",
|
|
52
52
|
"typescript": "4.1"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "7d3b3e9bb7b0f55017fa61a3142748e07967f626"
|
|
55
55
|
}
|