@justeattakeaway/pie-notification 0.5.5 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,6 +28,14 @@
28
28
  },
29
29
  "default": "['h2', 'h3', 'h4', 'h5', 'h6']"
30
30
  },
31
+ {
32
+ "kind": "variable",
33
+ "name": "positions",
34
+ "type": {
35
+ "text": "['inline-content', 'full-width']"
36
+ },
37
+ "default": "['inline-content', 'full-width']"
38
+ },
31
39
  {
32
40
  "kind": "variable",
33
41
  "name": "componentSelector",
@@ -67,6 +75,14 @@
67
75
  "name": "ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT",
68
76
  "default": "`${componentSelector}-supporting-action-click`",
69
77
  "description": "Event name for when the notification supporting action is clicked."
78
+ },
79
+ {
80
+ "kind": "variable",
81
+ "name": "defaultProps",
82
+ "type": {
83
+ "text": "DefaultProps"
84
+ },
85
+ "default": "{\n isOpen: true,\n variant: 'neutral',\n position: 'inline-content',\n isDismissible: true,\n isCompact: false,\n headingLevel: 'h2',\n hideIcon: false,\n hasStackedActions: false,\n}"
70
86
  }
71
87
  ],
72
88
  "exports": [
@@ -86,6 +102,14 @@
86
102
  "module": "src/defs.js"
87
103
  }
88
104
  },
105
+ {
106
+ "kind": "js",
107
+ "name": "positions",
108
+ "declaration": {
109
+ "name": "positions",
110
+ "module": "src/defs.js"
111
+ }
112
+ },
89
113
  {
90
114
  "kind": "js",
91
115
  "name": "componentSelector",
@@ -133,6 +157,14 @@
133
157
  "name": "ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT",
134
158
  "module": "src/defs.js"
135
159
  }
160
+ },
161
+ {
162
+ "kind": "js",
163
+ "name": "defaultProps",
164
+ "declaration": {
165
+ "name": "defaultProps",
166
+ "module": "src/defs.js"
167
+ }
136
168
  }
137
169
  ]
138
170
  },
@@ -148,11 +180,7 @@
148
180
  {
149
181
  "kind": "field",
150
182
  "name": "isOpen",
151
- "type": {
152
- "text": "boolean"
153
- },
154
183
  "privacy": "public",
155
- "default": "true",
156
184
  "attribute": "isOpen"
157
185
  },
158
186
  {
@@ -162,27 +190,27 @@
162
190
  "text": "NonNullable<NotificationProps['variant']>"
163
191
  },
164
192
  "privacy": "public",
165
- "default": "'neutral'",
166
193
  "attribute": "variant"
167
194
  },
168
195
  {
169
196
  "kind": "field",
170
- "name": "isDismissible",
197
+ "name": "position",
171
198
  "type": {
172
- "text": "boolean"
199
+ "text": "NonNullable<NotificationProps['position']>"
173
200
  },
174
201
  "privacy": "public",
175
- "default": "true",
202
+ "attribute": "position"
203
+ },
204
+ {
205
+ "kind": "field",
206
+ "name": "isDismissible",
207
+ "privacy": "public",
176
208
  "attribute": "isDismissible"
177
209
  },
178
210
  {
179
211
  "kind": "field",
180
212
  "name": "isCompact",
181
- "type": {
182
- "text": "boolean"
183
- },
184
213
  "privacy": "public",
185
- "default": "false",
186
214
  "attribute": "isCompact"
187
215
  },
188
216
  {
@@ -201,29 +229,14 @@
201
229
  "text": "NonNullable<NotificationProps['headingLevel']>"
202
230
  },
203
231
  "privacy": "public",
204
- "default": "'h2'",
205
232
  "attribute": "headingLevel"
206
233
  },
207
234
  {
208
235
  "kind": "field",
209
236
  "name": "hideIcon",
210
- "type": {
211
- "text": "boolean"
212
- },
213
237
  "privacy": "public",
214
- "default": "false",
215
238
  "attribute": "hideIcon"
216
239
  },
217
- {
218
- "kind": "field",
219
- "name": "hideCloseIcon",
220
- "type": {
221
- "text": "boolean"
222
- },
223
- "privacy": "public",
224
- "default": "false",
225
- "attribute": "hideCloseIcon"
226
- },
227
240
  {
228
241
  "kind": "field",
229
242
  "name": "leadingAction",
@@ -245,11 +258,7 @@
245
258
  {
246
259
  "kind": "field",
247
260
  "name": "hasStackedActions",
248
- "type": {
249
- "text": "boolean"
250
- },
251
261
  "privacy": "public",
252
- "default": "false",
253
262
  "attribute": "hasStackedActions"
254
263
  },
255
264
  {
@@ -277,15 +286,6 @@
277
286
  "privacy": "protected",
278
287
  "default": "false"
279
288
  },
280
- {
281
- "kind": "field",
282
- "name": "_hasContentGutter",
283
- "type": {
284
- "text": "boolean"
285
- },
286
- "privacy": "protected",
287
- "default": "false"
288
- },
289
289
  {
290
290
  "kind": "method",
291
291
  "name": "updateIconProperties",
@@ -509,10 +509,6 @@
509
509
  "attributes": [
510
510
  {
511
511
  "name": "isOpen",
512
- "type": {
513
- "text": "boolean"
514
- },
515
- "default": "true",
516
512
  "fieldName": "isOpen"
517
513
  },
518
514
  {
@@ -520,23 +516,21 @@
520
516
  "type": {
521
517
  "text": "NonNullable<NotificationProps['variant']>"
522
518
  },
523
- "default": "'neutral'",
524
519
  "fieldName": "variant"
525
520
  },
526
521
  {
527
- "name": "isDismissible",
522
+ "name": "position",
528
523
  "type": {
529
- "text": "boolean"
524
+ "text": "NonNullable<NotificationProps['position']>"
530
525
  },
531
- "default": "true",
526
+ "fieldName": "position"
527
+ },
528
+ {
529
+ "name": "isDismissible",
532
530
  "fieldName": "isDismissible"
533
531
  },
534
532
  {
535
533
  "name": "isCompact",
536
- "type": {
537
- "text": "boolean"
538
- },
539
- "default": "false",
540
534
  "fieldName": "isCompact"
541
535
  },
542
536
  {
@@ -551,25 +545,12 @@
551
545
  "type": {
552
546
  "text": "NonNullable<NotificationProps['headingLevel']>"
553
547
  },
554
- "default": "'h2'",
555
548
  "fieldName": "headingLevel"
556
549
  },
557
550
  {
558
551
  "name": "hideIcon",
559
- "type": {
560
- "text": "boolean"
561
- },
562
- "default": "false",
563
552
  "fieldName": "hideIcon"
564
553
  },
565
- {
566
- "name": "hideCloseIcon",
567
- "type": {
568
- "text": "boolean"
569
- },
570
- "default": "false",
571
- "fieldName": "hideCloseIcon"
572
- },
573
554
  {
574
555
  "name": "leadingAction",
575
556
  "type": {
@@ -586,10 +567,6 @@
586
567
  },
587
568
  {
588
569
  "name": "hasStackedActions",
589
- "type": {
590
- "text": "boolean"
591
- },
592
- "default": "false",
593
570
  "fieldName": "hasStackedActions"
594
571
  }
595
572
  ],
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
1
2
  import type { CSSResult } from 'lit';
2
3
  import type { LitElement } from 'lit';
3
4
  import type { nothing } from 'lit';
@@ -19,6 +20,10 @@ export declare const componentClass = "c-notification";
19
20
 
20
21
  export declare const componentSelector = "pie-notification";
21
22
 
23
+ export declare type DefaultProps = ComponentDefaultPropsGeneric<NotificationProps, 'isOpen' | 'variant' | 'position' | 'isDismissible' | 'isCompact' | 'headingLevel' | 'hideIcon' | 'hasStackedActions'>;
24
+
25
+ export declare const defaultProps: DefaultProps;
26
+
22
27
  export declare const headingLevels: readonly ["h2", "h3", "h4", "h5", "h6"];
23
28
 
24
29
  export declare interface NotificationProps {
@@ -26,6 +31,10 @@ export declare interface NotificationProps {
26
31
  * Set the variant of the notification.
27
32
  */
28
33
  variant?: typeof variants[number];
34
+ /**
35
+ * The position of the notification defining proper styles if the component appear within the content or at the top of the interface.
36
+ */
37
+ position?: typeof positions[number];
29
38
  /**
30
39
  * When true, allows dismissing the notification by clicking on the close button.
31
40
  */
@@ -102,24 +111,19 @@ export declare const ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT: string;
102
111
  export declare class PieNotification extends LitElement implements NotificationProps {
103
112
  isOpen: boolean;
104
113
  variant: NonNullable<NotificationProps['variant']>;
114
+ position: NonNullable<NotificationProps['position']>;
105
115
  isDismissible: boolean;
106
116
  isCompact: boolean;
107
117
  heading: string;
108
118
  headingLevel: NonNullable<NotificationProps['headingLevel']>;
109
119
  hideIcon: boolean;
110
- hideCloseIcon: boolean;
111
120
  leadingAction: NotificationProps['leadingAction'];
112
121
  supportingAction: NotificationProps['supportingAction'];
113
122
  hasStackedActions: boolean;
114
123
  _iconSlot: Array<HTMLElement>;
115
124
  protected _hasExternalIcon: boolean;
116
125
  protected _hasIconClass: boolean;
117
- protected _hasContentGutter: boolean;
118
126
  static styles: CSSResult;
119
- /**
120
- * Lifecycle method executed after component renders.
121
- */
122
- protected firstUpdated(): void;
123
127
  /**
124
128
  * Lifecycle method executed when component is about to update.
125
129
  * It update icon properties if variant has changes.
@@ -233,6 +237,8 @@ export declare class PieNotification extends LitElement implements NotificationP
233
237
  render(): TemplateResult | typeof nothing;
234
238
  }
235
239
 
240
+ export declare const positions: readonly ["inline-content", "full-width"];
241
+
236
242
  export declare const variants: readonly ["neutral", "neutral-alternative", "info", "success", "warning", "error"];
237
243
 
238
244
  export { }
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { unsafeCSS as _, LitElement as N, nothing as a } from "lit";
2
- import { html as l, unsafeStatic as O } from "lit/static-html.js";
3
- import { validPropertyValues as m, defineCustomElement as x, dispatchCustomEvent as u } from "@justeattakeaway/pie-webc-core";
4
- import { property as s, queryAssignedElements as E, state as g } from "lit/decorators.js";
1
+ import { unsafeCSS as O, LitElement as x, nothing as c } from "lit";
2
+ import { html as d, unsafeStatic as E } from "lit/static-html.js";
3
+ import { validPropertyValues as v, defineCustomElement as k, dispatchCustomEvent as g } from "@justeattakeaway/pie-webc-core";
4
+ import { property as l, queryAssignedElements as w, state as $ } from "lit/decorators.js";
5
5
  import "@justeattakeaway/pie-button";
6
6
  import "@justeattakeaway/pie-icon-button";
7
7
  import "@justeattakeaway/pie-icons-webc/dist/IconAlertCircle.js";
@@ -9,37 +9,40 @@ import "@justeattakeaway/pie-icons-webc/dist/IconAlertTriangle.js";
9
9
  import "@justeattakeaway/pie-icons-webc/dist/IconCheckCircle.js";
10
10
  import "@justeattakeaway/pie-icons-webc/dist/IconClose.js";
11
11
  import "@justeattakeaway/pie-icons-webc/dist/IconInfoCircle.js";
12
- const k = ["neutral", "neutral-alternative", "info", "success", "warning", "error"], A = ["h2", "h3", "h4", "h5", "h6"], o = "pie-notification", h = "c-notification", z = `${o}-close`, S = `${o}-open`, V = `${o}-leading-action-click`, w = `${o}-supporting-action-click`, T = `*,*:after,*:before{box-sizing:inherit}.c-notification{--notification-border-radius: var(--dt-radius-rounded-c);--notification-background-color: var(--dt-color-container-subtle);--notification-direction: column;--notification-icon-size-override: 22px;--notification-heading-font-size: calc(var(--dt-font-size-20) * 1px);--notification-heading-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--notification-font-size: calc(var(--dt-font-size-16) * 1px);--notification-line-height: calc(var(--dt-font-size-16-line-height) * 1px);--notification-icon-fill: var(--dt-color-content-default);padding:var(--dt-spacing-d);border-radius:var(--notification-border-radius);background-color:var(--notification-background-color);position:relative;display:flex;flex-direction:var(--notification-direction);gap:var(--dt-spacing-d);font-size:var(--notification-font-size);line-height:var(--notification-line-height)}.c-notification h1,.c-notification h2,.c-notification h3,.c-notification h4,.c-notification h5,.c-notification h6{margin:0;font-size:var(--notification-heading-font-size);line-height:var(--notification-heading-line-height)}.c-notification[isCompact]{--notification-direction: row}.c-notification[variant=neutral-alternative]{--notification-background-color: var(--dt-color-container-default)}.c-notification[variant=info]{--notification-background-color: var(--dt-color-support-info-02);--notification-icon-fill: var(--dt-color-blue)}.c-notification[variant=success]{--notification-background-color: var(--dt-color-support-positive-02)}.c-notification[variant=warning]{--notification-background-color: var(--dt-color-support-warning-02)}.c-notification[variant=error]{--notification-background-color: var(--dt-color-support-error-02);--notification-icon-fill: var(--dt-color-red)}.c-notification-content-section{display:flex;flex-direction:row}.c-notification-content-section article[hasGutter]{padding-inline-end:var(--dt-spacing-e)}.c-notification-content-section .has-icon{display:block ruby;margin-inline-end:var(--dt-spacing-c)}.c-notification-heading-icon{padding-block-start:var(--dt-spacing-a);color:var(--notification-icon-fill)}.c-notification-icon-close{position:absolute;inset-block-start:var(--dt-spacing-b);inset-inline-end:var(--dt-spacing-b)}.c-notification-footer{display:flex;flex-direction:row;justify-content:flex-end;gap:var(--dt-spacing-d)}.c-notification-footer[isCompact]{align-self:flex-end}@media (max-width: 640px){.c-notification-footer[isStacked]{flex-direction:column}}
12
+ const A = ["neutral", "neutral-alternative", "info", "success", "warning", "error"], z = ["h2", "h3", "h4", "h5", "h6"], S = ["inline-content", "full-width"], o = "pie-notification", h = "c-notification", D = `${o}-close`, V = `${o}-open`, T = `${o}-leading-action-click`, B = `${o}-supporting-action-click`, r = {
13
+ isOpen: !0,
14
+ variant: "neutral",
15
+ position: "inline-content",
16
+ isDismissible: !0,
17
+ isCompact: !1,
18
+ headingLevel: "h2",
19
+ hideIcon: !1,
20
+ hasStackedActions: !1
21
+ }, L = `*,*:after,*:before{box-sizing:inherit}.c-notification{--notification-border-radius: var(--dt-radius-rounded-c);--notification-background-color: var(--dt-color-container-subtle);--notification-direction: column;--notification-heading-font-size: calc(var(--dt-font-heading-s-size--narrow) * 1px);--notification-heading-line-height: calc(var(--dt-font-heading-s-line-height--narrow) * 1px);--notification-font-size: calc(var(--dt-font-body-l-size) * 1px);--notification-line-height: calc(var(--dt-font-body-l-line-height) * 1px);--notification-icon-fill: var(--dt-color-content-default);--notification-close-icon-offset: var(--dt-spacing-b);--notification-heading-icon-offset: 2px;padding:var(--dt-spacing-d);border-radius:var(--notification-border-radius);background-color:var(--notification-background-color);position:relative;display:flex;flex-direction:var(--notification-direction);gap:var(--dt-spacing-d);font-size:var(--notification-font-size);line-height:var(--notification-line-height)}.c-notification[isCompact]{--notification-direction: row}.c-notification[position=full-width]{--notification-border-radius: var(--dt-radius-rounded-none)}.c-notification[variant=neutral-alternative]{--notification-background-color: var(--dt-color-container-default)}.c-notification[variant=info]{--notification-background-color: var(--dt-color-support-info-02);--notification-icon-fill: var(--dt-color-blue)}.c-notification[variant=success]{--notification-background-color: var(--dt-color-support-positive-02)}.c-notification[variant=warning]{--notification-background-color: var(--dt-color-support-warning-02)}.c-notification[variant=error]{--notification-background-color: var(--dt-color-support-error-02);--notification-icon-fill: var(--dt-color-red)}.c-notification-heading{margin:0;margin-block-end:var(--dt-spacing-a);font-size:var(--notification-heading-font-size);line-height:var(--notification-heading-line-height)}@media (min-width: 768px){.c-notification-heading{--notification-heading-font-size: calc(var(--dt-font-heading-s-size--wide) * 1px);--notification-heading-line-height: calc(var(--dt-font-heading-s-line-height--wide) * 1px)}}.c-notification-content-section{display:flex;flex-direction:row}.c-notification-content-section .has-icon{display:block ruby;margin-inline-end:var(--dt-spacing-c)}.c-notification-content-section[isDismissible]{max-width:calc(100% - var(--notification-close-icon-offset) - 40px)}.c-notification-heading-icon{padding-block-start:var(--notification-heading-icon-offset);color:var(--notification-icon-fill)}.c-notification-icon-close{position:absolute;inset-block-start:var(--notification-close-icon-offset);inset-inline-end:var(--notification-close-icon-offset)}.c-notification-footer{display:flex;flex-direction:row;justify-content:flex-end;gap:var(--dt-spacing-d)}.c-notification-footer[isCompact]{align-self:flex-end}@media (max-width: 768px){.c-notification-footer[isStacked]{flex-direction:column-reverse}}
13
22
  `;
14
- var B = Object.defineProperty, D = Object.getOwnPropertyDescriptor, e = (f, t, i, c) => {
15
- for (var r = c > 1 ? void 0 : c ? D(t, i) : t, d = f.length - 1, p; d >= 0; d--)
16
- (p = f[d]) && (r = (c ? p(t, i, r) : p(r)) || r);
17
- return c && r && B(t, i, r), r;
23
+ var P = Object.defineProperty, F = Object.getOwnPropertyDescriptor, e = (u, i, t, a) => {
24
+ for (var s = a > 1 ? void 0 : a ? F(i, t) : i, f = u.length - 1, p; f >= 0; f--)
25
+ (p = u[f]) && (s = (a ? p(i, t, s) : p(s)) || s);
26
+ return a && s && P(i, t, s), s;
18
27
  };
19
- class n extends N {
28
+ class n extends x {
20
29
  constructor() {
21
- super(...arguments), this.isOpen = !0, this.variant = "neutral", this.isDismissible = !0, this.isCompact = !1, this.headingLevel = "h2", this.hideIcon = !1, this.hideCloseIcon = !1, this.hasStackedActions = !1, this._hasExternalIcon = !1, this._hasIconClass = !1, this._hasContentGutter = !1;
22
- }
23
- /**
24
- * Lifecycle method executed after component renders.
25
- */
26
- firstUpdated() {
27
- this.updateIconProperties();
30
+ super(...arguments), this.isOpen = r.isOpen, this.variant = r.variant, this.position = r.position, this.isDismissible = r.isDismissible, this.isCompact = r.isCompact, this.headingLevel = r.headingLevel, this.hideIcon = r.hideIcon, this.hasStackedActions = r.hasStackedActions, this._hasExternalIcon = !1, this._hasIconClass = !1;
28
31
  }
29
32
  /**
30
33
  * Lifecycle method executed when component is about to update.
31
34
  * It update icon properties if variant has changes.
32
35
  */
33
- willUpdate(t) {
34
- t.has("variant") && this.updateIconProperties();
36
+ willUpdate(i) {
37
+ i.has("variant") && this.updateIconProperties();
35
38
  }
36
39
  /**
37
40
  * Lifecycle method executed when component is updated.
38
41
  * It dispatches an event if notification is opened.
39
42
  * It applies a gutter if there's no heading content in order to avoid the close button overlap the content.
40
43
  */
41
- updated(t) {
42
- t.has("isOpen") && this.isOpen && u(this, S, { targetNotification: this }), (t.has("heading") || t.has("isDismissible") || t.has("isCompact")) && (this._hasContentGutter = (this.heading === "" || this.heading === void 0) && this.isDismissible && !this.isCompact);
44
+ updated(i) {
45
+ i.has("isOpen") && this.isOpen && g(this, V, { targetNotification: this });
43
46
  }
44
47
  /**
45
48
  * Method responsible to check if an external icon has been provided.
@@ -56,11 +59,11 @@ class n extends N {
56
59
  *
57
60
  * @private
58
61
  */
59
- renderFooter(t, i) {
60
- return l`
62
+ renderFooter(i, t) {
63
+ return d`
61
64
  <footer class="${h}-footer" data-test-id="${o}-footer" ?isCompact="${this.isCompact}" ?isStacked="${this.hasStackedActions && !this.isCompact}">
62
- ${i ? this.renderActionButton(i, "supporting") : a}
63
- ${t ? this.renderActionButton(t, "leading") : a}
65
+ ${t ? this.renderActionButton(t, "supporting") : c}
66
+ ${i ? this.renderActionButton(i, "leading") : c}
64
67
  </footer>
65
68
  `;
66
69
  }
@@ -73,12 +76,8 @@ class n extends N {
73
76
  *
74
77
  * @private
75
78
  */
76
- renderNotificationHeading(t, i) {
77
- return l`
78
- <header class="${h}-header" data-test-id="${o}-header">
79
- <${i} class="${h}-heading" data-test-id="${o}-heading">${t}</${i}>
80
- </header>
81
- `;
79
+ renderNotificationHeading(i, t) {
80
+ return d`<${t} class="${h}-heading" data-test-id="${o}-heading">${i}</${t}>`;
82
81
  }
83
82
  /**
84
83
  * Util method that returns a boolean if variant has a default icon.
@@ -87,8 +86,8 @@ class n extends N {
87
86
  *
88
87
  * @private
89
88
  */
90
- variantHasDefaultIcon(t) {
91
- return ["info", "success", "warning", "error"].includes(t);
89
+ variantHasDefaultIcon(i) {
90
+ return ["info", "success", "warning", "error"].includes(i);
92
91
  }
93
92
  /**
94
93
  * Util method that returns an icon from a variant that has default icon.
@@ -97,18 +96,18 @@ class n extends N {
97
96
  *
98
97
  * @private
99
98
  */
100
- getDefaultVariantIcon(t) {
101
- switch (t) {
99
+ getDefaultVariantIcon(i) {
100
+ switch (i) {
102
101
  case "info":
103
- return l`<icon-info-circle size="s" data-test-id="${o}-heading-icon-info"></icon-info-circle>`;
102
+ return d`<icon-info-circle size="m" data-test-id="${o}-heading-icon-info"></icon-info-circle>`;
104
103
  case "success":
105
- return l`<icon-check-circle size="s" data-test-id="${o}-heading-icon-success"></icon-check-circle>`;
104
+ return d`<icon-check-circle size="m" data-test-id="${o}-heading-icon-success"></icon-check-circle>`;
106
105
  case "warning":
107
- return l`<icon-alert-triangle size="s" data-test-id="${o}-heading-icon-warning"></icon-alert-triangle>`;
106
+ return d`<icon-alert-triangle size="m" data-test-id="${o}-heading-icon-warning"></icon-alert-triangle>`;
108
107
  case "error":
109
- return l`<icon-alert-circle size="s" data-test-id="${o}-heading-icon-error"></icon-alert-circle>`;
108
+ return d`<icon-alert-circle size="m" data-test-id="${o}-heading-icon-error"></icon-alert-circle>`;
110
109
  default:
111
- return a;
110
+ return c;
112
111
  }
113
112
  }
114
113
  /**
@@ -119,8 +118,8 @@ class n extends N {
119
118
  *
120
119
  * @private
121
120
  */
122
- renderIconVariant(t) {
123
- return this.variantHasDefaultIcon(t) ? this.getDefaultVariantIcon(t) : a;
121
+ renderIconVariant(i) {
122
+ return this.variantHasDefaultIcon(i) ? this.getDefaultVariantIcon(i) : c;
124
123
  }
125
124
  /**
126
125
  * Template for the heading icon area.
@@ -132,10 +131,10 @@ class n extends N {
132
131
  *
133
132
  * @private
134
133
  */
135
- renderIcon(t, i, c) {
136
- return l`
137
- <div data-test-id="${o}-icon-area" class="${c ? "has-icon " : ""}${h}-heading-icon">
138
- ${i ? a : this.renderIconVariant(t)}
134
+ renderIcon(i, t, a) {
135
+ return d`
136
+ <div data-test-id="${o}-icon-area" class="${a ? "has-icon " : ""}${h}-heading-icon">
137
+ ${t ? c : this.renderIconVariant(i)}
139
138
  <slot name="icon"></slot>
140
139
  </div>
141
140
  `;
@@ -147,7 +146,7 @@ class n extends N {
147
146
  * @private
148
147
  */
149
148
  renderCloseButton() {
150
- return l`
149
+ return d`
151
150
  <pie-icon-button
152
151
  variant="ghost-secondary"
153
152
  size="small"
@@ -165,7 +164,7 @@ class n extends N {
165
164
  * @private
166
165
  */
167
166
  handleCloseButton() {
168
- this.closeNotificationComponent(), u(this, z, { targetNotification: this });
167
+ this.closeNotificationComponent(), g(this, D, { targetNotification: this });
169
168
  }
170
169
  /**
171
170
  * Util method responsible to close the component.
@@ -183,8 +182,8 @@ class n extends N {
183
182
  *
184
183
  * @private
185
184
  */
186
- handleActionClick(t) {
187
- u(this, t === "leading" ? V : w, { targetNotification: this });
185
+ handleActionClick(i) {
186
+ g(this, i === "leading" ? T : B, { targetNotification: this });
188
187
  }
189
188
  /**
190
189
  * Render the action button depending on action type and its action.
@@ -195,109 +194,117 @@ class n extends N {
195
194
  * @returns {TemplateResult | typeof nothing} - The rendered action button or nothing if the action text is not defined.
196
195
  * @private
197
196
  */
198
- renderActionButton(t, i) {
199
- const { text: c, ariaLabel: r } = t;
200
- return c ? l`
197
+ renderActionButton(i, t) {
198
+ const { text: a, ariaLabel: s } = i;
199
+ return a ? d`
201
200
  <pie-button
202
- variant="${i === "leading" ? "primary" : "ghost"}"
201
+ variant="${t === "leading" ? "primary" : "ghost"}"
203
202
  size="small-productive"
204
- aria-label="${r || a}"
205
- @click="${() => this.handleActionClick(i)}"
206
- data-test-id="${o}-${i}-action"
203
+ aria-label="${s || c}"
204
+ @click="${() => this.handleActionClick(t)}"
205
+ data-test-id="${o}-${t}-action"
207
206
  ?isFullWidth="${this.hasStackedActions}"
208
207
  type="button">
209
- ${c}
208
+ ${a}
210
209
  </pie-button>
211
- ` : a;
210
+ ` : c;
212
211
  }
213
212
  render() {
214
213
  const {
215
- variant: t,
216
- heading: i,
217
- headingLevel: c,
218
- isDismissible: r,
219
- isCompact: d,
220
- _hasExternalIcon: p,
214
+ variant: i,
215
+ position: t,
216
+ heading: a,
217
+ headingLevel: s,
218
+ isDismissible: f,
219
+ isCompact: p,
220
+ _hasExternalIcon: I,
221
221
  hideIcon: C,
222
- _hasIconClass: $,
223
- leadingAction: v,
224
- supportingAction: I,
225
- isOpen: b,
226
- _hasContentGutter: y
222
+ _hasIconClass: y,
223
+ leadingAction: m,
224
+ supportingAction: _,
225
+ isOpen: N
227
226
  } = this;
228
- return b ? l`
229
- <div data-test-id="${o}" class="${h}" variant="${t}" ?isCompact="${d}">
230
- ${r && !d ? this.renderCloseButton() : a}
227
+ if (!N)
228
+ return c;
229
+ const b = f && !p;
230
+ return d`
231
+ <div
232
+ data-test-id="${o}"
233
+ class="${h}"
234
+ variant="${i}"
235
+ position="${t}"
236
+ ?isCompact="${p}">
237
+ ${b ? this.renderCloseButton() : c}
231
238
 
232
- <section class="${h}-content-section">
233
- ${C ? a : this.renderIcon(t, p, $)}
234
- <article ?hasGutter="${y}">
235
- ${i ? this.renderNotificationHeading(i, O(c)) : a}
239
+ <section class="${h}-content-section" ?isDismissible="${b}">
240
+ ${C ? c : this.renderIcon(i, I, y)}
241
+ <article>
242
+ ${a ? this.renderNotificationHeading(a, E(s)) : c}
236
243
  <slot></slot>
237
244
  </article>
238
245
  </section>
239
246
 
240
- ${v ? this.renderFooter(v, I) : a}
241
- </div>` : a;
247
+ ${m ? this.renderFooter(m, _) : c}
248
+ </div>`;
242
249
  }
243
250
  }
244
- n.styles = _(T);
251
+ n.styles = O(L);
245
252
  e([
246
- s({ type: Boolean })
253
+ l({ type: Boolean })
247
254
  ], n.prototype, "isOpen", 2);
248
255
  e([
249
- s(),
250
- m(o, k, "neutral")
256
+ l(),
257
+ v(o, A, r.variant)
251
258
  ], n.prototype, "variant", 2);
252
259
  e([
253
- s({ type: Boolean })
260
+ l(),
261
+ v(o, S, r.position)
262
+ ], n.prototype, "position", 2);
263
+ e([
264
+ l({ type: Boolean })
254
265
  ], n.prototype, "isDismissible", 2);
255
266
  e([
256
- s({ type: Boolean })
267
+ l({ type: Boolean })
257
268
  ], n.prototype, "isCompact", 2);
258
269
  e([
259
- s({ type: String })
270
+ l({ type: String })
260
271
  ], n.prototype, "heading", 2);
261
272
  e([
262
- s(),
263
- m(o, A, "h2")
273
+ l(),
274
+ v(o, z, r.headingLevel)
264
275
  ], n.prototype, "headingLevel", 2);
265
276
  e([
266
- s({ type: Boolean })
277
+ l({ type: Boolean })
267
278
  ], n.prototype, "hideIcon", 2);
268
279
  e([
269
- s({ type: Boolean })
270
- ], n.prototype, "hideCloseIcon", 2);
271
- e([
272
- s({ type: Object })
280
+ l({ type: Object })
273
281
  ], n.prototype, "leadingAction", 2);
274
282
  e([
275
- s({ type: Object })
283
+ l({ type: Object })
276
284
  ], n.prototype, "supportingAction", 2);
277
285
  e([
278
- s({ type: Boolean })
286
+ l({ type: Boolean })
279
287
  ], n.prototype, "hasStackedActions", 2);
280
288
  e([
281
- E({ slot: "icon" })
289
+ w({ slot: "icon" })
282
290
  ], n.prototype, "_iconSlot", 2);
283
291
  e([
284
- g()
292
+ $()
285
293
  ], n.prototype, "_hasExternalIcon", 2);
286
294
  e([
287
- g()
295
+ $()
288
296
  ], n.prototype, "_hasIconClass", 2);
289
- e([
290
- g()
291
- ], n.prototype, "_hasContentGutter", 2);
292
- x(o, n);
297
+ k(o, n);
293
298
  export {
294
- z as ON_NOTIFICATION_CLOSE_EVENT,
295
- V as ON_NOTIFICATION_LEADING_ACTION_CLICK_EVENT,
296
- S as ON_NOTIFICATION_OPEN_EVENT,
297
- w as ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT,
299
+ D as ON_NOTIFICATION_CLOSE_EVENT,
300
+ T as ON_NOTIFICATION_LEADING_ACTION_CLICK_EVENT,
301
+ V as ON_NOTIFICATION_OPEN_EVENT,
302
+ B as ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT,
298
303
  n as PieNotification,
299
304
  h as componentClass,
300
305
  o as componentSelector,
301
- A as headingLevels,
302
- k as variants
306
+ r as defaultProps,
307
+ z as headingLevels,
308
+ S as positions,
309
+ A as variants
303
310
  };
package/dist/react.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
1
2
  import type { CSSResult } from 'lit';
2
3
  import type { LitElement } from 'lit';
3
4
  import type { nothing } from 'lit';
@@ -20,6 +21,10 @@ export declare const componentClass = "c-notification";
20
21
 
21
22
  export declare const componentSelector = "pie-notification";
22
23
 
24
+ export declare type DefaultProps = ComponentDefaultPropsGeneric<NotificationProps, 'isOpen' | 'variant' | 'position' | 'isDismissible' | 'isCompact' | 'headingLevel' | 'hideIcon' | 'hasStackedActions'>;
25
+
26
+ export declare const defaultProps: DefaultProps;
27
+
23
28
  export declare const headingLevels: readonly ["h2", "h3", "h4", "h5", "h6"];
24
29
 
25
30
  export declare interface NotificationProps {
@@ -27,6 +32,10 @@ export declare interface NotificationProps {
27
32
  * Set the variant of the notification.
28
33
  */
29
34
  variant?: typeof variants[number];
35
+ /**
36
+ * The position of the notification defining proper styles if the component appear within the content or at the top of the interface.
37
+ */
38
+ position?: typeof positions[number];
30
39
  /**
31
40
  * When true, allows dismissing the notification by clicking on the close button.
32
41
  */
@@ -105,24 +114,19 @@ export declare const PieNotification: React_2.ForwardRefExoticComponent<Notifica
105
114
  declare class PieNotification_2 extends LitElement implements NotificationProps {
106
115
  isOpen: boolean;
107
116
  variant: NonNullable<NotificationProps['variant']>;
117
+ position: NonNullable<NotificationProps['position']>;
108
118
  isDismissible: boolean;
109
119
  isCompact: boolean;
110
120
  heading: string;
111
121
  headingLevel: NonNullable<NotificationProps['headingLevel']>;
112
122
  hideIcon: boolean;
113
- hideCloseIcon: boolean;
114
123
  leadingAction: NotificationProps['leadingAction'];
115
124
  supportingAction: NotificationProps['supportingAction'];
116
125
  hasStackedActions: boolean;
117
126
  _iconSlot: Array<HTMLElement>;
118
127
  protected _hasExternalIcon: boolean;
119
128
  protected _hasIconClass: boolean;
120
- protected _hasContentGutter: boolean;
121
129
  static styles: CSSResult;
122
- /**
123
- * Lifecycle method executed after component renders.
124
- */
125
- protected firstUpdated(): void;
126
130
  /**
127
131
  * Lifecycle method executed when component is about to update.
128
132
  * It update icon properties if variant has changes.
@@ -243,6 +247,8 @@ declare type PieNotificationEvents = {
243
247
  onPieNotificationOpen?: (event: CustomEvent) => void;
244
248
  };
245
249
 
250
+ export declare const positions: readonly ["inline-content", "full-width"];
251
+
246
252
  declare type ReactBaseType = React_2.HTMLAttributes<HTMLDivElement>;
247
253
 
248
254
  export declare const variants: readonly ["neutral", "neutral-alternative", "info", "success", "warning", "error"];
package/dist/react.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as i from "react";
2
2
  import { createComponent as o } from "@lit/react";
3
3
  import { PieNotification as t } from "./index.js";
4
- import { ON_NOTIFICATION_CLOSE_EVENT as E, ON_NOTIFICATION_LEADING_ACTION_CLICK_EVENT as A, ON_NOTIFICATION_OPEN_EVENT as g, ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT as L, componentClass as d, componentSelector as k, headingLevels as F, variants as S } from "./index.js";
4
+ import { ON_NOTIFICATION_CLOSE_EVENT as E, ON_NOTIFICATION_LEADING_ACTION_CLICK_EVENT as A, ON_NOTIFICATION_OPEN_EVENT as g, ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT as L, componentClass as d, componentSelector as k, defaultProps as F, headingLevels as S, positions as V, variants as u } from "./index.js";
5
5
  import "lit";
6
6
  import "lit/static-html.js";
7
7
  import "@justeattakeaway/pie-webc-core";
@@ -37,6 +37,8 @@ export {
37
37
  T as PieNotification,
38
38
  d as componentClass,
39
39
  k as componentSelector,
40
- F as headingLevels,
41
- S as variants
40
+ F as defaultProps,
41
+ S as headingLevels,
42
+ V as positions,
43
+ u as variants
42
44
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-notification",
3
3
  "description": "PIE Design System Notification built using Web Components",
4
- "version": "0.5.5",
4
+ "version": "0.6.1",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -41,9 +41,9 @@
41
41
  "cem-plugin-module-file-extensions": "0.0.5"
42
42
  },
43
43
  "dependencies": {
44
- "@justeattakeaway/pie-icon-button": "0.28.5",
45
- "@justeattakeaway/pie-icons-webc": "0.23.1",
46
- "@justeattakeaway/pie-webc-core": "0.22.0"
44
+ "@justeattakeaway/pie-icon-button": "0.28.6",
45
+ "@justeattakeaway/pie-icons-webc": "0.24.0",
46
+ "@justeattakeaway/pie-webc-core": "0.23.0"
47
47
  },
48
48
  "volta": {
49
49
  "extends": "../../../package.json"
package/src/defs.ts CHANGED
@@ -1,5 +1,8 @@
1
+ import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
2
+
1
3
  export const variants = ['neutral', 'neutral-alternative', 'info', 'success', 'warning', 'error'] as const;
2
4
  export const headingLevels = ['h2', 'h3', 'h4', 'h5', 'h6'] as const;
5
+ export const positions = ['inline-content', 'full-width'] as const;
3
6
 
4
7
  export type ActionProps = {
5
8
  /**
@@ -19,6 +22,11 @@ export interface NotificationProps {
19
22
  */
20
23
  variant?: typeof variants[number];
21
24
 
25
+ /**
26
+ * The position of the notification defining proper styles if the component appear within the content or at the top of the interface.
27
+ */
28
+ position?: typeof positions[number];
29
+
22
30
  /**
23
31
  * When true, allows dismissing the notification by clicking on the close button.
24
32
  */
@@ -95,3 +103,16 @@ export const ON_NOTIFICATION_LEADING_ACTION_CLICK_EVENT = `${componentSelector}-
95
103
  * @constant
96
104
  */
97
105
  export const ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT = `${componentSelector}-supporting-action-click`;
106
+
107
+ export type DefaultProps = ComponentDefaultPropsGeneric<NotificationProps, 'isOpen' | 'variant' | 'position' | 'isDismissible' | 'isCompact' | 'headingLevel' | 'hideIcon' | 'hasStackedActions'>;
108
+
109
+ export const defaultProps: DefaultProps = {
110
+ isOpen: true,
111
+ variant: 'neutral',
112
+ position: 'inline-content',
113
+ isDismissible: true,
114
+ isCompact: false,
115
+ headingLevel: 'h2',
116
+ hideIcon: false,
117
+ hasStackedActions: false,
118
+ };
package/src/index.ts CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  type NotificationProps,
13
13
  type ActionProps,
14
14
  variants,
15
+ positions,
15
16
  headingLevels,
16
17
  componentSelector,
17
18
  componentClass,
@@ -19,6 +20,7 @@ import {
19
20
  ON_NOTIFICATION_OPEN_EVENT,
20
21
  ON_NOTIFICATION_LEADING_ACTION_CLICK_EVENT,
21
22
  ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT,
23
+ defaultProps,
22
24
  } from './defs';
23
25
  import styles from './notification.scss?inline';
24
26
 
@@ -42,30 +44,31 @@ export * from './defs';
42
44
  */
43
45
  export class PieNotification extends LitElement implements NotificationProps {
44
46
  @property({ type: Boolean })
45
- public isOpen = true;
47
+ public isOpen = defaultProps.isOpen;
46
48
 
47
49
  @property()
48
- @validPropertyValues(componentSelector, variants, 'neutral')
49
- public variant: NonNullable<NotificationProps['variant']> = 'neutral';
50
+ @validPropertyValues(componentSelector, variants, defaultProps.variant)
51
+ public variant: NonNullable<NotificationProps['variant']> = defaultProps.variant;
52
+
53
+ @property()
54
+ @validPropertyValues(componentSelector, positions, defaultProps.position)
55
+ public position: NonNullable<NotificationProps['position']> = defaultProps.position;
50
56
 
51
57
  @property({ type: Boolean })
52
- public isDismissible = true;
58
+ public isDismissible = defaultProps.isDismissible;
53
59
 
54
60
  @property({ type: Boolean })
55
- public isCompact = false;
61
+ public isCompact = defaultProps.isCompact;
56
62
 
57
63
  @property({ type: String })
58
64
  public heading!: string;
59
65
 
60
66
  @property()
61
- @validPropertyValues(componentSelector, headingLevels, 'h2')
62
- public headingLevel: NonNullable<NotificationProps['headingLevel']> = 'h2';
63
-
64
- @property({ type: Boolean })
65
- public hideIcon = false;
67
+ @validPropertyValues(componentSelector, headingLevels, defaultProps.headingLevel)
68
+ public headingLevel: NonNullable<NotificationProps['headingLevel']> = defaultProps.headingLevel;
66
69
 
67
70
  @property({ type: Boolean })
68
- public hideCloseIcon = false;
71
+ public hideIcon = defaultProps.hideIcon;
69
72
 
70
73
  @property({ type: Object })
71
74
  public leadingAction!: NotificationProps['leadingAction'];
@@ -74,7 +77,7 @@ export class PieNotification extends LitElement implements NotificationProps {
74
77
  public supportingAction!: NotificationProps['supportingAction'];
75
78
 
76
79
  @property({ type: Boolean })
77
- public hasStackedActions = false;
80
+ public hasStackedActions = defaultProps.hasStackedActions;
78
81
 
79
82
  @queryAssignedElements({ slot: 'icon' }) _iconSlot!: Array<HTMLElement>;
80
83
 
@@ -84,19 +87,9 @@ export class PieNotification extends LitElement implements NotificationProps {
84
87
  @state()
85
88
  protected _hasIconClass = false;
86
89
 
87
- @state()
88
- protected _hasContentGutter = false;
89
-
90
90
  // Renders a `CSSResult` generated from SCSS by Vite
91
91
  static styles = unsafeCSS(styles);
92
92
 
93
- /**
94
- * Lifecycle method executed after component renders.
95
- */
96
- protected firstUpdated (): void {
97
- this.updateIconProperties();
98
- }
99
-
100
93
  /**
101
94
  * Lifecycle method executed when component is about to update.
102
95
  * It update icon properties if variant has changes.
@@ -116,10 +109,6 @@ export class PieNotification extends LitElement implements NotificationProps {
116
109
  if (_changedProperties.has('isOpen') && this.isOpen) {
117
110
  dispatchCustomEvent(this, ON_NOTIFICATION_OPEN_EVENT, { targetNotification: this });
118
111
  }
119
-
120
- if (_changedProperties.has('heading') || _changedProperties.has('isDismissible') || _changedProperties.has('isCompact')) {
121
- this._hasContentGutter = (this.heading === '' || this.heading === undefined) && (this.isDismissible && !this.isCompact);
122
- }
123
112
  }
124
113
 
125
114
  /**
@@ -158,11 +147,7 @@ export class PieNotification extends LitElement implements NotificationProps {
158
147
  * @private
159
148
  */
160
149
  private renderNotificationHeading (heading: NotificationProps['heading'], headingTag: StaticValue): TemplateResult {
161
- return html`
162
- <header class="${componentClass}-header" data-test-id="${componentSelector}-header">
163
- <${headingTag} class="${componentClass}-heading" data-test-id="${componentSelector}-heading">${heading}</${headingTag}>
164
- </header>
165
- `;
150
+ return html`<${headingTag} class="${componentClass}-heading" data-test-id="${componentSelector}-heading">${heading}</${headingTag}>`;
166
151
  }
167
152
 
168
153
  /**
@@ -188,13 +173,13 @@ export class PieNotification extends LitElement implements NotificationProps {
188
173
  private getDefaultVariantIcon (variant: NonNullable<NotificationProps['variant']>) {
189
174
  switch (variant) {
190
175
  case 'info':
191
- return html`<icon-info-circle size="s" data-test-id="${componentSelector}-heading-icon-info"></icon-info-circle>`;
176
+ return html`<icon-info-circle size="m" data-test-id="${componentSelector}-heading-icon-info"></icon-info-circle>`;
192
177
  case 'success':
193
- return html`<icon-check-circle size="s" data-test-id="${componentSelector}-heading-icon-success"></icon-check-circle>`;
178
+ return html`<icon-check-circle size="m" data-test-id="${componentSelector}-heading-icon-success"></icon-check-circle>`;
194
179
  case 'warning':
195
- return html`<icon-alert-triangle size="s" data-test-id="${componentSelector}-heading-icon-warning"></icon-alert-triangle>`;
180
+ return html`<icon-alert-triangle size="m" data-test-id="${componentSelector}-heading-icon-warning"></icon-alert-triangle>`;
196
181
  case 'error':
197
- return html`<icon-alert-circle size="s" data-test-id="${componentSelector}-heading-icon-error"></icon-alert-circle>`;
182
+ return html`<icon-alert-circle size="m" data-test-id="${componentSelector}-heading-icon-error"></icon-alert-circle>`;
198
183
  default:
199
184
  return nothing as never;
200
185
  }
@@ -323,6 +308,7 @@ export class PieNotification extends LitElement implements NotificationProps {
323
308
  render () {
324
309
  const {
325
310
  variant,
311
+ position,
326
312
  heading,
327
313
  headingLevel,
328
314
  isDismissible,
@@ -333,20 +319,26 @@ export class PieNotification extends LitElement implements NotificationProps {
333
319
  leadingAction,
334
320
  supportingAction,
335
321
  isOpen,
336
- _hasContentGutter,
337
322
  } = this;
338
323
 
339
324
  if (!isOpen) {
340
325
  return nothing;
341
326
  }
342
327
 
343
- return html`
344
- <div data-test-id="${componentSelector}" class="${componentClass}" variant="${variant}" ?isCompact="${isCompact}">
345
- ${isDismissible && !isCompact ? this.renderCloseButton() : nothing}
328
+ const showCloseButton = isDismissible && !isCompact;
346
329
 
347
- <section class="${componentClass}-content-section">
330
+ return html`
331
+ <div
332
+ data-test-id="${componentSelector}"
333
+ class="${componentClass}"
334
+ variant="${variant}"
335
+ position="${position}"
336
+ ?isCompact="${isCompact}">
337
+ ${showCloseButton ? this.renderCloseButton() : nothing}
338
+
339
+ <section class="${componentClass}-content-section" ?isDismissible="${showCloseButton}">
348
340
  ${!hideIcon ? this.renderIcon(variant, _hasExternalIcon, _hasIconClass) : nothing}
349
- <article ?hasGutter="${_hasContentGutter}">
341
+ <article>
350
342
  ${heading ? this.renderNotificationHeading(heading, unsafeStatic(headingLevel)) : nothing}
351
343
  <slot></slot>
352
344
  </article>
@@ -1,17 +1,18 @@
1
1
  @use '@justeattakeaway/pie-css/scss' as p;
2
2
 
3
3
  .c-notification {
4
- $breakpoint-narrow: 640px;
4
+ $breakpoint-wide: 768px;
5
5
 
6
6
  --notification-border-radius: var(--dt-radius-rounded-c);
7
7
  --notification-background-color: var(--dt-color-container-subtle);
8
8
  --notification-direction: column;
9
- --notification-icon-size-override: 22px;
10
- --notification-heading-font-size: #{p.font-size(--dt-font-size-20)};
11
- --notification-heading-line-height: calc(var(--dt-font-size-20-line-height) * 1px);
12
- --notification-font-size: #{p.font-size(--dt-font-size-16)};
13
- --notification-line-height: calc(var(--dt-font-size-16-line-height) * 1px);
9
+ --notification-heading-font-size: #{p.font-size(--dt-font-heading-s-size--narrow)};
10
+ --notification-heading-line-height: #{p.line-height(--dt-font-heading-s-line-height--narrow)};
11
+ --notification-font-size: #{p.font-size(--dt-font-body-l-size)};
12
+ --notification-line-height: #{p.line-height(--dt-font-body-l-line-height)};
14
13
  --notification-icon-fill: var(--dt-color-content-default);
14
+ --notification-close-icon-offset: var(--dt-spacing-b);
15
+ --notification-heading-icon-offset: 2px;
15
16
 
16
17
  padding: var(--dt-spacing-d);
17
18
  border-radius: var(--notification-border-radius);
@@ -23,21 +24,14 @@
23
24
  font-size: var(--notification-font-size);
24
25
  line-height: var(--notification-line-height);
25
26
 
26
- h1,
27
- h2,
28
- h3,
29
- h4,
30
- h5,
31
- h6 {
32
- margin: 0;
33
- font-size: var(--notification-heading-font-size);
34
- line-height: var(--notification-heading-line-height);
35
- }
36
-
37
27
  &[isCompact] {
38
28
  --notification-direction: row;
39
29
  }
40
30
 
31
+ &[position='full-width'] {
32
+ --notification-border-radius: var(--dt-radius-rounded-none);
33
+ }
34
+
41
35
  &[variant='neutral-alternative'] {
42
36
  --notification-background-color: var(--dt-color-container-default);
43
37
  }
@@ -60,31 +54,42 @@
60
54
  --notification-icon-fill: var(--dt-color-red);
61
55
  }
62
56
 
63
- &-content-section {
64
- display: flex;
65
- flex-direction: row;
66
57
 
67
- article {
68
- &[hasGutter] {
69
- padding-inline-end: var(--dt-spacing-e);
70
- }
58
+ &-heading {
59
+ margin: 0;
60
+ margin-block-end: var(--dt-spacing-a);
61
+ font-size: var(--notification-heading-font-size);
62
+ line-height: var(--notification-heading-line-height);
63
+
64
+ @media (min-width: $breakpoint-wide) {
65
+ --notification-heading-font-size: #{p.font-size(--dt-font-heading-s-size--wide)};
66
+ --notification-heading-line-height: #{p.line-height(--dt-font-heading-s-line-height--wide)};
71
67
  }
68
+ }
72
69
 
70
+ &-content-section {
71
+ display: flex;
72
+ flex-direction: row;
73
+
73
74
  .has-icon {
74
75
  display: block ruby; // This is a hack to avoid the icon overlap the text in Firefox
75
76
  margin-inline-end: var(--dt-spacing-c);
76
77
  }
78
+
79
+ &[isDismissible] {
80
+ max-width: calc(100% - var(--notification-close-icon-offset) - 40px); // 40px is the size of the medium icon button
81
+ }
77
82
  }
78
83
 
79
84
  &-heading-icon {
80
- padding-block-start: var(--dt-spacing-a);
85
+ padding-block-start: var(--notification-heading-icon-offset);
81
86
  color: var(--notification-icon-fill);
82
87
  }
83
88
 
84
89
  &-icon-close {
85
90
  position: absolute;
86
- inset-block-start: var(--dt-spacing-b);
87
- inset-inline-end: var(--dt-spacing-b);
91
+ inset-block-start: var(--notification-close-icon-offset);
92
+ inset-inline-end: var(--notification-close-icon-offset);
88
93
  }
89
94
 
90
95
  &-footer {
@@ -97,9 +102,9 @@
97
102
  align-self: flex-end;
98
103
  }
99
104
 
100
- @media (max-width: $breakpoint-narrow) {
105
+ @media (max-width: $breakpoint-wide) {
101
106
  &[isStacked] {
102
- flex-direction: column;
107
+ flex-direction: column-reverse;
103
108
  }
104
109
  }
105
110
  }