@workday/canvas-kit-react 12.0.0-alpha.841-next.0 → 12.0.0-alpha.846-next.0

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.
Files changed (140) hide show
  1. package/common/lib/utils/getTranslateFromOrigin.ts +22 -2
  2. package/dist/commonjs/button/lib/BaseButton.d.ts +5 -5
  3. package/dist/commonjs/button/lib/BaseButton.js +1 -1
  4. package/dist/commonjs/button/lib/DeleteButton.js +1 -1
  5. package/dist/commonjs/button/lib/PrimaryButton.js +2 -2
  6. package/dist/commonjs/button/lib/SecondaryButton.js +2 -2
  7. package/dist/commonjs/button/lib/TertiaryButton.js +4 -4
  8. package/dist/commonjs/checkbox/lib/CheckboxCheck.js +2 -2
  9. package/dist/commonjs/combobox/lib/hooks/useComboboxInput.d.ts +1 -1
  10. package/dist/commonjs/common/lib/CanvasProvider.d.ts +6 -6
  11. package/dist/commonjs/common/lib/utils/getTranslateFromOrigin.d.ts +11 -0
  12. package/dist/commonjs/common/lib/utils/getTranslateFromOrigin.d.ts.map +1 -1
  13. package/dist/commonjs/common/lib/utils/getTranslateFromOrigin.js +19 -3
  14. package/dist/commonjs/icon/lib/SystemIcon.d.ts +2 -1
  15. package/dist/commonjs/icon/lib/SystemIcon.d.ts.map +1 -1
  16. package/dist/commonjs/icon/lib/SystemIcon.js +3 -3
  17. package/dist/commonjs/icon/lib/SystemIconCircle.js +1 -1
  18. package/dist/commonjs/menu/lib/MenuItem.d.ts +1 -1
  19. package/dist/commonjs/modal/lib/ModalBody.d.ts +1 -0
  20. package/dist/commonjs/modal/lib/ModalBody.d.ts.map +1 -1
  21. package/dist/commonjs/modal/lib/ModalBody.js +8 -12
  22. package/dist/commonjs/modal/lib/ModalCard.d.ts +1 -0
  23. package/dist/commonjs/modal/lib/ModalCard.d.ts.map +1 -1
  24. package/dist/commonjs/modal/lib/ModalCard.js +8 -14
  25. package/dist/commonjs/modal/lib/ModalHeading.d.ts +1 -0
  26. package/dist/commonjs/modal/lib/ModalHeading.d.ts.map +1 -1
  27. package/dist/commonjs/modal/lib/ModalHeading.js +8 -12
  28. package/dist/commonjs/modal/lib/ModalOverflowOverlay.d.ts +1 -0
  29. package/dist/commonjs/modal/lib/ModalOverflowOverlay.d.ts.map +1 -1
  30. package/dist/commonjs/modal/lib/ModalOverflowOverlay.js +7 -9
  31. package/dist/commonjs/modal/lib/ModalOverlay.d.ts +9 -4
  32. package/dist/commonjs/modal/lib/ModalOverlay.d.ts.map +1 -1
  33. package/dist/commonjs/modal/lib/ModalOverlay.js +19 -65
  34. package/dist/commonjs/popup/lib/Popper.js +2 -4
  35. package/dist/commonjs/popup/lib/PopupBody.d.ts +1 -0
  36. package/dist/commonjs/popup/lib/PopupBody.d.ts.map +1 -1
  37. package/dist/commonjs/popup/lib/PopupBody.js +8 -2
  38. package/dist/commonjs/popup/lib/PopupCard.d.ts +9 -0
  39. package/dist/commonjs/popup/lib/PopupCard.d.ts.map +1 -1
  40. package/dist/commonjs/popup/lib/PopupCard.js +28 -41
  41. package/dist/commonjs/popup/lib/PopupCloseIcon.d.ts +1 -0
  42. package/dist/commonjs/popup/lib/PopupCloseIcon.d.ts.map +1 -1
  43. package/dist/commonjs/popup/lib/PopupCloseIcon.js +8 -3
  44. package/dist/commonjs/popup/lib/PopupHeading.d.ts +1 -0
  45. package/dist/commonjs/popup/lib/PopupHeading.d.ts.map +1 -1
  46. package/dist/commonjs/popup/lib/PopupHeading.js +8 -2
  47. package/dist/commonjs/select/lib/hooks/useSelectInput.d.ts +1 -1
  48. package/dist/commonjs/tabs/lib/TabsItem.d.ts +1 -1
  49. package/dist/commonjs/toast/lib/Toast.d.ts.map +1 -1
  50. package/dist/commonjs/toast/lib/Toast.js +7 -2
  51. package/dist/commonjs/toast/lib/ToastBody.d.ts +1 -0
  52. package/dist/commonjs/toast/lib/ToastBody.d.ts.map +1 -1
  53. package/dist/commonjs/toast/lib/ToastBody.js +7 -2
  54. package/dist/commonjs/toast/lib/ToastCloseIcon.d.ts +1 -0
  55. package/dist/commonjs/toast/lib/ToastCloseIcon.d.ts.map +1 -1
  56. package/dist/commonjs/toast/lib/ToastCloseIcon.js +7 -2
  57. package/dist/commonjs/toast/lib/ToastIcon.d.ts +1 -0
  58. package/dist/commonjs/toast/lib/ToastIcon.d.ts.map +1 -1
  59. package/dist/commonjs/toast/lib/ToastIcon.js +7 -2
  60. package/dist/commonjs/toast/lib/ToastMessage.d.ts +1 -0
  61. package/dist/commonjs/toast/lib/ToastMessage.d.ts.map +1 -1
  62. package/dist/commonjs/toast/lib/ToastMessage.js +8 -2
  63. package/dist/es6/button/lib/BaseButton.d.ts +5 -5
  64. package/dist/es6/button/lib/BaseButton.js +1 -1
  65. package/dist/es6/button/lib/DeleteButton.js +1 -1
  66. package/dist/es6/button/lib/PrimaryButton.js +2 -2
  67. package/dist/es6/button/lib/SecondaryButton.js +2 -2
  68. package/dist/es6/button/lib/TertiaryButton.js +4 -4
  69. package/dist/es6/checkbox/lib/CheckboxCheck.js +2 -2
  70. package/dist/es6/combobox/lib/hooks/useComboboxInput.d.ts +1 -1
  71. package/dist/es6/common/lib/CanvasProvider.d.ts +6 -6
  72. package/dist/es6/common/lib/utils/getTranslateFromOrigin.d.ts +11 -0
  73. package/dist/es6/common/lib/utils/getTranslateFromOrigin.d.ts.map +1 -1
  74. package/dist/es6/common/lib/utils/getTranslateFromOrigin.js +17 -2
  75. package/dist/es6/icon/lib/SystemIcon.d.ts +2 -1
  76. package/dist/es6/icon/lib/SystemIcon.d.ts.map +1 -1
  77. package/dist/es6/icon/lib/SystemIcon.js +3 -3
  78. package/dist/es6/icon/lib/SystemIconCircle.js +1 -1
  79. package/dist/es6/menu/lib/MenuItem.d.ts +1 -1
  80. package/dist/es6/modal/lib/ModalBody.d.ts +1 -0
  81. package/dist/es6/modal/lib/ModalBody.d.ts.map +1 -1
  82. package/dist/es6/modal/lib/ModalBody.js +8 -12
  83. package/dist/es6/modal/lib/ModalCard.d.ts +1 -0
  84. package/dist/es6/modal/lib/ModalCard.d.ts.map +1 -1
  85. package/dist/es6/modal/lib/ModalCard.js +8 -14
  86. package/dist/es6/modal/lib/ModalHeading.d.ts +1 -0
  87. package/dist/es6/modal/lib/ModalHeading.d.ts.map +1 -1
  88. package/dist/es6/modal/lib/ModalHeading.js +8 -12
  89. package/dist/es6/modal/lib/ModalOverflowOverlay.d.ts +1 -0
  90. package/dist/es6/modal/lib/ModalOverflowOverlay.d.ts.map +1 -1
  91. package/dist/es6/modal/lib/ModalOverflowOverlay.js +6 -5
  92. package/dist/es6/modal/lib/ModalOverlay.d.ts +9 -4
  93. package/dist/es6/modal/lib/ModalOverlay.d.ts.map +1 -1
  94. package/dist/es6/modal/lib/ModalOverlay.js +20 -66
  95. package/dist/es6/popup/lib/Popper.js +2 -4
  96. package/dist/es6/popup/lib/PopupBody.d.ts +1 -0
  97. package/dist/es6/popup/lib/PopupBody.d.ts.map +1 -1
  98. package/dist/es6/popup/lib/PopupBody.js +7 -1
  99. package/dist/es6/popup/lib/PopupCard.d.ts +9 -0
  100. package/dist/es6/popup/lib/PopupCard.d.ts.map +1 -1
  101. package/dist/es6/popup/lib/PopupCard.js +30 -43
  102. package/dist/es6/popup/lib/PopupCloseIcon.d.ts +1 -0
  103. package/dist/es6/popup/lib/PopupCloseIcon.d.ts.map +1 -1
  104. package/dist/es6/popup/lib/PopupCloseIcon.js +7 -2
  105. package/dist/es6/popup/lib/PopupHeading.d.ts +1 -0
  106. package/dist/es6/popup/lib/PopupHeading.d.ts.map +1 -1
  107. package/dist/es6/popup/lib/PopupHeading.js +7 -1
  108. package/dist/es6/select/lib/hooks/useSelectInput.d.ts +1 -1
  109. package/dist/es6/tabs/lib/TabsItem.d.ts +1 -1
  110. package/dist/es6/toast/lib/Toast.d.ts.map +1 -1
  111. package/dist/es6/toast/lib/Toast.js +7 -2
  112. package/dist/es6/toast/lib/ToastBody.d.ts +1 -0
  113. package/dist/es6/toast/lib/ToastBody.d.ts.map +1 -1
  114. package/dist/es6/toast/lib/ToastBody.js +7 -2
  115. package/dist/es6/toast/lib/ToastCloseIcon.d.ts +1 -0
  116. package/dist/es6/toast/lib/ToastCloseIcon.d.ts.map +1 -1
  117. package/dist/es6/toast/lib/ToastCloseIcon.js +6 -1
  118. package/dist/es6/toast/lib/ToastIcon.d.ts +1 -0
  119. package/dist/es6/toast/lib/ToastIcon.d.ts.map +1 -1
  120. package/dist/es6/toast/lib/ToastIcon.js +6 -1
  121. package/dist/es6/toast/lib/ToastMessage.d.ts +1 -0
  122. package/dist/es6/toast/lib/ToastMessage.d.ts.map +1 -1
  123. package/dist/es6/toast/lib/ToastMessage.js +7 -1
  124. package/icon/lib/SystemIcon.tsx +2 -1
  125. package/modal/lib/ModalBody.tsx +11 -16
  126. package/modal/lib/ModalCard.tsx +16 -18
  127. package/modal/lib/ModalHeading.tsx +11 -16
  128. package/modal/lib/ModalOverflowOverlay.tsx +9 -5
  129. package/modal/lib/ModalOverlay.tsx +57 -65
  130. package/package.json +4 -4
  131. package/popup/lib/Popper.tsx +2 -4
  132. package/popup/lib/PopupBody.tsx +11 -1
  133. package/popup/lib/PopupCard.tsx +64 -63
  134. package/popup/lib/PopupCloseIcon.tsx +12 -5
  135. package/popup/lib/PopupHeading.tsx +11 -1
  136. package/toast/lib/Toast.tsx +14 -7
  137. package/toast/lib/ToastBody.tsx +16 -12
  138. package/toast/lib/ToastCloseIcon.tsx +14 -1
  139. package/toast/lib/ToastIcon.tsx +10 -11
  140. package/toast/lib/ToastMessage.tsx +12 -3
@@ -2,8 +2,14 @@ import React from 'react';
2
2
  import { createSubcomponent } from '@workday/canvas-kit-react/common';
3
3
  import { useToastModel } from './hooks/useToastModel';
4
4
  import { Subtext } from '@workday/canvas-kit-react/text';
5
+ import { createStencil } from '@workday/canvas-kit-styling';
6
+ import { mergeStyles } from '@workday/canvas-kit-react/layout';
7
+ import { system } from '@workday/canvas-tokens-web';
8
+ export const toastMessageStencil = createStencil({
9
+ base: { name: "d80f47", styles: "box-sizing:border-box;word-break:break-word;margin-block-start:var(--cnvs-sys-space-zero);margin-block-end:var(--cnvs-sys-space-zero);" }
10
+ }, "toast-message-759382");
5
11
  export const ToastMessage = createSubcomponent('p')({
6
12
  modelHook: useToastModel,
7
13
  })(({ children, ...elemProps }, Element, model) => {
8
- return (React.createElement(Subtext, Object.assign({ size: "large", wordBreak: "break-word", marginY: "zero", id: model.state.id, as: Element }, elemProps), children));
14
+ return (React.createElement(Subtext, Object.assign({ size: "large", id: model.state.id, as: Element }, mergeStyles(elemProps, toastMessageStencil())), children));
9
15
  });
@@ -49,7 +49,8 @@ export interface SystemIconStyles {
49
49
  /**
50
50
  * The hover color of the SystemIcon. This defines `accentHover` and `fillHover`. `colorHover` may be overwritten by `accentHover` and `fillHover`.
51
51
  * @default base.licorice200
52
- * @deprecated `colorHover` is deprecated and will be removed in a future version. Please use the following instead in your style overrides:
52
+ * @deprecated `colorHover` is deprecated and will be removed in a future version. We have removed the default hover styles on SystemIcon. Please
53
+ * use the following instead in your style overrides:
53
54
  * ```tsx
54
55
  * '&:hover': {
55
56
  * [systemIconStencil.vars.color]: desiredColorHoverColor
@@ -1,32 +1,27 @@
1
1
  import * as React from 'react';
2
2
 
3
- import {
4
- createSubcomponent,
5
- ExtractProps,
6
- getTheme,
7
- styled,
8
- StyledType,
9
- } from '@workday/canvas-kit-react/common';
3
+ import {createSubcomponent, ExtractProps} from '@workday/canvas-kit-react/common';
10
4
  import {Popup} from '@workday/canvas-kit-react/popup';
11
- import {space} from '@workday/canvas-kit-react/tokens';
12
5
 
13
6
  import {useModalModel} from './hooks';
7
+ import {createStencil} from '@workday/canvas-kit-styling';
8
+ import {system} from '@workday/canvas-tokens-web';
9
+ import {mergeStyles} from '@workday/canvas-kit-react/layout';
14
10
 
15
11
  export interface ModalBodyProps extends ExtractProps<typeof Popup.Body, never> {}
16
12
 
17
- const ResponsiveModalBody = styled(Popup.Body)<ModalBodyProps & StyledType>(({theme}) => {
18
- const {canvas: canvasTheme} = getTheme(theme);
19
- return {
20
- [canvasTheme.breakpoints.down('s')]: {
21
- marginBottom: space.zero,
22
- padding: `${space.xxxs} ${space.xxs} ${space.xxs} ${space.xxs}`,
13
+ export const modalBodyStencil = createStencil({
14
+ base: {
15
+ '@media screen and (max-width: 768px)': {
16
+ marginBlockEnd: system.space.zero,
17
+ padding: `${system.space.x1} ${system.space.x2} ${system.space.x2}`,
23
18
  },
24
- };
19
+ },
25
20
  });
26
21
 
27
22
  export const ModalBody = createSubcomponent('div')({
28
23
  displayName: 'Modal.Body',
29
24
  modelHook: useModalModel,
30
25
  })<ModalBodyProps>((elemProps, Element) => {
31
- return <ResponsiveModalBody as={Element} {...elemProps} />;
26
+ return <Popup.Body as={Element} {...mergeStyles(elemProps, modalBodyStencil())} />;
32
27
  });
@@ -1,29 +1,27 @@
1
1
  import * as React from 'react';
2
2
 
3
- import {
4
- createSubcomponent,
5
- ExtractProps,
6
- StyledType,
7
- styled,
8
- getTheme,
9
- } from '@workday/canvas-kit-react/common';
10
- import {space} from '@workday/canvas-kit-react/tokens';
3
+ import {createSubcomponent, ExtractProps} from '@workday/canvas-kit-react/common';
11
4
  import {Popup} from '@workday/canvas-kit-react/popup';
12
5
 
13
6
  import {useModalCard, useModalModel} from './hooks';
7
+ import {calc, createStencil} from '@workday/canvas-kit-styling';
8
+ import {system} from '@workday/canvas-tokens-web';
9
+ import {mergeStyles} from '@workday/canvas-kit-react/layout';
14
10
 
15
11
  export interface ModalCardProps extends ExtractProps<typeof Popup.Card, never> {}
16
12
 
17
- const ResponsiveModalCard = styled(Popup.Card)<ModalCardProps & StyledType>(({theme}) => {
18
- const {canvas: canvasTheme} = getTheme(theme);
19
- return {
20
- margin: space.xl,
21
- [canvasTheme.breakpoints.down('s')]: {
22
- margin: space.s, // 16px all around margin on smaller screen sizes
23
- padding: space.s, // brings total padding between edge and content to 24px
24
- borderRadius: space.m, // 24px border radius on smaller devices.
13
+ export const modalCardStencil = createStencil({
14
+ base: {
15
+ margin: system.space.x10,
16
+ width: calc.add(calc.multiply(system.space.x20, 5), system.space.x10),
17
+ borderWidth: system.space.zero,
18
+ boxShadow: system.depth[6],
19
+ '@media screen and (max-width: 768px)': {
20
+ margin: system.space.x4, // 16px all around margin on smaller screen sizes
21
+ padding: system.space.x4, // brings total padding between edge and content to 24px
22
+ borderRadius: system.space.x6, // 24px border radius on smaller devices.
25
23
  },
26
- };
24
+ },
27
25
  });
28
26
 
29
27
  export const ModalCard = createSubcomponent('div')({
@@ -31,5 +29,5 @@ export const ModalCard = createSubcomponent('div')({
31
29
  modelHook: useModalModel,
32
30
  elemPropsHook: useModalCard,
33
31
  })<ModalCardProps>((elemProps, Element) => {
34
- return <ResponsiveModalCard as={Element} width={440} borderWidth={0} depth={6} {...elemProps} />;
32
+ return <Popup.Card as={Element} {...mergeStyles(elemProps, modalCardStencil())} />;
35
33
  });
@@ -1,27 +1,22 @@
1
1
  import * as React from 'react';
2
2
 
3
- import {
4
- createSubcomponent,
5
- ExtractProps,
6
- getTheme,
7
- styled,
8
- StyledType,
9
- } from '@workday/canvas-kit-react/common';
3
+ import {createSubcomponent, ExtractProps} from '@workday/canvas-kit-react/common';
10
4
  import {Popup} from '@workday/canvas-kit-react/popup';
11
- import {space} from '@workday/canvas-kit-react/tokens';
12
5
 
13
6
  import {useModalHeading, useModalModel} from './hooks';
7
+ import {createStencil} from '@workday/canvas-kit-styling';
8
+ import {system} from '@workday/canvas-tokens-web';
9
+ import {mergeStyles} from '@workday/canvas-kit-react/layout';
14
10
 
15
11
  export interface ModalHeadingProps extends ExtractProps<typeof Popup.Heading, never> {}
16
12
 
17
- const ResponsiveModalHeading = styled(Popup.Heading)<ModalHeadingProps & StyledType>(({theme}) => {
18
- const {canvas: canvasTheme} = getTheme(theme);
19
- return {
20
- [canvasTheme.breakpoints.down('s')]: {
21
- marginBottom: space.zero,
22
- padding: `${space.xxs} ${space.xxs} ${space.xxxs} ${space.xxs}`,
13
+ export const modalHeadingStencil = createStencil({
14
+ base: {
15
+ '@media screen and (max-width: 768px)': {
16
+ marginBlockEnd: system.space.zero,
17
+ padding: `${system.space.x2} ${system.space.x2} ${system.space.x1}`,
23
18
  },
24
- };
19
+ },
25
20
  });
26
21
 
27
22
  export const ModalHeading = createSubcomponent('h2')({
@@ -29,5 +24,5 @@ export const ModalHeading = createSubcomponent('h2')({
29
24
  modelHook: useModalModel,
30
25
  elemPropsHook: useModalHeading,
31
26
  })<ModalHeadingProps>((elemProps, Element) => {
32
- return <ResponsiveModalHeading as={Element} {...elemProps} />;
27
+ return <Popup.Heading as={Element} {...mergeStyles(elemProps, modalHeadingStencil())} />;
33
28
  });
@@ -1,18 +1,22 @@
1
1
  import * as React from 'react';
2
2
 
3
- import {createSubcomponent, ExtractProps, StyledType} from '@workday/canvas-kit-react/common';
3
+ import {createSubcomponent, ExtractProps} from '@workday/canvas-kit-react/common';
4
4
 
5
5
  import {ModalOverlay} from './ModalOverlay';
6
- import styled from '@emotion/styled';
7
6
  import {useModalModel} from './hooks';
7
+ import {createStencil} from '@workday/canvas-kit-styling';
8
+ import {mergeStyles} from '@workday/canvas-kit-react/layout';
8
9
 
9
- const StyledOverlay = styled(ModalOverlay)<StyledType>({
10
- '& > div': {maxHeight: 'inherit'}, // reset maxHeight of centering div
10
+ export const modalOverflowOverlayStencil = createStencil({
11
+ base: {
12
+ '& > div': {maxHeight: 'inherit'}, // reset maxHeight of centering div
13
+ overflow: 'hidden auto',
14
+ },
11
15
  });
12
16
 
13
17
  export const ModalOverflowOverlay = createSubcomponent('div')({
14
18
  displayName: 'Modal.OverflowOverlay',
15
19
  modelHook: useModalModel,
16
20
  })<ExtractProps<typeof ModalOverlay, never>>((elemProps, Element) => {
17
- return <StyledOverlay as={Element} overflowX="hidden" overflowY="auto" {...elemProps} />;
21
+ return <ModalOverlay as={Element} {...mergeStyles(elemProps, modalOverflowOverlayStencil())} />;
18
22
  });
@@ -4,81 +4,62 @@ import ReactDOM from 'react-dom';
4
4
  import {
5
5
  createSubcomponent,
6
6
  createElemPropsHook,
7
- StyledType,
8
7
  useWindowSize,
9
8
  useForkRef,
10
- getTheme,
11
9
  } from '@workday/canvas-kit-react/common';
12
10
  import {usePopupModel, usePopupStack} from '@workday/canvas-kit-react/popup';
13
- import {keyframes} from '@emotion/react';
14
- import styled from '@emotion/styled';
15
- import {Box, BoxProps} from '@workday/canvas-kit-react/layout';
11
+ import {Box, BoxProps, mergeStyles} from '@workday/canvas-kit-react/layout';
16
12
  import {useModalModel} from './hooks';
13
+ import {createStencil, cssVar, keyframes} from '@workday/canvas-kit-styling';
14
+ import {system} from '@workday/canvas-tokens-web';
17
15
 
18
16
  export interface ModalOverlayProps extends BoxProps {}
19
17
 
20
- const fadeIn = keyframes`
21
- from {
22
- background: none;
23
- }
24
- to {
25
- background: rgba(0,0,0,0.65);
26
- }
27
- `;
18
+ const fadeIn = keyframes({
19
+ '0%': {
20
+ background: 'none',
21
+ },
22
+ '100%': {
23
+ background: cssVar(system.color.bg.overlay),
24
+ },
25
+ });
28
26
 
29
- const Container = styled(Box)<StyledType>(
30
- {
27
+ export const modalOverlayContainerStencil = createStencil({
28
+ vars: {
29
+ containerCenter: '',
30
+ },
31
+ base: ({containerCenter}) => ({
31
32
  position: 'fixed',
32
- top: 0,
33
- left: 0,
33
+ top: system.space.zero,
34
+ left: system.space.zero,
34
35
  width: '100vw',
35
36
  height: '100vh',
36
- background: 'rgba(0,0,0,0.65)',
37
- animationName: `${fadeIn}`,
37
+ background: system.color.bg.overlay,
38
38
  animationDuration: '0.3s',
39
+ animationName: fadeIn,
39
40
  // Allow overriding of animation in special cases
40
41
  '.wd-no-animation &': {
41
42
  animation: 'none',
42
43
  },
43
- },
44
- ({theme}) => {
45
- const {canvas: canvasTheme} = getTheme(theme);
46
- return {
47
- [canvasTheme.breakpoints.down('s')]: {
48
- height: '100%',
44
+ // Responsive Container
45
+ '& > div': {
46
+ maxHeight: '100%',
47
+ display: 'flex',
48
+ position: 'absolute',
49
+ left: system.space.zero,
50
+ top: system.space.zero,
51
+ justifyContent: 'center',
52
+ alignItems: 'center',
53
+ height: '100%',
54
+ width: containerCenter,
55
+ },
56
+ '@media screen and (max-width: 768px)': {
57
+ height: '100%',
58
+ '& > div': {
59
+ alignItems: 'end',
49
60
  },
50
- };
51
- }
52
- );
53
-
54
- // This centering container helps fix an issue with Chrome. Chrome doesn't normally do subpixel
55
- // positioning, but seems to when using flexbox centering. This messes up Popper calculations inside
56
- // the Modal. The centering container forces a "center" pixel calculation by making sure the width
57
- // is always an even number
58
- const ResponsiveContainer = styled('div')(({theme}) => {
59
- const {canvas: canvasTheme} = getTheme(theme);
60
- return {
61
- maxHeight: '100%',
62
- display: 'flex',
63
- position: 'absolute',
64
- left: 0,
65
- top: 0,
66
- justifyContent: 'center',
67
- alignItems: 'center',
68
- height: '100%',
69
- [canvasTheme.breakpoints.down('s')]: {
70
- alignItems: 'end',
71
61
  },
72
- };
73
- });
74
-
75
- export const ModalOverlay = createSubcomponent('div')({
76
- displayName: 'Modal.Overlay',
77
- modelHook: useModalModel,
78
- })<ModalOverlayProps>((elemProps, Element, model) => {
79
- return model.state.visibility !== 'hidden' ? (
80
- <OpenModalOverlay as={Element} model={model} {...elemProps} />
81
- ) : null;
62
+ }),
82
63
  });
83
64
 
84
65
  export const useModalOverlay = createElemPropsHook(usePopupModel)(({state}, ref) => {
@@ -97,18 +78,20 @@ const OpenModalOverlay = createSubcomponent('div')({
97
78
  elemPropsHook: useModalOverlay,
98
79
  })<ModalOverlayProps>((elemProps, Element, model) => {
99
80
  const windowSize = useWindowSize();
81
+ const containerCenter = windowSize.width % 2 === 1 ? 'calc(100vw - 1px)' : '100vw';
100
82
  const content = (
101
- <Container as={Element} {...elemProps}>
102
- <ResponsiveContainer
103
- // make sure the centering container is an even number of pixels to avoid sub-pixel
104
- // inaccuracies due to centering
105
- style={{
106
- width: windowSize.width % 2 === 1 ? 'calc(100vw - 1px)' : '100vw',
107
- }}
83
+ <Box {...mergeStyles(elemProps, modalOverlayContainerStencil({containerCenter}))}>
84
+ {/* This centering container helps fix an issue with Chrome. Chrome doesn't normally do
85
+ subpixel positioning, but seems to when using flexbox centering. This messes up Popper
86
+ calculations inside the Modal. The centering container forces a "center" pixel calculation
87
+ by making sure the width is always an even number */}
88
+ <Box
89
+ // make sure the centering container is an even number of pixels to avoid sub-pixel
90
+ // inaccuracies due to centering
108
91
  >
109
92
  {elemProps.children}
110
- </ResponsiveContainer>
111
- </Container>
93
+ </Box>
94
+ </Box>
112
95
  );
113
96
 
114
97
  // only render something on the client
@@ -118,3 +101,12 @@ const OpenModalOverlay = createSubcomponent('div')({
118
101
  return null;
119
102
  }
120
103
  });
104
+
105
+ export const ModalOverlay = createSubcomponent('div')({
106
+ displayName: 'Modal.Overlay',
107
+ modelHook: useModalModel,
108
+ })<ModalOverlayProps>((elemProps, Element, model) => {
109
+ return model.state.visibility !== 'hidden' ? (
110
+ <OpenModalOverlay as={Element} model={model} {...elemProps} />
111
+ ) : null;
112
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-react",
3
- "version": "12.0.0-alpha.841-next.0",
3
+ "version": "12.0.0-alpha.846-next.0",
4
4
  "description": "The parent module that contains all Workday Canvas Kit React components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -49,8 +49,8 @@
49
49
  "@emotion/styled": "^11.6.0",
50
50
  "@popperjs/core": "^2.5.4",
51
51
  "@workday/canvas-colors-web": "^2.0.0",
52
- "@workday/canvas-kit-popup-stack": "^12.0.0-alpha.841-next.0",
53
- "@workday/canvas-kit-styling": "^12.0.0-alpha.841-next.0",
52
+ "@workday/canvas-kit-popup-stack": "^12.0.0-alpha.846-next.0",
53
+ "@workday/canvas-kit-styling": "^12.0.0-alpha.846-next.0",
54
54
  "@workday/canvas-system-icons-web": "^3.0.0",
55
55
  "@workday/canvas-tokens-web": "^2.0.0",
56
56
  "@workday/design-assets-types": "^0.2.8",
@@ -67,5 +67,5 @@
67
67
  "@workday/canvas-accent-icons-web": "^3.0.0",
68
68
  "@workday/canvas-applet-icons-web": "^2.0.0"
69
69
  },
70
- "gitHead": "066c4b170850949586bf9f89370f5302a6c8f9a4"
70
+ "gitHead": "92573a5cb42a250072618c814c0bc78edaf0480a"
71
71
  }
@@ -154,10 +154,8 @@ const OpenPopper = React.forwardRef<HTMLDivElement, PopperProps>(
154
154
  enabled: true,
155
155
  phase: 'afterWrite',
156
156
  fn({state}) {
157
- if (placementRef.current !== state.placement) {
158
- setPlacement(state.placement);
159
- onPlacementChange?.(state.placement);
160
- }
157
+ setPlacement(state.placement);
158
+ onPlacementChange?.(state.placement);
161
159
  },
162
160
  };
163
161
  }, [setPlacement, onPlacementChange]);
@@ -3,10 +3,20 @@ import * as React from 'react';
3
3
  import {createSubcomponent, ExtractProps} from '@workday/canvas-kit-react/common';
4
4
  import {Card} from '@workday/canvas-kit-react/card';
5
5
  import {usePopupModel} from './hooks';
6
+ import {createStencil} from '@workday/canvas-kit-styling';
7
+ import {mergeStyles} from '../../layout';
8
+ import {system} from '@workday/canvas-tokens-web';
9
+
10
+ export const popupBodyStencil = createStencil({
11
+ base: {
12
+ overflowY: 'auto',
13
+ padding: system.space.x2,
14
+ },
15
+ });
6
16
 
7
17
  export const PopupBody = createSubcomponent('div')({
8
18
  displayName: 'Popup.Body',
9
19
  modelHook: usePopupModel,
10
20
  })<ExtractProps<typeof Card.Body>>(elemProps => {
11
- return <Card.Body overflowY="auto" padding="xxs" {...elemProps} />;
21
+ return <Card.Body {...mergeStyles(elemProps, popupBodyStencil())} />;
12
22
  });
@@ -1,65 +1,38 @@
1
1
  import * as React from 'react';
2
- import {keyframes} from '@emotion/react';
3
2
 
4
3
  import {Card} from '@workday/canvas-kit-react/card';
5
- import {space, type} from '@workday/canvas-kit-react/tokens';
4
+ import {space} from '@workday/canvas-kit-react/tokens';
6
5
  import {
7
- styled,
8
- TransformOrigin,
9
- getTranslateFromOrigin,
10
- StyledType,
11
6
  ExtractProps,
12
- useConstant,
13
7
  createSubcomponent,
8
+ getTransformOrigin,
14
9
  } from '@workday/canvas-kit-react/common';
15
- import {Flex, FlexStyleProps} from '@workday/canvas-kit-react/layout';
10
+ import {FlexStyleProps, mergeStyles} from '@workday/canvas-kit-react/layout';
16
11
 
17
12
  import {getTransformFromPlacement} from './getTransformFromPlacement';
18
13
  import {usePopupCard, usePopupModel} from './hooks';
14
+ import {createStencil, createVars, cssVar, keyframes} from '@workday/canvas-kit-styling';
15
+ import {system} from '@workday/canvas-tokens-web';
19
16
 
20
17
  export type FlexAndBoxProps = ExtractProps<typeof Card, never> & FlexStyleProps;
21
18
  export interface PopupCardProps extends FlexAndBoxProps {
22
19
  children?: React.ReactNode;
23
20
  }
24
21
 
25
- const popupAnimation = (transformOrigin: TransformOrigin) => {
26
- const translate = getTranslateFromOrigin(transformOrigin, space.xxs);
22
+ const translateVars = createVars('positionX', 'positionY');
27
23
 
28
- return keyframes`
29
- 0% {
30
- opacity: 0;
31
- transform: translate(${translate.x}px, ${translate.y}px);
32
- }
33
- 100% {
34
- opacity: 1;
35
- transform: translate(0);
36
- }
37
- `;
38
- };
39
-
40
- const StyledPopupCard = styled(Card)<
41
- StyledType & {width?: number | string; transformOrigin?: TransformOrigin}
42
- >(({transformOrigin, theme}) => {
43
- if (transformOrigin == null) {
44
- return {};
45
- }
46
-
47
- return {
48
- animation: popupAnimation(transformOrigin),
49
- animationDuration: '150ms',
50
- animationTimingFunction: 'ease-out',
51
- transformOrigin: `${transformOrigin.vertical} ${transformOrigin.horizontal}`,
52
- [theme.canvas.breakpoints.down('s')]: {
53
- animation: popupAnimation({vertical: 'bottom', horizontal: 'center'}),
54
- animationDuration: '150ms',
55
- animationTimingFunction: 'ease-out',
56
- transformOrigin: 'bottom center',
57
- },
58
- // Allow overriding of animation in special cases
59
- '.wd-no-animation &': {
60
- animation: 'none',
61
- },
62
- };
24
+ /**
25
+ * Keyframe for the dots loading animation.
26
+ */
27
+ const fadeIn = keyframes({
28
+ '0%': {
29
+ opacity: 1,
30
+ transform: `translate(${cssVar(translateVars.positionX)}, ${cssVar(translateVars.positionY)})`,
31
+ },
32
+ '100%': {
33
+ opacity: 1,
34
+ transform: `translate(0)`,
35
+ },
63
36
  });
64
37
 
65
38
  function getSpace(value?: string | number) {
@@ -72,7 +45,7 @@ function getSpace(value?: string | number) {
72
45
 
73
46
  function getMaxHeight(margin?: string | number) {
74
47
  // set the default margin offset to space.xl
75
- let marginOffset: string | number = space.xl;
48
+ let marginOffset: string | number = cssVar(system.space.x10);
76
49
 
77
50
  if (margin) {
78
51
  // parse the margin prop
@@ -91,33 +64,61 @@ function getMaxHeight(margin?: string | number) {
91
64
  return `calc(100vh - ${marginOffset})`;
92
65
  }
93
66
 
67
+ export const popupCardStencil = createStencil({
68
+ vars: {
69
+ maxHeight: '',
70
+ transformOriginHorizontal: '',
71
+ transformOriginVertical: '',
72
+ },
73
+ base: ({maxHeight, transformOriginHorizontal, transformOriginVertical}) => ({
74
+ ...system.type.subtext.large,
75
+ display: 'flex',
76
+ position: 'relative',
77
+ maxWidth: `calc(100vw - ${system.space.x8})`,
78
+ flexDirection: 'column',
79
+ boxShadow: system.depth[5],
80
+ minHeight: system.space.zero,
81
+ padding: system.space.x6,
82
+ maxHeight: maxHeight,
83
+ overflowY: 'auto',
84
+ animationName: fadeIn,
85
+ animationDuration: '150ms',
86
+ animationTimingFunction: 'ease-out',
87
+ transformOrigin: `${transformOriginVertical} ${transformOriginHorizontal}`,
88
+ // Allow overriding of animation in special cases
89
+ '.wd-no-animation &': {
90
+ animation: 'none',
91
+ },
92
+ '@media screen and (max-width: 768px)': {
93
+ transformOrigin: 'bottom center',
94
+ },
95
+ }),
96
+ });
97
+
94
98
  export const PopupCard = createSubcomponent('div')({
95
99
  displayName: 'Popup.Card',
96
100
  modelHook: usePopupModel,
97
101
  elemPropsHook: usePopupCard,
98
- })<PopupCardProps>(({children, ...elemProps}, Element, model) => {
102
+ })<PopupCardProps>(({children, ref, ...elemProps}, Element, model) => {
99
103
  const transformOrigin = React.useMemo(() => {
100
104
  return getTransformFromPlacement(model.state.placement || 'bottom');
101
105
  }, [model.state.placement]);
106
+ const translate = getTransformOrigin(transformOrigin, cssVar(system.space.x2));
107
+ const cardMaxHeight = getMaxHeight(elemProps.margin);
102
108
 
103
- // As is a Flex that will render an element of `Element`
104
- const As = useConstant(() => Flex.as(Element));
105
109
  return (
106
- <StyledPopupCard
107
- as={As}
108
- transformOrigin={transformOrigin}
109
- position="relative"
110
- depth={5}
111
- maxWidth={`calc(100vw - ${space.l})`}
112
- flexDirection="column"
113
- minHeight={0}
114
- padding="m"
115
- maxHeight={getMaxHeight(elemProps.margin)}
116
- overflowY="auto"
117
- {...type.levels.subtext.large}
118
- {...elemProps}
110
+ <Card
111
+ ref={ref}
112
+ {...mergeStyles(elemProps, [
113
+ popupCardStencil({
114
+ transformOriginHorizontal: transformOrigin.horizontal,
115
+ transformOriginVertical: transformOrigin.vertical,
116
+ maxHeight: cardMaxHeight,
117
+ }),
118
+ translateVars({positionX: translate.x, positionY: translate.y}),
119
+ ])}
119
120
  >
120
121
  {children}
121
- </StyledPopupCard>
122
+ </Card>
122
123
  );
123
124
  });
@@ -3,12 +3,22 @@ import React from 'react';
3
3
  import {xIcon} from '@workday/canvas-system-icons-web';
4
4
  import {createSubcomponent, ExtractProps} from '@workday/canvas-kit-react/common';
5
5
  import {TertiaryButton} from '@workday/canvas-kit-react/button';
6
- import {space} from '@workday/canvas-kit-react/tokens';
7
6
 
8
7
  import {usePopupCloseButton, usePopupModel} from './hooks';
8
+ import {createStencil} from '@workday/canvas-kit-styling';
9
+ import {system} from '@workday/canvas-tokens-web';
10
+ import {mergeStyles} from '../../layout';
9
11
 
10
12
  export interface PopupCloseIconProps extends ExtractProps<typeof TertiaryButton, never> {}
11
13
 
14
+ export const popupCloseIconStencil = createStencil({
15
+ base: {
16
+ position: 'absolute',
17
+ insetInlineEnd: system.space.x1,
18
+ top: system.space.x1,
19
+ },
20
+ });
21
+
12
22
  export const PopupCloseIcon = createSubcomponent('button')({
13
23
  displayName: 'Popup.CloseIcon',
14
24
  modelHook: usePopupModel,
@@ -20,10 +30,7 @@ export const PopupCloseIcon = createSubcomponent('button')({
20
30
  size="medium"
21
31
  icon={xIcon}
22
32
  type="button"
23
- position="absolute"
24
- insetInlineEnd={space.xxxs}
25
- top={space.xxxs}
26
- {...elemProps}
33
+ {...mergeStyles(elemProps, popupCloseIconStencil())}
27
34
  />
28
35
  );
29
36
  });
@@ -4,18 +4,28 @@ import {createSubcomponent, ExtractProps} from '@workday/canvas-kit-react/common
4
4
  import {Card} from '@workday/canvas-kit-react/card';
5
5
 
6
6
  import {usePopupHeading, usePopupModel} from './hooks';
7
+ import {createStencil} from '@workday/canvas-kit-styling';
8
+ import {system} from '@workday/canvas-tokens-web';
9
+ import {mergeStyles} from '../../layout';
7
10
 
8
11
  export interface PopupHeadingProps extends ExtractProps<typeof Card.Heading, never> {
9
12
  children?: React.ReactNode;
10
13
  }
11
14
 
15
+ export const popupHeadingStencil = createStencil({
16
+ base: {
17
+ marginBlockEnd: system.space.x2,
18
+ padding: system.space.x2,
19
+ },
20
+ });
21
+
12
22
  export const PopupHeading = createSubcomponent('h2')({
13
23
  displayName: 'Popup.Heading',
14
24
  modelHook: usePopupModel,
15
25
  elemPropsHook: usePopupHeading,
16
26
  })<PopupHeadingProps>(({children, ...elemProps}, Element) => {
17
27
  return (
18
- <Card.Heading as={Element} marginBottom="xxs" padding="xxs" {...elemProps}>
28
+ <Card.Heading as={Element} {...mergeStyles(elemProps, popupHeadingStencil())}>
19
29
  {children}
20
30
  </Card.Heading>
21
31
  );