@workday/canvas-kit-docs 6.1.3 → 6.2.1
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/5.0-MIGRATION-GUIDE.mdx +81 -7
- package/dist/mdx/preview-react/menu/examples/ContextMenu.tsx +2 -0
- package/dist/mdx/react/_examples/CookieBanner.mdx +8 -0
- package/dist/mdx/react/_examples/examples/CookieBanner.tsx +97 -0
- package/dist/mdx/react/popup/Popup.mdx +62 -0
- package/dist/mdx/react/popup/examples/FullScreen.tsx +115 -0
- package/package.json +3 -3
|
@@ -10,6 +10,7 @@ any questions about the update.
|
|
|
10
10
|
- [Canvas Kit Preview](#canvas-kit-preview)
|
|
11
11
|
- [Type Deprecations and Hierarchy Updates](#type-deprecations-and-hierarchy-updates)
|
|
12
12
|
- [Canvas Kit CSS Maintenance Mode](#canvas-kit-css-maintenance-mode)
|
|
13
|
+
- [Prop Interfaces](#prop-interfaces)
|
|
13
14
|
- [Component Changes](#component-changes)
|
|
14
15
|
- [Component Promotions](#component-promotions)
|
|
15
16
|
- [Core](#core)
|
|
@@ -423,6 +424,59 @@ provide more focused support and to dedicate our efforts to making bigger and be
|
|
|
423
424
|
our most used components: Canvas Kit React. If you have questions or concerns, please
|
|
424
425
|
[let us know](https://github.com/Workday/canvas-kit/issues/new?labels=&template=question.md).
|
|
425
426
|
|
|
427
|
+
### Prop Interfaces
|
|
428
|
+
|
|
429
|
+
Many components were updated to be polymorphic using the `createComponent` utility function. Most
|
|
430
|
+
components in Canvas Kit extend from an HTML interface and spread extra props onto the HTML element.
|
|
431
|
+
Since these components are now polymorphic, the exported props no longer extend from an HTML
|
|
432
|
+
interface since the HTML interface is now determined by an optional `as` prop. It is common to wrap
|
|
433
|
+
Canvas Kit components with your own component and extend from the Canvas Kit component's prop
|
|
434
|
+
interface. To support this use-case in addition to polymorphic prop interfaces, `ExtractProp` was
|
|
435
|
+
introduced. `ExtractProp` understands these polymorphic components and will return the base props in
|
|
436
|
+
addition to the HTML interface. There is an optional second argument that can override the default
|
|
437
|
+
HTML interface if your wrapper component uses the `as`.
|
|
438
|
+
|
|
439
|
+
```tsx
|
|
440
|
+
// v4
|
|
441
|
+
import {TextInput, TextInputProps} from '@workday/canvas-kit-react-text-input';
|
|
442
|
+
|
|
443
|
+
const FancyTextInput: React.FC<TextInputProps> = props => <TextInput {...props} />;
|
|
444
|
+
|
|
445
|
+
// v5
|
|
446
|
+
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
447
|
+
import {ExtractProps} from '@workday/canvas-kit-react/common';
|
|
448
|
+
|
|
449
|
+
const FancyTextInput: React.FC<ExtractProps<typeof TextInput>> = props => {};
|
|
450
|
+
|
|
451
|
+
// v5 via createComponent
|
|
452
|
+
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
453
|
+
import {createComponent} from '@workday/canvas-kit-react/common';
|
|
454
|
+
|
|
455
|
+
const FancyTextInput = createComponent(TextInput)({
|
|
456
|
+
displayName: 'FancyTextInput',
|
|
457
|
+
Component((props) => <TextInput {...props} />)
|
|
458
|
+
})
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
Components that made this change:
|
|
462
|
+
|
|
463
|
+
- Button
|
|
464
|
+
- IconButton
|
|
465
|
+
- Card
|
|
466
|
+
- Hyperlink
|
|
467
|
+
- Select
|
|
468
|
+
- TextArea
|
|
469
|
+
- TextInput
|
|
470
|
+
- Checkbox
|
|
471
|
+
- Radio
|
|
472
|
+
- ColorInput
|
|
473
|
+
- ColorPreview
|
|
474
|
+
- Modal
|
|
475
|
+
- Popup
|
|
476
|
+
- Skeleton
|
|
477
|
+
- Tabs
|
|
478
|
+
- Toast
|
|
479
|
+
|
|
426
480
|
## Component Changes
|
|
427
481
|
|
|
428
482
|
### Component Promotions
|
|
@@ -799,20 +853,25 @@ Button prop interface and accesses properties like `onClick`, you'll need to pro
|
|
|
799
853
|
attribute yourself in order to avoid TypeScript issues (this doesn't affect runtime). This is not
|
|
800
854
|
code-moddable since intent cannot be pre-determined.
|
|
801
855
|
|
|
856
|
+
#### Props
|
|
857
|
+
|
|
858
|
+
The exported props no longer extend from the `HTMLButtonElement` interface. Use
|
|
859
|
+
[ExtractProps](#prop-interfaces) instead.
|
|
860
|
+
|
|
802
861
|
```tsx
|
|
803
862
|
interface MyButtonProps extends ButtonProps {}
|
|
804
863
|
|
|
805
864
|
// onClick no longer exists in `ButtonProps`, so TypeScript will complain about onClick not
|
|
806
865
|
// existing in `MyButtonProps` (`onClick` does exist as a prop on `<Button>`, however)
|
|
807
866
|
const MyButton = ({children, onClick}: MyButtonProps) => (
|
|
808
|
-
<
|
|
867
|
+
<SecondaryButton onClick={onClick}>{children}</SecondaryButton>
|
|
809
868
|
);
|
|
810
869
|
|
|
811
870
|
// After
|
|
812
|
-
interface MyButtonProps extends
|
|
871
|
+
interface MyButtonProps extends ExtractProps<typeof SecondaryButton> {}
|
|
813
872
|
|
|
814
873
|
// After (alternate fix)
|
|
815
|
-
interface MyButtonProps extends
|
|
874
|
+
interface MyButtonProps extends ExtractProps<> {
|
|
816
875
|
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
817
876
|
}
|
|
818
877
|
```
|
|
@@ -881,6 +940,21 @@ const props = {
|
|
|
881
940
|
import {Card} from './Card' // where `Card` is a re-exported Canvas Kit `Card`
|
|
882
941
|
```
|
|
883
942
|
|
|
943
|
+
#### Props
|
|
944
|
+
|
|
945
|
+
The exported props no longer extend from the `HTMLDivElement` interface. Use
|
|
946
|
+
[ExtractProps](#prop-interfaces) instead.
|
|
947
|
+
|
|
948
|
+
```tsx
|
|
949
|
+
// NOT handled by the codemod
|
|
950
|
+
|
|
951
|
+
// v4
|
|
952
|
+
interface MyCard extends CardProps {}
|
|
953
|
+
|
|
954
|
+
// v5
|
|
955
|
+
interface MyCard extends ExtractProps<typeof Card>
|
|
956
|
+
```
|
|
957
|
+
|
|
884
958
|
---
|
|
885
959
|
|
|
886
960
|
### Inputs
|
|
@@ -924,14 +998,14 @@ element that `inputRef` was applied to previously. Select and Select (Preview) d
|
|
|
924
998
|
`inputRef` in v4, but now support `ref` in v5. See each component's documentation for information on
|
|
925
999
|
which element `ref` is forwarded to for that particular component.
|
|
926
1000
|
|
|
1001
|
+
#### Props
|
|
1002
|
+
|
|
927
1003
|
Input component prop interfaces no longer extend directly from their underlying element interface
|
|
928
1004
|
(e.g. `TextInputProps` no longer extends from `React.InputHTMLAttributes<HTMLInputElement>`).
|
|
929
1005
|
`createComponent` returns a component that determines the element interface via the `as` prop. This
|
|
930
1006
|
is why input component props no longer contain an element interface directly. If you extend from an
|
|
931
1007
|
input component prop interface, or have code that uses an input component prop interface and
|
|
932
|
-
accesses properties like `onClick`, you'll need to
|
|
933
|
-
avoid TypeScript issues (this doesn't affect runtime). This is not code-moddable since intent cannot
|
|
934
|
-
be pre-determined.
|
|
1008
|
+
accesses properties like `onClick`, you'll need to use [ExtractProps](#prop-interfaces) instead.
|
|
935
1009
|
|
|
936
1010
|
```tsx
|
|
937
1011
|
interface MyTextInputProps extends TextInputProps {}
|
|
@@ -941,7 +1015,7 @@ interface MyTextInputProps extends TextInputProps {}
|
|
|
941
1015
|
const MyTextInput = ({onClick}: MyTextInputProps) => <TextInput onClick={onClick} />;
|
|
942
1016
|
|
|
943
1017
|
// Fix
|
|
944
|
-
interface MyTextInputProps extends
|
|
1018
|
+
interface MyTextInputProps extends ExtractProps<typeof TextInput> {}
|
|
945
1019
|
|
|
946
1020
|
// Alternate fix
|
|
947
1021
|
interface MyTextInputProps extends TextInputProps {
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
usePopupModel,
|
|
9
9
|
useAlwaysCloseOnOutsideClick,
|
|
10
10
|
useCloseOnEscape,
|
|
11
|
+
useTransferOnFullscreenExit,
|
|
11
12
|
} from '@workday/canvas-kit-react/popup';
|
|
12
13
|
|
|
13
14
|
const ContextMenuTarget = createComponent('div')({
|
|
@@ -40,6 +41,7 @@ export default () => {
|
|
|
40
41
|
|
|
41
42
|
useAlwaysCloseOnOutsideClick(model);
|
|
42
43
|
useCloseOnEscape(model);
|
|
44
|
+
useTransferOnFullscreenExit(model);
|
|
43
45
|
|
|
44
46
|
return (
|
|
45
47
|
<Popup model={model}>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import {createComponent, styled, StyledType} from '@workday/canvas-kit-react/common';
|
|
4
|
+
import {colors, commonColors, depth, type, space} from '@workday/canvas-kit-react/tokens';
|
|
5
|
+
import {PrimaryButton, TertiaryButton} from '@workday/canvas-kit-react/button';
|
|
6
|
+
|
|
7
|
+
const CookieBannerItem = createComponent('div')({
|
|
8
|
+
displayName: 'CookieBanner.Item',
|
|
9
|
+
Component: ({isRow, ...elProps}: ItemProps, ref) => (
|
|
10
|
+
<BannerItem ref={ref} isRow={isRow} {...elProps} />
|
|
11
|
+
),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const CookieBanner = createComponent('div')({
|
|
15
|
+
displayName: 'CookieBanner',
|
|
16
|
+
Component: (props: BannerProps, ref, Element) => <Banner ref={ref} as={Element} {...props} />,
|
|
17
|
+
subComponents: {Item: CookieBannerItem},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export default () => {
|
|
21
|
+
const DefaultNotice = `We use cookies to ensure that we give you the best experience on our website.
|
|
22
|
+
If you continue without changing your settings, we'll assume that you are willing to receive cookies.`;
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<ExampleContainer>
|
|
26
|
+
<CookieBanner isClosed={false}>
|
|
27
|
+
<CookieBanner.Item>{DefaultNotice}</CookieBanner.Item>
|
|
28
|
+
<CookieBanner.Item isRow>
|
|
29
|
+
<TertiaryButton>Settings</TertiaryButton>
|
|
30
|
+
<PrimaryButton>Continue</PrimaryButton>
|
|
31
|
+
</CookieBanner.Item>
|
|
32
|
+
</CookieBanner>
|
|
33
|
+
</ExampleContainer>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
interface BannerProps {
|
|
38
|
+
isClosed?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface ItemProps {
|
|
42
|
+
isRow?: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const ExampleContainer = styled('div')({
|
|
46
|
+
minHeight: 84,
|
|
47
|
+
margin: space.xs,
|
|
48
|
+
position: 'relative',
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const Banner = styled('div')<BannerProps & StyledType>(
|
|
52
|
+
type.levels.subtext.medium,
|
|
53
|
+
{
|
|
54
|
+
backgroundColor: commonColors.background,
|
|
55
|
+
borderTop: `1px solid ${colors.soap400}`,
|
|
56
|
+
display: 'flex',
|
|
57
|
+
...depth[1],
|
|
58
|
+
padding: space.m,
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
justifyContent: 'space-between',
|
|
61
|
+
position: 'absolute',
|
|
62
|
+
bottom: 0,
|
|
63
|
+
left: 0,
|
|
64
|
+
right: 0,
|
|
65
|
+
zIndex: 99,
|
|
66
|
+
transition: 'transform 0.2s ease-out',
|
|
67
|
+
'@media (max-width: 450px)': {
|
|
68
|
+
flexDirection: 'column',
|
|
69
|
+
alignItems: 'stretch',
|
|
70
|
+
textAlign: 'center',
|
|
71
|
+
padding: `${space.s} 0`,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
({isClosed}) => isClosed && {transform: 'translateY(100%)'}
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const BannerItem = styled('div')<ItemProps & StyledType>(
|
|
78
|
+
{
|
|
79
|
+
marginLeft: space.s,
|
|
80
|
+
marginRight: space.s,
|
|
81
|
+
'@media (max-width: 450px)': {
|
|
82
|
+
'&:not(:first-of-type)': {
|
|
83
|
+
marginTop: space.s,
|
|
84
|
+
'> *': {
|
|
85
|
+
flex: 1,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
({isRow}) =>
|
|
91
|
+
isRow && {
|
|
92
|
+
display: 'flex',
|
|
93
|
+
'> *': {
|
|
94
|
+
marginLeft: space.s,
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
);
|
|
@@ -9,6 +9,7 @@ import FocusRedirect from './examples/FocusRedirect';
|
|
|
9
9
|
import FocusTrap from './examples/FocusTrap';
|
|
10
10
|
import RTL from './examples/RTL';
|
|
11
11
|
import CustomTarget from './examples/CustomTarget';
|
|
12
|
+
import FullScreen from './examples/FullScreen';
|
|
12
13
|
import {
|
|
13
14
|
PopupModelConfigComponent,
|
|
14
15
|
PopupStateComponent,
|
|
@@ -143,6 +144,25 @@ requires a `label` prop.
|
|
|
143
144
|
|
|
144
145
|
<ExampleCodeBlock code={CustomTarget} />
|
|
145
146
|
|
|
147
|
+
### Full Screen API
|
|
148
|
+
|
|
149
|
+
By default, popups are created as children of the `document.body` element, but the `PopupStack`
|
|
150
|
+
supports the [Fullscreen API](https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API). When
|
|
151
|
+
fullscreen is entered, the `PopupStack` will automatically create a new stacking context for all
|
|
152
|
+
future popups. Any existing popups will disappear, but not be removed. They disappear because the
|
|
153
|
+
fullscreen API is only showing content within the fullscreen element. There are instances where a
|
|
154
|
+
popup may not close when fullscreen is exited:
|
|
155
|
+
|
|
156
|
+
- The escape key is used to exit fullscreen
|
|
157
|
+
- There is a button to exit fullscreen, but the popup doesn't use `useCloseOnOutsideClick`
|
|
158
|
+
|
|
159
|
+
If fullscreen is exited, popups within the fullscreen stacking context are not removed or
|
|
160
|
+
transferred automatically. If you do not handle this case, the popup may not render correctly. This
|
|
161
|
+
example shows a popup that closes when fullscreen is entered/exited and another popup that transfers
|
|
162
|
+
the popup's stack context when entering/exiting fullscreen.
|
|
163
|
+
|
|
164
|
+
<ExampleCodeBlock code={FullScreen} />
|
|
165
|
+
|
|
146
166
|
### RTL
|
|
147
167
|
|
|
148
168
|
The Popup component automatically handles right-to-left rendering.
|
|
@@ -396,6 +416,15 @@ stack. This is useful for Tooltips or hierarchical menus. Adds a
|
|
|
396
416
|
This should be used with popup elements that should close no matter their position in the stack
|
|
397
417
|
(i.e. Tooltips).
|
|
398
418
|
|
|
419
|
+
### useCloseOnFullscreenExit
|
|
420
|
+
|
|
421
|
+
```ts
|
|
422
|
+
useCloseOnFullscreenExit(model: PopupModel): {}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
Closes the popup when fullscreen is exited. Entering/exiting fullscreen changes the context of the
|
|
426
|
+
entire screen. This should be added to popup types that are very context sensitive like Tooltips.
|
|
427
|
+
|
|
399
428
|
### useDisableBodyScroll
|
|
400
429
|
|
|
401
430
|
```ts
|
|
@@ -442,6 +471,10 @@ This should be used on popup elements that need to hide content (i.e. Modals).
|
|
|
442
471
|
|
|
443
472
|
### useInitialFocus
|
|
444
473
|
|
|
474
|
+
```ts
|
|
475
|
+
useInitialFocus(model: PopupModel): {}
|
|
476
|
+
```
|
|
477
|
+
|
|
445
478
|
Moves focus within the popup when the popup becomes visible. This is useful for keyboard and screen
|
|
446
479
|
reader users alike. This should be used with [useFocusRedirect](#usefocusredirect) or
|
|
447
480
|
[useFocusTrap](#usefocustrap) for a complete focus management solution.
|
|
@@ -451,12 +484,41 @@ menus, etc.
|
|
|
451
484
|
|
|
452
485
|
### useReturnFocus
|
|
453
486
|
|
|
487
|
+
```ts
|
|
488
|
+
useReturnFocus(model: PopupModel): {}
|
|
489
|
+
```
|
|
490
|
+
|
|
454
491
|
Returns focus to the target element when the popup is hidden. This works well with
|
|
455
492
|
[useInitialFocus](#useinitialfocus). This should be used with [useFocusRedirect](#usefocusredirect)
|
|
456
493
|
or [useFocusTrap](#usefocustrap) for a complete focus management solution.
|
|
457
494
|
|
|
458
495
|
This should ble used on popup elements that use [useInitialFocus](#useinitialfocus).
|
|
459
496
|
|
|
497
|
+
### useTransferOnFullscreenEnter
|
|
498
|
+
|
|
499
|
+
```ts
|
|
500
|
+
useTransferOnFullscreenEnter(model: PopupModel): {}
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
Makes the popup transfer to the fullscreen element when fullscreen is entered. Without this, the
|
|
504
|
+
popup would seem to disappear because the popup container element is not a child of the fullscreen
|
|
505
|
+
element.
|
|
506
|
+
|
|
507
|
+
Don't use this in conjunction with a hook that will close the popup when entering fullscreen. Doing
|
|
508
|
+
so would open the popup when the intention was to close it.
|
|
509
|
+
|
|
510
|
+
### useTransferOnFullscreenExit
|
|
511
|
+
|
|
512
|
+
```ts
|
|
513
|
+
useTransferOnFullscreenExit(model: PopupModel): {}
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
Makes the popup transfer to fullscreen when fullscreen is exited. Without this hook, the popup would
|
|
517
|
+
not operate correctly with other popups on the screen.
|
|
518
|
+
|
|
519
|
+
Don't use this in conjunction with a hook that will close the popup when exiting fullscreen. Doing
|
|
520
|
+
so would open the popup when the intention was to close it.
|
|
521
|
+
|
|
460
522
|
### usePopupPopper
|
|
461
523
|
|
|
462
524
|
```ts
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
+
import {
|
|
5
|
+
Popup,
|
|
6
|
+
useCloseOnEscape,
|
|
7
|
+
useCloseOnOutsideClick,
|
|
8
|
+
useFocusTrap,
|
|
9
|
+
useInitialFocus,
|
|
10
|
+
useReturnFocus,
|
|
11
|
+
usePopupModel,
|
|
12
|
+
useCloseOnFullscreenExit,
|
|
13
|
+
useTransferOnFullscreenExit,
|
|
14
|
+
useTransferOnFullscreenEnter,
|
|
15
|
+
} from '@workday/canvas-kit-react/popup';
|
|
16
|
+
import {HStack, Flex} from '@workday/canvas-kit-labs-react/layout';
|
|
17
|
+
import {useIsFullscreen} from '@workday/canvas-kit-react/common';
|
|
18
|
+
import screenfull from 'screenfull';
|
|
19
|
+
|
|
20
|
+
const SelfClosePopup = () => {
|
|
21
|
+
const model = usePopupModel();
|
|
22
|
+
|
|
23
|
+
useCloseOnOutsideClick(model);
|
|
24
|
+
useCloseOnEscape(model);
|
|
25
|
+
useInitialFocus(model);
|
|
26
|
+
useReturnFocus(model);
|
|
27
|
+
useFocusTrap(model);
|
|
28
|
+
useCloseOnFullscreenExit(model);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Popup model={model}>
|
|
32
|
+
<Popup.Target>Open Self-close Popup</Popup.Target>
|
|
33
|
+
<Popup.Popper>
|
|
34
|
+
<Popup.Card width={400} padding="s">
|
|
35
|
+
<Popup.CloseIcon aria-label="Close" />
|
|
36
|
+
<Popup.Heading>Self-close Popup</Popup.Heading>
|
|
37
|
+
<Popup.Body>
|
|
38
|
+
<p>
|
|
39
|
+
When in fullscreen, the escape key will be highjacked by the browser to exit
|
|
40
|
+
fullscreen and <code>useCloseOnEscape</code> hook will not receive the escape key. To
|
|
41
|
+
close when fullscreen is exited, use the <code>useCloseOnFullscreenExit</code> hook.
|
|
42
|
+
</p>
|
|
43
|
+
</Popup.Body>
|
|
44
|
+
<Popup.CloseButton>Close</Popup.CloseButton>
|
|
45
|
+
</Popup.Card>
|
|
46
|
+
</Popup.Popper>
|
|
47
|
+
</Popup>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const TransferClosePopup = () => {
|
|
52
|
+
const model = usePopupModel();
|
|
53
|
+
|
|
54
|
+
useCloseOnEscape(model);
|
|
55
|
+
useInitialFocus(model);
|
|
56
|
+
useReturnFocus(model);
|
|
57
|
+
useFocusTrap(model);
|
|
58
|
+
useTransferOnFullscreenEnter(model);
|
|
59
|
+
useTransferOnFullscreenExit(model);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<Popup model={model}>
|
|
63
|
+
<Popup.Target>Open Transfer Popup</Popup.Target>
|
|
64
|
+
<Popup.Popper>
|
|
65
|
+
<Popup.Card width={400} padding="s">
|
|
66
|
+
<Popup.CloseIcon aria-label="Close" />
|
|
67
|
+
<Popup.Heading>Transfer Popup</Popup.Heading>
|
|
68
|
+
<Popup.Body>
|
|
69
|
+
<p>
|
|
70
|
+
When in fullscreen, the escape key will be highjacked by the browser to exit
|
|
71
|
+
fullscreen and <code>useCloseOnEscape</code> hook will not receive the escape key. To
|
|
72
|
+
close when fullscreen is exited, use the <code>useTransferOnFullscreenExit</code>{' '}
|
|
73
|
+
hook.
|
|
74
|
+
</p>
|
|
75
|
+
</Popup.Body>
|
|
76
|
+
<Popup.CloseButton>Close</Popup.CloseButton>
|
|
77
|
+
</Popup.Card>
|
|
78
|
+
</Popup.Popper>
|
|
79
|
+
</Popup>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default () => {
|
|
84
|
+
// you could make this a hook depending on which fullscreen library your application uses
|
|
85
|
+
const fullscreenElementRef = React.useRef<HTMLDivElement>();
|
|
86
|
+
const isFullscreen = useIsFullscreen();
|
|
87
|
+
|
|
88
|
+
const enterFullScreen = () => {
|
|
89
|
+
screenfull.request(fullscreenElementRef.current);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const exitFullscreen = () => {
|
|
93
|
+
screenfull.exit();
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<>
|
|
98
|
+
<SecondaryButton onClick={enterFullScreen}>Open Fullscreen</SecondaryButton>
|
|
99
|
+
<Flex
|
|
100
|
+
ref={fullscreenElementRef}
|
|
101
|
+
alignItems="center"
|
|
102
|
+
justifyContent="center"
|
|
103
|
+
background="white"
|
|
104
|
+
>
|
|
105
|
+
<HStack spacing="s">
|
|
106
|
+
<SelfClosePopup />
|
|
107
|
+
<TransferClosePopup />
|
|
108
|
+
{isFullscreen ? (
|
|
109
|
+
<SecondaryButton onClick={exitFullscreen}>Exit fullscreen</SecondaryButton>
|
|
110
|
+
) : null}
|
|
111
|
+
</HStack>
|
|
112
|
+
</Flex>
|
|
113
|
+
</>
|
|
114
|
+
);
|
|
115
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "6.1
|
|
3
|
+
"version": "6.2.1",
|
|
4
4
|
"description": "Documentation components of Canvas Kit components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@storybook/csf": "0.0.1",
|
|
53
|
-
"@workday/canvas-kit-react": "^6.1
|
|
53
|
+
"@workday/canvas-kit-react": "^6.2.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"fs-extra": "^10.0.0",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"mkdirp": "^1.0.3",
|
|
59
59
|
"typescript": "^3.8.3"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "5182205f93321ee45e30db5458ae7e4a9775d7d3"
|
|
62
62
|
}
|