@onewelcome/react-lib-components 1.4.0 → 1.6.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 (101) hide show
  1. package/README.md +7 -0
  2. package/dist/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  3. package/dist/Button/Button.d.ts +0 -1
  4. package/dist/ContextMenu/ContextMenu.d.ts +4 -1
  5. package/dist/DataGrid/DataGridActions/DataGridColumnsToggle.d.ts +1 -1
  6. package/dist/DataGrid/datagrid.interfaces.d.ts +5 -4
  7. package/dist/Form/Checkbox/Checkbox.d.ts +1 -1
  8. package/dist/Form/FormControl/FormControl.d.ts +1 -1
  9. package/dist/Form/FormHelperText/FormHelperText.d.ts +1 -1
  10. package/dist/Form/FormSelectorWrapper/FormSelectorWrapper.d.ts +1 -1
  11. package/dist/Form/Input/Input.d.ts +2 -2
  12. package/dist/Form/Radio/Radio.d.ts +1 -1
  13. package/dist/Form/Select/Select.d.ts +2 -2
  14. package/dist/Form/Select/Select.interfaces.d.ts +1 -1
  15. package/dist/Form/Textarea/Textarea.d.ts +1 -6
  16. package/dist/Form/Toggle/Toggle.d.ts +1 -1
  17. package/dist/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.d.ts +1 -1
  18. package/dist/Form/Wrapper/InputWrapper/InputWrapper.d.ts +1 -1
  19. package/dist/Form/Wrapper/RadioWrapper/RadioWrapper.d.ts +1 -1
  20. package/dist/Form/Wrapper/SelectWrapper/SelectWrapper.d.ts +1 -1
  21. package/dist/Form/Wrapper/TextareaWrapper/TextareaWrapper.d.ts +1 -1
  22. package/dist/Form/form.interfaces.d.ts +1 -0
  23. package/dist/Icon/Icon.d.ts +1 -1
  24. package/dist/Link/Link.d.ts +2 -3
  25. package/dist/Notifications/Banner/Banner.d.ts +11 -0
  26. package/dist/Notifications/Snackbar/interfaces.d.ts +2 -2
  27. package/dist/Pagination/Pagination.d.ts +3 -3
  28. package/dist/Popover/Popover.d.ts +3 -1
  29. package/dist/Tabs/TabButton.d.ts +0 -1
  30. package/dist/Typography/Typography.d.ts +2 -2
  31. package/dist/Wizard/Wizard.d.ts +1 -1
  32. package/dist/Wizard/wizardStateReducer.d.ts +2 -2
  33. package/dist/_BaseStyling_/BaseStyling.d.ts +4 -0
  34. package/dist/hooks/useDetermineStatusIcon.d.ts +3 -0
  35. package/dist/hooks/usePosition.d.ts +6 -5
  36. package/dist/hooks/useSpacing.d.ts +3 -3
  37. package/dist/index.d.ts +1 -0
  38. package/dist/interfaces.d.ts +1 -1
  39. package/dist/react-lib-components.cjs.development.js +483 -363
  40. package/dist/react-lib-components.cjs.development.js.map +1 -1
  41. package/dist/react-lib-components.cjs.production.min.js +1 -1
  42. package/dist/react-lib-components.cjs.production.min.js.map +1 -1
  43. package/dist/react-lib-components.esm.js +484 -365
  44. package/dist/react-lib-components.esm.js.map +1 -1
  45. package/dist/util/helper.d.ts +1 -1
  46. package/package.json +39 -38
  47. package/src/Button/BaseButton.module.scss +2 -2
  48. package/src/Button/Button.module.scss +4 -5
  49. package/src/Button/Button.tsx +0 -1
  50. package/src/Button/IconButton.module.scss +4 -5
  51. package/src/ContextMenu/ContextMenu.tsx +18 -7
  52. package/src/DataGrid/DataGrid.tsx +3 -2
  53. package/src/DataGrid/DataGridActions/DataGridActions.tsx +16 -9
  54. package/src/DataGrid/DataGridBody/DataGridCell.module.scss +2 -2
  55. package/src/DataGrid/DataGridHeader/DataGridHeader.test.tsx +8 -3
  56. package/src/DataGrid/DataGridHeader/DataGridHeader.tsx +3 -1
  57. package/src/DataGrid/datagrid.interfaces.ts +1 -0
  58. package/src/Form/Input/Input.module.scss +36 -25
  59. package/src/Form/Input/Input.test.tsx +22 -0
  60. package/src/Form/Input/Input.tsx +8 -5
  61. package/src/Form/Select/Select.module.scss +9 -6
  62. package/src/Form/Select/Select.test.tsx +11 -0
  63. package/src/Form/Select/Select.tsx +5 -9
  64. package/src/Form/Select/SelectService.ts +2 -2
  65. package/src/Form/Textarea/Textarea.module.scss +21 -13
  66. package/src/Form/Textarea/Textarea.test.tsx +8 -0
  67. package/src/Form/Textarea/Textarea.tsx +6 -12
  68. package/src/Form/Toggle/Toggle.module.scss +3 -3
  69. package/src/Form/Wrapper/InputWrapper/InputWrapper.module.scss +7 -3
  70. package/src/Form/Wrapper/InputWrapper/InputWrapper.tsx +2 -0
  71. package/src/Form/Wrapper/SelectWrapper/SelectWrapper.tsx +12 -1
  72. package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss +15 -14
  73. package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.tsx +2 -1
  74. package/src/Form/Wrapper/Wrapper/Wrapper.module.scss +2 -2
  75. package/src/Form/form.interfaces.ts +1 -0
  76. package/src/Link/Link.module.scss +5 -5
  77. package/src/Link/Link.tsx +14 -13
  78. package/src/Notifications/Banner/Banner.module.scss +76 -0
  79. package/src/Notifications/Banner/Banner.test.tsx +84 -0
  80. package/src/Notifications/Banner/Banner.tsx +78 -0
  81. package/src/Notifications/BaseModal/BaseModal.module.scss +2 -2
  82. package/src/Notifications/Snackbar/SnackbarContainer/SnackbarContainer.module.scss +2 -2
  83. package/src/Notifications/Snackbar/SnackbarItem/SnackbarItem.module.scss +4 -4
  84. package/src/Notifications/Snackbar/SnackbarItem/SnackbarItem.tsx +3 -2
  85. package/src/Popover/Popover.module.scss +2 -2
  86. package/src/Popover/Popover.test.tsx +4 -1
  87. package/src/Popover/Popover.tsx +40 -8
  88. package/src/Skeleton/Skeleton.module.scss +2 -2
  89. package/src/Tabs/TabButton.tsx +1 -2
  90. package/src/Tabs/Tabs.module.scss +2 -2
  91. package/src/Tabs/Tabs.tsx +13 -10
  92. package/src/Tiles/Tile.module.scss +4 -4
  93. package/src/Tooltip/Tooltip.module.scss +3 -3
  94. package/src/Tooltip/Tooltip.test.tsx +5 -5
  95. package/src/_BaseStyling_/BaseStyling.tsx +8 -0
  96. package/src/hooks/useDetermineStatusIcon.test.ts +28 -0
  97. package/src/hooks/useDetermineStatusIcon.tsx +35 -0
  98. package/src/hooks/usePosition.test.tsx +85 -85
  99. package/src/hooks/usePosition.ts +6 -3
  100. package/src/index.ts +1 -0
  101. package/src/mixins.module.scss +5 -5
@@ -0,0 +1,84 @@
1
+ /*
2
+ * Copyright 2022 OneWelcome B.V.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React from "react";
18
+ import { Banner, Props } from "./Banner";
19
+ import { render } from "@testing-library/react";
20
+
21
+ const defaultParams: Props = {
22
+ children: "The service will not be available between 02:00 and 03:00.",
23
+ title: "Maintenance is scheduled for next weekend",
24
+ type: "info"
25
+ };
26
+
27
+ const createBanner = (params?: (defaultParams: Props) => Props) => {
28
+ let parameters: Props = defaultParams;
29
+ if (params) {
30
+ parameters = params(defaultParams);
31
+ }
32
+ const queries = render(
33
+ <Banner {...parameters} data-testid="BannerTest">
34
+ {defaultParams.children}
35
+ </Banner>
36
+ );
37
+ const BannerComponent = queries.getByTestId("BannerTest");
38
+
39
+ return {
40
+ ...queries,
41
+ BannerComponent
42
+ };
43
+ };
44
+
45
+ describe("Banner should render", () => {
46
+ it("renders without crashing", () => {
47
+ const { BannerComponent } = createBanner();
48
+ expect(BannerComponent).toBeDefined();
49
+ const title = BannerComponent.querySelector(".headline");
50
+ const content = BannerComponent.querySelector(".content");
51
+ const icon = BannerComponent.querySelector(".icon");
52
+ expect(BannerComponent).toHaveClass("info");
53
+ expect(title).toBeDefined();
54
+ expect(title).toHaveTextContent(defaultParams.title);
55
+ expect(content).toBeDefined();
56
+ expect(content).toHaveTextContent(defaultParams.children);
57
+ expect(icon).toBeDefined();
58
+ });
59
+
60
+ it("renders ariaLabel correctly", () => {
61
+ const ariaLabel = "Information regarding your information";
62
+ const { BannerComponent } = createBanner(defaultParams => ({ ...defaultParams, ariaLabel }));
63
+ expect(BannerComponent).toBeDefined();
64
+ expect(BannerComponent).toHaveAttribute("aria-label", ariaLabel);
65
+ });
66
+
67
+ it("renders ariaLive correctly", () => {
68
+ const ariaLive = "polite";
69
+ const { BannerComponent } = createBanner(defaultParams => ({ ...defaultParams, ariaLive }));
70
+ expect(BannerComponent).toBeDefined();
71
+ expect(BannerComponent).toHaveAttribute("aria-live", ariaLive);
72
+ });
73
+
74
+ it("renders ariaRole correctly", () => {
75
+ const ariaRole = "alert";
76
+ const { BannerComponent } = createBanner(defaultParams => ({
77
+ ...defaultParams,
78
+ type: "error",
79
+ ariaRole
80
+ }));
81
+ expect(BannerComponent).toBeDefined();
82
+ expect(BannerComponent).toHaveAttribute("role", ariaRole);
83
+ });
84
+ });
@@ -0,0 +1,78 @@
1
+ /*
2
+ * Copyright 2022 OneWelcome B.V.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React, {
18
+ AriaAttributes,
19
+ AriaRole,
20
+ ComponentPropsWithRef,
21
+ ForwardRefRenderFunction
22
+ } from "react";
23
+ import { Typography } from "../../Typography/Typography";
24
+ import { Icon, Icons } from "../../Icon/Icon";
25
+ import classes from "./Banner.module.scss";
26
+
27
+ export type BannerType = "error" | "warning" | "info";
28
+ export interface Props extends ComponentPropsWithRef<"section"> {
29
+ children: string;
30
+ ariaRole?: AriaRole;
31
+ ariaLive?: AriaAttributes["aria-live"];
32
+ ariaLabel?: AriaAttributes["aria-label"];
33
+ type: BannerType;
34
+ title: string;
35
+ }
36
+
37
+ const BannerComponent: ForwardRefRenderFunction<HTMLElement, Props> = (
38
+ { children, ariaLabel, ariaRole, ariaLive, type, title, ...rest }: Props,
39
+ ref
40
+ ) => {
41
+ const getIconVariant = (type: BannerType): Icons | null => {
42
+ switch (type) {
43
+ case "info":
44
+ return Icons.InfoCircle;
45
+ case "error":
46
+ return Icons.Error;
47
+ case "warning":
48
+ return Icons.Warning;
49
+ default:
50
+ return null;
51
+ }
52
+ };
53
+
54
+ const icon = getIconVariant(type);
55
+
56
+ return (
57
+ <section
58
+ {...rest}
59
+ ref={ref}
60
+ aria-live={ariaLive}
61
+ aria-label={ariaLabel}
62
+ role={ariaRole}
63
+ className={`${classes["banner"]} ${classes[type]}`}
64
+ >
65
+ {icon && <Icon icon={icon} className={classes["icon"]} />}
66
+ <div className={classes["container"]}>
67
+ <Typography variant={"h4"} className={classes["headline"]}>
68
+ {title}
69
+ </Typography>
70
+ <Typography variant={"body"} className={classes["content"]} tag={"p"}>
71
+ {children}
72
+ </Typography>
73
+ </div>
74
+ </section>
75
+ );
76
+ };
77
+
78
+ export const Banner = React.forwardRef(BannerComponent);
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @import "../../mixins.module.scss";
17
+ @use "../../mixins.module.scss";
18
18
 
19
19
  $zIndex: 10;
20
20
  $marginTop: 3.125rem;
@@ -41,7 +41,7 @@ $marginTop: 3.125rem;
41
41
  left: 0;
42
42
  top: 0;
43
43
  background-color: transparent;
44
- @include transition(background-color, 0.5s, ease);
44
+ @include mixins.transition(background-color, 0.5s, ease);
45
45
  }
46
46
 
47
47
  &.visible {
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- @import "../../../mixins.module.scss";
16
+ @use "../../../mixins.module.scss";
17
17
 
18
18
  .snackbars {
19
19
  position: fixed;
@@ -21,7 +21,7 @@
21
21
  width: 100%;
22
22
  display: flex;
23
23
  flex-direction: column;
24
- @include transition(height, 0.2s, ease-in-out);
24
+ @include mixins.transition(height, 0.2s, ease-in-out);
25
25
 
26
26
  &.bottom {
27
27
  bottom: 3.5rem;
@@ -14,8 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @import "../../../readyclasses.module.scss";
18
- @import "../../../mixins.module.scss";
17
+ @use "../../../readyclasses.module.scss";
18
+ @use "../../../mixins.module.scss";
19
19
 
20
20
  .snackbar {
21
21
  padding: 1rem 1.25rem;
@@ -23,7 +23,7 @@
23
23
  display: flex;
24
24
  width: 100%;
25
25
  box-sizing: border-box;
26
- @include transition(height, 0.2s, ease-in-out);
26
+ @include mixins.transition(height, 0.2s, ease-in-out);
27
27
  flex-grow: 0;
28
28
 
29
29
  &.info {
@@ -114,7 +114,7 @@
114
114
  cursor: not-allowed;
115
115
  }
116
116
 
117
- @include focusOutline(var(--snackbar-text-color));
117
+ @include readyclasses.focusOutline(var(--snackbar-text-color));
118
118
 
119
119
  &:not(:disabled):hover,
120
120
  &:not(:disabled):focus {
@@ -96,9 +96,10 @@ export const SnackbarItem = ({
96
96
  onClose(id);
97
97
  actionProp.onClick && actionProp.onClick(e);
98
98
  }}
99
- children={actionProp.label}
100
99
  className={classes["action-button"]}
101
- ></button>
100
+ >
101
+ {actionProp.label}
102
+ </button>
102
103
  ));
103
104
 
104
105
  return (
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @import "../mixins.module.scss";
17
+ @use "../mixins.module.scss";
18
18
 
19
19
  .popover {
20
20
  $transition-property: transform, opacity;
@@ -28,7 +28,7 @@
28
28
  opacity: 0;
29
29
  transform: scale(0.5);
30
30
 
31
- @include transition($transition-property, 0.2s, ease-in-out);
31
+ @include mixins.transition($transition-property, 0.2s, ease-in-out);
32
32
 
33
33
  &.show {
34
34
  transform: scale(1);
@@ -32,7 +32,7 @@ const createPopover = (params?: (defaultParams: Props) => Props) => {
32
32
  <li>Test</li>
33
33
  </ul>
34
34
  ),
35
- show: false,
35
+ show: true,
36
36
  placement: { vertical: "top", horizontal: "left" }
37
37
  };
38
38
  let parameters: Props = defaultParams;
@@ -95,6 +95,9 @@ describe("Popover should render", () => {
95
95
  it("renders without crashing and has default left and top attributes", () => {
96
96
  const { popover } = createPopover();
97
97
 
98
+ window.dispatchEvent(new Event("resize"));
99
+ window.dispatchEvent(new Event("scroll"));
100
+
98
101
  expect(popover).toBeTruthy();
99
102
  });
100
103
  });
@@ -31,37 +31,69 @@ export interface Props extends ComponentPropsWithRef<"div"> {
31
31
  anchorEl?: RefObject<HTMLOrSVGElement>; //eslint-disable-line no-undef
32
32
  placement?: Placement;
33
33
  offset?: Offset;
34
+ debounceAmount?: number;
34
35
  transformOrigin?: Placement;
36
+ onAnchorOutOfView?: () => void;
35
37
  }
36
38
 
37
39
  const PopoverComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
38
- { children, className, show, placement, offset, transformOrigin, anchorEl, ...rest },
40
+ {
41
+ children,
42
+ className,
43
+ show,
44
+ placement,
45
+ offset,
46
+ debounceAmount,
47
+ transformOrigin,
48
+ anchorEl,
49
+ onAnchorOutOfView,
50
+ ...rest
51
+ },
39
52
  ref
40
53
  ) => {
41
54
  const elToBePositioned = useRef<HTMLDivElement>(null);
42
55
 
43
- if (show === undefined) {
44
- throw new Error('Please make sure to define the "show" property on your Popover component');
45
- }
46
-
47
56
  const { top, left, right, bottom, calculatePosition } = usePosition({
48
57
  elementToBePositioned: elToBePositioned,
49
58
  relativeElement: anchorEl,
50
59
  offset: offset,
51
60
  placement: placement,
52
- transformOrigin: transformOrigin
61
+ transformOrigin: transformOrigin,
62
+ debounceAmount: debounceAmount || undefined
53
63
  });
54
64
 
55
65
  useEffect(() => {
66
+ if (!show) {
67
+ return;
68
+ }
69
+
56
70
  window.addEventListener("resize", calculatePosition);
71
+ window.addEventListener("scroll", calculatePosition);
57
72
 
58
- return () => window.removeEventListener("resize", calculatePosition);
59
- }, []);
73
+ return () => {
74
+ window.removeEventListener("resize", calculatePosition);
75
+ window.removeEventListener("scroll", calculatePosition);
76
+ };
77
+ }, [show]);
60
78
 
61
79
  useEffect(() => {
62
80
  calculatePosition();
63
81
  }, [show]);
64
82
 
83
+ useEffect(() => {
84
+ const isAnchorOffscreen =
85
+ show &&
86
+ (top === 0 ||
87
+ left === 0 ||
88
+ right === 0 ||
89
+ bottom === 0 ||
90
+ window.innerHeight - (elToBePositioned.current as HTMLElement).offsetHeight === top);
91
+
92
+ if (isAnchorOffscreen) {
93
+ onAnchorOutOfView && onAnchorOutOfView();
94
+ }
95
+ }, [top, left, right, bottom]);
96
+
65
97
  return (
66
98
  <div ref={ref} {...rest}>
67
99
  <div
@@ -14,12 +14,12 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @import "../mixins.module.scss";
17
+ @use "../mixins.module.scss";
18
18
 
19
19
  .skeleton {
20
20
  display: block;
21
21
  height: auto;
22
- @include skeletonLoading();
22
+ @include mixins.skeletonLoading();
23
23
  }
24
24
 
25
25
  .no-height::before {
@@ -24,13 +24,12 @@ import React, {
24
24
  import classes from "./TabButton.module.scss";
25
25
 
26
26
  export interface Props extends ComponentPropsWithRef<"button"> {
27
- children?: string;
28
27
  tabActive?: boolean;
29
28
  focused?: boolean;
30
29
  }
31
30
 
32
31
  const TabButtonComponent: ForwardRefRenderFunction<HTMLButtonElement, Props> = (
33
- { children, tabActive, focused, ...rest }: Props,
32
+ { children, tabActive, focused, title, ...rest }: Props,
34
33
  ref
35
34
  ) => {
36
35
  let buttonRef = (ref as RefObject<HTMLButtonElement>) || createRef<HTMLButtonElement>();
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @import "../mixins.module.scss";
17
+ @use "../mixins.module.scss";
18
18
 
19
19
  $focus-width: 5px;
20
20
 
@@ -45,7 +45,7 @@ $focus-width: 5px;
45
45
  height: var(--tab-active-border-height);
46
46
  background-color: var(--tab-active-border-color);
47
47
 
48
- @include transition($transition-property, 0.2s, ease-in-out);
48
+ @include mixins.transition($transition-property, 0.2s, ease-in-out);
49
49
  }
50
50
 
51
51
  .tabdivider {
package/src/Tabs/Tabs.tsx CHANGED
@@ -111,16 +111,19 @@ const TabsComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
111
111
  useEffect(() => {
112
112
  const buttons = React.Children.map(children, (child, index) => {
113
113
  if (Object.prototype.hasOwnProperty.call(child.props, "title")) {
114
- return React.createElement(TabButton, {
115
- key: `${child.props.title.toLowerCase().replace(/\s/, "_")}_button`,
116
- tabIndex: activeTabIndex === index ? 0 : -1,
117
- "aria-selected": activeTabIndex === index,
118
- focused: usingKeyboardNavigation && activeTabIndex === index,
119
- tabActive: activeTabIndex === index,
120
- "aria-controls": `tab_${index}`,
121
- onClick: () => setActiveTabIndex(index),
122
- children: child.props.title
123
- });
114
+ return React.createElement(
115
+ TabButton,
116
+ {
117
+ key: `${child.props.title.toLowerCase().replace(/\s/, "_")}_button`,
118
+ tabIndex: activeTabIndex === index ? 0 : -1,
119
+ "aria-selected": activeTabIndex === index,
120
+ focused: usingKeyboardNavigation && activeTabIndex === index,
121
+ tabActive: activeTabIndex === index,
122
+ "aria-controls": `tab_${index}`,
123
+ onClick: () => setActiveTabIndex(index)
124
+ },
125
+ child.props.title
126
+ );
124
127
  }
125
128
  return null;
126
129
  });
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @import "../mixins.module.scss";
17
+ @use "../mixins.module.scss";
18
18
 
19
19
  .tile {
20
20
  border: 1px solid var(--light-grey-border);
@@ -22,7 +22,7 @@
22
22
  box-sizing: border-box;
23
23
  padding: 0 0 2rem;
24
24
  background-color: var(--light);
25
- @include transition(box-shadow, 0.2s, ease-in-out);
25
+ @include mixins.transition(box-shadow, 0.2s, ease-in-out);
26
26
  font-family: var(--font-family);
27
27
 
28
28
  &:hover {
@@ -71,14 +71,14 @@
71
71
 
72
72
  .image {
73
73
  margin-top: 2.5rem;
74
- @include skeletonLoading();
74
+ @include mixins.skeletonLoading();
75
75
  border-radius: 0.5rem;
76
76
  width: 3rem;
77
77
  height: 3rem;
78
78
  }
79
79
 
80
80
  .title {
81
- @include skeletonLoading();
81
+ @include mixins.skeletonLoading();
82
82
  color: transparent;
83
83
  display: inline-block;
84
84
  width: 70%;
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @import "../mixins.module.scss";
17
+ @use "../mixins.module.scss";
18
18
 
19
19
  .wrapper {
20
20
  display: flex;
@@ -24,7 +24,7 @@
24
24
  .tooltip-wrapper {
25
25
  .icon {
26
26
  margin-left: 0.5rem;
27
- @include transition(all, 0.2s, ease-in-out);
27
+ @include mixins.transition(all, 0.2s, ease-in-out);
28
28
  color: var(--greyed-out);
29
29
 
30
30
  &:hover {
@@ -46,7 +46,7 @@
46
46
  transform-origin: center left;
47
47
  pointer-events: none;
48
48
 
49
- @include transition($transition-property, 0.2s, ease-in-out);
49
+ @include mixins.transition($transition-property, 0.2s, ease-in-out);
50
50
 
51
51
  &.visible {
52
52
  opacity: 1;
@@ -16,7 +16,7 @@
16
16
 
17
17
  import React, { useEffect, useRef } from "react";
18
18
  import { Tooltip, Props } from "./Tooltip";
19
- import { render } from "@testing-library/react";
19
+ import { render, waitFor } from "@testing-library/react";
20
20
  import userEvent from "@testing-library/user-event";
21
21
 
22
22
  const defaultParams: Props = {
@@ -39,7 +39,7 @@ const createTooltip = (params?: (defaultParams: Props) => Props) => {
39
39
  };
40
40
 
41
41
  describe("Tooltip should render", () => {
42
- it("renders without crashing", () => {
42
+ it("renders without crashing", async () => {
43
43
  const { tooltip, getByText } = createTooltip(defaultParams => ({
44
44
  ...defaultParams,
45
45
  className: "testing"
@@ -49,7 +49,7 @@ describe("Tooltip should render", () => {
49
49
  const label = getByText("Label");
50
50
 
51
51
  expect(tooltip).toHaveClass("testing");
52
- expect(tooltipText).toHaveStyle({ top: "0px", left: "16px" });
52
+ await waitFor(() => expect(tooltipText).toHaveStyle({ top: "0px", left: "16px" }));
53
53
  expect(label).toBeTruthy();
54
54
  expect(tooltipText).toBeTruthy();
55
55
  expect(tooltip).toBeTruthy();
@@ -65,7 +65,7 @@ describe("Tooltip should render", () => {
65
65
  expect(getByText(labelText)).toBeDefined();
66
66
  });
67
67
 
68
- it("should override the default placement and offset values", () => {
68
+ it("should override the default placement and offset values", async () => {
69
69
  const { tooltip, getByText } = createTooltip(defaultParams => ({
70
70
  ...defaultParams,
71
71
  placement: { horizontal: "center", vertical: "center" },
@@ -74,7 +74,7 @@ describe("Tooltip should render", () => {
74
74
  }));
75
75
 
76
76
  const tooltipText = getByText("This is a test message");
77
- expect(tooltipText).toHaveStyle({ right: "1024px", bottom: "768px" });
77
+ await waitFor(() => expect(tooltipText).toHaveStyle({ right: "1024px", bottom: "768px" }));
78
78
  expect(tooltip).toBeTruthy();
79
79
  });
80
80
  });
@@ -42,11 +42,14 @@ interface CSSProperties {
42
42
  modalShadowColor?: string;
43
43
  modalBackgroundColor?: string;
44
44
  modalHeaderBackgroundColor?: string;
45
+ skeletonBackgroundColor?: string;
46
+ skeletonAnimationColorRgb?: string;
45
47
  snackbarTextColor?: string;
46
48
  snackbarInfoBackgroundColor?: string;
47
49
  snackbarSuccessBackgroundColor?: string;
48
50
  snackbarErrorBackgroundColor?: string;
49
51
  snackbarBorderRadius?: string;
52
+ bannerBorderRadius?: string;
50
53
  dataGridRowBackgroundColor?: string;
51
54
  dataGridRowHoverBackgroundColor?: string;
52
55
  tabsBackgroundColor?: string;
@@ -59,6 +62,7 @@ interface CSSProperties {
59
62
  default?: string;
60
63
  success?: string;
61
64
  error?: string;
65
+ info?: string;
62
66
  disabled?: string;
63
67
  greyedOut?: string;
64
68
  lightGreyBorder?: string;
@@ -103,11 +107,14 @@ export const BaseStyling = ({ children, properties = {} }: Props) => {
103
107
  modalShadowColor: "rgba(0, 0, 0, 0.16)",
104
108
  modalBackgroundColor: "#f5f8f8",
105
109
  modalHeaderBackgroundColor: "var(--light)",
110
+ skeletonBackgroundColor: "var(--disabled)",
111
+ skeletonAnimationColorRgb: "255, 255, 255",
106
112
  snackbarTextColor: "var(--light)",
107
113
  snackbarInfoBackgroundColor: "#003b5e",
108
114
  snackbarSuccessBackgroundColor: "#008a28",
109
115
  snackbarErrorBackgroundColor: "#d9291c",
110
116
  snackbarBorderRadius: "8px",
117
+ bannerBorderRadius: "8px",
111
118
  dataGridRowBackgroundColor: "transparent",
112
119
  dataGridRowHoverBackgroundColor: "#f5e6f0",
113
120
  tabsBackgroundColor: "var(--light)",
@@ -120,6 +127,7 @@ export const BaseStyling = ({ children, properties = {} }: Props) => {
120
127
  default: "#0f0f1e",
121
128
  success: "#008a28",
122
129
  error: "#d9291c",
130
+ info: "var(--color-secondary)",
123
131
  disabled: "#e9e9eb",
124
132
  greyedOut: "#6f6f76",
125
133
  lightGreyBorder: "#e9e9eb",
@@ -0,0 +1,28 @@
1
+ import { renderHook } from "@testing-library/react-hooks";
2
+ import { useDetermineStatusIcon } from "./useDetermineStatusIcon";
3
+
4
+ describe("it should return the correct icon", () => {
5
+ it("should return an icon of type success", () => {
6
+ const { result } = renderHook(useDetermineStatusIcon, {
7
+ initialProps: { success: true, error: false }
8
+ });
9
+
10
+ expect(result.current).toBeDefined();
11
+ expect(result.current?.props?.["data-icon-status"]).toEqual("success");
12
+ });
13
+
14
+ it("should return an icon of type error", () => {
15
+ const { result } = renderHook(useDetermineStatusIcon, {
16
+ initialProps: { success: true, error: true }
17
+ });
18
+
19
+ expect(result.current).toBeDefined();
20
+ expect(result.current?.props?.["data-icon-status"]).toEqual("error");
21
+ });
22
+
23
+ it("should return null", () => {
24
+ const { result } = renderHook(useDetermineStatusIcon);
25
+
26
+ expect(result.current).toBeNull();
27
+ });
28
+ });
@@ -0,0 +1,35 @@
1
+ /*
2
+ * Copyright 2022 OneWelcome B.V.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { FormElement } from "../Form/form.interfaces";
18
+ import React, { ReactElement, useRef } from "react";
19
+ import { Icon, Icons } from "../Icon/Icon";
20
+ export const useDetermineStatusIcon = (params: Partial<FormElement>): ReactElement | null => {
21
+ const { error, success } = params || false;
22
+ let icon = null;
23
+ const errorRef = useRef(null);
24
+ const successRef = useRef(null);
25
+
26
+ if (error) {
27
+ icon = <Icon ref={errorRef} data-icon-status="error" icon={Icons.Error} />;
28
+ } else if (success) {
29
+ icon = (
30
+ <Icon ref={successRef} data-icon-status="success" icon={Icons.CheckmarkCircleBreakout} />
31
+ );
32
+ }
33
+
34
+ return icon;
35
+ };