@covalent/components 0.0.0-COVALENT
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/.babelrc +10 -0
- package/.eslintrc.json +18 -0
- package/.storybook/main.js +34 -0
- package/.storybook/manager-head.html +62 -0
- package/.storybook/manager.js +1 -0
- package/.storybook/preview-head.html +20 -0
- package/.storybook/preview.js +20 -0
- package/README.md +179 -0
- package/component-config.json +313 -0
- package/index.html +288 -0
- package/jest.config.js +18 -0
- package/package.json +315 -0
- package/project.json +104 -0
- package/public/index.scss +1 -0
- package/public/reset.css +128 -0
- package/src/action-ribbon/_action-ribbon.theme.scss +90 -0
- package/src/action-ribbon/action-ribbon-base.ts +164 -0
- package/src/action-ribbon/action-ribbon.scss +20 -0
- package/src/action-ribbon/action-ribbon.spec.ts +11 -0
- package/src/action-ribbon/action-ribbon.stories.js +78 -0
- package/src/action-ribbon/action-ribbon.ts +26 -0
- package/src/alert/_alert.theme.scss +116 -0
- package/src/alert/alert-base.ts +175 -0
- package/src/alert/alert.scss +55 -0
- package/src/alert/alert.spec.ts +26 -0
- package/src/alert/alert.stories.js +76 -0
- package/src/alert/alert.ts +26 -0
- package/src/app-shell/app-shell.scss +387 -0
- package/src/app-shell/app-shell.stories.js +323 -0
- package/src/app-shell/app-shell.ts +388 -0
- package/src/badge/badge.scss +60 -0
- package/src/badge/badge.spec.ts +40 -0
- package/src/badge/badge.stories.js +88 -0
- package/src/badge/badge.ts +122 -0
- package/src/button/Overview.mdx +160 -0
- package/src/button/button.scss +28 -0
- package/src/button/button.spec.ts +11 -0
- package/src/button/button.stories.js +102 -0
- package/src/button/button.ts +17 -0
- package/src/card/card-base.ts +69 -0
- package/src/card/card.scss +45 -0
- package/src/card/card.spec.ts +11 -0
- package/src/card/card.ts +21 -0
- package/src/card/cards.stories.js +40 -0
- package/src/checkbox/checkbox.scss +8 -0
- package/src/checkbox/checkbox.spec.ts +11 -0
- package/src/checkbox/checkbox.stories.js +61 -0
- package/src/checkbox/checkbox.ts +18 -0
- package/src/chips/chip-base.ts +276 -0
- package/src/chips/chip-set-base.ts +184 -0
- package/src/chips/chip-set.scss +15 -0
- package/src/chips/chip-set.spec.ts +11 -0
- package/src/chips/chip-set.ts +27 -0
- package/src/chips/chip.scss +40 -0
- package/src/chips/chip.spec.ts +11 -0
- package/src/chips/chip.ts +26 -0
- package/src/chips/chips.stories.js +81 -0
- package/src/circular-progress/circular-progress.spec.ts +11 -0
- package/src/circular-progress/circular-progress.stories.js +40 -0
- package/src/circular-progress/circular-progress.ts +16 -0
- package/src/code-editor/code-editor.scss +20 -0
- package/src/code-editor/code-editor.spec.ts +11 -0
- package/src/code-editor/code-editor.stories.js +44 -0
- package/src/code-editor/code-editor.theme.ts +199 -0
- package/src/code-editor/code-editor.ts +231 -0
- package/src/code-snippet/code-snippet.scss +126 -0
- package/src/code-snippet/code-snippet.spec.ts +11 -0
- package/src/code-snippet/code-snippet.stories.js +134 -0
- package/src/code-snippet/code-snippet.ts +93 -0
- package/src/data-table/_data-table.theme.scss +39 -0
- package/src/data-table/data-table.stories.js +24 -0
- package/src/data-table/data-table.stories.scss +11 -0
- package/src/dialog/Overview.mdx +39 -0
- package/src/dialog/dialog.scss +17 -0
- package/src/dialog/dialog.spec.ts +11 -0
- package/src/dialog/dialog.stories.js +89 -0
- package/src/dialog/dialog.ts +44 -0
- package/src/drawer/drawer.scss +4 -0
- package/src/drawer/drawer.spec.ts +11 -0
- package/src/drawer/drawer.ts +18 -0
- package/src/empty-state/_empty-state.theme.scss +0 -0
- package/src/empty-state/empty-state.scss +67 -0
- package/src/empty-state/empty-state.spec.ts +11 -0
- package/src/empty-state/empty-state.stories.js +117 -0
- package/src/empty-state/empty-state.ts +61 -0
- package/src/expansion-panel/Overview.mdx +108 -0
- package/src/expansion-panel/expansion-panel-incorrect-example.png +0 -0
- package/src/expansion-panel/expansion-panel-item.scss +243 -0
- package/src/expansion-panel/expansion-panel-item.ts +95 -0
- package/src/expansion-panel/expansion-panel.spec.ts +11 -0
- package/src/expansion-panel/expansion-panel.stories.js +76 -0
- package/src/expansion-panel/expansion-panel.ts +94 -0
- package/src/focused-page/focused-page.scss +113 -0
- package/src/focused-page/focused-page.spec.ts +11 -0
- package/src/focused-page/focused-page.stories.js +167 -0
- package/src/focused-page/focused-page.ts +201 -0
- package/src/formfield/formfield.scss +8 -0
- package/src/formfield/formfield.spec.ts +11 -0
- package/src/formfield/formfield.ts +24 -0
- package/src/full-screen-dialog/full-screen-dialog.scss +37 -0
- package/src/full-screen-dialog/full-screen-dialog.spec.ts +11 -0
- package/src/full-screen-dialog/full-screen-dialog.stories.js +172 -0
- package/src/full-screen-dialog/full-screen-dialog.ts +84 -0
- package/src/icon/_icon-list.ts +316 -0
- package/src/icon/icon-demo.scss +25 -0
- package/src/icon/icon-demo.ts +37 -0
- package/src/icon/icon.spec.ts +11 -0
- package/src/icon/icon.stories.js +55 -0
- package/src/icon/icon.ts +16 -0
- package/src/icon-button/_icon-button.theme.scss +9 -0
- package/src/icon-button/icon-button.scss +12 -0
- package/src/icon-button/icon-button.spec.ts +11 -0
- package/src/icon-button/icon-button.stories.js +24 -0
- package/src/icon-button/icon-button.ts +19 -0
- package/src/icon-button-toggle/icon-button-toggle.scss +19 -0
- package/src/icon-button-toggle/icon-button-toggle.spec.ts +11 -0
- package/src/icon-button-toggle/icon-button-toggle.stories.js +32 -0
- package/src/icon-button-toggle/icon-button-toggle.ts +50 -0
- package/src/icon-checkbox/icon-check-toggle.ts +64 -0
- package/src/icon-checkbox/icon-check.spec.ts +11 -0
- package/src/icon-checkbox/icon-checkbox.scss +95 -0
- package/src/icon-checkbox/icon-checkbox.stories.js +77 -0
- package/src/icon-lockup/icon-lockup.scss +47 -0
- package/src/icon-lockup/icon-lockup.spec.ts +11 -0
- package/src/icon-lockup/icon-lockup.stories.js +93 -0
- package/src/icon-lockup/icon-lockup.ts +125 -0
- package/src/icon-radio/icon-radio-toggle.ts +43 -0
- package/src/icon-radio/icon-radio.scss +63 -0
- package/src/icon-radio/icon-radio.spec.ts +11 -0
- package/src/icon-radio/icon-radio.stories.js +23 -0
- package/src/index.scss +1 -0
- package/src/index.ts +57 -0
- package/src/linear-progress/linear-progress.scss +4 -0
- package/src/linear-progress/linear-progress.spec.ts +11 -0
- package/src/linear-progress/linear-progress.stories.js +43 -0
- package/src/linear-progress/linear-progress.ts +18 -0
- package/src/list/Overview.mdx +91 -0
- package/src/list/_list.theme.scss +100 -0
- package/src/list/check-list-item.spec.ts +11 -0
- package/src/list/check-list-item.ts +25 -0
- package/src/list/list-item.scss +56 -0
- package/src/list/list-item.spec.ts +11 -0
- package/src/list/list-item.ts +31 -0
- package/src/list/list.scss +25 -0
- package/src/list/list.stories.js +120 -0
- package/src/list/list.ts +23 -0
- package/src/list/nav-list-item.scss +159 -0
- package/src/list/nav-list-item.ts +223 -0
- package/src/list/radio-list-item.ts +25 -0
- package/src/menu/menu.scss +3 -0
- package/src/menu/menu.spec.ts +11 -0
- package/src/menu/menu.stories.js +110 -0
- package/src/menu/menu.ts +23 -0
- package/src/notebook-cell/notebook-cell.scss +185 -0
- package/src/notebook-cell/notebook-cell.spec.ts +11 -0
- package/src/notebook-cell/notebook-cell.stories.js +87 -0
- package/src/notebook-cell/notebook-cell.ts +300 -0
- package/src/radio/radio.scss +3 -0
- package/src/radio/radio.spec.ts +11 -0
- package/src/radio/radio.stories.js +56 -0
- package/src/radio/radio.ts +18 -0
- package/src/select/select.scss +16 -0
- package/src/select/select.spec.ts +11 -0
- package/src/select/select.stories.js +57 -0
- package/src/select/select.ts +18 -0
- package/src/side-sheet/side-sheet.scss +49 -0
- package/src/side-sheet/side-sheet.spec.ts +11 -0
- package/src/side-sheet/side-sheet.stories.js +96 -0
- package/src/side-sheet/side-sheet.ts +37 -0
- package/src/skeleton/_skeleton.styles.scss +24 -0
- package/src/skeleton/skeleton.stories.js +77 -0
- package/src/slider/slider-range.ts +16 -0
- package/src/slider/slider.spec.ts +11 -0
- package/src/slider/slider.stories.js +54 -0
- package/src/slider/slider.ts +16 -0
- package/src/snackbar/snackbar.scss +8 -0
- package/src/snackbar/snackbar.spec.ts +11 -0
- package/src/snackbar/snackbar.stories.js +42 -0
- package/src/snackbar/snackbar.ts +18 -0
- package/src/status-dialog/status-dialog.scss +204 -0
- package/src/status-dialog/status-dialog.spec.ts +48 -0
- package/src/status-dialog/status-dialog.stories.js +136 -0
- package/src/status-dialog/status-dialog.ts +188 -0
- package/src/status-header/_status-header.theme.scss +79 -0
- package/src/status-header/status-header-base.ts +42 -0
- package/src/status-header/status-header-item.scss +17 -0
- package/src/status-header/status-header-item.spec.ts +11 -0
- package/src/status-header/status-header-item.ts +32 -0
- package/src/status-header/status-header.scss +57 -0
- package/src/status-header/status-header.spec.ts +11 -0
- package/src/status-header/status-header.stories.js +114 -0
- package/src/status-header/status-header.ts +26 -0
- package/src/switch/switch.scss +17 -0
- package/src/switch/switch.spec.ts +11 -0
- package/src/switch/switch.stories.js +41 -0
- package/src/switch/switch.ts +18 -0
- package/src/tab/Overview.mdx +38 -0
- package/src/tab/tab-bar.spec.ts +11 -0
- package/src/tab/tab-bar.ts +16 -0
- package/src/tab/tab.scss +10 -0
- package/src/tab/tab.spec.ts +11 -0
- package/src/tab/tab.stories.js +30 -0
- package/src/tab/tab.ts +18 -0
- package/src/text-lockup/text-lockup.scss +66 -0
- package/src/text-lockup/text-lockup.spec.ts +11 -0
- package/src/text-lockup/text-lockup.stories.js +67 -0
- package/src/text-lockup/text-lockup.ts +55 -0
- package/src/textarea/textarea.spec.ts +11 -0
- package/src/textarea/textarea.stories.js +39 -0
- package/src/textarea/textarea.ts +19 -0
- package/src/textfield/textfield.scss +34 -0
- package/src/textfield/textfield.spec.ts +11 -0
- package/src/textfield/textfield.stories.js +60 -0
- package/src/textfield/textfield.ts +25 -0
- package/src/theme/_index.scss +46 -0
- package/src/theme/prebuilt/dark-theme.scss +17 -0
- package/src/theme/prebuilt/light-theme.scss +17 -0
- package/src/toolbar/toolbar.scss +37 -0
- package/src/toolbar/toolbar.spec.ts +11 -0
- package/src/toolbar/toolbar.stories.js +66 -0
- package/src/toolbar/toolbar.ts +27 -0
- package/src/tooltip/tooltip.scss +16 -0
- package/src/tooltip/tooltip.spec.ts +11 -0
- package/src/tooltip/tooltip.stories.js +72 -0
- package/src/tooltip/tooltip.ts +185 -0
- package/src/top-app-bar/top-app-bar-fixed.ts +23 -0
- package/src/top-app-bar/top-app-bar.scss +14 -0
- package/src/top-app-bar/top-app-bar.spec.ts +11 -0
- package/src/top-app-bar/top-app-bar.stories.js +41 -0
- package/src/top-app-bar/top-app-bar.ts +23 -0
- package/src/tree-list/tree-list-item.scss +96 -0
- package/src/tree-list/tree-list-item.spec.ts +11 -0
- package/src/tree-list/tree-list-item.ts +87 -0
- package/src/tree-list/tree-list.scss +13 -0
- package/src/tree-list/tree-list.spec.ts +11 -0
- package/src/tree-list/tree-list.stories.js +151 -0
- package/src/tree-list/tree-list.ts +53 -0
- package/src/typography/typography.scss +45 -0
- package/src/typography/typography.spec.ts +11 -0
- package/src/typography/typography.stories.js +23 -0
- package/src/typography/typography.ts +27 -0
- package/stories/Introduction.mdx +47 -0
- package/stories/color-use.mdx +509 -0
- package/stories/demos/dialog.component.html +187 -0
- package/stories/demos/dialog.component.js +57 -0
- package/stories/demos/grid.content.html +99 -0
- package/stories/demos/lorem-ipsum.content.html +338 -0
- package/stories/demos/material-web.content.html +2125 -0
- package/stories/demos/table-column-sorting.content.html +92 -0
- package/stories/demos/table-pagination.content.html +139 -0
- package/stories/demos/table-progress-indicator.content.html +77 -0
- package/stories/demos/table-row-selection.content.html +219 -0
- package/stories/demos/table.content.html +64 -0
- package/stories/demos/top-app-bar.component.js +57 -0
- package/stories/guide-representing-state.mdx +282 -0
- package/stories/info-and-help.mdx +484 -0
- package/stories/item-detail-and-editing.mdx +529 -0
- package/stories/markdown-elements.mdx +194 -0
- package/stories/writing-and-naming.mdx +157 -0
- package/tsconfig.json +34 -0
- package/tsconfig.lib.json +17 -0
- package/tsconfig.spec.json +14 -0
- package/types.d.ts +15 -0
- package/vite.config.js +58 -0
@@ -0,0 +1,116 @@
|
|
1
|
+
@mixin theme() {
|
2
|
+
.mdc-banner {
|
3
|
+
--mdc-theme-surface: var(--cv-theme-surface-container-highest);
|
4
|
+
--mdc-theme-text-primary-on-background: var(--cv-theme-on-surface);
|
5
|
+
--mdc-theme-text-secondary-on-background: var(--cv-theme-on-surface);
|
6
|
+
|
7
|
+
background-color: var(--mdc-theme-surface);
|
8
|
+
|
9
|
+
.mdc-banner__graphic {
|
10
|
+
--mdc-theme-surface: var(--mdc-theme-text-icon-on-background);
|
11
|
+
}
|
12
|
+
|
13
|
+
.mdc-banner__text {
|
14
|
+
color: var(--mdc-theme-text-primary-on-background);
|
15
|
+
|
16
|
+
.mdc-typography--body2 {
|
17
|
+
font-family: var(--mdc-typography-body2-font-family);
|
18
|
+
font-size: var(--mdc-typography-body2-font-size);
|
19
|
+
font-weight: var(--mdc-typography-body2-font-weight);
|
20
|
+
line-height: var(--mdc-typography-body2-line-height);
|
21
|
+
}
|
22
|
+
|
23
|
+
.mdc-typography--body1 {
|
24
|
+
color: var(--mdc-theme-text-secondary-on-background);
|
25
|
+
font-family: var(--mdc-typography-body1-font-family);
|
26
|
+
font-size: var(--mdc-typography-body1-font-size);
|
27
|
+
font-weight: var(--mdc-typography-body1-font-weight);
|
28
|
+
line-height: var(--mdc-typography-body1-line-height);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
&.cv-banner--inline {
|
33
|
+
--mdc-theme-surface: var(--cv-theme-surface-container);
|
34
|
+
}
|
35
|
+
|
36
|
+
&.caution {
|
37
|
+
--mdc-theme-surface: var(--mdc-theme-caution);
|
38
|
+
--mdc-theme-text-primary-on-background: var(--mdc-theme-on-caution);
|
39
|
+
--mdc-theme-text-secondary-on-background: var(--mdc-theme-on-caution);
|
40
|
+
--mdc-theme-text-icon-on-background: var(--mdc-theme-on-caution);
|
41
|
+
|
42
|
+
&.cv-banner--inline {
|
43
|
+
--mdc-theme-surface: var(--cv-theme-caution-container);
|
44
|
+
--mdc-theme-text-primary-on-background: var(
|
45
|
+
--mdc-theme-on-caution-container
|
46
|
+
);
|
47
|
+
--mdc-theme-text-secondary-on-background: var(
|
48
|
+
--mdc-theme-on-caution-container
|
49
|
+
);
|
50
|
+
--mdc-theme-text-icon-on-background: var(
|
51
|
+
--mdc-theme-on-caution-container
|
52
|
+
);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
&.negative {
|
57
|
+
--mdc-theme-surface: var(--mdc-theme-negative);
|
58
|
+
--mdc-theme-text-primary-on-background: var(--mdc-theme-on-negative);
|
59
|
+
--mdc-theme-text-secondary-on-background: var(--mdc-theme-on-negative);
|
60
|
+
--mdc-theme-text-icon-on-background: var(--mdc-theme-on-negative);
|
61
|
+
|
62
|
+
&.cv-banner--inline {
|
63
|
+
--mdc-theme-surface: var(--cv-theme-negative-container);
|
64
|
+
--mdc-theme-text-primary-on-background: var(
|
65
|
+
--mdc-theme-on-negative-container
|
66
|
+
);
|
67
|
+
--mdc-theme-text-secondary-on-background: var(
|
68
|
+
--mdc-theme-on-negative-container
|
69
|
+
);
|
70
|
+
--mdc-theme-text-icon-on-background: var(
|
71
|
+
--mdc-theme-on-negative-container
|
72
|
+
);
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
&.active {
|
77
|
+
--mdc-theme-surface: var(--mdc-theme-secondary);
|
78
|
+
--mdc-theme-text-primary-on-background: var(--mdc-theme-on-secondary);
|
79
|
+
--mdc-theme-text-secondary-on-background: var(--mdc-theme-on-secondary);
|
80
|
+
--mdc-theme-text-icon-on-background: var(--mdc-theme-on-secondary);
|
81
|
+
|
82
|
+
&.cv-banner--inline {
|
83
|
+
--mdc-theme-surface: var(--cv-theme-secondary-container);
|
84
|
+
--mdc-theme-text-primary-on-background: var(
|
85
|
+
--mdc-theme-on-secondary-container
|
86
|
+
);
|
87
|
+
--mdc-theme-text-secondary-on-background: var(
|
88
|
+
--mdc-theme-on-secondary-container
|
89
|
+
);
|
90
|
+
--mdc-theme-text-icon-on-background: var(
|
91
|
+
--mdc-theme-on-secondary-container
|
92
|
+
);
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
&.positive {
|
97
|
+
--mdc-theme-surface: var(--mdc-theme-positive);
|
98
|
+
--mdc-theme-text-primary-on-background: var(--mdc-theme-on-positive);
|
99
|
+
--mdc-theme-text-secondary-on-background: var(--mdc-theme-on-positive);
|
100
|
+
--mdc-theme-text-icon-on-background: var(--mdc-theme-on-positive);
|
101
|
+
|
102
|
+
&.cv-banner--inline {
|
103
|
+
--mdc-theme-surface: var(--cv-theme-positive-container);
|
104
|
+
--mdc-theme-text-primary-on-background: var(
|
105
|
+
--mdc-theme-on-positive-container
|
106
|
+
);
|
107
|
+
--mdc-theme-text-secondary-on-background: var(
|
108
|
+
--mdc-theme-on-positive-container
|
109
|
+
);
|
110
|
+
--mdc-theme-text-icon-on-background: var(
|
111
|
+
--mdc-theme-on-positive-container
|
112
|
+
);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
@@ -0,0 +1,175 @@
|
|
1
|
+
import { addHasRemoveClass } from '@material/mwc-base/base-element';
|
2
|
+
import { observer } from '@material/mwc-base/observer';
|
3
|
+
import { MDCBannerFoundation } from '@material/banner/foundation';
|
4
|
+
import { MDCBannerAdapter } from '@material/banner/adapter';
|
5
|
+
import { Action, CloseReason, events } from '@material/banner/constants';
|
6
|
+
|
7
|
+
import { html, LitElement, TemplateResult } from 'lit';
|
8
|
+
import { classMap } from 'lit/directives/class-map.js';
|
9
|
+
import { property, query, state } from 'lit/decorators.js';
|
10
|
+
|
11
|
+
import '../icon/icon';
|
12
|
+
|
13
|
+
export class AlertBase extends LitElement {
|
14
|
+
protected mdcFoundation!: MDCBannerFoundation;
|
15
|
+
protected readonly mdcFoundationClass = MDCBannerFoundation;
|
16
|
+
private _resizeObserver!: ResizeObserver;
|
17
|
+
|
18
|
+
@query('.mdc-banner') protected mdcRoot!: HTMLElement;
|
19
|
+
@query('.mdc-banner__content') protected mdcContent!: HTMLElement;
|
20
|
+
@query('.mdc-banner__graphic-text-wrapper')
|
21
|
+
protected mdcGraphicTextWrapper!: HTMLElement;
|
22
|
+
@state() protected currentWidth = 0;
|
23
|
+
|
24
|
+
@property({ type: Boolean, reflect: true })
|
25
|
+
@observer(function (this: AlertBase, value: boolean) {
|
26
|
+
if (this.mdcFoundation) {
|
27
|
+
if (value) {
|
28
|
+
this.mdcFoundation.open();
|
29
|
+
} else {
|
30
|
+
this.mdcFoundation.close(this.reason);
|
31
|
+
this.reason = CloseReason.UNSPECIFIED;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
})
|
35
|
+
open = true;
|
36
|
+
|
37
|
+
@property({ type: String }) titleText = '';
|
38
|
+
@property({ type: String }) descriptionText = '';
|
39
|
+
|
40
|
+
@property({ type: String }) icon = '';
|
41
|
+
@property({ type: String }) iconAriaLabel = '';
|
42
|
+
|
43
|
+
@property({ type: Boolean }) inline = false;
|
44
|
+
/**
|
45
|
+
* The state representation active|negative|positive|caution
|
46
|
+
*/
|
47
|
+
@property()
|
48
|
+
state = '';
|
49
|
+
|
50
|
+
constructor() {
|
51
|
+
super();
|
52
|
+
// Create ResizeObserver with callback
|
53
|
+
this._resizeObserver = new ResizeObserver((entries) => {
|
54
|
+
for (const entry of entries) {
|
55
|
+
const newWidth = entry.contentRect.width;
|
56
|
+
if (newWidth !== this.currentWidth) {
|
57
|
+
this.currentWidth = newWidth;
|
58
|
+
this.mdcFoundation.layout();
|
59
|
+
}
|
60
|
+
}
|
61
|
+
});
|
62
|
+
}
|
63
|
+
|
64
|
+
// Cleanup when element is removed
|
65
|
+
disconnectedCallback() {
|
66
|
+
super.disconnectedCallback();
|
67
|
+
this._resizeObserver.disconnect();
|
68
|
+
}
|
69
|
+
|
70
|
+
protected reason: CloseReason = CloseReason.UNSPECIFIED;
|
71
|
+
|
72
|
+
protected override render() {
|
73
|
+
const classes = {
|
74
|
+
'mdc-banner': true,
|
75
|
+
'cv-banner--inline': this.inline,
|
76
|
+
negative: this.state === 'negative',
|
77
|
+
positive: this.state === 'positive',
|
78
|
+
caution: this.state === 'caution',
|
79
|
+
active: this.state === 'active',
|
80
|
+
};
|
81
|
+
return html` <div class="${classMap(classes)}" role="banner">
|
82
|
+
<div
|
83
|
+
class="mdc-banner__content"
|
84
|
+
role="alertdialog"
|
85
|
+
aria-live="assertive"
|
86
|
+
aria-label="${this.titleText}"
|
87
|
+
>
|
88
|
+
<div class="mdc-banner__graphic-text-wrapper">
|
89
|
+
${this.icon ? this.renderIcon() : ''}
|
90
|
+
<div class="mdc-banner__text">
|
91
|
+
<span class="mdc-typography--body1">${this.titleText}</span>
|
92
|
+
<div class="mdc-typography--body2">${this.descriptionText}</div>
|
93
|
+
</div>
|
94
|
+
</div>
|
95
|
+
<div class="mdc-banner__actions">
|
96
|
+
<slot name="action-items"></slot>
|
97
|
+
</div>
|
98
|
+
</div>
|
99
|
+
</div>`;
|
100
|
+
}
|
101
|
+
|
102
|
+
/** @soyTemplate */
|
103
|
+
protected renderIcon(): TemplateResult {
|
104
|
+
return html` <div
|
105
|
+
class="mdc-banner__graphic"
|
106
|
+
role="img"
|
107
|
+
aria-label="${this.iconAriaLabel}"
|
108
|
+
>
|
109
|
+
<slot name="icon">
|
110
|
+
<cv-icon class="mdc-banner__icon"> ${this.icon} </cv-icon>
|
111
|
+
</slot>
|
112
|
+
</div>`;
|
113
|
+
}
|
114
|
+
|
115
|
+
protected createAdapter(): MDCBannerAdapter {
|
116
|
+
return {
|
117
|
+
...addHasRemoveClass(this.mdcRoot),
|
118
|
+
getContentHeight: () => {
|
119
|
+
return this.mdcContent.offsetHeight;
|
120
|
+
},
|
121
|
+
setStyleProperty: (property: any, value: string) => {
|
122
|
+
this.mdcRoot.style.setProperty(property, value);
|
123
|
+
},
|
124
|
+
trapFocus: () => {
|
125
|
+
/* */
|
126
|
+
},
|
127
|
+
releaseFocus: () => {
|
128
|
+
/* */
|
129
|
+
},
|
130
|
+
notifyActionClicked: (action: Action) =>
|
131
|
+
this.dispatchEvent(
|
132
|
+
new CustomEvent(events.ACTION_CLICKED, {
|
133
|
+
bubbles: true,
|
134
|
+
cancelable: true,
|
135
|
+
detail: { reason: action },
|
136
|
+
}),
|
137
|
+
),
|
138
|
+
notifyClosed: () => {
|
139
|
+
/* */
|
140
|
+
},
|
141
|
+
notifyClosing: () => {
|
142
|
+
this.open = false;
|
143
|
+
},
|
144
|
+
notifyOpened: () => {
|
145
|
+
/* */
|
146
|
+
},
|
147
|
+
notifyOpening: () => {
|
148
|
+
this.open = true;
|
149
|
+
},
|
150
|
+
};
|
151
|
+
}
|
152
|
+
|
153
|
+
/** @export */
|
154
|
+
show() {
|
155
|
+
this.open = true;
|
156
|
+
}
|
157
|
+
|
158
|
+
/** @export */
|
159
|
+
close(reason = CloseReason.UNSPECIFIED) {
|
160
|
+
this.reason = reason;
|
161
|
+
this.open = false;
|
162
|
+
}
|
163
|
+
|
164
|
+
protected override async firstUpdated() {
|
165
|
+
if (this.mdcFoundation !== undefined) {
|
166
|
+
this.mdcFoundation.destroy();
|
167
|
+
}
|
168
|
+
this.mdcFoundation = new this.mdcFoundationClass(this.createAdapter());
|
169
|
+
if (this.open) {
|
170
|
+
this.mdcFoundation.open();
|
171
|
+
}
|
172
|
+
// Observe when element is resized
|
173
|
+
this._resizeObserver.observe(this.mdcGraphicTextWrapper);
|
174
|
+
}
|
175
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
@use '@material/banner/banner' as banner-core;
|
2
|
+
@use '@material/elevation/mixins' as elevation-mixins;
|
3
|
+
@use '@material/feature-targeting/feature-targeting';
|
4
|
+
@use '@material/shape';
|
5
|
+
|
6
|
+
@use './alert.theme';
|
7
|
+
|
8
|
+
$query: feature-targeting.all();
|
9
|
+
|
10
|
+
:host {
|
11
|
+
@include banner-core.core-styles();
|
12
|
+
@include alert.theme();
|
13
|
+
@include elevation-mixins.overlay-common(
|
14
|
+
$query
|
15
|
+
); // COPYBARA_COMMENT_THIS_LINE
|
16
|
+
|
17
|
+
.mdc-banner {
|
18
|
+
@include shape.radius(8px);
|
19
|
+
@include elevation-mixins.overlay-surface-position($query: $query);
|
20
|
+
@include elevation-mixins.overlay-dimensions(100%, $query: $query);
|
21
|
+
@include elevation-mixins.elevation(1, $query: $query);
|
22
|
+
|
23
|
+
overflow: hidden;
|
24
|
+
border: none;
|
25
|
+
|
26
|
+
.mdc-banner__content {
|
27
|
+
max-width: inherit;
|
28
|
+
}
|
29
|
+
|
30
|
+
.mdc-banner__graphic {
|
31
|
+
background: none;
|
32
|
+
margin-left: 24px;
|
33
|
+
width: 24px;
|
34
|
+
font-variation-settings: 'FILL' 1;
|
35
|
+
}
|
36
|
+
|
37
|
+
.mdc-banner__text {
|
38
|
+
margin-left: 24px;
|
39
|
+
}
|
40
|
+
|
41
|
+
.mdc-banner__actions {
|
42
|
+
align-self: center;
|
43
|
+
align-items: center;
|
44
|
+
}
|
45
|
+
|
46
|
+
&.cv-banner--inline {
|
47
|
+
@include shape.radius(0);
|
48
|
+
@include elevation-mixins.elevation(0, $query: $query);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
::slotted(*) {
|
53
|
+
margin-left: 8px;
|
54
|
+
}
|
55
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/**
|
2
|
+
* @vitest-environment jsdom
|
3
|
+
*/
|
4
|
+
import { it, describe, expect } from 'vitest';
|
5
|
+
import { CovalentAlert } from './alert';
|
6
|
+
|
7
|
+
global.ResizeObserver = class MockResizeObserver {
|
8
|
+
constructor() {
|
9
|
+
/**/
|
10
|
+
}
|
11
|
+
observe() {
|
12
|
+
/**/
|
13
|
+
}
|
14
|
+
unobserve() {
|
15
|
+
/**/
|
16
|
+
}
|
17
|
+
disconnect() {
|
18
|
+
/**/
|
19
|
+
}
|
20
|
+
};
|
21
|
+
|
22
|
+
describe('Alert', () => {
|
23
|
+
it('should work', () => {
|
24
|
+
expect(new CovalentAlert()).toBeDefined();
|
25
|
+
});
|
26
|
+
});
|
@@ -0,0 +1,76 @@
|
|
1
|
+
import './alert';
|
2
|
+
|
3
|
+
export default {
|
4
|
+
title: 'Components/Alert',
|
5
|
+
parameters: {
|
6
|
+
layout: 'padded',
|
7
|
+
},
|
8
|
+
argTypes: {
|
9
|
+
state: {
|
10
|
+
options: ['neutral', 'active', 'positive', 'negative', 'caution'],
|
11
|
+
control: { type: 'select' },
|
12
|
+
},
|
13
|
+
actionElement: {
|
14
|
+
options: ['button', 'close icon', 'none'],
|
15
|
+
control: { type: 'select' },
|
16
|
+
},
|
17
|
+
},
|
18
|
+
args: {
|
19
|
+
title: 'Alert title',
|
20
|
+
description: 'Alert description',
|
21
|
+
state: 'active',
|
22
|
+
actionElement: 'button',
|
23
|
+
},
|
24
|
+
};
|
25
|
+
|
26
|
+
export const PageLevel = ({
|
27
|
+
title,
|
28
|
+
description,
|
29
|
+
state,
|
30
|
+
icon,
|
31
|
+
actionElement,
|
32
|
+
inline,
|
33
|
+
}) => {
|
34
|
+
switch (state) {
|
35
|
+
case 'positive':
|
36
|
+
icon = 'check';
|
37
|
+
break;
|
38
|
+
case 'negative':
|
39
|
+
icon = 'error';
|
40
|
+
break;
|
41
|
+
case 'caution':
|
42
|
+
icon = 'warning';
|
43
|
+
break;
|
44
|
+
case 'active':
|
45
|
+
default:
|
46
|
+
icon = 'info';
|
47
|
+
}
|
48
|
+
|
49
|
+
return `
|
50
|
+
<cv-alert
|
51
|
+
titleText="${title}"
|
52
|
+
descriptionText="${description}"
|
53
|
+
state="${state}"
|
54
|
+
${icon ? `icon="${icon}"` : ''}
|
55
|
+
${icon ? `iconAriaLabel="${icon}"` : ''}
|
56
|
+
${inline ? `inline` : ''}>
|
57
|
+
${
|
58
|
+
actionElement === 'button'
|
59
|
+
? `<cv-button slot="action-items">Button text</cv-button>`
|
60
|
+
: ''
|
61
|
+
}
|
62
|
+
${
|
63
|
+
actionElement === 'close icon'
|
64
|
+
? `<cv-icon-button slot="action-items" icon="close"></cv-icon-button>`
|
65
|
+
: ''
|
66
|
+
}
|
67
|
+
</cv-alert>`;
|
68
|
+
};
|
69
|
+
|
70
|
+
export const Inline = PageLevel.bind({});
|
71
|
+
Inline.args = {
|
72
|
+
inline: true,
|
73
|
+
};
|
74
|
+
Inline.parameters = {
|
75
|
+
layout: 'fullscreen',
|
76
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { css, unsafeCSS } from 'lit';
|
2
|
+
import { customElement } from 'lit/decorators.js';
|
3
|
+
import { AlertBase } from './alert-base';
|
4
|
+
import styles from './alert.scss?inline';
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Action ribbon
|
8
|
+
*
|
9
|
+
* @slot - This element has a slot
|
10
|
+
*/
|
11
|
+
@customElement('cv-alert')
|
12
|
+
export class CovalentAlert extends AlertBase {
|
13
|
+
static override styles = [
|
14
|
+
css`
|
15
|
+
${unsafeCSS(styles)}
|
16
|
+
`,
|
17
|
+
];
|
18
|
+
}
|
19
|
+
|
20
|
+
declare global {
|
21
|
+
interface HTMLElementTagNameMap {
|
22
|
+
'cv-alert': CovalentAlert;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
export default CovalentAlert;
|