@helsenorge/designsystem-react 7.5.0 → 7.7.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.
- package/CHANGELOG.md +25 -0
- package/components/Badge/Badge.d.ts +7 -1
- package/components/Badge/Badge.js +19 -9
- package/components/Badge/Badge.js.map +1 -1
- package/components/Badge/Badge.stories.d.ts +11 -0
- package/components/Badge/NotificationBadge.d.ts +17 -0
- package/components/Badge/NotificationBadge.js +68 -0
- package/components/Badge/NotificationBadge.js.map +1 -0
- package/components/ErrorWrapper/styles.module.scss +1 -0
- package/components/Expander/styles.module.scss +3 -2
- package/components/ExpanderList/styles.module.scss +6 -1
- package/components/LinkList/LinkList.stories.d.ts +1 -0
- package/components/ListHeader/ListHeader.d.ts +1 -1
- package/components/ListHeader/ListHeader.js +32 -28
- package/components/ListHeader/ListHeader.js.map +1 -1
- package/components/NotificationPanel/NotificationPanel.d.ts +4 -1
- package/components/NotificationPanel/NotificationPanel.js +65 -98
- package/components/NotificationPanel/NotificationPanel.js.map +1 -1
- package/components/NotificationPanel/NotificationPanel.stories.d.ts +6 -1
- package/components/NotificationPanel/styles.module.scss +14 -0
- package/components/NotificationPanel/styles.module.scss.d.ts +1 -0
- package/components/ServiceMessage/ServiceMessage.js +66 -75
- package/components/ServiceMessage/ServiceMessage.js.map +1 -1
- package/components/ServiceMessage/ServiceMessage.stories.d.ts +1 -1
- package/components/ServiceMessage/styles.module.scss +13 -0
- package/components/ServiceMessage/styles.module.scss.d.ts +1 -0
- package/package.json +1 -1
- package/components/NotificationPanel/DetailButton/DetailButton.d.ts +0 -9
- package/components/NotificationPanel/DetailButton/DetailButton.js +0 -28
- package/components/NotificationPanel/DetailButton/DetailButton.js.map +0 -1
- package/components/NotificationPanel/DetailButton/styles.module.scss +0 -38
- package/components/NotificationPanel/DetailButton/styles.module.scss.d.ts +0 -13
|
@@ -1,127 +1,94 @@
|
|
|
1
1
|
import t from "react";
|
|
2
2
|
import c from "classnames";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { Icon as f } from "../Icon/Icon.js";
|
|
11
|
-
import D from "../Icons/CheckFill.js";
|
|
12
|
-
import M from "../Icons/ErrorSignFill.js";
|
|
13
|
-
import O from "../Icons/InfoSignFill.js";
|
|
14
|
-
import U from "../Icons/TriangleX.js";
|
|
3
|
+
import { AnalyticsId as R, IconSize as C } from "../../constants.js";
|
|
4
|
+
import { useUuid as T } from "../../hooks/useUuid.js";
|
|
5
|
+
import { getColor as $ } from "../../theme/currys/color.js";
|
|
6
|
+
import { getAriaLabelAttributes as F } from "../../utils/accessibility.js";
|
|
7
|
+
import V from "../Badge/NotificationBadge.js";
|
|
8
|
+
import H from "../Close/Close.js";
|
|
9
|
+
import M from "../Expander/Expander.js";
|
|
15
10
|
import e from "../NotificationPanel/styles.module.scss";
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
const
|
|
19
|
-
return /* @__PURE__ */ t.createElement("div", { className:
|
|
11
|
+
const U = ({ fluid: r, children: s }) => {
|
|
12
|
+
if (r) {
|
|
13
|
+
const i = c(e["fluid-wrapper"]);
|
|
14
|
+
return /* @__PURE__ */ t.createElement("div", { className: i }, s);
|
|
20
15
|
}
|
|
21
|
-
return
|
|
22
|
-
},
|
|
16
|
+
return s;
|
|
17
|
+
}, W = t.forwardRef((r, s) => {
|
|
23
18
|
const {
|
|
24
|
-
children:
|
|
25
|
-
variant:
|
|
26
|
-
dismissable:
|
|
19
|
+
children: i,
|
|
20
|
+
variant: o = "info",
|
|
21
|
+
dismissable: m = !1,
|
|
27
22
|
onClick: E,
|
|
28
|
-
expanderChildren:
|
|
29
|
-
expanderButtonText:
|
|
30
|
-
expanderButtonClosedText:
|
|
23
|
+
expanderChildren: l,
|
|
24
|
+
expanderButtonText: d,
|
|
25
|
+
expanderButtonClosedText: f,
|
|
31
26
|
expanderOpenFromStart: N = !1,
|
|
32
27
|
compactVariant: a,
|
|
33
|
-
label:
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
label: n,
|
|
29
|
+
labelHtmlMarkup: h = "h1",
|
|
30
|
+
fluid: v = !1,
|
|
31
|
+
size: u,
|
|
36
32
|
className: I,
|
|
37
|
-
labelId:
|
|
33
|
+
labelId: S,
|
|
38
34
|
role: g,
|
|
39
35
|
testId: w
|
|
40
|
-
} =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
{
|
|
44
|
-
svgIcon: O,
|
|
45
|
-
color: o.blueberry700,
|
|
46
|
-
hoverColor: o.blueberry700,
|
|
47
|
-
size: a ? n.XSmall : n.Small
|
|
48
|
-
}
|
|
49
|
-
),
|
|
50
|
-
warn: /* @__PURE__ */ t.createElement(
|
|
51
|
-
f,
|
|
52
|
-
{
|
|
53
|
-
svgIcon: M,
|
|
54
|
-
color: o.banana700,
|
|
55
|
-
hoverColor: o.banana700,
|
|
56
|
-
size: a ? n.XSmall : n.Small
|
|
57
|
-
}
|
|
58
|
-
),
|
|
59
|
-
alert: /* @__PURE__ */ t.createElement(
|
|
60
|
-
f,
|
|
61
|
-
{
|
|
62
|
-
svgIcon: U,
|
|
63
|
-
color: o.cherry700,
|
|
64
|
-
hoverColor: o.cherry700,
|
|
65
|
-
size: a ? n.XSmall : n.Small
|
|
66
|
-
}
|
|
67
|
-
),
|
|
68
|
-
success: /* @__PURE__ */ t.createElement(
|
|
69
|
-
f,
|
|
70
|
-
{
|
|
71
|
-
svgIcon: D,
|
|
72
|
-
color: o.kiwi900,
|
|
73
|
-
hoverColor: o.kiwi900,
|
|
74
|
-
size: a ? n.XSmall : n.Small
|
|
75
|
-
}
|
|
76
|
-
)
|
|
77
|
-
}, z = () => {
|
|
78
|
-
const h = a === "outline", F = c(e["notification-panel__content"]), X = c(e["notification-panel__label"], {
|
|
79
|
-
[e["notification-panel__label--no-content"]]: !l && !r,
|
|
36
|
+
} = r, p = T(S), A = () => {
|
|
37
|
+
const b = a === "outline", P = c(e["notification-panel__content"]), k = c(e["notification-panel__label"], {
|
|
38
|
+
[e["notification-panel__label--no-content"]]: !i && !l,
|
|
80
39
|
[e["notification-panel__label--compact"]]: !!a,
|
|
81
|
-
[e["notification-panel__label--outline"]]:
|
|
82
|
-
}),
|
|
83
|
-
[e["notification-panel__children--with-label"]]:
|
|
84
|
-
[e["notification-panel__children--expander-no-label"]]:
|
|
85
|
-
[e["notification-panel__children--outline"]]:
|
|
86
|
-
});
|
|
87
|
-
return /* @__PURE__ */ t.createElement("div", { className:
|
|
88
|
-
|
|
40
|
+
[e["notification-panel__label--outline"]]: b
|
|
41
|
+
}), y = c(e["notification-panel__children"], {
|
|
42
|
+
[e["notification-panel__children--with-label"]]: n,
|
|
43
|
+
[e["notification-panel__children--expander-no-label"]]: l && !n,
|
|
44
|
+
[e["notification-panel__children--outline"]]: b
|
|
45
|
+
}), z = h, [x, O] = t.useState(N);
|
|
46
|
+
return /* @__PURE__ */ t.createElement("div", { className: P, id: n ? void 0 : p }, n && /* @__PURE__ */ t.createElement(z, { className: k, id: p }, n), i && /* @__PURE__ */ t.createElement("div", { className: y }, i), l && d && f && !a && /* @__PURE__ */ t.createElement(
|
|
47
|
+
M,
|
|
89
48
|
{
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
49
|
+
title: x ? d : f,
|
|
50
|
+
onExpand: O,
|
|
51
|
+
expanded: x,
|
|
52
|
+
testId: "expand"
|
|
53
|
+
},
|
|
54
|
+
l
|
|
95
55
|
));
|
|
96
|
-
},
|
|
56
|
+
}, B = c(
|
|
97
57
|
e["notification-panel"],
|
|
98
|
-
e[`notification-panel--${
|
|
99
|
-
|
|
58
|
+
e[`notification-panel--${o}`],
|
|
59
|
+
u && e[`notification-panel--${u}`],
|
|
100
60
|
{
|
|
101
61
|
[e["notification-panel--compact"]]: !!a,
|
|
102
62
|
[e["notification-panel--compact--basic"]]: a === "basic",
|
|
103
63
|
[e["notification-panel--compact--outline"]]: a === "outline",
|
|
104
|
-
[e["notification-panel--with-content"]]:
|
|
105
|
-
[e["notification-panel--dismissable"]]:
|
|
64
|
+
[e["notification-panel--with-content"]]: l || n && i,
|
|
65
|
+
[e["notification-panel--dismissable"]]: m
|
|
106
66
|
},
|
|
107
67
|
I
|
|
108
|
-
),
|
|
109
|
-
return /* @__PURE__ */ t.createElement(
|
|
68
|
+
), _ = g || (o === "alert" || o === "error") && "alert" || void 0, L = _ ? F({ label: n, id: p }) : void 0;
|
|
69
|
+
return /* @__PURE__ */ t.createElement(U, { fluid: v }, /* @__PURE__ */ t.createElement(
|
|
110
70
|
"div",
|
|
111
71
|
{
|
|
112
|
-
ref:
|
|
113
|
-
role:
|
|
72
|
+
ref: s,
|
|
73
|
+
role: _,
|
|
114
74
|
"data-testid": w,
|
|
115
|
-
"data-analyticsid":
|
|
116
|
-
className:
|
|
117
|
-
...
|
|
75
|
+
"data-analyticsid": R.NotificationPanel,
|
|
76
|
+
className: B,
|
|
77
|
+
...L
|
|
118
78
|
},
|
|
119
|
-
/* @__PURE__ */ t.createElement(
|
|
120
|
-
|
|
121
|
-
|
|
79
|
+
/* @__PURE__ */ t.createElement(
|
|
80
|
+
V,
|
|
81
|
+
{
|
|
82
|
+
variant: o == "alert" ? "error" : o,
|
|
83
|
+
size: a ? C.XSmall : C.Small,
|
|
84
|
+
className: e["notification-panel__icon"]
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
m && /* @__PURE__ */ t.createElement("span", { className: e["notification-panel__close"] }, /* @__PURE__ */ t.createElement(H, { ariaLabel: r.ariaLabelCloseBtn, onClick: E, color: $("black") })),
|
|
88
|
+
A()
|
|
122
89
|
));
|
|
123
|
-
}),
|
|
90
|
+
}), ee = W;
|
|
124
91
|
export {
|
|
125
|
-
|
|
92
|
+
ee as default
|
|
126
93
|
};
|
|
127
94
|
//# sourceMappingURL=NotificationPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationPanel.js","sources":["../../../src/components/NotificationPanel/NotificationPanel.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { DetailButton } from './DetailButton/DetailButton';\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\nimport { palette } from '../../theme/palette';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport Close from '../Close';\nimport Icon from '../Icon';\nimport CheckFill from '../Icons/CheckFill';\nimport ErrorSignFill from '../Icons/ErrorSignFill';\nimport InfoSignFill from '../Icons/InfoSignFill';\nimport TriangleX from '../Icons/TriangleX';\n\nimport styles from './styles.module.scss';\n\nexport type NotificationPanelVariants = 'info' | 'warn' | 'alert' | 'success';\nexport type NotificationCompactVariants = 'basic' | 'outline';\nexport type NotificationPanelSizes = 'small' | 'medium' | 'large';\n\nexport interface NotificationPanelProps {\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds inner child elements. */\n children?: React.ReactNode;\n /** Adds inner expander elements. */\n expanderChildren?: React.ReactNode;\n /** Text for expanderButton. */\n expanderButtonText?: string;\n /** Text for expanderButton when closed. */\n expanderButtonClosedText?: string;\n /** Makes expander be open from start. */\n expanderOpenFromStart?: boolean;\n /** Changes the visual representation of the notification panel. */\n variant?: NotificationPanelVariants;\n /** Makes the panel more compact. Available in basic and outline. */\n compactVariant?: NotificationCompactVariants;\n /** Sets a fixed size for the content container. */\n size?: NotificationPanelSizes;\n /** Used in combination with dismissiable property to close the notification panel. */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Toggles the close button in the top right corner. */\n dismissable?: boolean;\n /** Enables a fluid outer container that spans the entire width of parent. */\n fluid?: boolean;\n /** Sets a label for the notification panel. */\n label?: string;\n /** Close button aria-label */\n ariaLabelCloseBtn?: string;\n /** Custom id for the label */\n labelId?: string;\n /** Custom role for the panel. Default is no role. If variant is alert or crisis, the aria role will be set to \"alert\" unless the role-prop is also set. */\n role?: 'region' | 'alert';\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\ntype WrapFluidProps = Pick<NotificationPanelProps, 'fluid'> & {\n children: React.ReactElement;\n};\n\nconst FluidWrapper: React.FC<WrapFluidProps> = ({ fluid, children }) => {\n if (fluid) {\n const fluidClasses = classNames(styles['fluid-wrapper']);\n\n return <div className={fluidClasses}>{children}</div>;\n }\n return children;\n};\n\nconst NotificationPanel = React.forwardRef<HTMLDivElement, NotificationPanelProps>((props, ref) => {\n const {\n children,\n variant = 'info',\n dismissable = false,\n onClick,\n expanderChildren,\n expanderButtonText,\n expanderButtonClosedText,\n expanderOpenFromStart = false,\n compactVariant,\n label,\n fluid = false,\n size,\n className,\n labelId,\n role,\n testId,\n } = props;\n const uuid = useUuid(labelId);\n const variantToIconMap = {\n info: (\n <Icon\n svgIcon={InfoSignFill}\n color={palette.blueberry700}\n hoverColor={palette.blueberry700}\n size={compactVariant ? IconSize.XSmall : IconSize.Small}\n />\n ),\n warn: (\n <Icon\n svgIcon={ErrorSignFill}\n color={palette.banana700}\n hoverColor={palette.banana700}\n size={compactVariant ? IconSize.XSmall : IconSize.Small}\n />\n ),\n alert: (\n <Icon\n svgIcon={TriangleX}\n color={palette.cherry700}\n hoverColor={palette.cherry700}\n size={compactVariant ? IconSize.XSmall : IconSize.Small}\n />\n ),\n success: (\n <Icon\n svgIcon={CheckFill}\n color={palette.kiwi900}\n hoverColor={palette.kiwi900}\n size={compactVariant ? IconSize.XSmall : IconSize.Small}\n />\n ),\n };\n const renderContent = (): JSX.Element => {\n const outlineVariant = compactVariant === 'outline';\n const contentClasses = classNames(styles['notification-panel__content']);\n const labelClasses = classNames(styles['notification-panel__label'], {\n [styles['notification-panel__label--no-content']]: !children && !expanderChildren,\n [styles['notification-panel__label--compact']]: !!compactVariant,\n [styles['notification-panel__label--outline']]: outlineVariant,\n });\n const childrenClasses = classNames(styles['notification-panel__children'], {\n [styles['notification-panel__children--with-label']]: label,\n [styles['notification-panel__children--expander-no-label']]: expanderChildren && !label,\n [styles['notification-panel__children--outline']]: outlineVariant,\n });\n\n return (\n <div className={contentClasses} id={!label ? uuid : undefined}>\n {label && (\n <h1 className={labelClasses} id={uuid}>\n {label}\n </h1>\n )}\n {children && <div className={childrenClasses}>{children}</div>}\n {expanderChildren && expanderButtonText && expanderButtonClosedText && !compactVariant && (\n <DetailButton\n expanderOpenFromStart={expanderOpenFromStart}\n content={expanderChildren}\n buttonText={expanderButtonText}\n buttonClosedText={expanderButtonClosedText}\n />\n )}\n </div>\n );\n };\n\n const notificationPanelClasses = classNames(\n styles['notification-panel'],\n styles[`notification-panel--${variant}`],\n size && styles[`notification-panel--${size}`],\n {\n [styles['notification-panel--compact']]: !!compactVariant,\n [styles['notification-panel--compact--basic']]: compactVariant === 'basic',\n [styles['notification-panel--compact--outline']]: compactVariant === 'outline',\n [styles['notification-panel--with-content']]: expanderChildren || (label && children),\n [styles['notification-panel--dismissable']]: dismissable,\n },\n className\n );\n\n const ariaRole = role || (variant === 'alert' && 'alert') || undefined;\n const ariaLabelAttributes = ariaRole ? getAriaLabelAttributes({ label, id: uuid }) : undefined;\n\n return (\n <FluidWrapper fluid={fluid}>\n <div\n ref={ref}\n role={ariaRole}\n data-testid={testId}\n data-analyticsid={AnalyticsId.NotificationPanel}\n className={notificationPanelClasses}\n {...ariaLabelAttributes}\n >\n <span className={styles['notification-panel__icon']}>{variantToIconMap[variant]}</span>\n {dismissable && (\n <span className={styles['notification-panel__close']}>\n <Close ariaLabel={props.ariaLabelCloseBtn} onClick={onClick} color={getColor('black')} />\n </span>\n )}\n {renderContent()}\n </div>\n </FluidWrapper>\n );\n});\n\nexport default NotificationPanel;\n"],"names":["FluidWrapper","fluid","children","fluidClasses","classNames","styles","React","NotificationPanel","props","ref","variant","dismissable","onClick","expanderChildren","expanderButtonText","expanderButtonClosedText","expanderOpenFromStart","compactVariant","label","size","className","labelId","role","testId","uuid","useUuid","variantToIconMap","Icon","InfoSignFill","palette","IconSize","ErrorSignFill","TriangleX","CheckFill","renderContent","outlineVariant","contentClasses","labelClasses","childrenClasses","DetailButton","notificationPanelClasses","ariaRole","ariaLabelAttributes","getAriaLabelAttributes","AnalyticsId","Close","getColor","NotificationPanel$1"],"mappings":";;;;;;;;;;;;;;;AAgEA,MAAMA,IAAyC,CAAC,EAAE,OAAAC,GAAO,UAAAC,QAAe;AACtE,MAAID,GAAO;AACT,UAAME,IAAeC,EAAWC,EAAO,eAAe,CAAC;AAEvD,WAAQC,gBAAAA,EAAA,cAAA,OAAA,EAAI,WAAWH,EAAA,GAAeD,CAAS;AAAA,EACjD;AACO,SAAAA;AACT,GAEMK,IAAoBD,EAAM,WAAmD,CAACE,GAAOC,MAAQ;AAC3F,QAAA;AAAA,IACJ,UAAAP;AAAA,IACA,SAAAQ,IAAU;AAAA,IACV,aAAAC,IAAc;AAAA,IACd,SAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,0BAAAC;AAAA,IACA,uBAAAC,IAAwB;AAAA,IACxB,gBAAAC;AAAA,IACA,OAAAC;AAAA,IACA,OAAAjB,IAAQ;AAAA,IACR,MAAAkB;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,MAAAC;AAAA,IACA,QAAAC;AAAA,EACE,IAAAf,GACEgB,IAAOC,EAAQJ,CAAO,GACtBK,IAAmB;AAAA,IACvB,MACEpB,gBAAAA,EAAA;AAAA,MAACqB;AAAA,MAAA;AAAA,QACC,SAASC;AAAA,QACT,OAAOC,EAAQ;AAAA,QACf,YAAYA,EAAQ;AAAA,QACpB,MAAMZ,IAAiBa,EAAS,SAASA,EAAS;AAAA,MAAA;AAAA,IACpD;AAAA,IAEF,MACExB,gBAAAA,EAAA;AAAA,MAACqB;AAAA,MAAA;AAAA,QACC,SAASI;AAAA,QACT,OAAOF,EAAQ;AAAA,QACf,YAAYA,EAAQ;AAAA,QACpB,MAAMZ,IAAiBa,EAAS,SAASA,EAA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AAA,WAAWrC,EAAM,mBAAmB,SAAAI,GAAkB,OAAOkC,EAAS,OAAO,GAAG,CACzF;AAAA,IAEDZ,EAAc;AAAA,EAAA,CAEnB;AAEJ,CAAC,GAEDa,KAAexC;"}
|
|
1
|
+
{"version":3,"file":"NotificationPanel.js","sources":["../../../src/components/NotificationPanel/NotificationPanel.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport NotificationBadge from '../Badge/NotificationBadge';\nimport Close from '../Close';\nimport Expander from '../Expander';\n\nimport styles from './styles.module.scss';\n\nexport type NotificationPanelVariants = 'info' | 'warn' | 'alert' | 'error' | 'success';\nexport type NotificationCompactVariants = 'basic' | 'outline';\nexport type NotificationPanelSizes = 'small' | 'medium' | 'large';\nexport type LabelTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'span';\n\nexport interface NotificationPanelProps {\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds inner child elements. */\n children?: React.ReactNode;\n /** Adds inner expander elements. */\n expanderChildren?: React.ReactNode;\n /** Text for expanderButton. */\n expanderButtonText?: string;\n /** Text for expanderButton when closed. */\n expanderButtonClosedText?: string;\n /** Makes expander be open from start. */\n expanderOpenFromStart?: boolean;\n /** Changes the visual representation of the notification panel. */\n variant?: NotificationPanelVariants;\n /** Makes the panel more compact. Available in basic and outline. */\n compactVariant?: NotificationCompactVariants;\n /** Sets a fixed size for the content container. */\n size?: NotificationPanelSizes;\n /** Used in combination with dismissiable property to close the notification panel. */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Toggles the close button in the top right corner. */\n dismissable?: boolean;\n /** Enables a fluid outer container that spans the entire width of parent. */\n fluid?: boolean;\n /** Sets a label for the notification panel. */\n label?: string;\n /** Changes the underlying element of the label. */\n labelHtmlMarkup?: LabelTags;\n /** Close button aria-label */\n ariaLabelCloseBtn?: string;\n /** Custom id for the label */\n labelId?: string;\n /** Custom role for the panel. Default is no role. If variant is alert or crisis, the aria role will be set to \"alert\" unless the role-prop is also set. */\n role?: 'region' | 'alert';\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\ntype WrapFluidProps = Pick<NotificationPanelProps, 'fluid'> & {\n children: React.ReactElement;\n};\n\nconst FluidWrapper: React.FC<WrapFluidProps> = ({ fluid, children }) => {\n if (fluid) {\n const fluidClasses = classNames(styles['fluid-wrapper']);\n\n return <div className={fluidClasses}>{children}</div>;\n }\n return children;\n};\n\nconst NotificationPanel = React.forwardRef<HTMLDivElement, NotificationPanelProps>((props, ref) => {\n const {\n children,\n variant = 'info',\n dismissable = false,\n onClick,\n expanderChildren,\n expanderButtonText,\n expanderButtonClosedText,\n expanderOpenFromStart = false,\n compactVariant,\n label,\n labelHtmlMarkup = 'h1',\n fluid = false,\n size,\n className,\n labelId,\n role,\n testId,\n } = props;\n const uuid = useUuid(labelId);\n const renderContent = (): JSX.Element => {\n const outlineVariant = compactVariant === 'outline';\n const contentClasses = classNames(styles['notification-panel__content']);\n const labelClasses = classNames(styles['notification-panel__label'], {\n [styles['notification-panel__label--no-content']]: !children && !expanderChildren,\n [styles['notification-panel__label--compact']]: !!compactVariant,\n [styles['notification-panel__label--outline']]: outlineVariant,\n });\n const childrenClasses = classNames(styles['notification-panel__children'], {\n [styles['notification-panel__children--with-label']]: label,\n [styles['notification-panel__children--expander-no-label']]: expanderChildren && !label,\n [styles['notification-panel__children--outline']]: outlineVariant,\n });\n const CustomTag = labelHtmlMarkup;\n\n const [expanderOpen, setExpanderOpen] = React.useState(expanderOpenFromStart);\n return (\n <div className={contentClasses} id={!label ? uuid : undefined}>\n {label && (\n <CustomTag className={labelClasses} id={uuid}>\n {label}\n </CustomTag>\n )}\n {children && <div className={childrenClasses}>{children}</div>}\n {expanderChildren && expanderButtonText && expanderButtonClosedText && !compactVariant && (\n <Expander\n title={expanderOpen ? expanderButtonText : expanderButtonClosedText}\n onExpand={setExpanderOpen}\n expanded={expanderOpen}\n testId=\"expand\"\n >\n {expanderChildren}\n </Expander>\n )}\n </div>\n );\n };\n\n const notificationPanelClasses = classNames(\n styles['notification-panel'],\n styles[`notification-panel--${variant}`],\n size && styles[`notification-panel--${size}`],\n {\n [styles['notification-panel--compact']]: !!compactVariant,\n [styles['notification-panel--compact--basic']]: compactVariant === 'basic',\n [styles['notification-panel--compact--outline']]: compactVariant === 'outline',\n [styles['notification-panel--with-content']]: expanderChildren || (label && children),\n [styles['notification-panel--dismissable']]: dismissable,\n },\n className\n );\n\n const ariaRole = role || ((variant === 'alert' || variant === 'error') && 'alert') || undefined;\n const ariaLabelAttributes = ariaRole ? getAriaLabelAttributes({ label, id: uuid }) : undefined;\n\n return (\n <FluidWrapper fluid={fluid}>\n <div\n ref={ref}\n role={ariaRole}\n data-testid={testId}\n data-analyticsid={AnalyticsId.NotificationPanel}\n className={notificationPanelClasses}\n {...ariaLabelAttributes}\n >\n <NotificationBadge\n variant={variant == 'alert' ? 'error' : variant}\n size={compactVariant ? IconSize.XSmall : IconSize.Small}\n className={styles['notification-panel__icon']}\n />\n {dismissable && (\n <span className={styles['notification-panel__close']}>\n <Close ariaLabel={props.ariaLabelCloseBtn} onClick={onClick} color={getColor('black')} />\n </span>\n )}\n {renderContent()}\n </div>\n </FluidWrapper>\n );\n});\n\nexport default NotificationPanel;\n"],"names":["FluidWrapper","fluid","children","fluidClasses","classNames","styles","React","NotificationPanel","props","ref","variant","dismissable","onClick","expanderChildren","expanderButtonText","expanderButtonClosedText","expanderOpenFromStart","compactVariant","label","labelHtmlMarkup","size","className","labelId","role","testId","uuid","useUuid","renderContent","outlineVariant","contentClasses","labelClasses","childrenClasses","CustomTag","expanderOpen","setExpanderOpen","Expander","notificationPanelClasses","ariaRole","ariaLabelAttributes","getAriaLabelAttributes","AnalyticsId","NotificationBadge","IconSize","Close","getColor","NotificationPanel$1"],"mappings":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AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAG;AAAA,MACA,MAAM4B;AAAA,MACN,eAAab;AAAA,MACb,oBAAkBgB,EAAY;AAAA,MAC9B,WAAWJ;AAAA,MACV,GAAGE;AAAA,IAAA;AAAA,IAEJhC,gBAAAA,EAAA;AAAA,MAACmC;AAAA,MAAA;AAAA,QACC,SAAS/B,KAAW,UAAU,UAAUA;AAAA,QACxC,MAAMO,IAAiByB,EAAS,SAASA,EAAS;AAAA,QAClD,WAAWrC,EAAO,0BAA0B;AAAA,MAAA;AAAA,IAC9C;AAAA,IACCM,KACEL,gBAAAA,EAAA,cAAA,QAAA,EAAK,WAAWD,EAAO,2BAA2B,EACjD,GAAAC,gBAAAA,EAAA,cAACqC,GAAM,EAAA,WAAWnC,EAAM,mBAAmB,SAAAI,GAAkB,OAAOgC,EAAS,OAAO,GAAG,CACzF;AAAA,IAEDjB,EAAc;AAAA,EAAA,CAEnB;AAEJ,CAAC,GAEDkB,KAAetC;"}
|
|
@@ -16,7 +16,8 @@ declare const meta: {
|
|
|
16
16
|
size: "large";
|
|
17
17
|
fluid: false;
|
|
18
18
|
label: string;
|
|
19
|
-
|
|
19
|
+
labelHtmlMarkup: "h1";
|
|
20
|
+
variant: "error";
|
|
20
21
|
role: undefined;
|
|
21
22
|
};
|
|
22
23
|
argTypes: {
|
|
@@ -33,6 +34,10 @@ declare const meta: {
|
|
|
33
34
|
label: {
|
|
34
35
|
control: string;
|
|
35
36
|
};
|
|
37
|
+
labelHtmlMarkup: {
|
|
38
|
+
control: string;
|
|
39
|
+
options: import("../Title").TitleTags[];
|
|
40
|
+
};
|
|
36
41
|
variant: {
|
|
37
42
|
control: string;
|
|
38
43
|
options: string[];
|
|
@@ -98,6 +98,20 @@
|
|
|
98
98
|
border: none;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
&--error {
|
|
102
|
+
border: 0.125rem solid $cherry700;
|
|
103
|
+
background-color: $cherry50;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&--error#{&}--compact {
|
|
107
|
+
box-shadow: none;
|
|
108
|
+
background-color: transparent;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&--error#{&}--compact--basic {
|
|
112
|
+
border: none;
|
|
113
|
+
}
|
|
114
|
+
|
|
101
115
|
&--success {
|
|
102
116
|
border: 0.125rem solid $kiwi900;
|
|
103
117
|
background-color: $kiwi50;
|
|
@@ -20,6 +20,7 @@ export type Styles = {
|
|
|
20
20
|
'notification-panel--compact--basic': string;
|
|
21
21
|
'notification-panel--compact--outline': string;
|
|
22
22
|
'notification-panel--dismissable': string;
|
|
23
|
+
'notification-panel--error': string;
|
|
23
24
|
'notification-panel--info': string;
|
|
24
25
|
'notification-panel--large': string;
|
|
25
26
|
'notification-panel--medium': string;
|
|
@@ -1,101 +1,92 @@
|
|
|
1
|
-
import e, { useState as
|
|
2
|
-
import
|
|
3
|
-
import { useBreakpoint as
|
|
4
|
-
import { useHover as
|
|
5
|
-
import { useUuid as
|
|
6
|
-
import { getColor as
|
|
7
|
-
import { breakpoints as
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { Icon as
|
|
12
|
-
import { IconSize as
|
|
13
|
-
import L from "../Icons/CheckFill.js";
|
|
1
|
+
import e, { useState as h } from "react";
|
|
2
|
+
import p from "classnames";
|
|
3
|
+
import { useBreakpoint as z } from "../../hooks/useBreakpoint.js";
|
|
4
|
+
import { useHover as u } from "../../hooks/useHover.js";
|
|
5
|
+
import { useUuid as w } from "../../hooks/useUuid.js";
|
|
6
|
+
import { getColor as H } from "../../theme/currys/color.js";
|
|
7
|
+
import { breakpoints as L } from "../../theme/grid.js";
|
|
8
|
+
import { getAriaLabelAttributes as M } from "../../utils/accessibility.js";
|
|
9
|
+
import X from "../Badge/NotificationBadge.js";
|
|
10
|
+
import y from "../Close/Close.js";
|
|
11
|
+
import { Icon as C } from "../Icon/Icon.js";
|
|
12
|
+
import { IconSize as E } from "../../constants.js";
|
|
14
13
|
import A from "../Icons/ChevronDown.js";
|
|
15
14
|
import U from "../Icons/ChevronUp.js";
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const d = w(), { isHovered: o, hoverRef: p } = h(), a = d < M.lg ? N.XSmall : N.Small, C = {
|
|
24
|
-
info: /* @__PURE__ */ e.createElement(n, { svgIcon: B, color: t.blueberry700, hoverColor: t.blueberry700, size: a, isHovered: o }),
|
|
25
|
-
warn: /* @__PURE__ */ e.createElement(n, { svgIcon: $, color: t.banana700, hoverColor: t.banana700, size: a, isHovered: o }),
|
|
26
|
-
alert: /* @__PURE__ */ e.createElement(n, { svgIcon: q, color: t.cherry700, hoverColor: t.cherry700, size: a, isHovered: o }),
|
|
27
|
-
success: /* @__PURE__ */ e.createElement(n, { svgIcon: L, color: t.kiwi900, hoverColor: t.kiwi900, size: a, isHovered: o })
|
|
28
|
-
}, b = s ? "button" : "span", E = u(
|
|
29
|
-
r["service-message__label-container"],
|
|
30
|
-
s && r["service-message__label-container--has-expander"]
|
|
15
|
+
import B from "../Icons/Forward.js";
|
|
16
|
+
import $ from "../Icons/X.js";
|
|
17
|
+
import s from "../ServiceMessage/styles.module.scss";
|
|
18
|
+
const j = ({ label: c, variant: t, id: m, hasExpander: r, isExpanded: i, dismissable: v, onExpand: l, onDismiss: _, closeBtnText: n }) => {
|
|
19
|
+
const g = z(), { isHovered: a, hoverRef: d } = u(), o = g < L.lg ? E.XSmall : E.Small, N = r ? "button" : "span", f = p(
|
|
20
|
+
s["service-message__label-container"],
|
|
21
|
+
r && s["service-message__label-container--has-expander"]
|
|
31
22
|
);
|
|
32
|
-
return /* @__PURE__ */ e.createElement("div", { className:
|
|
33
|
-
|
|
23
|
+
return /* @__PURE__ */ e.createElement("div", { className: f, ref: d }, /* @__PURE__ */ e.createElement("div", { className: s["service-message__container"] }, /* @__PURE__ */ e.createElement("div", { className: s["service-message__row"] }, /* @__PURE__ */ e.createElement("div", { className: s["service-message__col"] }, /* @__PURE__ */ e.createElement("div", { className: s["service-message__label"] }, /* @__PURE__ */ e.createElement(X, { variant: t == "alert" ? "error" : t, size: o, isHovered: a }), /* @__PURE__ */ e.createElement("h1", { className: s["service-message__title"], id: m }, /* @__PURE__ */ e.createElement(
|
|
24
|
+
N,
|
|
34
25
|
{
|
|
35
|
-
className:
|
|
36
|
-
onClick:
|
|
37
|
-
"aria-expanded":
|
|
26
|
+
className: s["service-message__toggle"],
|
|
27
|
+
onClick: r ? l : void 0,
|
|
28
|
+
"aria-expanded": r ? i : void 0
|
|
38
29
|
},
|
|
39
30
|
c
|
|
40
|
-
)),
|
|
41
|
-
},
|
|
42
|
-
const { hoverRef:
|
|
43
|
-
return /* @__PURE__ */ e.createElement("div", { className:
|
|
31
|
+
)), r && /* @__PURE__ */ e.createElement(C, { size: o, svgIcon: i ? U : A, isHovered: a }), !r && v && /* @__PURE__ */ e.createElement(y, { onClick: _, ariaLabel: n, className: s["service-message__close"] }))))));
|
|
32
|
+
}, F = ({ info: c, extraInfo: t, urlTitle: m, url: r, target: i, dismissable: v, closeBtnText: l, onDismiss: _ }) => {
|
|
33
|
+
const { hoverRef: n, isHovered: g } = u(), { hoverRef: a, isHovered: d } = u(), o = r && m;
|
|
34
|
+
return /* @__PURE__ */ e.createElement("div", { className: s["service-message__container"] }, /* @__PURE__ */ e.createElement("div", { className: s["service-message__row"] }, /* @__PURE__ */ e.createElement("div", { className: s["service-message__col"] }, /* @__PURE__ */ e.createElement("div", { className: s["service-message__content"] }, c && /* @__PURE__ */ e.createElement("p", { className: s["service-message__info"] }, c), t && /* @__PURE__ */ e.createElement("p", { className: p(s["service-message__info"], s["service-message__info--extra"]) }, t), /* @__PURE__ */ e.createElement("div", { className: s["service-message__actions"] }, o && /* @__PURE__ */ e.createElement("a", { className: s["service-message__action"], href: r, ref: n, target: i }, m, /* @__PURE__ */ e.createElement(C, { size: E.XSmall, svgIcon: B, color: H("blueberry", 700), isHovered: g })), v && /* @__PURE__ */ e.createElement(
|
|
44
35
|
"button",
|
|
45
36
|
{
|
|
46
|
-
ref:
|
|
47
|
-
className:
|
|
48
|
-
"aria-label":
|
|
49
|
-
onClick:
|
|
37
|
+
ref: a,
|
|
38
|
+
className: p(s["service-message__action"], s["service-message__action--close"]),
|
|
39
|
+
"aria-label": l,
|
|
40
|
+
onClick: _
|
|
50
41
|
},
|
|
51
|
-
|
|
52
|
-
/* @__PURE__ */ e.createElement(
|
|
42
|
+
l,
|
|
43
|
+
/* @__PURE__ */ e.createElement(C, { size: E.XSmall, svgIcon: $, color: H("blueberry", 700), isHovered: d })
|
|
53
44
|
))))));
|
|
54
|
-
},
|
|
45
|
+
}, q = ({
|
|
55
46
|
label: c,
|
|
56
|
-
dismissable:
|
|
47
|
+
dismissable: t = !0,
|
|
57
48
|
onDismiss: m,
|
|
58
|
-
info:
|
|
49
|
+
info: r,
|
|
59
50
|
extraInfo: i,
|
|
60
|
-
urlTitle:
|
|
61
|
-
url:
|
|
62
|
-
target:
|
|
63
|
-
closeBtnText:
|
|
64
|
-
expanderOpenFromStart:
|
|
65
|
-
variant:
|
|
66
|
-
testId:
|
|
51
|
+
urlTitle: v,
|
|
52
|
+
url: l,
|
|
53
|
+
target: _ = "_self",
|
|
54
|
+
closeBtnText: n = "fjern melding",
|
|
55
|
+
expanderOpenFromStart: g = !1,
|
|
56
|
+
variant: a = "error",
|
|
57
|
+
testId: d
|
|
67
58
|
}) => {
|
|
68
|
-
const [
|
|
69
|
-
|
|
70
|
-
},
|
|
71
|
-
return /* @__PURE__ */ e.createElement("div", { className:
|
|
72
|
-
|
|
59
|
+
const [o, N] = h(g), f = w(), b = !!r || !!i, S = a === "alert" || a === "error" ? "alert" : "region", R = M({ label: c, id: f }), k = () => {
|
|
60
|
+
b && N(!o);
|
|
61
|
+
}, I = p(s["service-message"], s[`service-message--${a}`]);
|
|
62
|
+
return /* @__PURE__ */ e.createElement("div", { className: I, role: S, ...R, "data-testid": d }, /* @__PURE__ */ e.createElement(
|
|
63
|
+
j,
|
|
73
64
|
{
|
|
74
65
|
label: c,
|
|
75
|
-
variant:
|
|
76
|
-
id:
|
|
77
|
-
hasExpander:
|
|
78
|
-
isExpanded:
|
|
79
|
-
dismissable:
|
|
80
|
-
onExpand:
|
|
66
|
+
variant: a,
|
|
67
|
+
id: f,
|
|
68
|
+
hasExpander: b,
|
|
69
|
+
isExpanded: o,
|
|
70
|
+
dismissable: t,
|
|
71
|
+
onExpand: k,
|
|
81
72
|
onDismiss: m,
|
|
82
|
-
closeBtnText:
|
|
73
|
+
closeBtnText: n
|
|
83
74
|
}
|
|
84
|
-
),
|
|
85
|
-
|
|
75
|
+
), b && o && /* @__PURE__ */ e.createElement(
|
|
76
|
+
F,
|
|
86
77
|
{
|
|
87
|
-
info:
|
|
78
|
+
info: r,
|
|
88
79
|
extraInfo: i,
|
|
89
|
-
urlTitle:
|
|
90
|
-
url:
|
|
91
|
-
target:
|
|
92
|
-
dismissable:
|
|
80
|
+
urlTitle: v,
|
|
81
|
+
url: l,
|
|
82
|
+
target: _,
|
|
83
|
+
dismissable: t,
|
|
93
84
|
onDismiss: m,
|
|
94
|
-
closeBtnText:
|
|
85
|
+
closeBtnText: n
|
|
95
86
|
}
|
|
96
87
|
));
|
|
97
|
-
},
|
|
88
|
+
}, te = q;
|
|
98
89
|
export {
|
|
99
|
-
|
|
90
|
+
te as default
|
|
100
91
|
};
|
|
101
92
|
//# sourceMappingURL=ServiceMessage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceMessage.js","sources":["../../../src/components/ServiceMessage/ServiceMessage.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useHover } from '../../hooks/useHover';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\nimport { breakpoints } from '../../theme/grid';\nimport { palette } from '../../theme/palette';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { AnchorLinkTargets } from '../AnchorLink';\nimport Close from '../Close';\nimport Icon, { IconSize } from '../Icon';\nimport CheckFill from '../Icons/CheckFill';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronUp from '../Icons/ChevronUp';\nimport ErrorSignFill from '../Icons/ErrorSignFill';\nimport Forward from '../Icons/Forward';\nimport InfoSignFill from '../Icons/InfoSignFill';\nimport TriangleX from '../Icons/TriangleX';\nimport X from '../Icons/X';\nimport { NotificationPanelVariants } from '../NotificationPanel';\n\nimport styles from './styles.module.scss';\n\ninterface LabelProps {\n label: string;\n variant: NotificationPanelVariants;\n id: string;\n hasExpander: boolean;\n isExpanded: boolean;\n dismissable: boolean;\n onExpand: () => void;\n onDismiss?: () => void;\n closeBtnText?: string;\n}\n\nconst Label: React.FC<LabelProps> = ({ label, variant, id, hasExpander, isExpanded, dismissable, onExpand, onDismiss, closeBtnText }) => {\n const breakpoint = useBreakpoint();\n const { isHovered, hoverRef } = useHover<HTMLDivElement>();\n\n const iconSize = breakpoint < breakpoints.lg ? IconSize.XSmall : IconSize.Small;\n const variantToIconMap = {\n info: (\n <Icon svgIcon={InfoSignFill} color={palette.blueberry700} hoverColor={palette.blueberry700} size={iconSize} isHovered={isHovered} />\n ),\n warn: <Icon svgIcon={ErrorSignFill} color={palette.banana700} hoverColor={palette.banana700} size={iconSize} isHovered={isHovered} />,\n alert: <Icon svgIcon={TriangleX} color={palette.cherry700} hoverColor={palette.cherry700} size={iconSize} isHovered={isHovered} />,\n success: <Icon svgIcon={CheckFill} color={palette.kiwi900} hoverColor={palette.kiwi900} size={iconSize} isHovered={isHovered} />,\n };\n const CustomTag = hasExpander ? 'button' : 'span';\n\n const labelContainerClasses = classNames(\n styles['service-message__label-container'],\n hasExpander && styles[`service-message__label-container--has-expander`]\n );\n\n return (\n <div className={labelContainerClasses} ref={hoverRef}>\n <div className={styles['service-message__container']}>\n <div className={styles['service-message__row']}>\n <div className={styles['service-message__col']}>\n <div className={styles['service-message__label']}>\n {variantToIconMap[variant]}\n <h1 className={styles['service-message__title']} id={id}>\n <CustomTag\n className={styles['service-message__toggle']}\n onClick={hasExpander ? onExpand : undefined}\n aria-expanded={hasExpander ? isExpanded : undefined}\n >\n {label}\n </CustomTag>\n </h1>\n {hasExpander && <Icon size={iconSize} svgIcon={isExpanded ? ChevronUp : ChevronDown} isHovered={isHovered} />}\n {!hasExpander && dismissable && (\n <Close onClick={onDismiss} ariaLabel={closeBtnText} className={styles['service-message__close']} />\n )}\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n};\n\ninterface ContentProps {\n info?: string;\n extraInfo?: string;\n urlTitle?: string;\n url?: string;\n target?: AnchorLinkTargets;\n dismissable: boolean;\n onDismiss?: () => void;\n closeBtnText?: string;\n}\n\nconst Content: React.FC<ContentProps> = ({ info, extraInfo, urlTitle, url, target, dismissable, closeBtnText, onDismiss }) => {\n const { hoverRef: readMoreRef, isHovered: readMoreHoverRefIsHovered } = useHover<HTMLAnchorElement>();\n const { hoverRef: closeButtonRef, isHovered: closeButtonIsHovered } = useHover<HTMLButtonElement>();\n\n const hasUrl = url && urlTitle;\n\n return (\n <div className={styles['service-message__container']}>\n <div className={styles['service-message__row']}>\n <div className={styles['service-message__col']}>\n <div className={styles['service-message__content']}>\n {info && <p className={styles['service-message__info']}>{info}</p>}\n {extraInfo && (\n <p className={classNames(styles['service-message__info'], styles['service-message__info--extra'])}>{extraInfo}</p>\n )}\n <div className={styles['service-message__actions']}>\n {hasUrl && (\n <a className={styles['service-message__action']} href={url} ref={readMoreRef} target={target}>\n {urlTitle}\n <Icon size={IconSize.XSmall} svgIcon={Forward} color={getColor('blueberry', 700)} isHovered={readMoreHoverRefIsHovered} />\n </a>\n )}\n\n {dismissable && (\n <button\n ref={closeButtonRef}\n className={classNames(styles['service-message__action'], styles['service-message__action--close'])}\n aria-label={closeBtnText}\n onClick={onDismiss}\n >\n {closeBtnText}\n <Icon size={IconSize.XSmall} svgIcon={X} color={getColor('blueberry', 700)} isHovered={closeButtonIsHovered} />\n </button>\n )}\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nexport interface ServiceMessageProps {\n /** Sets a label for the notification panel. */\n label: string;\n /** String displayed in service-message when expanded */\n info?: string;\n /** String displayed in service-message when expanded, with a smaller font */\n extraInfo?: string;\n /** function that runs on dismiss */\n onDismiss?: () => void;\n /** Allows for dismiss to be an option, also for ServiceMessage with only label as content */\n dismissable?: boolean;\n /** Makes expander be open from start. */\n expanderOpenFromStart?: boolean;\n /** Name that describes a url-link for the user*/\n urlTitle?: string;\n /** Url for further information*/\n url?: string;\n /** Sets target for the anchorlink to the url*/\n target?: AnchorLinkTargets;\n /** Text on close-button in service messages. */\n closeBtnText?: string;\n /** Changes the visual representation. */\n variant?: NotificationPanelVariants;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst ServiceMessage: React.FC<ServiceMessageProps> = ({\n label,\n dismissable = true,\n onDismiss,\n info,\n extraInfo,\n urlTitle,\n url,\n target = '_self',\n closeBtnText = 'fjern melding',\n expanderOpenFromStart = false,\n variant = 'alert',\n testId,\n}) => {\n const [isExpanded, setIsExpanded] = useState<boolean>(expanderOpenFromStart);\n\n const labelId = useUuid();\n const hasExpander = !!info || !!extraInfo;\n\n const ariaRole = variant === 'alert' ? 'alert' : 'region';\n const ariaLabelAttributes = getAriaLabelAttributes({ label, id: labelId });\n\n const handleClick = (): void => {\n hasExpander && setIsExpanded(!isExpanded);\n };\n\n const classes = classNames(styles['service-message'], styles[`service-message--${variant}`]);\n\n return (\n <div className={classes} role={ariaRole} {...ariaLabelAttributes} data-testid={testId}>\n <Label\n label={label}\n variant={variant}\n id={labelId}\n hasExpander={hasExpander}\n isExpanded={isExpanded}\n dismissable={dismissable}\n onExpand={handleClick}\n onDismiss={onDismiss}\n closeBtnText={closeBtnText}\n />\n {hasExpander && isExpanded && (\n <Content\n info={info}\n extraInfo={extraInfo}\n urlTitle={urlTitle}\n url={url}\n target={target}\n dismissable={dismissable}\n onDismiss={onDismiss}\n closeBtnText={closeBtnText}\n />\n )}\n </div>\n );\n};\n\nexport default ServiceMessage;\n"],"names":["Label","label","variant","id","hasExpander","isExpanded","dismissable","onExpand","onDismiss","closeBtnText","breakpoint","useBreakpoint","isHovered","hoverRef","useHover","iconSize","breakpoints","IconSize","variantToIconMap","React","Icon","InfoSignFill","palette","ErrorSignFill","TriangleX","CheckFill","CustomTag","labelContainerClasses","classNames","styles","ChevronUp","ChevronDown","Close","Content","info","extraInfo","urlTitle","url","target","readMoreRef","readMoreHoverRefIsHovered","closeButtonRef","closeButtonIsHovered","hasUrl","Forward","getColor","X","ServiceMessage","expanderOpenFromStart","testId","setIsExpanded","useState","labelId","useUuid","ariaRole","ariaLabelAttributes","getAriaLabelAttributes","handleClick","classes","ServiceMessage$1"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsCA,MAAMA,IAA8B,CAAC,EAAE,OAAAC,GAAO,SAAAC,GAAS,IAAAC,GAAI,aAAAC,GAAa,YAAAC,GAAY,aAAAC,GAAa,UAAAC,GAAU,WAAAC,GAAW,cAAAC,EAAA,MAAmB;AACvI,QAAMC,IAAaC,KACb,EAAE,WAAAC,GAAW,UAAAC,EAAS,IAAIC,EAAyB,GAEnDC,IAAWL,IAAaM,EAAY,KAAKC,EAAS,SAASA,EAAS,OACpEC,IAAmB;AAAA,IACvB,MACEC,gBAAAA,EAAA,cAACC,GAAK,EAAA,SAASC,GAAc,OAAOC,EAAQ,cAAc,YAAYA,EAAQ,cAAc,MAAMP,GAAU,WAAAH,GAAsB;AAAA,IAEpI,MAAMO,gBAAAA,EAAA,cAACC,GAAK,EAAA,SAASG,GAAe,OAAOD,EAAQ,WAAW,YAAYA,EAAQ,WAAW,MAAMP,GAAU,WAAAH,GAAsB;AAAA,IACnI,OAAOO,gBAAAA,EAAA,cAACC,GAAK,EAAA,SAASI,GAAW,OAAOF,EAAQ,WAAW,YAAYA,EAAQ,WA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MACA,WAAAE;AAAA,MACA,cAAAC;AAAA,IAAA;AAAA,EAAA,CAGN;AAEJ,GAEAkD,KAAeZ;"}
|
|
1
|
+
{"version":3,"file":"ServiceMessage.js","sources":["../../../src/components/ServiceMessage/ServiceMessage.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useHover } from '../../hooks/useHover';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\nimport { breakpoints } from '../../theme/grid';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { AnchorLinkTargets } from '../AnchorLink';\nimport NotificationBadge from '../Badge/NotificationBadge';\nimport Close from '../Close';\nimport Icon, { IconSize } from '../Icon';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronUp from '../Icons/ChevronUp';\nimport Forward from '../Icons/Forward';\nimport X from '../Icons/X';\nimport { NotificationPanelVariants } from '../NotificationPanel';\n\nimport styles from './styles.module.scss';\n\ninterface LabelProps {\n label: string;\n variant: NotificationPanelVariants;\n id: string;\n hasExpander: boolean;\n isExpanded: boolean;\n dismissable: boolean;\n onExpand: () => void;\n onDismiss?: () => void;\n closeBtnText?: string;\n}\n\nconst Label: React.FC<LabelProps> = ({ label, variant, id, hasExpander, isExpanded, dismissable, onExpand, onDismiss, closeBtnText }) => {\n const breakpoint = useBreakpoint();\n const { isHovered, hoverRef } = useHover<HTMLDivElement>();\n\n const iconSize = breakpoint < breakpoints.lg ? IconSize.XSmall : IconSize.Small;\n const CustomTag = hasExpander ? 'button' : 'span';\n\n const labelContainerClasses = classNames(\n styles['service-message__label-container'],\n hasExpander && styles[`service-message__label-container--has-expander`]\n );\n\n return (\n <div className={labelContainerClasses} ref={hoverRef}>\n <div className={styles['service-message__container']}>\n <div className={styles['service-message__row']}>\n <div className={styles['service-message__col']}>\n <div className={styles['service-message__label']}>\n <NotificationBadge variant={variant == 'alert' ? 'error' : variant} size={iconSize} isHovered={isHovered} />\n <h1 className={styles['service-message__title']} id={id}>\n <CustomTag\n className={styles['service-message__toggle']}\n onClick={hasExpander ? onExpand : undefined}\n aria-expanded={hasExpander ? isExpanded : undefined}\n >\n {label}\n </CustomTag>\n </h1>\n {hasExpander && <Icon size={iconSize} svgIcon={isExpanded ? ChevronUp : ChevronDown} isHovered={isHovered} />}\n {!hasExpander && dismissable && (\n <Close onClick={onDismiss} ariaLabel={closeBtnText} className={styles['service-message__close']} />\n )}\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n};\n\ninterface ContentProps {\n info?: string;\n extraInfo?: string;\n urlTitle?: string;\n url?: string;\n target?: AnchorLinkTargets;\n dismissable: boolean;\n onDismiss?: () => void;\n closeBtnText?: string;\n}\n\nconst Content: React.FC<ContentProps> = ({ info, extraInfo, urlTitle, url, target, dismissable, closeBtnText, onDismiss }) => {\n const { hoverRef: readMoreRef, isHovered: readMoreHoverRefIsHovered } = useHover<HTMLAnchorElement>();\n const { hoverRef: closeButtonRef, isHovered: closeButtonIsHovered } = useHover<HTMLButtonElement>();\n\n const hasUrl = url && urlTitle;\n\n return (\n <div className={styles['service-message__container']}>\n <div className={styles['service-message__row']}>\n <div className={styles['service-message__col']}>\n <div className={styles['service-message__content']}>\n {info && <p className={styles['service-message__info']}>{info}</p>}\n {extraInfo && (\n <p className={classNames(styles['service-message__info'], styles['service-message__info--extra'])}>{extraInfo}</p>\n )}\n <div className={styles['service-message__actions']}>\n {hasUrl && (\n <a className={styles['service-message__action']} href={url} ref={readMoreRef} target={target}>\n {urlTitle}\n <Icon size={IconSize.XSmall} svgIcon={Forward} color={getColor('blueberry', 700)} isHovered={readMoreHoverRefIsHovered} />\n </a>\n )}\n\n {dismissable && (\n <button\n ref={closeButtonRef}\n className={classNames(styles['service-message__action'], styles['service-message__action--close'])}\n aria-label={closeBtnText}\n onClick={onDismiss}\n >\n {closeBtnText}\n <Icon size={IconSize.XSmall} svgIcon={X} color={getColor('blueberry', 700)} isHovered={closeButtonIsHovered} />\n </button>\n )}\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nexport interface ServiceMessageProps {\n /** Sets a label for the notification panel. */\n label: string;\n /** String displayed in service-message when expanded */\n info?: string;\n /** String displayed in service-message when expanded, with a smaller font */\n extraInfo?: string;\n /** function that runs on dismiss */\n onDismiss?: () => void;\n /** Allows for dismiss to be an option, also for ServiceMessage with only label as content */\n dismissable?: boolean;\n /** Makes expander be open from start. */\n expanderOpenFromStart?: boolean;\n /** Name that describes a url-link for the user*/\n urlTitle?: string;\n /** Url for further information*/\n url?: string;\n /** Sets target for the anchorlink to the url*/\n target?: AnchorLinkTargets;\n /** Text on close-button in service messages. */\n closeBtnText?: string;\n /** Changes the visual representation. */\n variant?: NotificationPanelVariants;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst ServiceMessage: React.FC<ServiceMessageProps> = ({\n label,\n dismissable = true,\n onDismiss,\n info,\n extraInfo,\n urlTitle,\n url,\n target = '_self',\n closeBtnText = 'fjern melding',\n expanderOpenFromStart = false,\n variant = 'error',\n testId,\n}) => {\n const [isExpanded, setIsExpanded] = useState<boolean>(expanderOpenFromStart);\n\n const labelId = useUuid();\n const hasExpander = !!info || !!extraInfo;\n\n const ariaRole = variant === 'alert' || variant === 'error' ? 'alert' : 'region';\n const ariaLabelAttributes = getAriaLabelAttributes({ label, id: labelId });\n\n const handleClick = (): void => {\n hasExpander && setIsExpanded(!isExpanded);\n };\n\n const classes = classNames(styles['service-message'], styles[`service-message--${variant}`]);\n\n return (\n <div className={classes} role={ariaRole} {...ariaLabelAttributes} data-testid={testId}>\n <Label\n label={label}\n variant={variant}\n id={labelId}\n hasExpander={hasExpander}\n isExpanded={isExpanded}\n dismissable={dismissable}\n onExpand={handleClick}\n onDismiss={onDismiss}\n closeBtnText={closeBtnText}\n />\n {hasExpander && isExpanded && (\n <Content\n info={info}\n extraInfo={extraInfo}\n urlTitle={urlTitle}\n url={url}\n target={target}\n dismissable={dismissable}\n onDismiss={onDismiss}\n closeBtnText={closeBtnText}\n />\n )}\n </div>\n );\n};\n\nexport default ServiceMessage;\n"],"names":["Label","label","variant","id","hasExpander","isExpanded","dismissable","onExpand","onDismiss","closeBtnText","breakpoint","useBreakpoint","isHovered","hoverRef","useHover","iconSize","breakpoints","IconSize","CustomTag","labelContainerClasses","classNames","styles","React","NotificationBadge","Icon","ChevronUp","ChevronDown","Close","Content","info","extraInfo","urlTitle","url","target","readMoreRef","readMoreHoverRefIsHovered","closeButtonRef","closeButtonIsHovered","hasUrl","Forward","getColor","X","ServiceMessage","expanderOpenFromStart","testId","setIsExpanded","useState","labelId","useUuid","ariaRole","ariaLabelAttributes","getAriaLabelAttributes","handleClick","classes","ServiceMessage$1"],"mappings":";;;;;;;;;;;;;;;;;AAkCA,MAAMA,IAA8B,CAAC,EAAE,OAAAC,GAAO,SAAAC,GAAS,IAAAC,GAAI,aAAAC,GAAa,YAAAC,GAAY,aAAAC,GAAa,UAAAC,GAAU,WAAAC,GAAW,cAAAC,EAAA,MAAmB;AACvI,QAAMC,IAAaC,KACb,EAAE,WAAAC,GAAW,UAAAC,EAAS,IAAIC,EAAyB,GAEnDC,IAAWL,IAAaM,EAAY,KAAKC,EAAS,SAASA,EAAS,OACpEC,IAAYd,IAAc,WAAW,QAErCe,IAAwBC;AAAA,IAC5BC,EAAO,kCAAkC;AAAA,IACzCjB,KAAeiB,EAAO,gDAAgD;AAAA,EAAA;AAItE,SAAAC,gBAAAA,EAAA,cAAC,SAAI,WAAWH,GAAuB,KAAKN,EAC1C,GAAAS,gBAAAA,EAAA,cAAC,SAAI,WAAWD,EAAO,4BAA4B,EACjD,GAAAC,gBAAAA,EAAA,cAAC,SAAI,WAAWD,EAAO,sBAAsB,EAC3C,GAAAC,gBAAAA,EAAA,cAAC,OAAI,EAAA,WAAWD,EAAO,sBAAsB,KAC1CC,gBAAAA,EAAA,cAAA,OAAA,EAAI,WAAWD,EAAO,wBAAwB,KAC5CC,gBAAAA,EAAA,cAAAC,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uB,EAAE,OAAAlD,GAAO,IAAI8C,GAAS,GAEnEK,IAAc,MAAY;AACf,IAAAhD,KAAAyC,EAAc,CAACxC,CAAU;AAAA,EAAA,GAGpCgD,IAAUjC,EAAWC,EAAO,iBAAiB,GAAGA,EAAO,oBAAoBnB,CAAO,EAAE,CAAC;AAGzF,SAAAoB,gBAAAA,EAAA,cAAC,SAAI,WAAW+B,GAAS,MAAMJ,GAAW,GAAGC,GAAqB,eAAaN,EAC7E,GAAAtB,gBAAAA,EAAA;AAAA,IAACtB;AAAA,IAAA;AAAA,MACC,OAAAC;AAAA,MACA,SAAAC;AAAA,MACA,IAAI6C;AAAA,MACJ,aAAA3C;AAAA,MACA,YAAAC;AAAA,MACA,aAAAC;AAAA,MACA,UAAU8C;AAAA,MACV,WAAA5C;AAAA,MACA,cAAAC;AAAA,IAAA;AAAA,EAAA,GAEDL,KAAeC,KACdiB,gBAAAA,EAAA;AAAA,IAACM;AAAA,IAAA;AAAA,MACC,MAAAC;AAAA,MACA,WAAAC;AAAA,MACA,UAAAC;AAAA,MACA,KAAAC;AAAA,MACA,QAAAC;AAAA,MACA,aAAA3B;AAAA,MACA,WAAAE;AAAA,MACA,cAAAC;AAAA,IAAA;AAAA,EAAA,CAGN;AAEJ,GAEA6C,KAAeZ;"}
|
|
@@ -67,6 +67,19 @@
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
&--error {
|
|
71
|
+
background-color: $cherry50;
|
|
72
|
+
|
|
73
|
+
&:hover {
|
|
74
|
+
background-color: rgba-to-rgb(rgba($cherry500, 0.1), $cherry50);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&#{$servicemessage},
|
|
78
|
+
&#{$servicemessage}__label-container {
|
|
79
|
+
border-color: $cherry700;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
70
83
|
&__container {
|
|
71
84
|
@include make-container;
|
|
72
85
|
@include make-container-max-widths;
|
|
@@ -16,6 +16,7 @@ export type Styles = {
|
|
|
16
16
|
'service-message__title': string;
|
|
17
17
|
'service-message__toggle': string;
|
|
18
18
|
'service-message--alert': string;
|
|
19
|
+
'service-message--error': string;
|
|
19
20
|
'service-message--info': string;
|
|
20
21
|
'service-message--success': string;
|
|
21
22
|
'service-message--warn': string;
|
package/package.json
CHANGED