@outbook/webcomponents-notification-alert 1.0.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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # notification-alert
2
+
3
+ [no content]
@@ -0,0 +1,65 @@
1
+ @use '@outbook/design-decisions/measures';
2
+ @use '@outbook/colorful/palettes-oklch' as colors;
3
+ @use '@outbook/webcomponents-type-icon/type-icon';
4
+
5
+ $webcomponent-notification-alert-loaded: false !default;
6
+
7
+ $-baseline: measures.$baseline;
8
+
9
+ @mixin style() {
10
+ @if not $webcomponent-notification-alert-loaded {
11
+ $webcomponent-notification-alert-loaded: true !global;
12
+
13
+ @include type-icon.style();
14
+
15
+ outbook-notification-alert {
16
+ --alert--font-size: #{$-baseline * 2.5};
17
+ --alert--line-height: #{$-baseline * 4};
18
+ --alert--icon-size: #{$-baseline * 4};
19
+ --alert--color: light-dark(#{colors.$neutral_900}, #{colors.$neutral_200});
20
+
21
+ &[type="info"] {
22
+ --alert--color: light-dark(#{colors.$sky_900}, #{colors.$sky_200});
23
+ }
24
+
25
+ &[type="success"] {
26
+ --alert--color: light-dark(#{colors.$green_900}, #{colors.$green_200});
27
+ }
28
+
29
+ &[type="error"] {
30
+ --alert--color: light-dark(#{colors.$red_900}, #{colors.$red_200});
31
+ }
32
+
33
+ &[type="warning"] {
34
+ --alert--color: light-dark(#{colors.$amber_900}, #{colors.$amber_200});
35
+ }
36
+
37
+ &[size="small"] {
38
+ --alert--font-size: #{$-baseline * 2};
39
+ --alert--line-height: #{$-baseline * 3};
40
+ --alert--icon-size: #{$-baseline * 3};
41
+ }
42
+
43
+ .notification-alert {
44
+ display: flex;
45
+ }
46
+
47
+ .notification-alert__icon {
48
+ width: var(--alert--icon-size);
49
+ height: var(--alert--icon-size);
50
+ margin-right: #{$-baseline};
51
+ }
52
+
53
+ .notification-alert__text {
54
+ font-size: var(--alert--font-size);
55
+ line-height: var(--alert--line-height);
56
+ margin: 0;
57
+ }
58
+
59
+ .notification-alert__icon,
60
+ .notification-alert__text {
61
+ color: var(--alert--color);
62
+ }
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,83 @@
1
+ import { html, LitElement, svg } from 'lit';
2
+ import { classMap } from 'lit/directives/class-map.js';
3
+ import { ifDefined } from 'lit/directives/if-defined.js';
4
+ import { TypeIcon } from '@outbook/webcomponents-type-icon';
5
+
6
+ const SIZE_LIST = ['small', 'medium'];
7
+ const ICON_LIST = {
8
+ error: svg`<path d="M480-280q17 0 28.5-11.5T520-320q0-17-11.5-28.5T480-360q-17 0-28.5 11.5T440-320q0 17 11.5 28.5T480-280Zm0-160q17 0 28.5-11.5T520-480v-160q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640v160q0 17 11.5 28.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"/>`,
9
+ info: svg`<path d="M480-280q17 0 28.5-11.5T520-320v-160q0-17-11.5-28.5T480-520q-17 0-28.5 11.5T440-480v160q0 17 11.5 28.5T480-280Zm0-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"/>`,
10
+ success: svg`<path d="m382-354 339-339q12-12 28-12t28 12q12 12 12 28.5T777-636L410-268q-12 12-28 12t-28-12L182-440q-12-12-11.5-28.5T183-497q12-12 28.5-12t28.5 12l142 143Z"/>`,
11
+ warning: svg`<path d="M109-120q-11 0-20-5.5T75-140q-5-9-5.5-19.5T75-180l370-640q6-10 15.5-15t19.5-5q10 0 19.5 5t15.5 15l370 640q6 10 5.5 20.5T885-140q-5 9-14 14.5t-20 5.5H109Zm69-80h604L480-720 178-200Zm302-40q17 0 28.5-11.5T520-280q0-17-11.5-28.5T480-320q-17 0-28.5 11.5T440-280q0 17 11.5 28.5T480-240Zm0-120q17 0 28.5-11.5T520-400v-120q0-17-11.5-28.5T480-560q-17 0-28.5 11.5T440-520v120q0 17 11.5 28.5T480-360Zm0-100Z"/>`
12
+ };
13
+
14
+ export class ComponentNotificationAlert extends LitElement {
15
+ static properties = {
16
+ text: { type: String },
17
+ type: { type: String },
18
+ size: { type: String },
19
+ testId: { type: String }
20
+ };
21
+
22
+ createRenderRoot() {
23
+ return this;
24
+ }
25
+
26
+ render() {
27
+ const iconName = ICON_LIST[this.type] ? this.type : 'info';
28
+ const size = SIZE_LIST.includes(this.size) ? this.size : 'medium';
29
+
30
+ const mainClasses = classMap({
31
+ 'notification-alert': true,
32
+ [`notification-alert--${this.type}`]: true,
33
+ [`notification-alert--size-${size}`]: true
34
+ });
35
+
36
+ return html`
37
+ <div class="${mainClasses}" role="alert">
38
+ <div class="notification-alert__icon">
39
+ ${TypeIcon({ icon: iconName, icons: ICON_LIST })}
40
+ </div>
41
+ <p
42
+ class="notification-alert__text"
43
+ data-test-id="${ifDefined(this.testId)}"
44
+ >
45
+ ${this.text}
46
+ </p>
47
+ </div>
48
+ `;
49
+ }
50
+ }
51
+
52
+ customElements.define('outbook-notification-alert', ComponentNotificationAlert);
53
+
54
+ /**
55
+ * Wrapper function.
56
+ *
57
+ * @param {Object} props
58
+ * @param {string} props.type - Maps to the 'type' attribute ('info', 'success', 'error', 'warning')
59
+ * @param {string} props.text - Maps to the 'text' attribute
60
+ * @param {string} [props.size] - Maps to the 'size' attribute ('small', 'medium')
61
+ * @param {string} [props.testId] - Maps to the 'test-id' attribute
62
+ * @param {string} [props.extraClasses] - Classes to add to the host element
63
+ * @param {string} [props.descriptionId] - Maps to the 'id' attribute
64
+ */
65
+ export function NotificationAlert(props) {
66
+ const {
67
+ type = 'info',
68
+ text,
69
+ size = 'medium',
70
+ testId,
71
+ extraClasses,
72
+ descriptionId
73
+ } = props;
74
+
75
+ return html`<outbook-notification-alert
76
+ type="${type}"
77
+ size="${size}"
78
+ text="${text}"
79
+ test-id="${ifDefined(testId)}"
80
+ class="${ifDefined(extraClasses)}"
81
+ id="${ifDefined(descriptionId)}"
82
+ ></outbook-notification-alert>`;
83
+ }
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@outbook/webcomponents-notification-alert",
3
+ "version": "1.0.0",
4
+ "main": "notification-alert.js",
5
+ "type": "module",
6
+ "private": false,
7
+ "scripts": {},
8
+ "bugs": {
9
+ "url": "https://gitlab.com/arr2019/web-components/issues"
10
+ },
11
+ "homepage": "https://gitlab.com/arr2019/web-components/pkg/notification-alert#readme",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://gitlab.com/arr2019/web-components.git",
15
+ "folder": "pkg/notification-alert"
16
+ },
17
+ "publishConfig": {
18
+ "registry": "https://registry.npmjs.org/"
19
+ },
20
+ "author": "Antonio Rodríguez",
21
+ "license": "MIT",
22
+ "description": "Web components notification-alert",
23
+ "dependencies": {
24
+ "@outbook/colorful": ">=1.0.0",
25
+ "@outbook/design-decisions": ">=1.0.0",
26
+ "@outbook/webcomponents-type-icon": ">=1.0.0"
27
+ },
28
+ "peerDependencies": {
29
+ "sass": "^1.97.2",
30
+ "lit": "^3.0.0"
31
+ }
32
+ }