@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,160 @@
|
|
1
|
+
import { Canvas, DocsContainer, Meta, Story } from '@storybook/blocks';
|
2
|
+
import * as ButtonStories from './button.stories';
|
3
|
+
|
4
|
+
<Meta of={ButtonStories} />
|
5
|
+
|
6
|
+
<style>
|
7
|
+
{`
|
8
|
+
cv-button {
|
9
|
+
margin-right: 8px;
|
10
|
+
}
|
11
|
+
.docs-story div:first-of-type {
|
12
|
+
text-align: center;
|
13
|
+
}
|
14
|
+
#story--example-button--outlined,
|
15
|
+
#story--example-button--text {
|
16
|
+
margin-right: 8px;
|
17
|
+
}
|
18
|
+
cv-button[outlined].destructive {
|
19
|
+
margin-right: 4rem;
|
20
|
+
}
|
21
|
+
`}
|
22
|
+
</style>
|
23
|
+
|
24
|
+
# Buttons
|
25
|
+
|
26
|
+
## Basics
|
27
|
+
|
28
|
+
- Each page can have only one primary action button
|
29
|
+
- It is common and okay for some pages to have no primary action
|
30
|
+
- Include an icon in your button only in specific circumstances
|
31
|
+
|
32
|
+
<Canvas>
|
33
|
+
<cv-button label="Text button" />
|
34
|
+
|
35
|
+
{' '}
|
36
|
+
<cv-button label="Outlined button" outlined />
|
37
|
+
|
38
|
+
<cv-button label="Contained button" raised />
|
39
|
+
</Canvas>
|
40
|
+
|
41
|
+
---
|
42
|
+
|
43
|
+
## Anatomy
|
44
|
+
|
45
|
+
Buttons contain a text label and optional icon.
|
46
|
+
|
47
|
+
<Canvas>
|
48
|
+
<cv-button id="no-icon" raised label="No icon" />
|
49
|
+
|
50
|
+
{' '}
|
51
|
+
<cv-button id="left-icon" raised label="Left icon" icon="sailing" />
|
52
|
+
|
53
|
+
<cv-button id="right-icon" raised label="Right icon" icon="sailing" trailingIcon="true" />
|
54
|
+
</Canvas>
|
55
|
+
|
56
|
+
### Spacing
|
57
|
+
|
58
|
+
Separate all buttons with an 8px gap.
|
59
|
+
|
60
|
+
<Canvas>
|
61
|
+
<cv-button outlined label="Button" />
|
62
|
+
|
63
|
+
{' '}
|
64
|
+
<cv-button outlined label="Button" />
|
65
|
+
|
66
|
+
<cv-button outlined label="Button" />
|
67
|
+
</Canvas>
|
68
|
+
|
69
|
+
---
|
70
|
+
|
71
|
+
## Placement
|
72
|
+
|
73
|
+
Place the primary action to the right, followed by secondary actions.
|
74
|
+
|
75
|
+
#### Sequence
|
76
|
+
|
77
|
+
1. Primary action button (if any)
|
78
|
+
|
79
|
+
Many pages will not have primary actions. This is OK.
|
80
|
+
|
81
|
+
2. Secondary action buttons
|
82
|
+
|
83
|
+
3. Lesser functions as icon buttons
|
84
|
+
|
85
|
+
<Canvas>
|
86
|
+
<cv-button outlined label="Button" />
|
87
|
+
|
88
|
+
{' '}
|
89
|
+
<cv-button outlined label="Button" />
|
90
|
+
|
91
|
+
<cv-button raised label="Primary" class="primary accent" />
|
92
|
+
</Canvas>
|
93
|
+
|
94
|
+
### In footers
|
95
|
+
|
96
|
+
In footers (such as card, dialog, page, or sheet footers) align all buttons to the right, but place destructive actions to the left to minimize accidental clicks.
|
97
|
+
|
98
|
+
<Canvas>
|
99
|
+
<cv-button outlined label="Delete" class="destructive" />
|
100
|
+
|
101
|
+
{' '}
|
102
|
+
<cv-button outlined label="Button" />
|
103
|
+
|
104
|
+
<cv-button raised label="Primary" class="primary accent" />
|
105
|
+
</Canvas>
|
106
|
+
|
107
|
+
---
|
108
|
+
|
109
|
+
## Styling
|
110
|
+
|
111
|
+
Use “default” outline buttons for everything except the primary action (if any).
|
112
|
+
|
113
|
+
<Canvas>
|
114
|
+
<cv-button outlined label="Button" />
|
115
|
+
|
116
|
+
<cv-button outlined label="Button" />
|
117
|
+
</Canvas>
|
118
|
+
|
119
|
+
### Primary action
|
120
|
+
|
121
|
+
If the page has a primary action, use an “accent” contained button.
|
122
|
+
|
123
|
+
<Canvas>
|
124
|
+
<cv-button outlined label="Button" />
|
125
|
+
|
126
|
+
{' '}
|
127
|
+
<cv-button outlined label="Button" />
|
128
|
+
|
129
|
+
<cv-button raised label="Primary" class="primary accent" />
|
130
|
+
</Canvas>
|
131
|
+
|
132
|
+
### Destructive action
|
133
|
+
|
134
|
+
#### When the primary action is destructive
|
135
|
+
|
136
|
+
If the primary action is a destructive one (for example, it deletes some data), then it uses the negative color.
|
137
|
+
|
138
|
+
<Canvas>
|
139
|
+
<form>
|
140
|
+
<cv-button outlined label="Button" />
|
141
|
+
|
142
|
+
<cv-button outlined label="Button" />
|
143
|
+
|
144
|
+
<cv-button raised label="Delete" color="negative" />
|
145
|
+
|
146
|
+
</form>
|
147
|
+
</Canvas>
|
148
|
+
|
149
|
+
#### When the destructive action is not the primary action
|
150
|
+
|
151
|
+
If the destructive action is not the primary action, do not use the negative color. This calls extra attention to it, and we want the focus to remain on the primary action.
|
152
|
+
|
153
|
+
<Canvas>
|
154
|
+
<cv-button outlined label="Delete" class="destructive" />
|
155
|
+
|
156
|
+
{' '}
|
157
|
+
<cv-button outlined label="Button" />
|
158
|
+
|
159
|
+
<cv-button raised label="Primary" />
|
160
|
+
</Canvas>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
:host {
|
2
|
+
// override MDC button color
|
3
|
+
--mdc-button-outline-color: var(--cv-theme-outline);
|
4
|
+
// override MDC button text tranform
|
5
|
+
--mdc-typography-button-text-transform: none;
|
6
|
+
}
|
7
|
+
|
8
|
+
@mixin buttonColor($colorMap) {
|
9
|
+
@each $color, $value in $colorMap {
|
10
|
+
:host([color='#{$color}']) {
|
11
|
+
--mdc-theme-primary: var(--cv-theme-#{$value});
|
12
|
+
--mdc-theme-on-primary: var(--cv-theme-on-#{$value});
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
// --- apply button color --- //
|
18
|
+
@include buttonColor(
|
19
|
+
(
|
20
|
+
'primary': 'primary',
|
21
|
+
'secondary': 'secondary',
|
22
|
+
'emphasis': 'emphasis',
|
23
|
+
'neutral': 'neutral',
|
24
|
+
'caution': 'caution',
|
25
|
+
'negative': 'negative',
|
26
|
+
'positive': 'positive',
|
27
|
+
)
|
28
|
+
);
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import './button';
|
2
|
+
|
3
|
+
export default {
|
4
|
+
title: 'Components/Button',
|
5
|
+
args: {
|
6
|
+
label: 'Button',
|
7
|
+
icon: 'houseboat',
|
8
|
+
showIcon: false,
|
9
|
+
trailingIcon: false,
|
10
|
+
disabled: false,
|
11
|
+
dense: false,
|
12
|
+
},
|
13
|
+
argTypes: {
|
14
|
+
style: {
|
15
|
+
options: ['raised', 'outlined'],
|
16
|
+
control: { type: 'select' },
|
17
|
+
},
|
18
|
+
color: {
|
19
|
+
options: [
|
20
|
+
'primary',
|
21
|
+
'secondary',
|
22
|
+
'emphasis',
|
23
|
+
'positive',
|
24
|
+
'negative',
|
25
|
+
'caution',
|
26
|
+
],
|
27
|
+
control: { type: 'select' },
|
28
|
+
},
|
29
|
+
},
|
30
|
+
};
|
31
|
+
|
32
|
+
const Template = ({
|
33
|
+
label,
|
34
|
+
showIcon,
|
35
|
+
trailingIcon,
|
36
|
+
icon,
|
37
|
+
style,
|
38
|
+
color,
|
39
|
+
disabled,
|
40
|
+
dense,
|
41
|
+
}) => {
|
42
|
+
return `<cv-button id="myButton"
|
43
|
+
label="${label}"
|
44
|
+
${showIcon && trailingIcon ? `trailingIcon` : ''}
|
45
|
+
${showIcon && icon ? `icon="${icon}"` : ''}
|
46
|
+
${dense ? 'dense' : ''}
|
47
|
+
${disabled ? 'disabled' : ''}
|
48
|
+
${style}
|
49
|
+
${color ? `color="${color}"` : ''}>
|
50
|
+
</cv-button>`;
|
51
|
+
};
|
52
|
+
|
53
|
+
export const Contained = Template.bind({});
|
54
|
+
Contained.args = {
|
55
|
+
style: 'raised',
|
56
|
+
};
|
57
|
+
|
58
|
+
export const Outlined = Template.bind({});
|
59
|
+
Outlined.args = {
|
60
|
+
style: 'outlined',
|
61
|
+
};
|
62
|
+
|
63
|
+
export const Text = Template.bind({});
|
64
|
+
Text.args = {
|
65
|
+
style: 'text',
|
66
|
+
};
|
67
|
+
|
68
|
+
export const secondary = Template.bind({});
|
69
|
+
secondary.args = {
|
70
|
+
style: 'raised',
|
71
|
+
color: 'secondary',
|
72
|
+
};
|
73
|
+
|
74
|
+
export const emphasis = Template.bind({});
|
75
|
+
emphasis.args = {
|
76
|
+
style: 'raised',
|
77
|
+
color: 'emphasis',
|
78
|
+
};
|
79
|
+
|
80
|
+
export const caution = Template.bind({});
|
81
|
+
caution.args = {
|
82
|
+
style: 'raised',
|
83
|
+
color: 'caution',
|
84
|
+
};
|
85
|
+
|
86
|
+
export const negative = Template.bind({});
|
87
|
+
negative.args = {
|
88
|
+
style: 'raised',
|
89
|
+
color: 'negative',
|
90
|
+
};
|
91
|
+
|
92
|
+
export const positive = Template.bind({});
|
93
|
+
positive.args = {
|
94
|
+
style: 'raised',
|
95
|
+
color: 'positive',
|
96
|
+
};
|
97
|
+
|
98
|
+
export const dense = Template.bind({});
|
99
|
+
dense.args = {
|
100
|
+
dense: true,
|
101
|
+
style: 'raised',
|
102
|
+
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { css, unsafeCSS } from 'lit';
|
2
|
+
import { customElement } from 'lit/decorators.js';
|
3
|
+
import { ButtonBase } from '@material/mwc-button/mwc-button-base';
|
4
|
+
import { styles as baseStyles } from '@material/mwc-button/styles.css';
|
5
|
+
import styles from './button.scss?inline';
|
6
|
+
declare global {
|
7
|
+
interface HTMLElementTagNameMap {
|
8
|
+
'cv-button': CovalentButton;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
@customElement('cv-button')
|
13
|
+
export class CovalentButton extends ButtonBase {
|
14
|
+
static override styles = [baseStyles, css`${unsafeCSS(styles)}`];
|
15
|
+
}
|
16
|
+
|
17
|
+
export default CovalentButton;
|
@@ -0,0 +1,69 @@
|
|
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 CardBase extends LitElement {
|
6
|
+
/**
|
7
|
+
* The title of the card
|
8
|
+
*/
|
9
|
+
@property()
|
10
|
+
cardTitle = '';
|
11
|
+
|
12
|
+
/**
|
13
|
+
* The sub-title of the card
|
14
|
+
*/
|
15
|
+
@property()
|
16
|
+
subTitle = '';
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Displays the action bar
|
20
|
+
*/
|
21
|
+
@property({ type: Boolean }) actionBar = false;
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Displays the ripple affect in primary area
|
25
|
+
*/
|
26
|
+
@property({ type: Boolean }) interactive = false;
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Style the card as an outline variant
|
30
|
+
*/
|
31
|
+
@property({ type: Boolean }) outlined = false;
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Style the card 100% height
|
35
|
+
*/
|
36
|
+
@property({ type: Boolean }) fullHeight = false;
|
37
|
+
|
38
|
+
override render() {
|
39
|
+
const classes = {
|
40
|
+
'mdc-card': true,
|
41
|
+
'mdc-card--outlined': this.outlined,
|
42
|
+
'cv-height-full': this.fullHeight,
|
43
|
+
};
|
44
|
+
return html` <div class="${classMap(classes)}">
|
45
|
+
${this.cardTitle
|
46
|
+
? html`
|
47
|
+
<div class="mdc-card__actions mdc-typography--headline5">
|
48
|
+
${this.cardTitle}
|
49
|
+
</div>
|
50
|
+
`
|
51
|
+
: ''}
|
52
|
+
${this.interactive
|
53
|
+
? html`
|
54
|
+
<div class="mdc-card__primary-action">
|
55
|
+
<slot></slot>
|
56
|
+
<div class="mdc-card__ripple"></div>
|
57
|
+
</div>
|
58
|
+
`
|
59
|
+
: html`<slot></slot>`}
|
60
|
+
${this.actionBar
|
61
|
+
? html`
|
62
|
+
<div class="mdc-card__actions">
|
63
|
+
<slot name="card-actions"></slot>
|
64
|
+
</div>
|
65
|
+
`
|
66
|
+
: ''}
|
67
|
+
</div>`;
|
68
|
+
}
|
69
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
@use '@material/card';
|
2
|
+
|
3
|
+
@include card.core-styles;
|
4
|
+
|
5
|
+
:host([fullHeight]) {
|
6
|
+
display: block;
|
7
|
+
height: 100%;
|
8
|
+
}
|
9
|
+
|
10
|
+
.mdc-card {
|
11
|
+
--mdc-theme-surface: var(--cv-theme-surface-container-lowest, #ffffff);
|
12
|
+
|
13
|
+
box-shadow: none;
|
14
|
+
|
15
|
+
&.cv-height-full {
|
16
|
+
height: 100%;
|
17
|
+
|
18
|
+
.mdc-card__primary-action {
|
19
|
+
height: 100%;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
.mdc-typography--headline5 {
|
25
|
+
font-family: var(--mdc-typography-headline5-font-family);
|
26
|
+
font-size: var(--mdc-typography-headline5-font-size);
|
27
|
+
font-weight: var(--mdc-typography-headline5-font-weight);
|
28
|
+
line-height: var(--mdc-typography-headline5-line-height);
|
29
|
+
color: var(--mdc-theme-text-primary-on-background);
|
30
|
+
}
|
31
|
+
|
32
|
+
.mdc-card__actions {
|
33
|
+
color: var(--mdc-theme-text-primary-on-background);
|
34
|
+
justify-content: space-between;
|
35
|
+
}
|
36
|
+
|
37
|
+
.mdc-card__actions:first-of-type {
|
38
|
+
border-bottom: 1px solid var(--mdc-theme-border);
|
39
|
+
padding-left: 16px;
|
40
|
+
}
|
41
|
+
|
42
|
+
.mdc-card.mdc-card--outlined {
|
43
|
+
background-color: var(--mdc-theme-surface);
|
44
|
+
border-color: var(--cv-theme-outline-variant);
|
45
|
+
}
|
package/src/card/card.ts
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
import { css, unsafeCSS } from 'lit';
|
2
|
+
import { customElement } from 'lit/decorators.js';
|
3
|
+
import { CardBase } from './card-base';
|
4
|
+
import styles from './card.scss?inline';
|
5
|
+
|
6
|
+
declare global {
|
7
|
+
interface HTMLElementTagNameMap {
|
8
|
+
'cv-card': CovalentCard;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
@customElement('cv-card')
|
13
|
+
export class CovalentCard extends CardBase {
|
14
|
+
static override styles = [
|
15
|
+
css`
|
16
|
+
${unsafeCSS(styles)}
|
17
|
+
`,
|
18
|
+
];
|
19
|
+
}
|
20
|
+
|
21
|
+
export default CovalentCard;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import './card';
|
2
|
+
import tableContent from '../../stories/demos/table.content.html?raw';
|
3
|
+
import '../data-table/data-table.stories.scss';
|
4
|
+
|
5
|
+
export default {
|
6
|
+
title: 'Components/Cards',
|
7
|
+
args: {
|
8
|
+
cardTitle: 'Card title',
|
9
|
+
outlined: false,
|
10
|
+
actionBar: false,
|
11
|
+
fullHeight: false,
|
12
|
+
},
|
13
|
+
};
|
14
|
+
|
15
|
+
export const Basic = ({ outlined, fullHeight, actionBar, cardTitle }) => {
|
16
|
+
return `
|
17
|
+
<cv-card
|
18
|
+
cardTitle='${cardTitle}'
|
19
|
+
${actionBar ? 'actionBar' : ''}
|
20
|
+
${outlined ? 'outlined' : ''}
|
21
|
+
${fullHeight ? 'fullHeight' : ''}
|
22
|
+
>
|
23
|
+
${tableContent}
|
24
|
+
<div slot="card-actions" class="mdc-card__action-buttons">
|
25
|
+
<cv-button label="Action 1"></cv-button>
|
26
|
+
<cv-button label="Action 2"></cv-button>
|
27
|
+
</div>
|
28
|
+
<div slot="card-actions" class="mdc-card__action-icons">
|
29
|
+
<cv-icon-button icon="share"></cv-icon-button>
|
30
|
+
<cv-icon-button icon="more_vert"></cv-icon-button>
|
31
|
+
</div>
|
32
|
+
</cv-card>
|
33
|
+
`;
|
34
|
+
};
|
35
|
+
|
36
|
+
export const Outline = Basic.bind({});
|
37
|
+
Outline.args = {
|
38
|
+
outlined: true,
|
39
|
+
cardTitle: '',
|
40
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
:host {
|
4
|
+
--mdc-checkbox-checked-color: var(--mdc-theme-primary);
|
5
|
+
--mdc-checkbox-disabled-color: var(--mdc-theme-text-disabled-on-background);
|
6
|
+
--mdc-checkbox-ink-color: var(--mdc-theme-on-primary);
|
7
|
+
--mdc-checkbox-unchecked-color: var(--mdc-theme-text-icon-on-background);
|
8
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* @vitest-environment jsdom
|
3
|
+
*/
|
4
|
+
import { it, describe, expect } from 'vitest';
|
5
|
+
import { CovalentCheckbox } from './checkbox';
|
6
|
+
|
7
|
+
describe('Check box', () => {
|
8
|
+
it('should work', () => {
|
9
|
+
expect(new CovalentCheckbox()).toBeDefined();
|
10
|
+
});
|
11
|
+
});
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import './checkbox';
|
2
|
+
import '../formfield/formfield';
|
3
|
+
|
4
|
+
export default {
|
5
|
+
title: 'Components/Checkbox',
|
6
|
+
argTypes: {},
|
7
|
+
};
|
8
|
+
|
9
|
+
const Template = ({ label = 'Bananas', disabled }) => {
|
10
|
+
return `<cv-checkbox
|
11
|
+
aria-label="${label}"
|
12
|
+
${disabled ? `disabled` : null}>
|
13
|
+
</cv-checkbox>
|
14
|
+
<cv-checkbox
|
15
|
+
aria-label="${label}"
|
16
|
+
checked
|
17
|
+
${disabled ? `disabled` : null}>
|
18
|
+
</cv-checkbox>
|
19
|
+
<cv-checkbox
|
20
|
+
aria-label="${label}"
|
21
|
+
indeterminate
|
22
|
+
${disabled ? `disabled` : null}>
|
23
|
+
</cv-checkbox>`;
|
24
|
+
};
|
25
|
+
|
26
|
+
const LabelTemplate = ({ label = 'Bananas', indeterminate }) => {
|
27
|
+
return `
|
28
|
+
<style>
|
29
|
+
cv-formfield {
|
30
|
+
display: block;
|
31
|
+
}
|
32
|
+
.child {
|
33
|
+
margin-left: 20px;
|
34
|
+
}
|
35
|
+
</style>
|
36
|
+
<cv-formfield label="${label}">
|
37
|
+
<cv-checkbox ${
|
38
|
+
indeterminate ? `indeterminate` : null
|
39
|
+
}></cv-checkbox>
|
40
|
+
</cv-formfield>
|
41
|
+
|
42
|
+
<cv-formfield label="${label}">
|
43
|
+
<cv-checkbox class="child"></cv-checkbox>
|
44
|
+
</cv-formfield>
|
45
|
+
|
46
|
+
<cv-formfield label="${label}">
|
47
|
+
<cv-checkbox class="child" checked></cv-checkbox>
|
48
|
+
</cv-formfield>`;
|
49
|
+
};
|
50
|
+
|
51
|
+
export const Basic = Template.bind({});
|
52
|
+
|
53
|
+
export const Disabled = Template.bind({});
|
54
|
+
Disabled.args = {
|
55
|
+
disabled: true,
|
56
|
+
};
|
57
|
+
|
58
|
+
export const WithLabel = LabelTemplate.bind({});
|
59
|
+
WithLabel.args = {
|
60
|
+
indeterminate: true,
|
61
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { css, unsafeCSS } from 'lit';
|
2
|
+
import { customElement } from 'lit/decorators.js';
|
3
|
+
import { CheckboxBase } from '@material/mwc-checkbox/mwc-checkbox-base';
|
4
|
+
import { styles as baseStyles } from '@material/mwc-checkbox/mwc-checkbox.css';
|
5
|
+
import styles from './checkbox.scss?inline';
|
6
|
+
|
7
|
+
declare global {
|
8
|
+
interface HTMLElementTagNameMap {
|
9
|
+
'cv-checkbox': CovalentCheckbox;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
@customElement('cv-checkbox')
|
14
|
+
export class CovalentCheckbox extends CheckboxBase {
|
15
|
+
static override styles = [baseStyles, css`${unsafeCSS(styles)}`];
|
16
|
+
}
|
17
|
+
|
18
|
+
export default CovalentCheckbox;
|