@workday/canvas-kit-react 6.0.0-alpha.0-next.21 → 6.0.0-alpha.0-next.27
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/action-bar/lib/ActionBar.tsx +43 -30
- package/common/lib/styles/accessibleHide.ts +2 -2
- package/common/lib/theming/README.md +189 -25
- package/common/lib/theming/breakpoints.ts +296 -16
- package/common/lib/theming/types.ts +191 -1
- package/dist/commonjs/action-bar/lib/ActionBar.d.ts.map +1 -1
- package/dist/commonjs/action-bar/lib/ActionBar.js +35 -27
- package/dist/commonjs/button/lib/parts/ButtonLabel.d.ts +1 -1
- package/dist/commonjs/common/lib/styles/accessibleHide.d.ts +2 -2
- package/dist/commonjs/common/lib/styles/accessibleHide.d.ts.map +1 -1
- package/dist/commonjs/common/lib/theming/breakpoints.d.ts +287 -6
- package/dist/commonjs/common/lib/theming/breakpoints.d.ts.map +1 -1
- package/dist/commonjs/common/lib/theming/breakpoints.js +192 -10
- package/dist/commonjs/common/lib/theming/types.d.ts +191 -1
- package/dist/commonjs/common/lib/theming/types.d.ts.map +1 -1
- package/dist/commonjs/common/lib/utils/components.d.ts +1 -1
- package/dist/commonjs/pagination/lib/Pagination/PageList.d.ts +1 -1
- package/dist/commonjs/pagination/lib/Pagination/Pagination.d.ts +5 -5
- package/dist/commonjs/pagination/lib/Pagination/common/List.d.ts +1 -1
- package/dist/commonjs/pagination/lib/Pagination/common/utils/space.d.ts +28 -28
- package/dist/commonjs/tokens/index.d.ts +3 -20
- package/dist/commonjs/tokens/index.d.ts.map +1 -1
- package/dist/commonjs/tokens/index.js +3 -6
- package/dist/commonjs/tokens/lib/depth.d.ts +109 -3
- package/dist/commonjs/tokens/lib/depth.d.ts.map +1 -1
- package/dist/commonjs/tokens/lib/depth.js +40 -5
- package/dist/es6/action-bar/lib/ActionBar.d.ts.map +1 -1
- package/dist/es6/action-bar/lib/ActionBar.js +33 -22
- package/dist/es6/button/lib/parts/ButtonLabel.d.ts +1 -1
- package/dist/es6/common/lib/styles/accessibleHide.d.ts +2 -2
- package/dist/es6/common/lib/styles/accessibleHide.d.ts.map +1 -1
- package/dist/es6/common/lib/theming/breakpoints.d.ts +287 -6
- package/dist/es6/common/lib/theming/breakpoints.d.ts.map +1 -1
- package/dist/es6/common/lib/theming/breakpoints.js +192 -10
- package/dist/es6/common/lib/theming/types.d.ts +191 -1
- package/dist/es6/common/lib/theming/types.d.ts.map +1 -1
- package/dist/es6/pagination/lib/Pagination/PageList.d.ts +1 -1
- package/dist/es6/pagination/lib/Pagination/Pagination.d.ts +5 -5
- package/dist/es6/pagination/lib/Pagination/common/List.d.ts +1 -1
- package/dist/es6/pagination/lib/Pagination/common/utils/space.d.ts +28 -28
- package/dist/es6/tokens/index.d.ts +3 -20
- package/dist/es6/tokens/index.d.ts.map +1 -1
- package/dist/es6/tokens/index.js +1 -1
- package/dist/es6/tokens/lib/depth.d.ts +109 -3
- package/dist/es6/tokens/lib/depth.d.ts.map +1 -1
- package/dist/es6/tokens/lib/depth.js +40 -2
- package/package.json +5 -6
- package/tokens/README.md +5 -12
- package/tokens/index.ts +2 -2
- package/tokens/lib/depth.ts +125 -3
- package/ts3.5/dist/commonjs/button/lib/parts/ButtonLabel.d.ts +1 -1
- package/ts3.5/dist/commonjs/common/lib/styles/accessibleHide.d.ts +2 -2
- package/ts3.5/dist/commonjs/common/lib/theming/breakpoints.d.ts +287 -6
- package/ts3.5/dist/commonjs/common/lib/theming/types.d.ts +191 -1
- package/ts3.5/dist/commonjs/common/lib/utils/components.d.ts +1 -1
- package/ts3.5/dist/commonjs/pagination/lib/Pagination/PageList.d.ts +1 -1
- package/ts3.5/dist/commonjs/pagination/lib/Pagination/Pagination.d.ts +5 -5
- package/ts3.5/dist/commonjs/pagination/lib/Pagination/common/List.d.ts +1 -1
- package/ts3.5/dist/commonjs/pagination/lib/Pagination/common/utils/space.d.ts +28 -28
- package/ts3.5/dist/commonjs/tokens/index.d.ts +3 -20
- package/ts3.5/dist/commonjs/tokens/lib/depth.d.ts +109 -3
- package/ts3.5/dist/es6/button/lib/parts/ButtonLabel.d.ts +1 -1
- package/ts3.5/dist/es6/common/lib/styles/accessibleHide.d.ts +2 -2
- package/ts3.5/dist/es6/common/lib/theming/breakpoints.d.ts +287 -6
- package/ts3.5/dist/es6/common/lib/theming/types.d.ts +191 -1
- package/ts3.5/dist/es6/pagination/lib/Pagination/PageList.d.ts +1 -1
- package/ts3.5/dist/es6/pagination/lib/Pagination/Pagination.d.ts +5 -5
- package/ts3.5/dist/es6/pagination/lib/Pagination/common/List.d.ts +1 -1
- package/ts3.5/dist/es6/pagination/lib/Pagination/common/utils/space.d.ts +28 -28
- package/ts3.5/dist/es6/tokens/index.d.ts +3 -20
- package/ts3.5/dist/es6/tokens/lib/depth.d.ts +109 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import styled from '@
|
|
3
|
-
import {colors, commonColors, space} from '@workday/canvas-kit-react/tokens';
|
|
2
|
+
import {styled} from '@workday/canvas-kit-react/common';
|
|
3
|
+
import {colors, commonColors, space, CSSProperties} from '@workday/canvas-kit-react/tokens';
|
|
4
4
|
|
|
5
5
|
export interface ActionBarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
6
6
|
/**
|
|
@@ -10,45 +10,58 @@ export interface ActionBarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
10
10
|
fixed?: boolean;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
function getFixedStyles(fixed = false): CSSProperties {
|
|
14
|
+
return fixed
|
|
15
|
+
? {
|
|
16
|
+
position: 'fixed',
|
|
17
|
+
left: 0,
|
|
18
|
+
bottom: 0,
|
|
19
|
+
right: 0,
|
|
20
|
+
}
|
|
21
|
+
: {};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const ActionBarContainer = styled('div')<ActionBarProps>(
|
|
14
25
|
{
|
|
15
26
|
borderTop: `solid 1px ${colors.soap400}`,
|
|
16
27
|
background: commonColors.background,
|
|
17
28
|
padding: space.s,
|
|
18
29
|
boxShadow: '0 -2px 4px rgba(0, 0, 0, 0.08)',
|
|
19
|
-
'@media (max-width: 575px)': {
|
|
20
|
-
padding: space.xxs,
|
|
21
|
-
},
|
|
22
30
|
},
|
|
23
|
-
({fixed}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
31
|
+
({fixed, theme}) => {
|
|
32
|
+
return {
|
|
33
|
+
...getFixedStyles(fixed),
|
|
34
|
+
[theme.canvas.breakpoints.down('s')]: {
|
|
35
|
+
padding: space.xxs,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
30
39
|
);
|
|
31
40
|
|
|
32
|
-
const ChildrenContainer = styled('div')(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
const ChildrenContainer = styled('div')(
|
|
42
|
+
{
|
|
43
|
+
display: 'inline-block',
|
|
44
|
+
padding: `0 ${space.m}`,
|
|
45
|
+
'*:not(:first-of-type)': {
|
|
46
|
+
marginLeft: space.s,
|
|
47
|
+
},
|
|
37
48
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
({theme}) => ({
|
|
50
|
+
[theme.canvas.breakpoints.down('s')]: {
|
|
51
|
+
display: 'flex',
|
|
52
|
+
padding: space.xxs,
|
|
53
|
+
justifyContent: 'center',
|
|
54
|
+
flexDirection: 'row-reverse',
|
|
55
|
+
'> *': {
|
|
56
|
+
flex: 1,
|
|
57
|
+
'&:not(:first-of-type)': {
|
|
58
|
+
marginRight: space.s,
|
|
59
|
+
marginLeft: 0,
|
|
60
|
+
},
|
|
48
61
|
},
|
|
49
62
|
},
|
|
50
|
-
}
|
|
51
|
-
|
|
63
|
+
})
|
|
64
|
+
);
|
|
52
65
|
|
|
53
66
|
export default class ActionBar extends React.Component<ActionBarProps> {
|
|
54
67
|
public render() {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {CSSProperties} from '@workday/canvas-kit-react/tokens';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A utility to hide content normal users while still making accessible to screenreaders
|
|
5
5
|
* See https://a11y-101.com/development/skip-link
|
|
6
6
|
*/
|
|
7
|
-
export const accessibleHide:
|
|
7
|
+
export const accessibleHide: CSSProperties = {
|
|
8
8
|
clip: 'rect(1px, 1px, 1px, 1px)', // Deprecated but still used by most browsers, clip-path will be taking its place soon.
|
|
9
9
|
clipPath: 'polygon(0px 0px, 0px 0px, 0px 0px, 0px 0px)',
|
|
10
10
|
position: 'absolute',
|
|
@@ -90,10 +90,10 @@ export const defaultCanvasTheme: CanvasTheme = {
|
|
|
90
90
|
breakpoints: {
|
|
91
91
|
values: {
|
|
92
92
|
zero: 0,
|
|
93
|
-
s:
|
|
94
|
-
m:
|
|
95
|
-
l:
|
|
96
|
-
xl:
|
|
93
|
+
s: 320,
|
|
94
|
+
m: 768,
|
|
95
|
+
l: 1024,
|
|
96
|
+
xl: 1440,
|
|
97
97
|
},
|
|
98
98
|
up,
|
|
99
99
|
down,
|
|
@@ -243,41 +243,205 @@ variable before falling back to the default theme.
|
|
|
243
243
|
|
|
244
244
|
## Breakpoints
|
|
245
245
|
|
|
246
|
-
|
|
247
|
-
|
|
246
|
+
Breakpoints are used by media queries to conditionally apply or modify styles based on the viewport
|
|
247
|
+
width. This allows the UI to be responsive to various screen sizes.
|
|
248
|
+
|
|
249
|
+
### Values
|
|
250
|
+
|
|
251
|
+
The canvas theme object provides five breakpoint values that correspond to the min-widths of our
|
|
252
|
+
standard screen sizes.
|
|
248
253
|
|
|
249
254
|
| Name | Size (px) |
|
|
250
255
|
| ------ | --------- |
|
|
251
256
|
| `zero` | 0 |
|
|
252
|
-
| `s` |
|
|
253
|
-
| `m` |
|
|
254
|
-
| `l` |
|
|
255
|
-
| `xl` |
|
|
257
|
+
| `s` | 320 |
|
|
258
|
+
| `m` | 768 |
|
|
259
|
+
| `l` | 1024 |
|
|
260
|
+
| `xl` | 1440 |
|
|
261
|
+
|
|
262
|
+
And these are our standard screen size ranges:
|
|
263
|
+
|
|
264
|
+
- `small` (320px - 767px) Used for mobile-sized screens
|
|
265
|
+
- `medium` (768px - 1023px) Used for tablet-sized screens
|
|
266
|
+
- `large` - (1024px - 1439px) Used for laptop and small desktop screens
|
|
267
|
+
- `extra-large` (≥1440px) Used for very large screens
|
|
268
|
+
|
|
269
|
+
> Note: Some applications may only require a subset of screen sizes and not use all breakpoints.
|
|
270
|
+
|
|
271
|
+
Our breakpoint system is customized within the theme object. `theme.canvas.breakpoints.values`.
|
|
272
|
+
|
|
273
|
+
```ts
|
|
274
|
+
import {useTheme} from '@workday/canvas-kit-react/common';
|
|
275
|
+
import {space} from '@workday/canvas-kit-react/tokens';
|
|
276
|
+
|
|
277
|
+
const {theme} = useTheme();
|
|
278
|
+
const {values} = theme.canvas.breakpoints;
|
|
279
|
+
const styles = {
|
|
280
|
+
[`@media (min-width: ${values.m}px)`]: {
|
|
281
|
+
padding: space.s,
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Functions
|
|
256
287
|
|
|
257
288
|
There are also several functions to help with generating media queries:
|
|
258
289
|
|
|
259
|
-
|
|
290
|
+
- [Up](#Up)
|
|
291
|
+
- [Down](#Down)
|
|
292
|
+
- [Between](#Between)
|
|
293
|
+
- [Only](#Only)
|
|
260
294
|
|
|
261
|
-
|
|
262
|
-
> BreakpointKey.m) or the string (e.g. 'm'). Example: theme.breakpoints.up(BreakpointKey.m) =>
|
|
263
|
-
> '@media (min-width:960px)'
|
|
295
|
+
#### Up
|
|
264
296
|
|
|
265
|
-
|
|
297
|
+
_Returns a media query above the `min-width` for the range of a given breakpoint_
|
|
266
298
|
|
|
267
|
-
|
|
268
|
-
|
|
299
|
+
Given a `start` breakpoint key ("zero", "s", "m", "l", "xl"), this function returns a media query
|
|
300
|
+
(string) using a `min-width`.
|
|
269
301
|
|
|
270
|
-
|
|
302
|
+
```ts
|
|
303
|
+
import {useTheme} from '@workday/canvas-kit-react/common';
|
|
304
|
+
import {space} from '@workday/canvas-kit-react/tokens';
|
|
305
|
+
|
|
306
|
+
const theme = useTheme();
|
|
307
|
+
const {up} = theme.canvas.breakpoints;
|
|
308
|
+
const mediaQuery = up('l'); // Returns '@media (min-width: 1024px)'
|
|
309
|
+
const styles = {
|
|
310
|
+
[mediaQuery]: {
|
|
311
|
+
padding: space.m,
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
```
|
|
271
315
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
316
|
+
#### Down
|
|
317
|
+
|
|
318
|
+
_Returns a media query below the `max-width` for the range of a given breakpoint_
|
|
319
|
+
|
|
320
|
+
Given an `end` breakpoint key ("zero", "s", "m", "l", "xl"), this function returns a media query
|
|
321
|
+
(string) using a `max-width`.
|
|
322
|
+
|
|
323
|
+
> Note: This function subtracts `0.5px` from the next breakpoint value to prevent collisions. For
|
|
324
|
+
> example, `breakpoints.values.s`, has a `min-width` of `320px`, and the `max-width` is `767.5px`).
|
|
325
|
+
|
|
326
|
+
If the `xl` breakpoint is provided, this function returns a media query with only a `min-width` of
|
|
327
|
+
`0`, as seen in the second example below.
|
|
328
|
+
|
|
329
|
+
```ts
|
|
330
|
+
import {useTheme} from '@workday/canvas-kit-react/common';
|
|
331
|
+
import {space} from '@workday/canvas-kit-react/tokens';
|
|
332
|
+
|
|
333
|
+
const theme = useTheme();
|
|
334
|
+
const {down} = theme.canvas.breakpoints;
|
|
335
|
+
const mediaQuery = down('m'); // Returns '@media (max-width: 1023.5px)'
|
|
336
|
+
const styles = {
|
|
337
|
+
[mediaQuery]: {
|
|
338
|
+
padding: space.m,
|
|
339
|
+
},
|
|
340
|
+
};
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
This example uses the `xl` breakpoint and only adds a `min-width` of `0` to the media query.
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
import {useTheme} from '@workday/canvas-kit-react/common';
|
|
347
|
+
import {space} from '@workday/canvas-kit-react/tokens';
|
|
348
|
+
|
|
349
|
+
const theme = useTheme();
|
|
350
|
+
const {down} = theme.canvas.breakpoints;
|
|
351
|
+
const mediaQuery = down('xl'); // Returns '@media (min-width: 0)'
|
|
352
|
+
const styles = {
|
|
353
|
+
[mediaQuery]: {
|
|
354
|
+
padding: space.m,
|
|
355
|
+
},
|
|
356
|
+
};
|
|
357
|
+
```
|
|
275
358
|
|
|
276
|
-
####
|
|
359
|
+
#### Between
|
|
277
360
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
361
|
+
_Returns a media query between two given breakpoints_
|
|
362
|
+
|
|
363
|
+
Given `start` and `end` breakpoint keys ("zero", "s", "m", "l", "xl"), this function returns a media
|
|
364
|
+
query (string) using a min-width and max-width.
|
|
365
|
+
|
|
366
|
+
> Note: This function subtracts `0.5px` from the next breakpoint value to prevent collisions. For
|
|
367
|
+
> example, `breakpoints.values.s`, has a `min-width` of `320px`, and the `max-width` is `767.5px`).
|
|
368
|
+
|
|
369
|
+
If the `xl` breakpoint is provided, this function returns a media query with only a `min-width`, as
|
|
370
|
+
seen in the second example below.
|
|
371
|
+
|
|
372
|
+
```ts
|
|
373
|
+
import {useTheme} from '@workday/canvas-kit-react/common';
|
|
374
|
+
import {space} from '@workday/canvas-kit-react/tokens';
|
|
375
|
+
|
|
376
|
+
const theme = useTheme();
|
|
377
|
+
const {between} = theme.canvas.breakpoints;
|
|
378
|
+
// Returns '@media (min-width: 320px) and (max-width: 1023.5px)'
|
|
379
|
+
const mediaQuery = between('s', 'm');
|
|
380
|
+
const styles = {
|
|
381
|
+
[mediaQuery]: {
|
|
382
|
+
padding: space.s,
|
|
383
|
+
},
|
|
384
|
+
};
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
This example uses `xl` as the `end` breakpoint and only adds a min-width to the media query.
|
|
388
|
+
|
|
389
|
+
```ts
|
|
390
|
+
import {useTheme} from '@workday/canvas-kit-react/common';
|
|
391
|
+
import {space} from '@workday/canvas-kit-react/tokens';
|
|
392
|
+
|
|
393
|
+
const theme = useTheme();
|
|
394
|
+
const {between} = theme.canvas.breakpoints;
|
|
395
|
+
const mediaQuery = between('m', 'xl'); // Returns '@media (min-width: 768px)'
|
|
396
|
+
const styles = {
|
|
397
|
+
[mediaQuery]: {
|
|
398
|
+
padding: space.s,
|
|
399
|
+
},
|
|
400
|
+
};
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
#### Only
|
|
404
|
+
|
|
405
|
+
_Returns a media query with a `min-width` and `max-width` for a given breakpoint_
|
|
406
|
+
|
|
407
|
+
Given a breakpoint key ("zero", "s", "m", "l", "xl"), this function returns a media query (string)
|
|
408
|
+
using a `min-width` and `max-width`.
|
|
409
|
+
|
|
410
|
+
> Note: This function subtracts `0.5px` from the next breakpoint value to prevent collisions.For
|
|
411
|
+
> example, `breakpoints.values.s`, has a `min-width` of `320px`, and the `max-width` is `767.5px`).
|
|
412
|
+
|
|
413
|
+
If the `xl` breakpoint is provided, this function returns a media query with only a `min-width` of
|
|
414
|
+
`1440px`, as seen in the second example below.
|
|
415
|
+
|
|
416
|
+
```ts
|
|
417
|
+
import {useTheme} from '@workday/canvas-kit-react/common';
|
|
418
|
+
import {space} from '@workday/canvas-kit-react/tokens';
|
|
419
|
+
|
|
420
|
+
const theme = useTheme();
|
|
421
|
+
const {only} = theme.canvas.breakpoints;
|
|
422
|
+
const mediaQuery = only('s'); // Returns '@media (min-width: 320px) and (max-width: 767.5px)'
|
|
423
|
+
const styles = {
|
|
424
|
+
[mediaQuery]: {
|
|
425
|
+
padding: space.s,
|
|
426
|
+
},
|
|
427
|
+
};
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
This example uses the `xl` breakpoint and only adds a `min-width` of `1440px` to the media query.
|
|
431
|
+
|
|
432
|
+
```ts
|
|
433
|
+
import {useTheme} from '@workday/canvas-kit-react/common';
|
|
434
|
+
import {space} from '@workday/canvas-kit-react/tokens';
|
|
435
|
+
|
|
436
|
+
const theme = useTheme();
|
|
437
|
+
const {only} = theme.canvas.breakpoints;
|
|
438
|
+
const mediaQuery = only('m', 'xl'); // Returns '@media (min-width: 1440px)'
|
|
439
|
+
const styles = {
|
|
440
|
+
[mediaQuery]: {
|
|
441
|
+
padding: space.s,
|
|
442
|
+
},
|
|
443
|
+
};
|
|
444
|
+
```
|
|
281
445
|
|
|
282
446
|
## useIsRTL Hook
|
|
283
447
|
|