@kaizen/components 1.64.3 → 1.64.4
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/cjs/Notification/InlineNotification/InlineNotification.cjs +4 -3
- package/dist/cjs/Notification/subcomponents/GenericNotification/GenericNotification.cjs +5 -3
- package/dist/esm/Notification/InlineNotification/InlineNotification.mjs +5 -4
- package/dist/esm/Notification/subcomponents/GenericNotification/GenericNotification.mjs +6 -4
- package/dist/styles.css +99 -95
- package/dist/types/Notification/InlineNotification/InlineNotification.d.ts +1 -4
- package/dist/types/Notification/subcomponents/GenericNotification/GenericNotification.d.ts +1 -4
- package/package.json +1 -1
- package/src/Notification/InlineNotification/InlineNotification.tsx +25 -16
- package/src/Notification/InlineNotification/_docs/InlineNotification.stickersheet.stories.tsx +18 -0
- package/src/Notification/subcomponents/GenericNotification/GenericNotification.stories.tsx +44 -1
- package/src/Notification/subcomponents/GenericNotification/GenericNotification.tsx +93 -72
- package/src/Notification/subcomponents/GenericNotification/_mixins.scss +5 -0
|
@@ -17,7 +17,7 @@ var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
|
17
17
|
* {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3082093392/Inline+Notification Guidance} |
|
|
18
18
|
* {@link https://cultureamp.design/storybook/?path=/docs/components-notifications-inline-notification--docs Storybook}
|
|
19
19
|
*/
|
|
20
|
-
var InlineNotification = function (_a) {
|
|
20
|
+
var InlineNotification = React.forwardRef(function (_a, ref) {
|
|
21
21
|
var isSubtle = _a.isSubtle,
|
|
22
22
|
_b = _a.hideCloseIcon,
|
|
23
23
|
hideCloseIcon = _b === void 0 ? false : _b,
|
|
@@ -28,8 +28,9 @@ var InlineNotification = function (_a) {
|
|
|
28
28
|
return React__default.default.createElement(GenericNotification.GenericNotification, tslib.__assign({
|
|
29
29
|
style: "inline",
|
|
30
30
|
persistent: persistent || hideCloseIcon,
|
|
31
|
-
classNameOverride: classnames__default.default(classNameOverride, [isSubtle && GenericNotification_module.subtle])
|
|
31
|
+
classNameOverride: classnames__default.default(classNameOverride, [isSubtle && GenericNotification_module.subtle]),
|
|
32
|
+
ref: ref
|
|
32
33
|
}, otherProps));
|
|
33
|
-
};
|
|
34
|
+
});
|
|
34
35
|
InlineNotification.displayName = "InlineNotification";
|
|
35
36
|
exports.InlineNotification = InlineNotification;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var classnames = require('classnames');
|
|
6
|
+
var isRefObject = require('../../../utils/isRefObject.cjs');
|
|
6
7
|
var CancelButton = require('../CancelButton/CancelButton.cjs');
|
|
7
8
|
var NotificationHeading = require('../NotificationHeading/NotificationHeading.cjs');
|
|
8
9
|
var NotificationIcon = require('../NotificationIcon/NotificationIcon.cjs');
|
|
@@ -14,7 +15,7 @@ function _interopDefault(e) {
|
|
|
14
15
|
}
|
|
15
16
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
16
17
|
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
17
|
-
var GenericNotification = function (_a) {
|
|
18
|
+
var GenericNotification = React.forwardRef(function (_a, ref) {
|
|
18
19
|
var type = _a.type,
|
|
19
20
|
variant = _a.variant,
|
|
20
21
|
style = _a.style,
|
|
@@ -34,7 +35,8 @@ var GenericNotification = function (_a) {
|
|
|
34
35
|
var _d = React.useState(false),
|
|
35
36
|
isRemoved = _d[0],
|
|
36
37
|
setIsRemoved = _d[1];
|
|
37
|
-
var
|
|
38
|
+
var fallbackRef = React.useRef(null);
|
|
39
|
+
var containerRef = isRefObject.isRefObject(ref) ? ref : fallbackRef;
|
|
38
40
|
React.useEffect(function () {
|
|
39
41
|
requestAnimationFrame(function () {
|
|
40
42
|
if (containerRef.current) {
|
|
@@ -83,6 +85,6 @@ var GenericNotification = function (_a) {
|
|
|
83
85
|
return setIsHidden(true);
|
|
84
86
|
}
|
|
85
87
|
}));
|
|
86
|
-
};
|
|
88
|
+
});
|
|
87
89
|
GenericNotification.displayName = "GenericNotification";
|
|
88
90
|
exports.GenericNotification = GenericNotification;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __rest, __assign } from 'tslib';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { GenericNotification } from '../subcomponents/GenericNotification/GenericNotification.mjs';
|
|
5
5
|
import styles from '../subcomponents/GenericNotification/GenericNotification.module.scss.mjs';
|
|
@@ -9,7 +9,7 @@ import styles from '../subcomponents/GenericNotification/GenericNotification.mod
|
|
|
9
9
|
* {@link https://cultureamp.design/storybook/?path=/docs/components-notifications-inline-notification--docs Storybook}
|
|
10
10
|
*/
|
|
11
11
|
const InlineNotification = /*#__PURE__*/function () {
|
|
12
|
-
const InlineNotification = function (_a) {
|
|
12
|
+
const InlineNotification = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
13
13
|
var isSubtle = _a.isSubtle,
|
|
14
14
|
_b = _a.hideCloseIcon,
|
|
15
15
|
hideCloseIcon = _b === void 0 ? false : _b,
|
|
@@ -20,9 +20,10 @@ const InlineNotification = /*#__PURE__*/function () {
|
|
|
20
20
|
return /*#__PURE__*/React.createElement(GenericNotification, __assign({
|
|
21
21
|
style: "inline",
|
|
22
22
|
persistent: persistent || hideCloseIcon,
|
|
23
|
-
classNameOverride: classnames(classNameOverride, [isSubtle && styles.subtle])
|
|
23
|
+
classNameOverride: classnames(classNameOverride, [isSubtle && styles.subtle]),
|
|
24
|
+
ref: ref
|
|
24
25
|
}, otherProps));
|
|
25
|
-
};
|
|
26
|
+
});
|
|
26
27
|
InlineNotification.displayName = "InlineNotification";
|
|
27
28
|
return InlineNotification;
|
|
28
29
|
}();
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { __rest, __assign } from 'tslib';
|
|
2
|
-
import React, { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import React, { forwardRef, useState, useRef, useEffect } from 'react';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
|
+
import { isRefObject } from '../../../utils/isRefObject.mjs';
|
|
4
5
|
import { CancelButton } from '../CancelButton/CancelButton.mjs';
|
|
5
6
|
import { NotificationHeading } from '../NotificationHeading/NotificationHeading.mjs';
|
|
6
7
|
import { NotificationIconType, NotificationIconVariant } from '../NotificationIcon/NotificationIcon.mjs';
|
|
7
8
|
import styles from './GenericNotification.module.scss.mjs';
|
|
8
9
|
const GenericNotification = /*#__PURE__*/function () {
|
|
9
|
-
const GenericNotification = function (_a) {
|
|
10
|
+
const GenericNotification = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
10
11
|
var type = _a.type,
|
|
11
12
|
variant = _a.variant,
|
|
12
13
|
style = _a.style,
|
|
@@ -26,7 +27,8 @@ const GenericNotification = /*#__PURE__*/function () {
|
|
|
26
27
|
var _d = useState(false),
|
|
27
28
|
isRemoved = _d[0],
|
|
28
29
|
setIsRemoved = _d[1];
|
|
29
|
-
var
|
|
30
|
+
var fallbackRef = useRef(null);
|
|
31
|
+
var containerRef = isRefObject(ref) ? ref : fallbackRef;
|
|
30
32
|
useEffect(function () {
|
|
31
33
|
requestAnimationFrame(function () {
|
|
32
34
|
if (containerRef.current) {
|
|
@@ -75,7 +77,7 @@ const GenericNotification = /*#__PURE__*/function () {
|
|
|
75
77
|
return setIsHidden(true);
|
|
76
78
|
}
|
|
77
79
|
}));
|
|
78
|
-
};
|
|
80
|
+
});
|
|
79
81
|
GenericNotification.displayName = "GenericNotification";
|
|
80
82
|
return GenericNotification;
|
|
81
83
|
}();
|
package/dist/styles.css
CHANGED
|
@@ -1,61 +1,59 @@
|
|
|
1
1
|
@layer tokens, normalize, reset;@layer tokens{:root{--theme-key:heart;--animation-easing-function-ease-in-out:cubic-bezier(0.455,0.03,0.515,0.955);--animation-easing-function-ease-in:cubic-bezier(0.55,0.085,0.68,0.53);--animation-easing-function-ease-out:cubic-bezier(0.25,0.46,0.45,0.94);--animation-easing-function-linear:linear;--animation-easing-function-bounce-in:cubic-bezier(0.485,0.155,0.24,1.245);--animation-easing-function-bounce-out:cubic-bezier(0.485,0.155,0.515,0.845);--animation-easing-function-bounce-in-out:cubic-bezier(0.76,-0.245,0.24,1.245);--animation-duration-instant:0ms;--animation-duration-immediate:100ms;--animation-duration-rapid:200ms;--animation-duration-fast:300ms;--animation-duration-slow:400ms;--animation-duration-deliberate:700ms;--border-solid-border-width:2px;--border-solid-border-radius:7px;--border-solid-border-style:solid;--border-solid-border-color:#e1e2ea;--border-solid-border-color-rgb:225,226,234;--border-dashed-border-width:2px;--border-dashed-border-radius:7px;--border-dashed-border-style:dashed;--border-borderless-border-width:2px;--border-borderless-border-radius:7px;--border-borderless-border-style:solid;--border-borderless-border-color:transparent;--border-borderless-border-color-rgb:0,0,0;--border-focus-ring-border-width:2px;--border-focus-ring-border-radius:10px;--border-focus-ring-border-style:solid;--border-width-1:1px;--color-purple-100:#f4edf8;--color-purple-100-rgb:244,237,248;--color-purple-200:#dfc9ea;--color-purple-200-rgb:223,201,234;--color-purple-300:#c9a5dd;--color-purple-300-rgb:201,165,221;--color-purple-400:#ae67b1;--color-purple-400-rgb:174,103,177;--color-purple-500:#844587;--color-purple-500-rgb:132,69,135;--color-purple-600:#5f3361;--color-purple-600-rgb:95,51,97;--color-purple-700:#4a234d;--color-purple-700-rgb:74,35,77;--color-purple-800:#2f2438;--color-purple-800-rgb:47,36,56;--color-blue-100:#e6f6ff;--color-blue-100-rgb:230,246,255;--color-blue-200:#bde2f5;--color-blue-200-rgb:189,226,245;--color-blue-300:#73c0e8;--color-blue-300-rgb:115,192,232;--color-blue-400:#008bd6;--color-blue-400-rgb:0,139,214;--color-blue-500:#0168b3;--color-blue-500-rgb:1,104,179;--color-blue-600:#004970;--color-blue-600-rgb:0,73,112;--color-blue-700:#003157;--color-blue-700-rgb:0,49,87;--color-green-100:#e8f8f4;--color-green-100-rgb:232,248,244;--color-green-200:#c4ede2;--color-green-200-rgb:196,237,226;--color-green-300:#8fdbc7;--color-green-300-rgb:143,219,199;--color-green-400:#5dcaad;--color-green-400-rgb:93,202,173;--color-green-500:#3f9a86;--color-green-500-rgb:63,154,134;--color-green-600:#2c7d67;--color-green-600-rgb:44,125,103;--color-green-700:#22594a;--color-green-700-rgb:34,89,74;--color-yellow-100:#fff9e4;--color-yellow-100-rgb:255,249,228;--color-yellow-200:#ffeeb3;--color-yellow-200-rgb:255,238,179;--color-yellow-300:#ffe36e;--color-yellow-300-rgb:255,227,110;--color-yellow-400:#ffca4d;--color-yellow-400-rgb:255,202,77;--color-yellow-500:#ffb600;--color-yellow-500-rgb:255,182,0;--color-yellow-600:#c68600;--color-yellow-600-rgb:198,134,0;--color-yellow-700:#876400;--color-yellow-700-rgb:135,100,0;--color-red-100:#fdeaee;--color-red-100-rgb:253,234,238;--color-red-200:#f9c2cb;--color-red-200-rgb:249,194,203;--color-red-300:#f597a8;--color-red-300-rgb:245,151,168;--color-red-400:#e0707d;--color-red-400-rgb:224,112,125;--color-red-500:#c93b55;--color-red-500-rgb:201,59,85;--color-red-600:#a82433;--color-red-600-rgb:168,36,51;--color-red-700:#6c1e20;--color-red-700-rgb:108,30,32;--color-orange-100:#fff0e8;--color-orange-100-rgb:255,240,232;--color-orange-200:#ffd1b9;--color-orange-200-rgb:255,209,185;--color-orange-300:#ffb08a;--color-orange-300-rgb:255,176,138;--color-orange-400:#ff9461;--color-orange-400-rgb:255,148,97;--color-orange-500:#e96c2f;--color-orange-500-rgb:233,108,47;--color-orange-600:#b74302;--color-orange-600-rgb:183,67,2;--color-orange-700:#903c00;--color-orange-700-rgb:144,60,0;--color-gray-100:#f9f9f9;--color-gray-100-rgb:249,249,249;--color-gray-200:#f4f4f5;--color-gray-200-rgb:244,244,245;--color-gray-300:#eaeaec;--color-gray-300-rgb:234,234,236;--color-gray-400:#cdcdd0;--color-gray-400-rgb:205,205,208;--color-gray-500:#878792;--color-gray-500-rgb:135,135,146;--color-gray-600:#524e56;--color-gray-600-rgb:82,78,86;--color-white:#fff;--color-white-rgb:255,255,255;--color-black:#000;--color-black-rgb:0,0,0;--data-viz-favorable:#7dd5bd;--data-viz-favorable-rgb:125,213,189;--data-viz-unfavorable:#e68d97;--data-viz-unfavorable-rgb:230,141,151;--layout-content-max-width:1392px;--layout-content-max-width-with-sidebar:1080px;--layout-content-side-margin:72px;--layout-mobile-actions-drawer-height:60px;--layout-navigation-bar-height:72px;--layout-breakpoints-medium:768px;--layout-breakpoints-large:1080px;--shadow-small-box-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 3px 16px 0 rgba(0,0,0,.06);--shadow-large-box-shadow:0 3px 9px 0 rgba(0,0,0,.1),0 8px 40px 0 rgba(0,0,0,.08);--spacing-0:0;--spacing-1:.0625rem;--spacing-2:.125rem;--spacing-4:.25rem;--spacing-6:.375rem;--spacing-8:.5rem;--spacing-12:.75rem;--spacing-16:1rem;--spacing-20:1.25rem;--spacing-24:1.5rem;--spacing-32:2rem;--spacing-40:2.5rem;--spacing-48:3rem;--spacing-56:3.5rem;--spacing-64:4rem;--spacing-72:4.5rem;--spacing-80:5rem;--spacing-96:6rem;--spacing-112:7rem;--spacing-128:8rem;--spacing-160:10rem;--spacing-200:12.5rem;--spacing-240:15rem;--spacing-280:17.5rem;--spacing-320:20rem;--spacing-xs:0.375rem;--spacing-sm:0.75rem;--spacing-md:1.5rem;--spacing-lg:2.25rem;--spacing-xl:3rem;--spacing-xxl:3.75rem;--spacing-xxxl:4.5rem;--spacing-xxxxl:5.25rem;--spacing-xxxxxl:6rem;--typography-data-large-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-data-large-font-weight:700;--typography-data-large-font-size:5.25rem;--typography-data-large-line-height:5.25rem;--typography-data-large-letter-spacing:normal;--typography-data-large-units-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-data-large-units-font-weight:700;--typography-data-large-units-font-size:2.625rem;--typography-data-large-units-line-height:5.25rem;--typography-data-large-units-letter-spacing:normal;--typography-data-medium-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-data-medium-font-weight:700;--typography-data-medium-font-size:3rem;--typography-data-medium-line-height:5rem;--typography-data-medium-letter-spacing:normal;--typography-data-medium-units-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-data-medium-units-font-weight:700;--typography-data-medium-units-font-size:1.5rem;--typography-data-medium-units-line-height:5rem;--typography-data-medium-units-letter-spacing:normal;--typography-data-small-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-data-small-font-weight:700;--typography-data-small-font-size:1.5rem;--typography-data-small-line-height:1.5rem;--typography-data-small-letter-spacing:normal;--typography-data-small-units-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-data-small-units-font-weight:700;--typography-data-small-units-font-size:1.125rem;--typography-data-small-units-line-height:1.5rem;--typography-data-small-units-letter-spacing:normal;--typography-display-0-font-family:"Tiempos Headline",Georgia,serif;--typography-display-0-font-weight:800;--typography-display-0-font-size:4.5rem;--typography-display-0-line-height:5.25rem;--typography-display-0-letter-spacing:0em;--typography-heading-1-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-heading-1-font-weight:700;--typography-heading-1-font-size:2.125rem;--typography-heading-1-line-height:2.625rem;--typography-heading-1-letter-spacing:normal;--typography-heading-2-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-heading-2-font-weight:700;--typography-heading-2-font-size:1.75rem;--typography-heading-2-line-height:2.25rem;--typography-heading-2-letter-spacing:normal;--typography-heading-3-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-heading-3-font-weight:700;--typography-heading-3-font-size:1.375rem;--typography-heading-3-line-height:1.875rem;--typography-heading-3-letter-spacing:normal;--typography-heading-4-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-heading-4-font-weight:600;--typography-heading-4-font-size:1.125rem;--typography-heading-4-line-height:1.5rem;--typography-heading-4-letter-spacing:normal;--typography-heading-5-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-heading-5-font-weight:600;--typography-heading-5-font-size:1rem;--typography-heading-5-line-height:1.5rem;--typography-heading-5-letter-spacing:normal;--typography-heading-6-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-heading-6-font-weight:700;--typography-heading-6-font-size:0.875rem;--typography-heading-6-line-height:1.5rem;--typography-heading-6-letter-spacing:normal;--typography-paragraph-intro-lede-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-paragraph-intro-lede-font-weight:400;--typography-paragraph-intro-lede-font-size:1.25rem;--typography-paragraph-intro-lede-line-height:1.875rem;--typography-paragraph-intro-lede-letter-spacing:0;--typography-paragraph-intro-lede-max-width:975px;--typography-paragraph-body-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-paragraph-body-font-weight:400;--typography-paragraph-body-font-size:1rem;--typography-paragraph-body-line-height:1.5rem;--typography-paragraph-body-letter-spacing:normal;--typography-paragraph-body-max-width:780px;--typography-paragraph-small-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-paragraph-small-font-weight:400;--typography-paragraph-small-font-size:0.875rem;--typography-paragraph-small-line-height:1.125rem;--typography-paragraph-small-letter-spacing:normal;--typography-paragraph-small-max-width:680px;--typography-paragraph-extra-small-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-paragraph-extra-small-font-weight:400;--typography-paragraph-extra-small-font-size:0.75rem;--typography-paragraph-extra-small-line-height:1.125rem;--typography-paragraph-extra-small-letter-spacing:normal;--typography-paragraph-extra-small-max-width:600px;--typography-paragraph-bold-font-weight:600;--typography-button-primary-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-button-primary-font-weight:700;--typography-button-primary-font-size:1.125rem;--typography-button-primary-line-height:1.5rem;--typography-button-primary-letter-spacing:normal;--typography-button-secondary-font-family:"Inter","Noto Sans",Helvetica,Arial,sans-serif;--typography-button-secondary-font-weight:500;--typography-button-secondary-font-size:1rem;--typography-button-secondary-line-height:1.5rem;--typography-button-secondary-letter-spacing:normal}}@layer normalize{html{text-size-adjust:100%;line-height:1.15}body{margin:0}main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{appearance:none}::-webkit-file-upload-button{appearance:button;font:inherit}details{display:block}summary{display:list-item}[hidden],template{display:none}}@layer reset{@font-face{font-family:Tiempos Headline;font-weight:800;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/tiempos/tiempos-headline-bold.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/tiempos/tiempos-headline-bold.woff)}@font-face{font-family:Tiempos Headline;font-weight:500;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/tiempos/tiempos-headline-medium.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/tiempos/tiempos-headline-medium.woff)}@font-face{font-family:Greycliff CF;font-weight:300;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/greycliff/greycliff-cf-light.woff) format("woff")}@font-face{font-family:Greycliff CF;font-weight:400;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/greycliff/greycliff-cf-regular.woff) format("woff")}@font-face{font-family:Greycliff CF;font-weight:500;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/greycliff/greycliff-cf-medium.woff) format("woff")}@font-face{font-family:Greycliff CF;font-weight:600;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/greycliff/greycliff-cf-demi-bold.woff) format("woff")}@font-face{font-family:Greycliff CF;font-weight:700;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/greycliff/greycliff-cf-bold.woff) format("woff")}@font-face{font-family:Greycliff CF;font-weight:800;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/greycliff/greycliff-cf-extra-bold.woff) format("woff")}@font-face{font-family:Inter;font-weight:300;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-light.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-light.woff)}@font-face{font-family:Inter;font-weight:400;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-regular.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-regular.woff)}@font-face{font-family:Inter;font-weight:500;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-medium.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-medium.woff)}@font-face{font-family:Inter;font-weight:600;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-demi-bold.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-demi-bold.woff)}@font-face{font-family:Inter;font-weight:700;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-bold.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-bold.woff)}@font-face{font-family:Inter;font-weight:800;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-extra-bold.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-extra-bold.woff)}@font-face{font-family:IBM Plex Mono;src:url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/ibm-plex-mono/ibm-plex-mono-regular.woff2),url(https://d1e7r7b0lb8p4d.cloudfront.net/fonts/ibm-plex-mono/ibm-plex-mono-regular.woff)}}@layer reset{*,:after,:before{border-color:var(--border-solid-border-color,"currentColor");border-style:solid;border-width:0}}
|
|
2
2
|
/** THIS IS AN AUTOGENERATED FILE **/
|
|
3
3
|
/** THIS IS AN AUTOGENERATED FILE **/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
/** THIS IS AN AUTOGENERATED FILE **/
|
|
5
|
+
/** THIS IS AN AUTOGENERATED FILE **/
|
|
6
|
+
/** THIS IS AN AUTOGENERATED FILE **/
|
|
7
|
+
/** THIS IS AN AUTOGENERATED FILE **/
|
|
8
|
+
.Tooltip-module_tooltip__efL1m {
|
|
9
|
+
max-width: 200px;
|
|
10
|
+
padding: var(--spacing-8, 0.5rem) var(--spacing-12, 0.75rem);
|
|
11
|
+
color: var(--color-white, #ffffff);
|
|
12
|
+
text-align: center;
|
|
13
|
+
font-family: var(--typography-paragraph-extra-small-font-family, "Inter", "Noto Sans", Helvetica, Arial, sans-serif);
|
|
14
|
+
font-size: var(--typography-paragraph-extra-small-font-size, 0.75rem);
|
|
15
|
+
font-weight: var(--typography-paragraph-extra-small-font-weight, 400);
|
|
16
|
+
letter-spacing: var(--typography-paragraph-extra-small-letter-spacing, normal);
|
|
17
|
+
line-height: var(--typography-paragraph-extra-small-line-height, 1.125rem);
|
|
18
|
+
border-radius: var(--border-solid-border-radius, 7px);
|
|
16
19
|
box-shadow: var(--shadow-small-box-shadow, 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 3px 16px 0 rgba(0, 0, 0, 0.06));
|
|
20
|
+
background-color: var(--color-purple-800, #2f2438);
|
|
21
|
+
text-wrap: pretty;
|
|
22
|
+
/* fixes FF gap */
|
|
23
|
+
transform: translate3d(0, 0, 0);
|
|
17
24
|
}
|
|
18
|
-
.
|
|
19
|
-
|
|
25
|
+
.Tooltip-module_tooltip__efL1m.Tooltip-module_reversed__NnCbZ {
|
|
26
|
+
background-color: var(--color-white, #ffffff);
|
|
27
|
+
color: var(--color-purple-800, #2f2438);
|
|
20
28
|
}
|
|
21
|
-
.
|
|
22
|
-
|
|
29
|
+
.Tooltip-module_tooltip__efL1m[data-placement=top] {
|
|
30
|
+
--origin: translateY(4px);
|
|
23
31
|
}
|
|
24
|
-
.
|
|
25
|
-
|
|
32
|
+
.Tooltip-module_tooltip__efL1m[data-placement=bottom] {
|
|
33
|
+
--origin: translateY(-4px);
|
|
26
34
|
}
|
|
27
|
-
.
|
|
28
|
-
|
|
35
|
+
.Tooltip-module_tooltip__efL1m[data-placement=right] {
|
|
36
|
+
--origin: translateX(-4px);
|
|
29
37
|
}
|
|
30
|
-
.
|
|
31
|
-
|
|
32
|
-
color: var(--color-purple-800);
|
|
33
|
-
width: 248px;
|
|
34
|
-
max-height: 22rem;
|
|
35
|
-
overflow: auto;
|
|
36
|
-
padding-block: var(--spacing-6);
|
|
37
|
-
outline: none;
|
|
38
|
-
border-radius: var(--border-solid-border-radius);
|
|
39
|
-
box-shadow: var(--shadow-large-box-shadow);
|
|
38
|
+
.Tooltip-module_tooltip__efL1m[data-placement=left] {
|
|
39
|
+
--origin: translateX(4px);
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
font-weight: var(--typography-heading-6-font-weight);
|
|
47
|
-
line-height: var(--typography-heading-6-line-height);
|
|
48
|
-
padding: var(--spacing-6) 10px;
|
|
49
|
-
margin-inline: var(--spacing-6);
|
|
41
|
+
.Tooltip-module_tooltip__efL1m[data-entering] {
|
|
42
|
+
animation: Tooltip-module_slide__lFdGA var(--animation-duration-fast, 300ms);
|
|
43
|
+
}
|
|
44
|
+
.Tooltip-module_tooltip__efL1m[data-exiting] {
|
|
45
|
+
animation: Tooltip-module_slide__lFdGA var(--animation-duration-fast, 300ms) reverse var(--animation-easing-function-ease-in, cubic-bezier(0.55, 0.085, 0.68, 0.53));
|
|
50
46
|
}
|
|
51
47
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
@keyframes Tooltip-module_slide__lFdGA {
|
|
49
|
+
from {
|
|
50
|
+
transform: var(--origin);
|
|
51
|
+
opacity: 0;
|
|
52
|
+
}
|
|
53
|
+
to {
|
|
54
|
+
transform: translateY(0);
|
|
55
|
+
opacity: 1;
|
|
56
|
+
}
|
|
59
57
|
}
|
|
60
58
|
.MenuItem-module_item__DPerF {
|
|
61
59
|
font-family: var(--typography-paragraph-body-font-family);
|
|
@@ -91,9 +89,6 @@
|
|
|
91
89
|
.MenuItem-module_item__DPerF[data-disabled] {
|
|
92
90
|
opacity: 0.3;
|
|
93
91
|
}
|
|
94
|
-
.Focusable-module_focusableWrapper__NfuIi {
|
|
95
|
-
display: inline-flex;
|
|
96
|
-
}
|
|
97
92
|
.Button-module_button__QOSYH {
|
|
98
93
|
--button-min-height-width: var(--spacing-48);
|
|
99
94
|
--button-padding-x: calc(
|
|
@@ -182,61 +177,66 @@
|
|
|
182
177
|
--button-icon-size: var(--spacing-16);
|
|
183
178
|
gap: var(--spacing-8);
|
|
184
179
|
}
|
|
180
|
+
.Focusable-module_focusableWrapper__NfuIi {
|
|
181
|
+
display: inline-flex;
|
|
182
|
+
}
|
|
183
|
+
.Menu-module_menu__iHYqh {
|
|
184
|
+
background-color: var(--color-white);
|
|
185
|
+
color: var(--color-purple-800);
|
|
186
|
+
width: 248px;
|
|
187
|
+
max-height: 22rem;
|
|
188
|
+
overflow: auto;
|
|
189
|
+
padding-block: var(--spacing-6);
|
|
190
|
+
outline: none;
|
|
191
|
+
border-radius: var(--border-solid-border-radius);
|
|
192
|
+
box-shadow: var(--shadow-large-box-shadow);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.Menu-module_menu__iHYqh .react-aria-Header {
|
|
196
|
+
font-family: var(--typography-heading-6-font-family);
|
|
197
|
+
font-size: var(--typography-heading-6-font-size);
|
|
198
|
+
letter-spacing: var(--typography-heading-6-letter-spacing);
|
|
199
|
+
font-weight: var(--typography-heading-6-font-weight);
|
|
200
|
+
line-height: var(--typography-heading-6-line-height);
|
|
201
|
+
padding: var(--spacing-6) 10px;
|
|
202
|
+
margin-inline: var(--spacing-6);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.Menu-module_menu__iHYqh section:not(:last-of-type)::after {
|
|
206
|
+
width: 100%;
|
|
207
|
+
height: 1px;
|
|
208
|
+
background-color: var(--border-solid-border-color);
|
|
209
|
+
content: "";
|
|
210
|
+
display: block;
|
|
211
|
+
margin-block: var(--spacing-6);
|
|
212
|
+
}
|
|
185
213
|
/** THIS IS AN AUTOGENERATED FILE **/
|
|
186
214
|
/** THIS IS AN AUTOGENERATED FILE **/
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
/** THIS IS AN AUTOGENERATED FILE **/
|
|
191
|
-
.Tooltip-module_tooltip__efL1m {
|
|
192
|
-
max-width: 200px;
|
|
193
|
-
padding: var(--spacing-8, 0.5rem) var(--spacing-12, 0.75rem);
|
|
194
|
-
color: var(--color-white, #ffffff);
|
|
195
|
-
text-align: center;
|
|
196
|
-
font-family: var(--typography-paragraph-extra-small-font-family, "Inter", "Noto Sans", Helvetica, Arial, sans-serif);
|
|
197
|
-
font-size: var(--typography-paragraph-extra-small-font-size, 0.75rem);
|
|
198
|
-
font-weight: var(--typography-paragraph-extra-small-font-weight, 400);
|
|
199
|
-
letter-spacing: var(--typography-paragraph-extra-small-letter-spacing, normal);
|
|
200
|
-
line-height: var(--typography-paragraph-extra-small-line-height, 1.125rem);
|
|
201
|
-
border-radius: var(--border-solid-border-radius, 7px);
|
|
202
|
-
box-shadow: var(--shadow-small-box-shadow, 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 3px 16px 0 rgba(0, 0, 0, 0.06));
|
|
203
|
-
background-color: var(--color-purple-800, #2f2438);
|
|
204
|
-
text-wrap: pretty;
|
|
205
|
-
/* fixes FF gap */
|
|
206
|
-
transform: translate3d(0, 0, 0);
|
|
207
|
-
}
|
|
208
|
-
.Tooltip-module_tooltip__efL1m.Tooltip-module_reversed__NnCbZ {
|
|
209
|
-
background-color: var(--color-white, #ffffff);
|
|
210
|
-
color: var(--color-purple-800, #2f2438);
|
|
215
|
+
.OverlayArrow-module_overlayArrow__hoDyK {
|
|
216
|
+
display: flex;
|
|
217
|
+
padding: 8px;
|
|
211
218
|
}
|
|
212
|
-
.
|
|
213
|
-
|
|
219
|
+
.OverlayArrow-module_overlayArrow__hoDyK[data-placement=top], .OverlayArrow-module_overlayArrow__hoDyK[data-placement=bottom] {
|
|
220
|
+
padding: 0 8px;
|
|
214
221
|
}
|
|
215
|
-
.
|
|
216
|
-
|
|
222
|
+
.OverlayArrow-module_overlayArrow__hoDyK[data-placement=left], .OverlayArrow-module_overlayArrow__hoDyK[data-placement=right] {
|
|
223
|
+
padding: 8px 0;
|
|
217
224
|
}
|
|
218
|
-
.
|
|
219
|
-
|
|
225
|
+
.OverlayArrow-module_overlayArrow__hoDyK path {
|
|
226
|
+
fill: var(--color-purple-800, #2f2438);
|
|
227
|
+
box-shadow: var(--shadow-small-box-shadow, 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 3px 16px 0 rgba(0, 0, 0, 0.06));
|
|
220
228
|
}
|
|
221
|
-
.
|
|
222
|
-
|
|
229
|
+
.OverlayArrow-module_overlayArrow__hoDyK[data-placement=right] svg {
|
|
230
|
+
transform: rotate(90deg);
|
|
223
231
|
}
|
|
224
|
-
.
|
|
225
|
-
|
|
232
|
+
.OverlayArrow-module_overlayArrow__hoDyK[data-placement=bottom] svg {
|
|
233
|
+
transform: rotate(180deg);
|
|
226
234
|
}
|
|
227
|
-
.
|
|
228
|
-
|
|
235
|
+
.OverlayArrow-module_overlayArrow__hoDyK[data-placement=left] svg {
|
|
236
|
+
transform: rotate(270deg);
|
|
229
237
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
from {
|
|
233
|
-
transform: var(--origin);
|
|
234
|
-
opacity: 0;
|
|
235
|
-
}
|
|
236
|
-
to {
|
|
237
|
-
transform: translateY(0);
|
|
238
|
-
opacity: 1;
|
|
239
|
-
}
|
|
238
|
+
.OverlayArrow-module_overlayArrow__hoDyK.OverlayArrow-module_reversed__-WGcR path {
|
|
239
|
+
fill: var(--color-white, #ffffff);
|
|
240
240
|
}
|
|
241
241
|
.SVG-module_icon__8J5Ev {
|
|
242
242
|
width: 20px;
|
|
@@ -5408,6 +5408,10 @@ input[type=range].InputRange-module_ratingScaleRange__gI-rs::-ms-thumb:not(:disa
|
|
|
5408
5408
|
box-sizing: border-box;
|
|
5409
5409
|
pointer-events: all;
|
|
5410
5410
|
}
|
|
5411
|
+
.GenericNotification-module_notification__-JP1M:focus {
|
|
5412
|
+
outline-offset: 1px;
|
|
5413
|
+
outline: 2px solid var(--color-blue-500);
|
|
5414
|
+
}
|
|
5411
5415
|
.GenericNotification-module_notification__-JP1M.GenericNotification-module_inline__OciO5, .GenericNotification-module_notification__-JP1M.GenericNotification-module_toast__GOVfC {
|
|
5412
5416
|
margin-bottom: var(--spacing-24, 1.5rem);
|
|
5413
5417
|
border-width: var(--border-width-1);
|
|
@@ -19,7 +19,4 @@ export type InlineNotificationProps = InlineNotificationBase & (GenericNotificat
|
|
|
19
19
|
* {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3082093392/Inline+Notification Guidance} |
|
|
20
20
|
* {@link https://cultureamp.design/storybook/?path=/docs/components-notifications-inline-notification--docs Storybook}
|
|
21
21
|
*/
|
|
22
|
-
export declare const InlineNotification:
|
|
23
|
-
({ isSubtle, hideCloseIcon, persistent, classNameOverride, ...otherProps }: InlineNotificationProps): JSX.Element;
|
|
24
|
-
displayName: string;
|
|
25
|
-
};
|
|
22
|
+
export declare const InlineNotification: React.ForwardRefExoticComponent<InlineNotificationProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -32,8 +32,5 @@ export type GenericNotificationVariant = {
|
|
|
32
32
|
variant: NotificationVariant;
|
|
33
33
|
};
|
|
34
34
|
export type GenericNotificationProps = GenericNotificationBase & (GenericNotificationType | GenericNotificationVariant);
|
|
35
|
-
export declare const GenericNotification:
|
|
36
|
-
({ type, variant, style, children, title, persistent, onHide, noBottomMargin, forceMultiline, headingProps, classNameOverride, ...restProps }: GenericNotificationProps): JSX.Element | null;
|
|
37
|
-
displayName: string;
|
|
38
|
-
};
|
|
35
|
+
export declare const GenericNotification: React.ForwardRefExoticComponent<GenericNotificationProps & React.RefAttributes<HTMLDivElement>>;
|
|
39
36
|
export {};
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from "react"
|
|
1
|
+
import React, { forwardRef, HTMLAttributes } from "react"
|
|
2
2
|
import classnames from "classnames"
|
|
3
3
|
import { HeadingProps } from "~components/Heading"
|
|
4
4
|
import { OverrideClassName } from "~components/types/OverrideClassName"
|
|
@@ -30,21 +30,30 @@ export type InlineNotificationProps = InlineNotificationBase &
|
|
|
30
30
|
* {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3082093392/Inline+Notification Guidance} |
|
|
31
31
|
* {@link https://cultureamp.design/storybook/?path=/docs/components-notifications-inline-notification--docs Storybook}
|
|
32
32
|
*/
|
|
33
|
-
export const InlineNotification =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
export const InlineNotification = forwardRef<
|
|
34
|
+
HTMLDivElement,
|
|
35
|
+
InlineNotificationProps
|
|
36
|
+
>(
|
|
37
|
+
(
|
|
38
|
+
{
|
|
39
|
+
isSubtle,
|
|
40
|
+
hideCloseIcon = false,
|
|
41
|
+
persistent = false,
|
|
42
|
+
classNameOverride,
|
|
43
|
+
...otherProps
|
|
44
|
+
},
|
|
45
|
+
ref
|
|
46
|
+
): JSX.Element => (
|
|
47
|
+
<GenericNotification
|
|
48
|
+
style="inline"
|
|
49
|
+
persistent={persistent || hideCloseIcon}
|
|
50
|
+
classNameOverride={classnames(classNameOverride, [
|
|
51
|
+
isSubtle && styles.subtle,
|
|
52
|
+
])}
|
|
53
|
+
ref={ref}
|
|
54
|
+
{...otherProps}
|
|
55
|
+
/>
|
|
56
|
+
)
|
|
48
57
|
)
|
|
49
58
|
|
|
50
59
|
InlineNotification.displayName = "InlineNotification"
|
package/src/Notification/InlineNotification/_docs/InlineNotification.stickersheet.stories.tsx
CHANGED
|
@@ -131,6 +131,19 @@ const VARIANTS_PROPS: Array<{
|
|
|
131
131
|
forceMultiline: true,
|
|
132
132
|
},
|
|
133
133
|
},
|
|
134
|
+
{
|
|
135
|
+
title: "Focus",
|
|
136
|
+
props: {
|
|
137
|
+
// @ts-ignore
|
|
138
|
+
"data-sb-pseudo-styles": "focus",
|
|
139
|
+
variant: "informative",
|
|
140
|
+
headingProps: {
|
|
141
|
+
variant: "heading-6",
|
|
142
|
+
tag: "span",
|
|
143
|
+
children: "Focused title",
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
134
147
|
]
|
|
135
148
|
|
|
136
149
|
const TYPE_PROPS: Array<{
|
|
@@ -206,6 +219,11 @@ const StickerSheetTemplate: StickerSheetStory = {
|
|
|
206
219
|
</StickerSheet>
|
|
207
220
|
</>
|
|
208
221
|
),
|
|
222
|
+
parameters: {
|
|
223
|
+
pseudo: {
|
|
224
|
+
focus: '[data-sb-pseudo-styles="focus"]',
|
|
225
|
+
},
|
|
226
|
+
},
|
|
209
227
|
}
|
|
210
228
|
|
|
211
229
|
export const StickerSheetDefault: StickerSheetStory = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from "react"
|
|
1
|
+
import React, { useRef, useState } from "react"
|
|
2
2
|
import { Meta, StoryObj } from "@storybook/react"
|
|
3
3
|
import { userEvent, within, expect, waitFor } from "@storybook/test"
|
|
4
4
|
import { GenericNotification } from "./index"
|
|
@@ -58,3 +58,46 @@ export const GenericNotificationTest: Story = {
|
|
|
58
58
|
})
|
|
59
59
|
},
|
|
60
60
|
}
|
|
61
|
+
|
|
62
|
+
export const RefTest: Story = {
|
|
63
|
+
render: () => {
|
|
64
|
+
const customRef = useRef<HTMLDivElement>(null)
|
|
65
|
+
const [isHidden, setIsHidden] = useState<boolean>(false)
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div>
|
|
69
|
+
<span data-testid="hidden-state">{isHidden ? "Hidden" : "Shown"}</span>
|
|
70
|
+
<GenericNotification
|
|
71
|
+
ref={customRef}
|
|
72
|
+
variant="success"
|
|
73
|
+
style="inline"
|
|
74
|
+
title="Success"
|
|
75
|
+
data-testid="generic-notification"
|
|
76
|
+
onHide={() => setIsHidden(true)}
|
|
77
|
+
>
|
|
78
|
+
This is my positive notification
|
|
79
|
+
</GenericNotification>
|
|
80
|
+
</div>
|
|
81
|
+
)
|
|
82
|
+
},
|
|
83
|
+
name: "Test: still renders and closes properly when custom ref passed in",
|
|
84
|
+
play: async ({ canvasElement }) => {
|
|
85
|
+
const canvas = within(canvasElement)
|
|
86
|
+
const element = canvas.getByTestId("generic-notification")
|
|
87
|
+
const hiddenState = canvas.getByTestId("hidden-state")
|
|
88
|
+
|
|
89
|
+
await waitFor(() => {
|
|
90
|
+
expect(element).toBeInTheDocument()
|
|
91
|
+
expect(hiddenState).toHaveTextContent("Shown")
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
await userEvent.click(canvas.getByTestId("close-button"))
|
|
95
|
+
|
|
96
|
+
await waitFor(() => {
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
expect(hiddenState).toHaveTextContent("Hidden")
|
|
99
|
+
expect(element).not.toBeInTheDocument()
|
|
100
|
+
}, 1000)
|
|
101
|
+
})
|
|
102
|
+
},
|
|
103
|
+
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
forwardRef,
|
|
3
|
+
HTMLAttributes,
|
|
4
|
+
useEffect,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
} from "react"
|
|
2
8
|
import classnames from "classnames"
|
|
3
9
|
import { HeadingProps } from "~components/Heading"
|
|
4
10
|
import {
|
|
@@ -6,6 +12,7 @@ import {
|
|
|
6
12
|
NotificationVariant,
|
|
7
13
|
} from "~components/Notification/types"
|
|
8
14
|
import { OverrideClassName } from "~components/types/OverrideClassName"
|
|
15
|
+
import { isRefObject } from "~components/utils/isRefObject"
|
|
9
16
|
import { CancelButton } from "../CancelButton"
|
|
10
17
|
import { NotificationHeading } from "../NotificationHeading"
|
|
11
18
|
import {
|
|
@@ -49,89 +56,103 @@ export type GenericNotificationVariant = {
|
|
|
49
56
|
export type GenericNotificationProps = GenericNotificationBase &
|
|
50
57
|
(GenericNotificationType | GenericNotificationVariant)
|
|
51
58
|
|
|
52
|
-
export const GenericNotification =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
export const GenericNotification = forwardRef<
|
|
60
|
+
HTMLDivElement,
|
|
61
|
+
GenericNotificationProps
|
|
62
|
+
>(
|
|
63
|
+
(
|
|
64
|
+
{
|
|
65
|
+
type,
|
|
66
|
+
variant,
|
|
67
|
+
style,
|
|
68
|
+
children,
|
|
69
|
+
title,
|
|
70
|
+
persistent = false,
|
|
71
|
+
onHide,
|
|
72
|
+
noBottomMargin,
|
|
73
|
+
forceMultiline,
|
|
74
|
+
headingProps,
|
|
75
|
+
classNameOverride,
|
|
76
|
+
...restProps
|
|
77
|
+
},
|
|
78
|
+
ref
|
|
79
|
+
): JSX.Element | null => {
|
|
80
|
+
const [isHidden, setIsHidden] = useState<boolean>(true)
|
|
81
|
+
const [isRemoved, setIsRemoved] = useState<boolean>(false)
|
|
68
82
|
|
|
69
|
-
|
|
83
|
+
const fallbackRef = useRef<HTMLDivElement>(null)
|
|
84
|
+
const containerRef = isRefObject(ref) ? ref : fallbackRef
|
|
70
85
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
requestAnimationFrame(() => {
|
|
88
|
+
if (containerRef.current) {
|
|
89
|
+
setIsHidden(false)
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
}, [])
|
|
78
93
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
94
|
+
const getMarginTop = (): string => {
|
|
95
|
+
if (isHidden && containerRef.current) {
|
|
96
|
+
return -containerRef.current.clientHeight + "px"
|
|
97
|
+
}
|
|
98
|
+
return "0"
|
|
82
99
|
}
|
|
83
|
-
return "0"
|
|
84
|
-
}
|
|
85
100
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
101
|
+
const onTransitionEnd = (
|
|
102
|
+
e: React.TransitionEvent<HTMLDivElement>
|
|
103
|
+
): void => {
|
|
104
|
+
// Be careful: this assumes the final CSS property to be animated is "margin-top".
|
|
105
|
+
if (isHidden && e.propertyName === "margin-top") {
|
|
106
|
+
setIsRemoved(true)
|
|
107
|
+
onHide?.()
|
|
108
|
+
}
|
|
91
109
|
}
|
|
92
|
-
}
|
|
93
110
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
111
|
+
if (isRemoved) {
|
|
112
|
+
return null
|
|
113
|
+
}
|
|
97
114
|
|
|
98
|
-
|
|
99
|
-
<div
|
|
100
|
-
ref={containerRef}
|
|
101
|
-
className={classnames(
|
|
102
|
-
styles.notification,
|
|
103
|
-
variant ? styles[variant] : styles[type],
|
|
104
|
-
styles[style],
|
|
105
|
-
isHidden && styles.hidden,
|
|
106
|
-
noBottomMargin && styles.noBottomMargin,
|
|
107
|
-
classNameOverride,
|
|
108
|
-
persistent && styles.persistent
|
|
109
|
-
)}
|
|
110
|
-
style={{ marginTop: getMarginTop() }}
|
|
111
|
-
onTransitionEnd={onTransitionEnd}
|
|
112
|
-
{...restProps}
|
|
113
|
-
>
|
|
114
|
-
<div className={styles.icon}>
|
|
115
|
-
{type ? (
|
|
116
|
-
<NotificationIconType type={type} />
|
|
117
|
-
) : (
|
|
118
|
-
<NotificationIconVariant variant={variant} />
|
|
119
|
-
)}
|
|
120
|
-
</div>
|
|
115
|
+
return (
|
|
121
116
|
<div
|
|
117
|
+
ref={containerRef}
|
|
122
118
|
className={classnames(
|
|
123
|
-
styles.
|
|
124
|
-
|
|
119
|
+
styles.notification,
|
|
120
|
+
variant ? styles[variant] : styles[type],
|
|
121
|
+
styles[style],
|
|
122
|
+
isHidden && styles.hidden,
|
|
123
|
+
noBottomMargin && styles.noBottomMargin,
|
|
124
|
+
classNameOverride,
|
|
125
|
+
persistent && styles.persistent
|
|
125
126
|
)}
|
|
127
|
+
style={{ marginTop: getMarginTop() }}
|
|
128
|
+
onTransitionEnd={onTransitionEnd}
|
|
129
|
+
{...restProps}
|
|
126
130
|
>
|
|
127
|
-
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
+
<div className={styles.icon}>
|
|
132
|
+
{type ? (
|
|
133
|
+
<NotificationIconType type={type} />
|
|
134
|
+
) : (
|
|
135
|
+
<NotificationIconVariant variant={variant} />
|
|
136
|
+
)}
|
|
137
|
+
</div>
|
|
138
|
+
<div
|
|
139
|
+
className={classnames(
|
|
140
|
+
styles.textContainer,
|
|
141
|
+
forceMultiline && styles.forceMultiline
|
|
142
|
+
)}
|
|
143
|
+
>
|
|
144
|
+
{style !== "global" && (
|
|
145
|
+
<NotificationHeading
|
|
146
|
+
titleProp={title}
|
|
147
|
+
headingProps={headingProps}
|
|
148
|
+
/>
|
|
149
|
+
)}
|
|
150
|
+
{children && <div className={styles.text}>{children}</div>}
|
|
151
|
+
</div>
|
|
152
|
+
{!persistent && <CancelButton onClick={() => setIsHidden(true)} />}
|
|
131
153
|
</div>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
)
|
|
136
157
|
|
|
137
158
|
GenericNotification.displayName = "GenericNotification"
|
|
@@ -22,6 +22,11 @@ $notification-slide-right: transform 300ms ease-out;
|
|
|
22
22
|
box-sizing: border-box;
|
|
23
23
|
pointer-events: all;
|
|
24
24
|
|
|
25
|
+
&:focus {
|
|
26
|
+
outline-offset: 1px;
|
|
27
|
+
outline: 2px solid var(--color-blue-500);
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
// Variants
|
|
26
31
|
&%ca-notification---inline,
|
|
27
32
|
&%ca-notification---toast {
|