@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,204 @@
|
|
1
|
+
:host {
|
2
|
+
--mdc-dialog-content-ink-color: var(--cv-theme-on-surface-variant);
|
3
|
+
--mdc-dialog-heading-ink-color: var(--cv-theme-on-surface);
|
4
|
+
--mdc-dialog-min-width: 96vw;
|
5
|
+
--mdc-theme-surface: var(--cv-theme-surface-container-lowest);
|
6
|
+
--mdc-typography-body1-font-family: var(
|
7
|
+
--cv-typography-subtitle1-font-family
|
8
|
+
);
|
9
|
+
--mdc-typography-headline6-font-size: var(
|
10
|
+
--cv-typography-headline6-font-size
|
11
|
+
);
|
12
|
+
--mdc-typography-headline6-font-weight: var(
|
13
|
+
--cv-typography-headline1-font-weight
|
14
|
+
);
|
15
|
+
|
16
|
+
.mdc-dialog {
|
17
|
+
&.error .status-dialog__state {
|
18
|
+
background-color: var(--cv-theme-negative-8);
|
19
|
+
|
20
|
+
cv-icon {
|
21
|
+
color: var(--cv-theme-negative);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
&.positive .status-dialog__state {
|
26
|
+
background-color: var(--cv-theme-positive-8);
|
27
|
+
|
28
|
+
cv-icon {
|
29
|
+
color: var(--cv-theme-positive);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
&.warning .status-dialog__state {
|
34
|
+
background-color: var(--cv-theme-caution-8);
|
35
|
+
|
36
|
+
cv-icon {
|
37
|
+
color: var(--cv-theme-caution);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
.mdc-dialog .mdc-dialog__surface {
|
43
|
+
max-width: calc(100vw - 40px);
|
44
|
+
}
|
45
|
+
|
46
|
+
.mdc-dialog .mdc-dialog__content {
|
47
|
+
padding: 0 16px;
|
48
|
+
|
49
|
+
&.padding-bottom {
|
50
|
+
padding-bottom: 2rem;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
.mdc-dialog__actions {
|
55
|
+
flex-shrink: 0;
|
56
|
+
padding: 16px;
|
57
|
+
}
|
58
|
+
|
59
|
+
.mdc-dialog__content {
|
60
|
+
flex-grow: 1;
|
61
|
+
}
|
62
|
+
|
63
|
+
.mdc-dialog__title {
|
64
|
+
flex: 1;
|
65
|
+
line-height: var(--cv-typography-body1-line-height);
|
66
|
+
margin: 0;
|
67
|
+
padding: 0 40px 0 0;
|
68
|
+
}
|
69
|
+
|
70
|
+
.mdc-dialog__title::before {
|
71
|
+
display: none;
|
72
|
+
}
|
73
|
+
|
74
|
+
.mdc-dialog.mdc-dialog--scrollable .mdc-dialog__title,
|
75
|
+
.mdc-dialog.mdc-dialog--scrollable .mdc-dialog__actions {
|
76
|
+
border: none;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
.status-dialog__arrow-icon {
|
81
|
+
margin-top: 2px;
|
82
|
+
|
83
|
+
&.open {
|
84
|
+
transform: rotate(0deg);
|
85
|
+
transition: transform 250ms ease-out;
|
86
|
+
}
|
87
|
+
|
88
|
+
&.close {
|
89
|
+
transform: rotate(180deg);
|
90
|
+
transition: transform 250ms ease-in;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
.status-dialog__container {
|
95
|
+
display: flex;
|
96
|
+
}
|
97
|
+
|
98
|
+
.status-dialog__content {
|
99
|
+
display: flex;
|
100
|
+
flex: 1;
|
101
|
+
flex-direction: column;
|
102
|
+
}
|
103
|
+
|
104
|
+
.status-dialog__container,
|
105
|
+
.status-dialog__content {
|
106
|
+
max-height: calc(100% - 32px);
|
107
|
+
overflow-y: auto;
|
108
|
+
}
|
109
|
+
|
110
|
+
.status-dialog__details {
|
111
|
+
display: none;
|
112
|
+
|
113
|
+
&.visible {
|
114
|
+
display: block;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
.status-dialog__heading {
|
119
|
+
--mdc-icon-button-size: 40px;
|
120
|
+
|
121
|
+
align-items: start;
|
122
|
+
box-sizing: border-box;
|
123
|
+
display: inline-flex;
|
124
|
+
justify-content: space-between;
|
125
|
+
padding: 18px 16px;
|
126
|
+
width: 100%;
|
127
|
+
|
128
|
+
&.no-heading {
|
129
|
+
justify-content: flex-end;
|
130
|
+
}
|
131
|
+
|
132
|
+
.status-dialog__close-icon {
|
133
|
+
position: absolute;
|
134
|
+
right: 8px;
|
135
|
+
top: 10px;
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
.status-dialog__state {
|
140
|
+
--mdc-icon-size: 32px;
|
141
|
+
|
142
|
+
padding: 14px 16px 0;
|
143
|
+
|
144
|
+
cv-icon {
|
145
|
+
font-variation-settings: 'FILL' 1;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
.status-dialog__toggle-details {
|
150
|
+
align-items: center;
|
151
|
+
color: var(--cv-theme-primary);
|
152
|
+
cursor: pointer;
|
153
|
+
display: inline-flex;
|
154
|
+
font-size: 14px;
|
155
|
+
font-style: normal;
|
156
|
+
font-weight: 400;
|
157
|
+
letter-spacing: 0.25px;
|
158
|
+
line-height: 20px;
|
159
|
+
padding: 16px 0;
|
160
|
+
}
|
161
|
+
|
162
|
+
@media screen and (min-width: 600px) {
|
163
|
+
:host {
|
164
|
+
--mdc-dialog-min-width: 575px;
|
165
|
+
|
166
|
+
.mdc-dialog .mdc-dialog__surface {
|
167
|
+
max-width: 575px;
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
@media screen and (max-width: 480px) {
|
173
|
+
:host {
|
174
|
+
.status-dialog__container {
|
175
|
+
flex-direction: column;
|
176
|
+
}
|
177
|
+
|
178
|
+
.status-dialog__heading .status-dialog__close-icon {
|
179
|
+
top: 18px;
|
180
|
+
}
|
181
|
+
|
182
|
+
.status-dialog__state {
|
183
|
+
padding: 4px;
|
184
|
+
|
185
|
+
cv-icon {
|
186
|
+
display: none;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
.mdc-dialog {
|
191
|
+
&.error .status-dialog__state {
|
192
|
+
background-color: var(--cv-theme-negative);
|
193
|
+
}
|
194
|
+
|
195
|
+
&.positive .status-dialog__state {
|
196
|
+
background-color: var(--cv-theme-positive);
|
197
|
+
}
|
198
|
+
|
199
|
+
&.warning .status-dialog__state {
|
200
|
+
background-color: var(--cv-theme-caution);
|
201
|
+
}
|
202
|
+
}
|
203
|
+
}
|
204
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
/**
|
2
|
+
* @vitest-environment jsdom
|
3
|
+
*/
|
4
|
+
import { it, describe, expect, beforeAll } from 'vitest';
|
5
|
+
import { CovalentStatusDialog } from './status-dialog';
|
6
|
+
|
7
|
+
describe('Dialog', () => {
|
8
|
+
let dialogElements: NodeListOf<CovalentStatusDialog>;
|
9
|
+
const heading = 'Test heading';
|
10
|
+
const content = 'Content in dialog';
|
11
|
+
|
12
|
+
beforeAll(() => {
|
13
|
+
document.body.innerHTML = `<cv-status-dialog heading="${heading}">${content}</cv-status-dialog>
|
14
|
+
<cv-status-dialog state="positive" heading="${heading}">
|
15
|
+
${content}
|
16
|
+
<div slot="details">Additional details</div>
|
17
|
+
</cv-status-dialog>
|
18
|
+
`;
|
19
|
+
dialogElements = document.body.querySelectorAll('cv-status-dialog');
|
20
|
+
});
|
21
|
+
|
22
|
+
it('should work', () => {
|
23
|
+
expect(new CovalentStatusDialog()).toBeDefined();
|
24
|
+
});
|
25
|
+
|
26
|
+
it('should display heading and content', () => {
|
27
|
+
const dialog = dialogElements[0];
|
28
|
+
expect(dialog.heading).toBe(heading);
|
29
|
+
expect(dialog.innerHTML).toContain(content);
|
30
|
+
});
|
31
|
+
|
32
|
+
it('should set the state of the dialog', () => {
|
33
|
+
const dialog = dialogElements[1];
|
34
|
+
expect(dialog.state).toBe('positive');
|
35
|
+
});
|
36
|
+
|
37
|
+
it('should show details link when details are present', () => {
|
38
|
+
const dialog = dialogElements[1];
|
39
|
+
expect(dialog.showDetailsLink).toBe(true);
|
40
|
+
});
|
41
|
+
|
42
|
+
it('should toggle details open and close', () => {
|
43
|
+
const dialog = dialogElements[1];
|
44
|
+
expect(dialog['expandDetails']).toBe(false);
|
45
|
+
expect(dialog.toggleDetails());
|
46
|
+
expect(dialog['expandDetails']).toBe(true);
|
47
|
+
});
|
48
|
+
});
|
@@ -0,0 +1,136 @@
|
|
1
|
+
import '../code-snippet/code-snippet';
|
2
|
+
import '../button/button';
|
3
|
+
import '../icon/icon';
|
4
|
+
import '../icon-button/icon-button';
|
5
|
+
import './status-dialog';
|
6
|
+
|
7
|
+
const dialogContent = {
|
8
|
+
error: `<p style="margin: 0;">
|
9
|
+
We’re experiencing an issue in the system, so the users didn’t get added.
|
10
|
+
</p>
|
11
|
+
<p style="margin-bottom: 0;">
|
12
|
+
Find a fix in the knowledge base. If the issue persists, contact Teradata Support and include the error details.
|
13
|
+
</p>`,
|
14
|
+
positive: `<p style="margin: 0;">
|
15
|
+
We’ve successfully added data sharing users.
|
16
|
+
</p>`,
|
17
|
+
warning: `<p style="margin: 0;">
|
18
|
+
This action will stop a process in use by other users, including: user a, user b, user c
|
19
|
+
</p>`,
|
20
|
+
};
|
21
|
+
|
22
|
+
const sqlContent = `
|
23
|
+
SELECT * FROM load_to_teradata (
|
24
|
+
ON (
|
25
|
+
SELECT "class" AS class_col,
|
26
|
+
"variable" AS variable_col,
|
27
|
+
"type" AS type_col,
|
28
|
+
category,
|
29
|
+
cnt,
|
30
|
+
"sum" AS sum_col,
|
31
|
+
"sumSq",
|
32
|
+
"totalCnt"
|
33
|
+
FROM aster_nb_modelSC
|
34
|
+
)
|
35
|
+
tdpid ('sdt12432.labs.teradata.com')
|
36
|
+
username ('sample_user')
|
37
|
+
password ('sample_user')
|
38
|
+
target_table ('td_nb_modelSC')
|
39
|
+
);
|
40
|
+
`;
|
41
|
+
|
42
|
+
export default {
|
43
|
+
title: 'Components/Status Dialog',
|
44
|
+
argTypes: {
|
45
|
+
state: {
|
46
|
+
options: ['error', 'positive', 'warning'],
|
47
|
+
control: { type: 'select' },
|
48
|
+
},
|
49
|
+
},
|
50
|
+
args: {
|
51
|
+
state: 'error',
|
52
|
+
open: false,
|
53
|
+
hideActions: false,
|
54
|
+
heading: 'Basic heading for the dialog',
|
55
|
+
},
|
56
|
+
};
|
57
|
+
|
58
|
+
const Template = ({ state, hideActions, heading }) => {
|
59
|
+
document.addEventListener(
|
60
|
+
'DOMContentLoaded',
|
61
|
+
() => {
|
62
|
+
const button = document.body.querySelector('#dialog-button');
|
63
|
+
button.addEventListener('click', () => {
|
64
|
+
const dialog = document.body.querySelector('#dialog');
|
65
|
+
dialog.open = true;
|
66
|
+
});
|
67
|
+
},
|
68
|
+
{ once: true }
|
69
|
+
);
|
70
|
+
|
71
|
+
const buttonName = `${heading}`.includes('Basic')
|
72
|
+
? 'Open basic dialog'
|
73
|
+
: `${`${state[0]}`.toUpperCase()}${`${state}`.substring(1)}`;
|
74
|
+
|
75
|
+
return `
|
76
|
+
<cv-button id="dialog-button" raised>${buttonName}</cv-button>
|
77
|
+
<cv-status-dialog id="dialog" state="${state}" heading="${heading}" ${
|
78
|
+
hideActions ? 'hideActions' : ''
|
79
|
+
} scrimClickAction="" >
|
80
|
+
${dialogContent[state]}
|
81
|
+
<cv-button raised slot="primaryAction" dialogAction="close">Close</cv-button>
|
82
|
+
</cv-status-dialog>`;
|
83
|
+
};
|
84
|
+
|
85
|
+
const TemplateWithDetails = ({ state, hideActions, heading }) => {
|
86
|
+
document.addEventListener(
|
87
|
+
'DOMContentLoaded',
|
88
|
+
() => {
|
89
|
+
const button = document.body.querySelector('#dialog-button-2');
|
90
|
+
button.addEventListener('click', () => {
|
91
|
+
const dialog = document.body.querySelector('#dialog-2');
|
92
|
+
dialog.open = true;
|
93
|
+
});
|
94
|
+
},
|
95
|
+
{ once: true }
|
96
|
+
);
|
97
|
+
|
98
|
+
return `
|
99
|
+
<cv-button id="dialog-button-2" raised>Open dialog with details</cv-button>
|
100
|
+
<cv-status-dialog id="dialog-2" state="${state}" heading="${heading}" ${
|
101
|
+
hideActions ? 'hideActions' : ''
|
102
|
+
} scrimClickAction="" >
|
103
|
+
${dialogContent[state]}
|
104
|
+
<div slot="details">
|
105
|
+
<cv-code-snippet language="sql" hideHeader=true>
|
106
|
+
${sqlContent}
|
107
|
+
</cv-code-snippet>
|
108
|
+
</div>
|
109
|
+
<cv-button raised slot="primaryAction" dialogAction="close">Close</cv-button>
|
110
|
+
</cv-status-dialog>`;
|
111
|
+
};
|
112
|
+
|
113
|
+
export const Basic = Template.bind({});
|
114
|
+
|
115
|
+
export const Positive = Template.bind({});
|
116
|
+
Positive.args = {
|
117
|
+
state: 'positive',
|
118
|
+
heading: 'Data sharing users added',
|
119
|
+
};
|
120
|
+
|
121
|
+
export const Warning = Template.bind({});
|
122
|
+
Warning.args = {
|
123
|
+
state: 'warning',
|
124
|
+
heading: 'Warning',
|
125
|
+
};
|
126
|
+
|
127
|
+
export const Error = Template.bind({});
|
128
|
+
Error.args = {
|
129
|
+
state: 'error',
|
130
|
+
heading: 'Couldn’t add data sharing users',
|
131
|
+
};
|
132
|
+
|
133
|
+
export const WithDetails = TemplateWithDetails.bind({});
|
134
|
+
WithDetails.args = {
|
135
|
+
heading: 'Couldn’t add data sharing users',
|
136
|
+
};
|
@@ -0,0 +1,188 @@
|
|
1
|
+
import { css, html, unsafeCSS } from 'lit';
|
2
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
3
|
+
import { styles as baseStyles } from '@material/mwc-dialog/mwc-dialog.css';
|
4
|
+
import { classMap } from 'lit/directives/class-map.js';
|
5
|
+
import CovalentDialog from '../dialog/dialog';
|
6
|
+
import styles from './status-dialog.scss?inline';
|
7
|
+
import '../icon/icon';
|
8
|
+
import '../icon-button/icon-button';
|
9
|
+
|
10
|
+
declare global {
|
11
|
+
interface HTMLElementTagNameMap {
|
12
|
+
'cv-status-dialog': CovalentStatusDialog;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Status Dialog
|
18
|
+
*
|
19
|
+
* @slot - This element has a slot
|
20
|
+
*/
|
21
|
+
@customElement('cv-status-dialog')
|
22
|
+
export class CovalentStatusDialog extends CovalentDialog {
|
23
|
+
@query('#details')
|
24
|
+
_details?: HTMLSlotElement;
|
25
|
+
|
26
|
+
/**
|
27
|
+
* The state representation error|positive|warning
|
28
|
+
*/
|
29
|
+
@property({ type: String })
|
30
|
+
state: 'error' | 'positive' | 'warning' = 'error';
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Whether the content details are expanded
|
34
|
+
*/
|
35
|
+
@state()
|
36
|
+
protected expandDetails = false;
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Whether the expand details link is shown
|
40
|
+
*/
|
41
|
+
@state()
|
42
|
+
showDetailsLink = false;
|
43
|
+
|
44
|
+
static override styles = [
|
45
|
+
baseStyles,
|
46
|
+
css`
|
47
|
+
${unsafeCSS(styles)}
|
48
|
+
`,
|
49
|
+
];
|
50
|
+
|
51
|
+
protected override firstUpdated(): void {
|
52
|
+
super.firstUpdated();
|
53
|
+
if (this._details) {
|
54
|
+
const detailNodes = this._details.assignedNodes({
|
55
|
+
flatten: true,
|
56
|
+
}) as Element[];
|
57
|
+
|
58
|
+
// Filter out non-element nodes
|
59
|
+
this.showDetailsLink = detailNodes.some(
|
60
|
+
(node) => node.nodeType === Node.ELEMENT_NODE
|
61
|
+
);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
toggleDetails() {
|
66
|
+
this.expandDetails = !this.expandDetails;
|
67
|
+
}
|
68
|
+
|
69
|
+
private _getStatusIcon(): string {
|
70
|
+
switch (this.state) {
|
71
|
+
case 'positive':
|
72
|
+
return 'check';
|
73
|
+
default:
|
74
|
+
return this.state;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
// Renders the details section in the dialog content
|
79
|
+
renderDetails() {
|
80
|
+
const detailsClasses = {
|
81
|
+
'status-dialog__details': true,
|
82
|
+
visible: this.expandDetails,
|
83
|
+
};
|
84
|
+
|
85
|
+
const animation = {
|
86
|
+
open: !this.expandDetails,
|
87
|
+
close: this.expandDetails,
|
88
|
+
};
|
89
|
+
|
90
|
+
const arrow = html`<cv-icon
|
91
|
+
class="${classMap(animation)} status-dialog__arrow-icon"
|
92
|
+
>arrow_drop_down</cv-icon
|
93
|
+
>`;
|
94
|
+
return html`${this.showDetailsLink
|
95
|
+
? html`<div>
|
96
|
+
<span
|
97
|
+
class="status-dialog__toggle-details"
|
98
|
+
@click="${this.toggleDetails}"
|
99
|
+
>${this.expandDetails ? 'Hide details' : 'Show details'} ${arrow}
|
100
|
+
</span>
|
101
|
+
</div>`
|
102
|
+
: ''}
|
103
|
+
<slot
|
104
|
+
name="details"
|
105
|
+
id="details"
|
106
|
+
class="${classMap(detailsClasses)}"
|
107
|
+
></slot>`;
|
108
|
+
}
|
109
|
+
|
110
|
+
protected override renderHeading() {
|
111
|
+
const headingClasses = {
|
112
|
+
'status-dialog__heading': true,
|
113
|
+
'no-heading': !this.heading,
|
114
|
+
};
|
115
|
+
let heading = html``;
|
116
|
+
if (this.heading) {
|
117
|
+
heading = html`<h2 id="title" class="mdc-dialog__title">
|
118
|
+
${this.heading}
|
119
|
+
</h2>`;
|
120
|
+
}
|
121
|
+
return html`<span class="${classMap(headingClasses)}">
|
122
|
+
${heading}
|
123
|
+
<cv-icon-button
|
124
|
+
class="status-dialog__close-icon"
|
125
|
+
icon="close"
|
126
|
+
@click=${this.close}
|
127
|
+
></cv-icon-button>
|
128
|
+
</span>`;
|
129
|
+
}
|
130
|
+
|
131
|
+
override render() {
|
132
|
+
const classes = {
|
133
|
+
'mdc-dialog--stacked': this.stacked,
|
134
|
+
error: this.state === 'error',
|
135
|
+
positive: this.state === 'positive',
|
136
|
+
warning: this.state === 'warning',
|
137
|
+
};
|
138
|
+
|
139
|
+
const heading = this.renderHeading();
|
140
|
+
|
141
|
+
const details = this.renderDetails();
|
142
|
+
|
143
|
+
const actionsClasses = {
|
144
|
+
'mdc-dialog__actions': !this.hideActions,
|
145
|
+
};
|
146
|
+
|
147
|
+
const contentClasses = {
|
148
|
+
'mdc-dialog__content': true,
|
149
|
+
'padding-bottom': this.hideActions,
|
150
|
+
};
|
151
|
+
|
152
|
+
return html` <div
|
153
|
+
class="mdc-dialog ${classMap(classes)}"
|
154
|
+
role="alertdialog"
|
155
|
+
aria-modal="true"
|
156
|
+
aria-labelledby="title"
|
157
|
+
aria-describedby="content"
|
158
|
+
>
|
159
|
+
<div class="mdc-dialog__container">
|
160
|
+
<div class="mdc-dialog__surface">
|
161
|
+
<div class="status-dialog__container">
|
162
|
+
<div class="status-dialog__state">
|
163
|
+
<cv-icon>${this._getStatusIcon()}<cv-icon>
|
164
|
+
</div>
|
165
|
+
<div class="status-dialog__content">
|
166
|
+
${heading}
|
167
|
+
<div id="content" class="${classMap(contentClasses)}">
|
168
|
+
<slot id="contentSlot"></slot>
|
169
|
+
${details}
|
170
|
+
</div>
|
171
|
+
<footer id="actions" class="${classMap(actionsClasses)}">
|
172
|
+
<span>
|
173
|
+
<slot name="secondaryAction"></slot>
|
174
|
+
</span>
|
175
|
+
<span>
|
176
|
+
<slot name="primaryAction"></slot>
|
177
|
+
</span>
|
178
|
+
</footer>
|
179
|
+
</div>
|
180
|
+
</div>
|
181
|
+
</div>
|
182
|
+
</div>
|
183
|
+
<div class="mdc-dialog__scrim"></div>
|
184
|
+
</div>`;
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
export default CovalentStatusDialog;
|
@@ -0,0 +1,79 @@
|
|
1
|
+
@mixin theme {
|
2
|
+
.status-header {
|
3
|
+
--cv-status-header-background: transparent;
|
4
|
+
--cv-status-header-icon-background: var(
|
5
|
+
--mdc-theme-surface-neutral-highlight-hover
|
6
|
+
);
|
7
|
+
--cv-status-header-icon-color: var(--mdc-theme-text-icon-on-background);
|
8
|
+
--cv-status-header-status-color: var(--mdc-theme-on-surface);
|
9
|
+
|
10
|
+
background-color: var(--cv-status-header-background);
|
11
|
+
|
12
|
+
.status-header-content {
|
13
|
+
max-width: inherit;
|
14
|
+
flex-direction: column;
|
15
|
+
}
|
16
|
+
|
17
|
+
.status-header-icon {
|
18
|
+
background-color: var(--cv-status-header-icon-background);
|
19
|
+
color: var(--cv-status-header-icon-color);
|
20
|
+
}
|
21
|
+
|
22
|
+
.status-header-text {
|
23
|
+
--mdc-theme-primary: var(--mdc-theme-surface-neutral-highlight-hover);
|
24
|
+
--mdc-theme-on-surface: var(--mdc-theme-text-icon-on-background);
|
25
|
+
|
26
|
+
color: var(--cv-status-header-status-color);
|
27
|
+
}
|
28
|
+
|
29
|
+
.status-header-helper {
|
30
|
+
color: var(--mdc-theme-text-secondary-on-background);
|
31
|
+
}
|
32
|
+
|
33
|
+
.status-header-title-text {
|
34
|
+
color: var(--mdc-theme-on-surface);
|
35
|
+
}
|
36
|
+
|
37
|
+
&.active {
|
38
|
+
--cv-status-header-background: var(
|
39
|
+
--mdc-theme-surface-secondary-highlight
|
40
|
+
);
|
41
|
+
--cv-status-header-icon-background: var(
|
42
|
+
--mdc-theme-surface-secondary-highlight-hover
|
43
|
+
);
|
44
|
+
--cv-status-header-icon-color: var(--mdc-theme-secondary);
|
45
|
+
--cv-status-header-status-color: var(--mdc-theme-secondary);
|
46
|
+
}
|
47
|
+
|
48
|
+
&.caution {
|
49
|
+
--cv-status-header-background: var(--mdc-theme-surface-caution-highlight);
|
50
|
+
--cv-status-header-icon-background: var(
|
51
|
+
--mdc-theme-surface-caution-highlight-hover
|
52
|
+
);
|
53
|
+
--cv-status-header-icon-color: var(--mdc-theme-caution);
|
54
|
+
--cv-status-header-status-color: var(--mdc-theme-caution);
|
55
|
+
}
|
56
|
+
|
57
|
+
&.error {
|
58
|
+
--cv-status-header-background: var(
|
59
|
+
--mdc-theme-surface-negative-highlight
|
60
|
+
);
|
61
|
+
--cv-status-header-icon-background: var(
|
62
|
+
--mdc-theme-surface-negative-highlight-hover
|
63
|
+
);
|
64
|
+
--cv-status-header-icon-color: var(--mdc-theme-negative);
|
65
|
+
--cv-status-header-status-color: var(--mdc-theme-negative);
|
66
|
+
}
|
67
|
+
|
68
|
+
&.positive {
|
69
|
+
--cv-status-header-background: var(
|
70
|
+
--mdc-theme-surface-positive-highlight
|
71
|
+
);
|
72
|
+
--cv-status-header-icon-background: var(
|
73
|
+
--mdc-theme-surface-positive-highlight-hover
|
74
|
+
);
|
75
|
+
--cv-status-header-icon-color: var(--mdc-theme-positive);
|
76
|
+
--cv-status-header-status-color: var(--mdc-theme-positive);
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { html, LitElement } from 'lit';
|
2
|
+
import { classMap } from 'lit/directives/class-map.js';
|
3
|
+
import { property } from 'lit/decorators.js';
|
4
|
+
|
5
|
+
export class StatusHeaderBase extends LitElement {
|
6
|
+
@property() state: 'active' | 'positive' | 'caution' | 'error' | 'neutral' =
|
7
|
+
'neutral';
|
8
|
+
@property({ type: String }) statusText = '';
|
9
|
+
@property({ type: String }) statusHelper = '';
|
10
|
+
@property({ type: String }) titleText = '';
|
11
|
+
|
12
|
+
protected override render() {
|
13
|
+
const classes = {
|
14
|
+
active: this.state === 'active',
|
15
|
+
caution: this.state === 'caution',
|
16
|
+
error: this.state === 'error',
|
17
|
+
positive: this.state === 'positive',
|
18
|
+
};
|
19
|
+
|
20
|
+
return html`
|
21
|
+
<div class="status-header ${classMap(classes)}">
|
22
|
+
<div class="status-header-title">
|
23
|
+
<div class="status-header-title-text">${this.titleText}</div>
|
24
|
+
<slot name="status-header-actions"></slot>
|
25
|
+
</div>
|
26
|
+
<div class="status-header-status">
|
27
|
+
<div class="status-header-icon">
|
28
|
+
<slot name="status-header-icon"></slot>
|
29
|
+
</div>
|
30
|
+
<div class="status-header-text-block">
|
31
|
+
<div class="status-header-text">${this.statusText}</div>
|
32
|
+
<div class="status-header-helper">${this.statusHelper}</div>
|
33
|
+
</div>
|
34
|
+
<div class="status-header-slot">
|
35
|
+
<slot name="status-header-text"></slot>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
<slot></slot>
|
39
|
+
</div>
|
40
|
+
`;
|
41
|
+
}
|
42
|
+
}
|