@justeattakeaway/pie-notification 0.20.3 → 0.21.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.
- package/README.md +74 -2
- package/custom-elements.json +8 -8
- package/dist/index.d.ts +16 -0
- package/dist/index.js +114 -101
- package/dist/react.d.ts +16 -0
- package/package.json +5 -5
- package/src/defs.ts +20 -0
- package/src/index.ts +16 -2
- package/src/notification.scss +5 -0
package/README.md
CHANGED
|
@@ -41,8 +41,8 @@ Ideally, you should install the component using the **`@justeattakeaway/pie-webc
|
|
|
41
41
|
| `isOpen` | `true`, `false` | When true, the notification is set to be open and visible. | `true` |
|
|
42
42
|
| `hideIcon` | `true`, `false` | When true, the icon will be hidden. | `false` |
|
|
43
43
|
| `hasStackedActions` | `true`, `false` | When true, action buttons will stack on narrow screens. Not available when `isCompact` is true. | `false` |
|
|
44
|
-
| `leadingAction` | `{
|
|
45
|
-
| `supportingAction` | `{
|
|
44
|
+
| `leadingAction` | `{`<br> `text: string,`<br> `ariaLabel?: string,`<br> `size?: "small-productive" \| "xsmall",`<br> `href?: string,`<br> `target?: string,`<br> `rel?: string,`<br> `download?: string`<br>`}` | An object representing the leading action of the notification. When `href` is provided, renders as a link. | `undefined` |
|
|
45
|
+
| `supportingAction` | `{`<br> `text: string,`<br> `ariaLabel?: string,`<br> `size?: "small-productive" \| "xsmall",`<br> `href?: string,`<br> `target?: string,`<br> `rel?: string,`<br> `download?: string`<br>`}` | An object representing the supporting action of the notification. When `href` is provided, renders as a link. <br> The action will only render if `leadingAction` is passed. | `undefined` |
|
|
46
46
|
| `aria` | `{ close?: string, label?: string }` | The ARIA labels used for various parts of the notification. Only pass `label` if there is no heading to ensure the region is announced with a title. | `undefined` |
|
|
47
47
|
|
|
48
48
|
### Slots
|
|
@@ -109,6 +109,78 @@ import { IconPlaceholder } from '@justeattakeaway/pie-icons-webc/dist/react/Icon
|
|
|
109
109
|
</PieNotification>
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
+
### With Link Actions
|
|
113
|
+
|
|
114
|
+
Actions can be rendered as links by providing an `href` property. This is useful when you want to navigate to a URL or trigger a file download.
|
|
115
|
+
|
|
116
|
+
**For HTML:**
|
|
117
|
+
|
|
118
|
+
```html
|
|
119
|
+
<pie-notification
|
|
120
|
+
heading="Update Available"
|
|
121
|
+
id="my-notification">
|
|
122
|
+
A new version is available with exciting features.
|
|
123
|
+
</pie-notification>
|
|
124
|
+
|
|
125
|
+
<script>
|
|
126
|
+
const notification = document.getElementById('my-notification');
|
|
127
|
+
notification.leadingAction = {
|
|
128
|
+
text: 'Learn More',
|
|
129
|
+
href: 'https://example.com',
|
|
130
|
+
target: '_blank',
|
|
131
|
+
rel: 'noopener noreferrer'
|
|
132
|
+
};
|
|
133
|
+
notification.supportingAction = {
|
|
134
|
+
text: 'Download',
|
|
135
|
+
href: '/path/to/file.pdf',
|
|
136
|
+
download: 'release-notes.pdf'
|
|
137
|
+
};
|
|
138
|
+
</script>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**For Native JS Applications, Vue, Angular, Svelte etc.:**
|
|
142
|
+
|
|
143
|
+
```html
|
|
144
|
+
<!-- Vue templates (using Nuxt 3) -->
|
|
145
|
+
<pie-notification
|
|
146
|
+
heading="Update Available"
|
|
147
|
+
:leading-action="{
|
|
148
|
+
text: 'Learn More',
|
|
149
|
+
href: 'https://example.com',
|
|
150
|
+
target: '_blank',
|
|
151
|
+
rel: 'noopener noreferrer'
|
|
152
|
+
}"
|
|
153
|
+
:supporting-action="{
|
|
154
|
+
text: 'Download',
|
|
155
|
+
href: '/path/to/file.pdf',
|
|
156
|
+
download: 'release-notes.pdf'
|
|
157
|
+
}">
|
|
158
|
+
A new version is available with exciting features.
|
|
159
|
+
</pie-notification>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**For React Applications:**
|
|
163
|
+
|
|
164
|
+
```jsx
|
|
165
|
+
import { PieNotification } from '@justeattakeaway/pie-webc/react/notification.js';
|
|
166
|
+
|
|
167
|
+
<PieNotification
|
|
168
|
+
heading="Update Available"
|
|
169
|
+
leadingAction={{
|
|
170
|
+
text: 'Learn More',
|
|
171
|
+
href: 'https://example.com',
|
|
172
|
+
target: '_blank',
|
|
173
|
+
rel: 'noopener noreferrer'
|
|
174
|
+
}}
|
|
175
|
+
supportingAction={{
|
|
176
|
+
text: 'Download',
|
|
177
|
+
href: '/path/to/file.pdf',
|
|
178
|
+
download: 'release-notes.pdf'
|
|
179
|
+
}}>
|
|
180
|
+
A new version is available with exciting features.
|
|
181
|
+
</PieNotification>
|
|
182
|
+
```
|
|
183
|
+
|
|
112
184
|
## Questions and Support
|
|
113
185
|
|
|
114
186
|
If you work at Just Eat Takeaway.com, please contact us on **#help-designsystem**. Otherwise, please raise an issue on [Github](https://github.com/justeattakeaway/pie/issues).
|
package/custom-elements.json
CHANGED
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"type": {
|
|
91
91
|
"text": "ActionProps"
|
|
92
92
|
},
|
|
93
|
-
"default": "{\
|
|
93
|
+
"default": "{\n text: '',\n ariaLabel: '',\n size: 'small-productive',\n}"
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
96
|
"kind": "variable",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"type": {
|
|
99
99
|
"text": "DefaultProps"
|
|
100
100
|
},
|
|
101
|
-
"default": "{\
|
|
101
|
+
"default": "{\n variant: 'neutral',\n position: 'inline-content',\n isDismissible: false,\n isCompact: false,\n headingLevel: 'h2',\n hideIcon: false,\n isOpen: true,\n hasStackedActions: false,\n leadingAction: defaultActionButtonProps,\n supportingAction: defaultActionButtonProps,\n}"
|
|
102
102
|
}
|
|
103
103
|
],
|
|
104
104
|
"exports": [
|
|
@@ -302,7 +302,7 @@
|
|
|
302
302
|
"kind": "method",
|
|
303
303
|
"name": "renderFooter",
|
|
304
304
|
"privacy": "private",
|
|
305
|
-
"description": "Template for the footer area\
|
|
305
|
+
"description": "Template for the footer area\nCalled within the main render function."
|
|
306
306
|
},
|
|
307
307
|
{
|
|
308
308
|
"kind": "method",
|
|
@@ -313,7 +313,7 @@
|
|
|
313
313
|
"text": "TemplateResult"
|
|
314
314
|
}
|
|
315
315
|
},
|
|
316
|
-
"description": "Template for the header area\
|
|
316
|
+
"description": "Template for the header area\nCalled within the main render function."
|
|
317
317
|
},
|
|
318
318
|
{
|
|
319
319
|
"kind": "method",
|
|
@@ -330,7 +330,7 @@
|
|
|
330
330
|
"text": "TemplateResult | typeof nothing"
|
|
331
331
|
}
|
|
332
332
|
},
|
|
333
|
-
"description": "Template for the heading icon area.\
|
|
333
|
+
"description": "Template for the heading icon area.\nIt can return an icon provided externally via named slot or it can return a default icon according to the chosen variant if defined.\nCalled within the main render function."
|
|
334
334
|
},
|
|
335
335
|
{
|
|
336
336
|
"kind": "method",
|
|
@@ -341,13 +341,13 @@
|
|
|
341
341
|
"text": "TemplateResult"
|
|
342
342
|
}
|
|
343
343
|
},
|
|
344
|
-
"description": "Template for the close button element. Called within the\
|
|
344
|
+
"description": "Template for the close button element. Called within the\nmain render function."
|
|
345
345
|
},
|
|
346
346
|
{
|
|
347
347
|
"kind": "method",
|
|
348
348
|
"name": "handleCloseButton",
|
|
349
349
|
"privacy": "private",
|
|
350
|
-
"description": "It handles the action when user clicks in the close button.\
|
|
350
|
+
"description": "It handles the action when user clicks in the close button.\nAlso triggers an event when is executed."
|
|
351
351
|
},
|
|
352
352
|
{
|
|
353
353
|
"kind": "method",
|
|
@@ -361,7 +361,7 @@
|
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
363
|
],
|
|
364
|
-
"description": "It handles the action button action.\
|
|
364
|
+
"description": "It handles the action button action.\nAlso triggers an event according to its `actionType`."
|
|
365
365
|
},
|
|
366
366
|
{
|
|
367
367
|
"kind": "method",
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,22 @@ export declare type ActionProps = {
|
|
|
18
18
|
* The size of the button.
|
|
19
19
|
*/
|
|
20
20
|
size?: typeof actionSizes[number];
|
|
21
|
+
/**
|
|
22
|
+
* The URL to navigate to when the action is clicked. When provided, the action renders as a link.
|
|
23
|
+
*/
|
|
24
|
+
href?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Where to display the linked URL when the action is a link.
|
|
27
|
+
*/
|
|
28
|
+
target?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The relationship between the current document and the linked URL.
|
|
31
|
+
*/
|
|
32
|
+
rel?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Causes the browser to download the linked URL. A string value specifies the filename.
|
|
35
|
+
*/
|
|
36
|
+
download?: string;
|
|
21
37
|
};
|
|
22
38
|
|
|
23
39
|
export declare const actionSizes: readonly ["small-productive", "xsmall"];
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import { classMap as
|
|
1
|
+
import { LitElement as A, unsafeCSS as I, nothing as s } from "lit";
|
|
2
|
+
import { classMap as O } from "lit/directives/class-map.js";
|
|
3
3
|
import { html as p, unsafeStatic as z } from "lit/static-html.js";
|
|
4
|
-
import { validPropertyValues as
|
|
4
|
+
import { validPropertyValues as N, safeCustomElement as _, dispatchCustomEvent as x } from "@justeattakeaway/pie-webc-core";
|
|
5
5
|
import { property as r, queryAssignedElements as S } from "lit/decorators.js";
|
|
6
|
-
import { ifDefined as
|
|
6
|
+
import { ifDefined as u } from "lit/directives/if-defined.js";
|
|
7
7
|
import "@justeattakeaway/pie-button";
|
|
8
8
|
import "@justeattakeaway/pie-icon-button";
|
|
9
9
|
import "@justeattakeaway/pie-icons-webc/dist/IconAlertCircle.js";
|
|
@@ -11,18 +11,18 @@ import "@justeattakeaway/pie-icons-webc/dist/IconAlertTriangle.js";
|
|
|
11
11
|
import "@justeattakeaway/pie-icons-webc/dist/IconCheckCircle.js";
|
|
12
12
|
import "@justeattakeaway/pie-icons-webc/dist/IconClose.js";
|
|
13
13
|
import "@justeattakeaway/pie-icons-webc/dist/IconInfoCircle.js";
|
|
14
|
-
const
|
|
14
|
+
const y = class y extends A {
|
|
15
15
|
willUpdate() {
|
|
16
|
-
this.getAttribute("v") || this.setAttribute("v",
|
|
16
|
+
this.getAttribute("v") || this.setAttribute("v", y.v);
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
let
|
|
21
|
-
const E = ["neutral", "neutral-alternative", "info", "success", "warning", "error", "translucent"],
|
|
19
|
+
y.v = "0.21.1";
|
|
20
|
+
let C = y;
|
|
21
|
+
const E = ["neutral", "neutral-alternative", "info", "success", "warning", "error", "translucent"], L = ["h2", "h3", "h4", "h5", "h6"], T = ["inline-content", "full-width"], B = ["small-productive", "xsmall"], t = "pie-notification", l = "c-notification", D = `${t}-close`, V = `${t}-open`, P = `${t}-leading-action-click`, F = `${t}-supporting-action-click`, $ = {
|
|
22
22
|
text: "",
|
|
23
23
|
ariaLabel: "",
|
|
24
24
|
size: "small-productive"
|
|
25
|
-
},
|
|
25
|
+
}, d = {
|
|
26
26
|
variant: "neutral",
|
|
27
27
|
position: "inline-content",
|
|
28
28
|
isDismissible: !1,
|
|
@@ -31,24 +31,24 @@ const E = ["neutral", "neutral-alternative", "info", "success", "warning", "erro
|
|
|
31
31
|
hideIcon: !1,
|
|
32
32
|
isOpen: !0,
|
|
33
33
|
hasStackedActions: !1,
|
|
34
|
-
leadingAction:
|
|
35
|
-
supportingAction:
|
|
36
|
-
}, j = "*,*:after,*:before{box-sizing:inherit}:host{display:block}.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-close-icon-offset: var(--dt-spacing-b);--notification-icon-fill: var(--dt-color-content-inverse);--notification-icon-background-color: var(--dt-color-container-inverse);--icon-size-override: 24px;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);color:var(--dt-color-content-default)}.c-notification.c-notification--compact{--notification-direction: row}.c-notification.c-notification--full-width{--notification-border-radius: var(--dt-radius-rounded-none)}.c-notification.c-notification--neutral-alternative{--notification-background-color: var(--dt-color-container-default)}.c-notification.c-notification--info{--notification-background-color: var(--dt-color-support-info-tonal);--notification-icon-background-color: var(--dt-color-support-info)}.c-notification.c-notification--success{--notification-background-color: var(--dt-color-support-positive-tonal);--notification-icon-background-color: var(--dt-color-support-positive)}.c-notification.c-notification--warning{--notification-background-color: var(--dt-color-support-warning-tonal);--notification-icon-background-color: var(--dt-color-support-warning);--notification-icon-fill: var(--dt-color-content-dark)}.c-notification.c-notification--error{--notification-background-color: var(--dt-color-support-error-tonal);--notification-icon-background-color: var(--dt-color-support-error);--notification-icon-fill: var(--dt-color-content-light)}.c-notification.c-notification--translucent{--notification-background-color: var(--dt-color-container-prominent);-webkit-backdrop-filter:blur(var(--dt-blur-prominent));backdrop-filter:blur(var(--dt-blur-prominent))}.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: 769px){.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;align-items:center;gap:var(--dt-spacing-c)}.c-notification-content-section.c-notification-content-section--dismissible{max-width:calc(100% - var(--notification-close-icon-offset) - 40px)}.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.c-notification-footer--compact{align-self:center}@media (max-width: 767px){.c-notification-footer.c-notification-footer--stacked{flex-direction:column-reverse}}.icon,::slotted([slot=icon]){display:inline-flex;align-self:flex-start;background-color:var(--notification-icon-background-color);color:var(--notification-icon-fill);border-radius:var(--dt-radius-rounded-b);padding:var(--dt-spacing-a)}";
|
|
37
|
-
var G = Object.defineProperty, H = Object.getOwnPropertyDescriptor,
|
|
38
|
-
for (var e =
|
|
39
|
-
(h = i[
|
|
40
|
-
return
|
|
34
|
+
leadingAction: $,
|
|
35
|
+
supportingAction: $
|
|
36
|
+
}, j = "*,*:after,*:before{box-sizing:inherit}:host{display:block}.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-heading-font-weight: var(--dt-font-heading-s-weight);--notification-font-size: calc(var(--dt-font-body-l-size) * 1px);--notification-line-height: calc(var(--dt-font-body-l-line-height) * 1px);--notification-font-weight: var(--dt-font-body-l-weight);--notification-close-icon-offset: var(--dt-spacing-b);--notification-icon-fill: var(--dt-color-content-inverse);--notification-icon-background-color: var(--dt-color-container-inverse);--icon-size-override: 24px;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);font-weight:var(--notification-font-weight);color:var(--dt-color-content-default)}.c-notification.c-notification--compact{--notification-direction: row}.c-notification.c-notification--full-width{--notification-border-radius: var(--dt-radius-rounded-none)}.c-notification.c-notification--neutral-alternative{--notification-background-color: var(--dt-color-container-default)}.c-notification.c-notification--info{--notification-background-color: var(--dt-color-support-info-tonal);--notification-icon-background-color: var(--dt-color-support-info)}.c-notification.c-notification--success{--notification-background-color: var(--dt-color-support-positive-tonal);--notification-icon-background-color: var(--dt-color-support-positive)}.c-notification.c-notification--warning{--notification-background-color: var(--dt-color-support-warning-tonal);--notification-icon-background-color: var(--dt-color-support-warning);--notification-icon-fill: var(--dt-color-content-dark)}.c-notification.c-notification--error{--notification-background-color: var(--dt-color-support-error-tonal);--notification-icon-background-color: var(--dt-color-support-error);--notification-icon-fill: var(--dt-color-content-light)}.c-notification.c-notification--translucent{--notification-background-color: var(--dt-color-container-prominent);-webkit-backdrop-filter:blur(var(--dt-blur-prominent));backdrop-filter:blur(var(--dt-blur-prominent))}.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);font-weight:var(--notification-heading-font-weight)}@media (min-width: 769px){.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;align-items:center;gap:var(--dt-spacing-c)}.c-notification-content-section.c-notification-content-section--dismissible{max-width:calc(100% - var(--notification-close-icon-offset) - 40px)}.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.c-notification-footer--compact{align-self:center;margin-inline-start:auto}@media (max-width: 767px){.c-notification-footer.c-notification-footer--stacked{flex-direction:column-reverse}}.icon,::slotted([slot=icon]){display:inline-flex;align-self:flex-start;background-color:var(--notification-icon-background-color);color:var(--notification-icon-fill);border-radius:var(--dt-radius-rounded-b);padding:var(--dt-spacing-a)}";
|
|
37
|
+
var G = Object.defineProperty, H = Object.getOwnPropertyDescriptor, c = (i, o, n, f) => {
|
|
38
|
+
for (var e = f > 1 ? void 0 : f ? H(o, n) : o, g = i.length - 1, h; g >= 0; g--)
|
|
39
|
+
(h = i[g]) && (e = (f ? h(o, n, e) : h(e)) || e);
|
|
40
|
+
return f && e && G(o, n, e), e;
|
|
41
41
|
};
|
|
42
|
-
let
|
|
42
|
+
let a = class extends C {
|
|
43
43
|
constructor() {
|
|
44
|
-
super(...arguments), this.isOpen =
|
|
44
|
+
super(...arguments), this.isOpen = d.isOpen, this.variant = d.variant, this.position = d.position, this.isDismissible = d.isDismissible, this.isCompact = d.isCompact, this.headingLevel = d.headingLevel, this.hideIcon = d.hideIcon, this.hasStackedActions = d.hasStackedActions;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
47
|
* Lifecycle method executed when component is updated.
|
|
48
48
|
* It dispatches an event if notification is opened.
|
|
49
49
|
*/
|
|
50
50
|
updated(i) {
|
|
51
|
-
i.has("isOpen") && this.isOpen &&
|
|
51
|
+
i.has("isOpen") && this.isOpen && x(this, V, { targetNotification: this });
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Template for the footer area
|
|
@@ -61,18 +61,18 @@ let c = class extends k {
|
|
|
61
61
|
leadingAction: i,
|
|
62
62
|
supportingAction: o,
|
|
63
63
|
isCompact: n,
|
|
64
|
-
hasStackedActions:
|
|
64
|
+
hasStackedActions: f
|
|
65
65
|
} = this, e = {
|
|
66
|
-
[`${
|
|
67
|
-
[`${
|
|
68
|
-
[`${
|
|
66
|
+
[`${l}-footer`]: !0,
|
|
67
|
+
[`${l}-footer--compact`]: n,
|
|
68
|
+
[`${l}-footer--stacked`]: f && !n
|
|
69
69
|
};
|
|
70
70
|
return p`
|
|
71
71
|
<footer
|
|
72
|
-
class="${
|
|
72
|
+
class="${O(e)}"
|
|
73
73
|
data-test-id="${t}-footer">
|
|
74
|
-
${o ? this.renderActionButton(o, "supporting") :
|
|
75
|
-
${i ? this.renderActionButton(i, "leading") :
|
|
74
|
+
${o ? this.renderActionButton(o, "supporting") : s}
|
|
75
|
+
${i ? this.renderActionButton(i, "leading") : s}
|
|
76
76
|
</footer>
|
|
77
77
|
`;
|
|
78
78
|
}
|
|
@@ -86,7 +86,7 @@ let c = class extends k {
|
|
|
86
86
|
const { heading: i, headingLevel: o } = this, n = z(o);
|
|
87
87
|
return p`<${n}
|
|
88
88
|
id="${t}-heading"
|
|
89
|
-
class="${
|
|
89
|
+
class="${l}-heading"
|
|
90
90
|
data-test-id="${t}-heading">
|
|
91
91
|
${i}
|
|
92
92
|
</${n}>`;
|
|
@@ -107,7 +107,7 @@ let c = class extends k {
|
|
|
107
107
|
case "error":
|
|
108
108
|
return p`<icon-alert-circle class="icon" size="m" data-test-id="${t}-heading-icon-error"></icon-alert-circle>`;
|
|
109
109
|
default:
|
|
110
|
-
return
|
|
110
|
+
return s;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
@@ -132,10 +132,10 @@ let c = class extends k {
|
|
|
132
132
|
<pie-icon-button
|
|
133
133
|
variant="ghost-secondary"
|
|
134
134
|
size="small"
|
|
135
|
-
class="${
|
|
135
|
+
class="${l}-icon-close"
|
|
136
136
|
data-test-id="${t}-icon-close"
|
|
137
137
|
@click="${this.handleCloseButton}"
|
|
138
|
-
aria-label="${
|
|
138
|
+
aria-label="${u((i = this.aria) == null ? void 0 : i.close)}">
|
|
139
139
|
<icon-close></icon-close>
|
|
140
140
|
</pie-icon-button>`;
|
|
141
141
|
}
|
|
@@ -146,7 +146,7 @@ let c = class extends k {
|
|
|
146
146
|
* @private
|
|
147
147
|
*/
|
|
148
148
|
handleCloseButton() {
|
|
149
|
-
this.isOpen = !1,
|
|
149
|
+
this.isOpen = !1, x(this, D, { targetNotification: this });
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
152
|
* It handles the action button action.
|
|
@@ -157,7 +157,7 @@ let c = class extends k {
|
|
|
157
157
|
* @private
|
|
158
158
|
*/
|
|
159
159
|
handleActionClick(i) {
|
|
160
|
-
|
|
160
|
+
x(this, i === "leading" ? P : F, { targetNotification: this });
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
163
163
|
* Render the action button depending on action type and its action.
|
|
@@ -169,19 +169,32 @@ let c = class extends k {
|
|
|
169
169
|
* @private
|
|
170
170
|
*/
|
|
171
171
|
renderActionButton(i, o) {
|
|
172
|
-
const {
|
|
172
|
+
const {
|
|
173
|
+
text: n,
|
|
174
|
+
ariaLabel: f,
|
|
175
|
+
size: e = $.size,
|
|
176
|
+
href: g,
|
|
177
|
+
target: h,
|
|
178
|
+
rel: k,
|
|
179
|
+
download: v
|
|
180
|
+
} = i;
|
|
173
181
|
if (!n)
|
|
174
|
-
return
|
|
175
|
-
const
|
|
182
|
+
return s;
|
|
183
|
+
const b = o === "leading" ? "primary" : "ghost", w = e && B.includes(e) ? e : $.size, m = !!g;
|
|
176
184
|
return p`
|
|
177
185
|
<pie-button
|
|
178
|
-
variant="${
|
|
179
|
-
size="${
|
|
180
|
-
aria-label="${
|
|
186
|
+
variant="${b}"
|
|
187
|
+
size="${u(w)}"
|
|
188
|
+
aria-label="${u(f)}"
|
|
181
189
|
@click="${() => this.handleActionClick(o)}"
|
|
182
190
|
data-test-id="${t}-${o}-action"
|
|
183
191
|
?isFullWidth="${this.hasStackedActions}"
|
|
184
|
-
|
|
192
|
+
tag="${m ? "a" : "button"}"
|
|
193
|
+
type="${m ? s : "button"}"
|
|
194
|
+
href="${u(g)}"
|
|
195
|
+
target="${u(h)}"
|
|
196
|
+
rel="${u(k)}"
|
|
197
|
+
download="${u(v)}">
|
|
185
198
|
${n}
|
|
186
199
|
</pie-button>
|
|
187
200
|
`;
|
|
@@ -191,104 +204,104 @@ let c = class extends k {
|
|
|
191
204
|
variant: i,
|
|
192
205
|
position: o,
|
|
193
206
|
heading: n,
|
|
194
|
-
isDismissible:
|
|
207
|
+
isDismissible: f,
|
|
195
208
|
isCompact: e,
|
|
196
|
-
hideIcon:
|
|
209
|
+
hideIcon: g,
|
|
197
210
|
leadingAction: h,
|
|
198
|
-
isOpen:
|
|
199
|
-
aria:
|
|
211
|
+
isOpen: k,
|
|
212
|
+
aria: v
|
|
200
213
|
} = this;
|
|
201
|
-
if (!
|
|
202
|
-
return
|
|
203
|
-
const
|
|
204
|
-
[
|
|
205
|
-
[`${
|
|
206
|
-
[`${
|
|
207
|
-
[`${
|
|
208
|
-
},
|
|
209
|
-
[`${
|
|
210
|
-
[`${
|
|
214
|
+
if (!k)
|
|
215
|
+
return s;
|
|
216
|
+
const b = f && !e, w = {
|
|
217
|
+
[l]: !0,
|
|
218
|
+
[`${l}--${i}`]: !0,
|
|
219
|
+
[`${l}--${o}`]: !0,
|
|
220
|
+
[`${l}--compact`]: e
|
|
221
|
+
}, m = {
|
|
222
|
+
[`${l}-content-section`]: !0,
|
|
223
|
+
[`${l}-content-section--dismissible`]: b
|
|
211
224
|
};
|
|
212
225
|
return p`
|
|
213
226
|
<div
|
|
214
227
|
data-test-id="${t}"
|
|
215
|
-
class="${
|
|
228
|
+
class="${O(w)}"
|
|
216
229
|
role="region"
|
|
217
230
|
aria-live="${i === "error" ? "assertive" : "polite"}"
|
|
218
|
-
aria-labelledby="${n ? `${t}-heading` :
|
|
219
|
-
aria-label="${!n &&
|
|
220
|
-
${
|
|
231
|
+
aria-labelledby="${n ? `${t}-heading` : s}"
|
|
232
|
+
aria-label="${!n && u(v == null ? void 0 : v.label)}">
|
|
233
|
+
${b ? this.renderCloseButton() : s}
|
|
221
234
|
|
|
222
|
-
<section class="${
|
|
223
|
-
${
|
|
235
|
+
<section class="${O(m)}">
|
|
236
|
+
${g ? s : this.renderIcon()}
|
|
224
237
|
<article>
|
|
225
|
-
${n ? this.renderNotificationHeading() :
|
|
238
|
+
${n ? this.renderNotificationHeading() : s}
|
|
226
239
|
<slot></slot>
|
|
227
240
|
</article>
|
|
228
241
|
</section>
|
|
229
242
|
|
|
230
|
-
${h != null && h.text ? this.renderFooter() :
|
|
243
|
+
${h != null && h.text ? this.renderFooter() : s}
|
|
231
244
|
</div>`;
|
|
232
245
|
}
|
|
233
246
|
};
|
|
234
|
-
|
|
235
|
-
|
|
247
|
+
a.styles = I(j);
|
|
248
|
+
c([
|
|
236
249
|
r({ type: Boolean })
|
|
237
|
-
],
|
|
238
|
-
|
|
250
|
+
], a.prototype, "isOpen", 2);
|
|
251
|
+
c([
|
|
239
252
|
r({ type: String }),
|
|
240
|
-
|
|
241
|
-
],
|
|
242
|
-
|
|
253
|
+
N(t, E, d.variant)
|
|
254
|
+
], a.prototype, "variant", 2);
|
|
255
|
+
c([
|
|
243
256
|
r({ type: String }),
|
|
244
|
-
|
|
245
|
-
],
|
|
246
|
-
|
|
257
|
+
N(t, T, d.position)
|
|
258
|
+
], a.prototype, "position", 2);
|
|
259
|
+
c([
|
|
247
260
|
r({ type: Boolean })
|
|
248
|
-
],
|
|
249
|
-
|
|
261
|
+
], a.prototype, "isDismissible", 2);
|
|
262
|
+
c([
|
|
250
263
|
r({ type: Boolean })
|
|
251
|
-
],
|
|
252
|
-
|
|
264
|
+
], a.prototype, "isCompact", 2);
|
|
265
|
+
c([
|
|
253
266
|
r({ type: String })
|
|
254
|
-
],
|
|
255
|
-
|
|
267
|
+
], a.prototype, "heading", 2);
|
|
268
|
+
c([
|
|
256
269
|
r({ type: String }),
|
|
257
|
-
|
|
258
|
-
],
|
|
259
|
-
|
|
270
|
+
N(t, L, d.headingLevel)
|
|
271
|
+
], a.prototype, "headingLevel", 2);
|
|
272
|
+
c([
|
|
260
273
|
r({ type: Boolean })
|
|
261
|
-
],
|
|
262
|
-
|
|
274
|
+
], a.prototype, "hideIcon", 2);
|
|
275
|
+
c([
|
|
263
276
|
r({ type: Object })
|
|
264
|
-
],
|
|
265
|
-
|
|
277
|
+
], a.prototype, "leadingAction", 2);
|
|
278
|
+
c([
|
|
266
279
|
r({ type: Object })
|
|
267
|
-
],
|
|
268
|
-
|
|
280
|
+
], a.prototype, "supportingAction", 2);
|
|
281
|
+
c([
|
|
269
282
|
r({ type: Boolean })
|
|
270
|
-
],
|
|
271
|
-
|
|
283
|
+
], a.prototype, "hasStackedActions", 2);
|
|
284
|
+
c([
|
|
272
285
|
r({ type: Object })
|
|
273
|
-
],
|
|
274
|
-
|
|
286
|
+
], a.prototype, "aria", 2);
|
|
287
|
+
c([
|
|
275
288
|
S({ slot: "icon" })
|
|
276
|
-
],
|
|
277
|
-
|
|
289
|
+
], a.prototype, "_iconSlot", 2);
|
|
290
|
+
a = c([
|
|
278
291
|
_("pie-notification")
|
|
279
|
-
],
|
|
292
|
+
], a);
|
|
280
293
|
export {
|
|
281
294
|
D as ON_NOTIFICATION_CLOSE_EVENT,
|
|
282
295
|
P as ON_NOTIFICATION_LEADING_ACTION_CLICK_EVENT,
|
|
283
296
|
V as ON_NOTIFICATION_OPEN_EVENT,
|
|
284
297
|
F as ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT,
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
298
|
+
a as PieNotification,
|
|
299
|
+
B as actionSizes,
|
|
300
|
+
l as componentClass,
|
|
288
301
|
t as componentSelector,
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
302
|
+
$ as defaultActionButtonProps,
|
|
303
|
+
d as defaultProps,
|
|
304
|
+
L as headingLevels,
|
|
305
|
+
T as positions,
|
|
293
306
|
E as variants
|
|
294
307
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -19,6 +19,22 @@ export declare type ActionProps = {
|
|
|
19
19
|
* The size of the button.
|
|
20
20
|
*/
|
|
21
21
|
size?: typeof actionSizes[number];
|
|
22
|
+
/**
|
|
23
|
+
* The URL to navigate to when the action is clicked. When provided, the action renders as a link.
|
|
24
|
+
*/
|
|
25
|
+
href?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Where to display the linked URL when the action is a link.
|
|
28
|
+
*/
|
|
29
|
+
target?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The relationship between the current document and the linked URL.
|
|
32
|
+
*/
|
|
33
|
+
rel?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Causes the browser to download the linked URL. A string value specifies the filename.
|
|
36
|
+
*/
|
|
37
|
+
download?: string;
|
|
22
38
|
};
|
|
23
39
|
|
|
24
40
|
export declare const actionSizes: readonly ["small-productive", "xsmall"];
|
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.
|
|
4
|
+
"version": "0.21.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/justeattakeaway/pie",
|
|
@@ -45,15 +45,15 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
47
47
|
"@justeattakeaway/pie-components-config": "0.21.0",
|
|
48
|
-
"@justeattakeaway/pie-css": "0.
|
|
48
|
+
"@justeattakeaway/pie-css": "0.26.0",
|
|
49
49
|
"@justeattakeaway/pie-monorepo-utils": "0.7.0",
|
|
50
50
|
"@justeattakeaway/pie-wrapper-react": "0.14.3",
|
|
51
51
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@justeattakeaway/pie-icon-button": "2.3.
|
|
55
|
-
"@justeattakeaway/pie-icons-webc": "1.
|
|
56
|
-
"@justeattakeaway/pie-webc-core": "
|
|
54
|
+
"@justeattakeaway/pie-icon-button": "2.3.5",
|
|
55
|
+
"@justeattakeaway/pie-icons-webc": "1.18.1",
|
|
56
|
+
"@justeattakeaway/pie-webc-core": "6.0.0"
|
|
57
57
|
},
|
|
58
58
|
"volta": {
|
|
59
59
|
"extends": "../../../package.json"
|
package/src/defs.ts
CHANGED
|
@@ -25,6 +25,26 @@ export type ActionProps = {
|
|
|
25
25
|
* The size of the button.
|
|
26
26
|
*/
|
|
27
27
|
size?: typeof actionSizes[number];
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The URL to navigate to when the action is clicked. When provided, the action renders as a link.
|
|
31
|
+
*/
|
|
32
|
+
href?: string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Where to display the linked URL when the action is a link.
|
|
36
|
+
*/
|
|
37
|
+
target?: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The relationship between the current document and the linked URL.
|
|
41
|
+
*/
|
|
42
|
+
rel?: string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Causes the browser to download the linked URL. A string value specifies the filename.
|
|
46
|
+
*/
|
|
47
|
+
download?: string;
|
|
28
48
|
};
|
|
29
49
|
|
|
30
50
|
export interface NotificationProps {
|
package/src/index.ts
CHANGED
|
@@ -232,7 +232,15 @@ export class PieNotification extends PieElement implements NotificationProps {
|
|
|
232
232
|
* @private
|
|
233
233
|
*/
|
|
234
234
|
private renderActionButton (action: ActionProps, actionType: 'leading' | 'supporting') : TemplateResult | typeof nothing {
|
|
235
|
-
const {
|
|
235
|
+
const {
|
|
236
|
+
text,
|
|
237
|
+
ariaLabel,
|
|
238
|
+
size = defaultActionButtonProps.size,
|
|
239
|
+
href,
|
|
240
|
+
target,
|
|
241
|
+
rel,
|
|
242
|
+
download,
|
|
243
|
+
} = action;
|
|
236
244
|
|
|
237
245
|
if (!text) {
|
|
238
246
|
return nothing;
|
|
@@ -240,6 +248,7 @@ export class PieNotification extends PieElement implements NotificationProps {
|
|
|
240
248
|
|
|
241
249
|
const buttonVariant = actionType === 'leading' ? 'primary' : 'ghost';
|
|
242
250
|
const buttonSize = size && actionSizes.includes(size) ? size : defaultActionButtonProps.size;
|
|
251
|
+
const isLink = !!href;
|
|
243
252
|
|
|
244
253
|
return html`
|
|
245
254
|
<pie-button
|
|
@@ -249,7 +258,12 @@ export class PieNotification extends PieElement implements NotificationProps {
|
|
|
249
258
|
@click="${() => this.handleActionClick(actionType)}"
|
|
250
259
|
data-test-id="${componentSelector}-${actionType}-action"
|
|
251
260
|
?isFullWidth="${this.hasStackedActions}"
|
|
252
|
-
|
|
261
|
+
tag="${isLink ? 'a' : 'button'}"
|
|
262
|
+
type="${isLink ? nothing : 'button'}"
|
|
263
|
+
href="${ifDefined(href)}"
|
|
264
|
+
target="${ifDefined(target)}"
|
|
265
|
+
rel="${ifDefined(rel)}"
|
|
266
|
+
download="${ifDefined(download)}">
|
|
253
267
|
${text}
|
|
254
268
|
</pie-button>
|
|
255
269
|
`;
|
package/src/notification.scss
CHANGED
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
--notification-direction: column;
|
|
12
12
|
--notification-heading-font-size: #{p.font-size(--dt-font-heading-s-size--narrow)};
|
|
13
13
|
--notification-heading-line-height: #{p.line-height(--dt-font-heading-s-line-height--narrow)};
|
|
14
|
+
--notification-heading-font-weight: var(--dt-font-heading-s-weight);
|
|
14
15
|
--notification-font-size: #{p.font-size(--dt-font-body-l-size)};
|
|
15
16
|
--notification-line-height: #{p.line-height(--dt-font-body-l-line-height)};
|
|
17
|
+
--notification-font-weight: var(--dt-font-body-l-weight);
|
|
16
18
|
--notification-close-icon-offset: var(--dt-spacing-b);
|
|
17
19
|
--notification-icon-fill: var(--dt-color-content-inverse);
|
|
18
20
|
--notification-icon-background-color: var(--dt-color-container-inverse);
|
|
@@ -27,6 +29,7 @@
|
|
|
27
29
|
gap: var(--dt-spacing-d);
|
|
28
30
|
font-size: var(--notification-font-size);
|
|
29
31
|
line-height: var(--notification-line-height);
|
|
32
|
+
font-weight: var(--notification-font-weight);
|
|
30
33
|
color: var(--dt-color-content-default);
|
|
31
34
|
|
|
32
35
|
&.c-notification--compact {
|
|
@@ -76,6 +79,7 @@
|
|
|
76
79
|
margin-block-end: var(--dt-spacing-a);
|
|
77
80
|
font-size: var(--notification-heading-font-size);
|
|
78
81
|
line-height: var(--notification-heading-line-height);
|
|
82
|
+
font-weight: var(--notification-heading-font-weight);
|
|
79
83
|
|
|
80
84
|
@include media('>md') {
|
|
81
85
|
--notification-heading-font-size: #{p.font-size(--dt-font-heading-s-size--wide)};
|
|
@@ -108,6 +112,7 @@
|
|
|
108
112
|
|
|
109
113
|
&.c-notification-footer--compact {
|
|
110
114
|
align-self: center;
|
|
115
|
+
margin-inline-start: auto;
|
|
111
116
|
}
|
|
112
117
|
|
|
113
118
|
@include media('<md') {
|