@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,56 @@
|
|
1
|
+
:host {
|
2
|
+
width: 100%;
|
3
|
+
box-sizing: border-box;
|
4
|
+
}
|
5
|
+
|
6
|
+
:host([graphic='avatar']) .mdc-deprecated-list-item__graphic {
|
7
|
+
--mdc-theme-text-icon-on-background: var(--cv-theme-on-secondary-container);
|
8
|
+
|
9
|
+
color: var(--cv-theme-on-secondary-container);
|
10
|
+
background-color: var(--cv-theme-secondary-container);
|
11
|
+
border-radius: 9999px;
|
12
|
+
}
|
13
|
+
|
14
|
+
:host([disabled]) {
|
15
|
+
color: var(--cv-theme-on-surface-38);
|
16
|
+
|
17
|
+
&:host([graphic='avatar']) .mdc-deprecated-list-item__graphic,
|
18
|
+
.mdc-deprecated-list-item__meta {
|
19
|
+
--mdc-theme-text-icon-on-background: var(--cv-theme-on-surface-38);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
.mdc-deprecated-list-item__meta.material-icons ::slotted(cv-icon) {
|
24
|
+
font-family: var(--mdc-icon-font);
|
25
|
+
font-size: var(--mdc-icon-size, 24px);
|
26
|
+
line-height: 1;
|
27
|
+
}
|
28
|
+
|
29
|
+
.mdc-deprecated-list-item__text {
|
30
|
+
padding-left: var(--cv-list-item-text-padding, 0);
|
31
|
+
}
|
32
|
+
|
33
|
+
.mdc-deprecated-list-item__secondary-text {
|
34
|
+
--mdc-icon-size: var(--mdc-typography-body2-font-size);
|
35
|
+
|
36
|
+
::slotted(*) {
|
37
|
+
display: inline-flex;
|
38
|
+
align-items: center;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
.mdc-deprecated-list-item__meta {
|
43
|
+
display: flex;
|
44
|
+
align-items: center;
|
45
|
+
}
|
46
|
+
|
47
|
+
:host(:not([left])) .mdc-deprecated-list-item__meta {
|
48
|
+
width: auto;
|
49
|
+
min-width: 40px;
|
50
|
+
}
|
51
|
+
|
52
|
+
.mdc-deprecated-list-item__meta ::slotted(*),
|
53
|
+
.mdc-deprecated-list-item__graphic ::slotted(*) {
|
54
|
+
display: flex;
|
55
|
+
align-items: center;
|
56
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* @vitest-environment jsdom
|
3
|
+
*/
|
4
|
+
import { it, describe, expect } from 'vitest';
|
5
|
+
import { CovalentListItem } from './list-item';
|
6
|
+
|
7
|
+
describe('List item', () => {
|
8
|
+
it('should work', () => {
|
9
|
+
expect(new CovalentListItem()).toBeDefined();
|
10
|
+
});
|
11
|
+
});
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { ListItemBase } from '@material/mwc-list/mwc-list-item-base';
|
2
|
+
|
3
|
+
import { css, unsafeCSS } from 'lit';
|
4
|
+
import { customElement } from 'lit/decorators.js';
|
5
|
+
|
6
|
+
import { styles as controlStyle } from '@material/mwc-list/mwc-control-list-item.css';
|
7
|
+
import { styles as listItemStyle } from '@material/mwc-list/mwc-list-item.css';
|
8
|
+
import styles from './list-item.scss?inline';
|
9
|
+
|
10
|
+
declare global {
|
11
|
+
interface HTMLElementTagNameMap {
|
12
|
+
'cv-list-item': CovalentListItem;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
@customElement('cv-list-item')
|
17
|
+
export class CovalentListItem extends ListItemBase {
|
18
|
+
static override styles = [
|
19
|
+
css`
|
20
|
+
${unsafeCSS(listItemStyle)}
|
21
|
+
`,
|
22
|
+
css`
|
23
|
+
${unsafeCSS(controlStyle)}
|
24
|
+
`,
|
25
|
+
css`
|
26
|
+
${unsafeCSS(styles)}
|
27
|
+
`,
|
28
|
+
];
|
29
|
+
}
|
30
|
+
|
31
|
+
export default CovalentListItem;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
:host {
|
2
|
+
padding-right: var(--cv-list-padding-right, 0);
|
3
|
+
padding-left: var(--cv-list-padding-left, 0);
|
4
|
+
}
|
5
|
+
|
6
|
+
:host(.subnav) ::slotted(*),
|
7
|
+
:host([subnav]) ::slotted(*) {
|
8
|
+
height: 32px;
|
9
|
+
font-weight: var(--mdc-typography-body2-font-weight);
|
10
|
+
border-radius: var(--cv-list-item-border-radius, 100px);
|
11
|
+
padding-right: var(--cv-list-padding-right, 16px);
|
12
|
+
padding-left: var(--cv-list-padding-left, 16px);
|
13
|
+
}
|
14
|
+
|
15
|
+
:host(.subnav),
|
16
|
+
:host([subnav]) {
|
17
|
+
--cv-list-padding-right: 0;
|
18
|
+
--cv-list-padding-left: 16px;
|
19
|
+
|
20
|
+
padding-left: 32px;
|
21
|
+
}
|
22
|
+
|
23
|
+
.mdc-deprecated-list {
|
24
|
+
width: 100%;
|
25
|
+
}
|
@@ -0,0 +1,120 @@
|
|
1
|
+
import './list';
|
2
|
+
import './list-item';
|
3
|
+
import './check-list-item';
|
4
|
+
import './radio-list-item';
|
5
|
+
import '../icon/icon';
|
6
|
+
|
7
|
+
export default {
|
8
|
+
title: 'Components/List',
|
9
|
+
parameters: {
|
10
|
+
layout: 'fullscreen',
|
11
|
+
},
|
12
|
+
};
|
13
|
+
|
14
|
+
const BasicTemplate = ({ selected, disabled }) => {
|
15
|
+
return `
|
16
|
+
<cv-list activatable>
|
17
|
+
<cv-list-item ${disabled ? `disabled` : null}>Item 0</cv-list-item>
|
18
|
+
<cv-list-item ${
|
19
|
+
selected ? `selected activated` : null
|
20
|
+
}>Item 1</cv-list-item>
|
21
|
+
<cv-list-item>Item 2</cv-list-item>
|
22
|
+
<cv-list-item>Item 3</cv-list-item>
|
23
|
+
</cv-list>`;
|
24
|
+
};
|
25
|
+
|
26
|
+
const IconTemplate = ({ icon, iconStyle = 'avatar', disabled }) => {
|
27
|
+
return `
|
28
|
+
<cv-list>
|
29
|
+
<cv-list-item graphic="${iconStyle}" ${disabled ? `disabled` : null}>
|
30
|
+
<span>${iconStyle} 0</span>
|
31
|
+
<cv-icon slot="graphic">${icon}</cv-icon>
|
32
|
+
</cv-list-item>
|
33
|
+
<cv-list-item graphic="${iconStyle}">
|
34
|
+
<span>${iconStyle} 2</span>
|
35
|
+
<cv-icon slot="graphic">${icon}</cv-icon>
|
36
|
+
</cv-list-item>
|
37
|
+
<cv-list-item graphic="${iconStyle}">
|
38
|
+
<span>${iconStyle} 3</span>
|
39
|
+
<cv-icon slot="graphic">${icon}</cv-icon>
|
40
|
+
</cv-list-item>
|
41
|
+
<cv-list-item graphic="${iconStyle}">
|
42
|
+
<span>${iconStyle} 4</span>
|
43
|
+
<cv-icon slot="graphic">${icon}</cv-icon>
|
44
|
+
</cv-list-item>
|
45
|
+
<cv-list-item graphic="${iconStyle}">
|
46
|
+
<span>${iconStyle} 5</span>
|
47
|
+
<cv-icon slot="graphic">${icon}</cv-icon>
|
48
|
+
</cv-list-item>
|
49
|
+
</cv-list>`;
|
50
|
+
};
|
51
|
+
|
52
|
+
const TwoLineTemplate = ({ icon, style, required, helper, disabled }) => {
|
53
|
+
return `
|
54
|
+
<cv-list>
|
55
|
+
<cv-list-item twoline ${disabled ? `disabled` : null}>
|
56
|
+
<span>Item 0</span>
|
57
|
+
<span slot="secondary">Secondary line</span>
|
58
|
+
</cv-list-item>
|
59
|
+
<cv-list-item twoline>
|
60
|
+
<span>Item 1</span>
|
61
|
+
<span slot="secondary">Secondary line</span>
|
62
|
+
</cv-list-item>
|
63
|
+
<cv-list-item twoline>
|
64
|
+
<span>Item 2</span>
|
65
|
+
<span slot="secondary">Secondary line</span>
|
66
|
+
</cv-list-item>
|
67
|
+
<cv-list-item twoline>
|
68
|
+
<span>Item 3</span>
|
69
|
+
<span slot="secondary">Secondary line</span>
|
70
|
+
</cv-list-item>
|
71
|
+
</cv-list>`;
|
72
|
+
};
|
73
|
+
|
74
|
+
const CheckRadioTemplate = ({ listType = 'check', disabled }) => {
|
75
|
+
return `
|
76
|
+
<cv-list multi>
|
77
|
+
<cv-${listType}-list-item selected ${
|
78
|
+
disabled ? `disabled` : null
|
79
|
+
}>Item 0</cv-${listType}-list-item>
|
80
|
+
<cv-${listType}-list-item selected>Item 1</cv-${listType}-list-item>
|
81
|
+
<li divider role="separator" padded></li>
|
82
|
+
<cv-${listType}-list-item left selected>Item 2 (left)</cv-${listType}-list-item>
|
83
|
+
<cv-${listType}-list-item left>Item 3 (left)</cv-${listType}-list-item>
|
84
|
+
</cv-list>`;
|
85
|
+
};
|
86
|
+
|
87
|
+
export const Basic = BasicTemplate.bind({});
|
88
|
+
Basic.args = {
|
89
|
+
selected: false,
|
90
|
+
disabled: false,
|
91
|
+
};
|
92
|
+
|
93
|
+
export const WithAvatar = IconTemplate.bind({});
|
94
|
+
WithAvatar.args = {
|
95
|
+
icon: 'folder',
|
96
|
+
iconStyle: 'avatar',
|
97
|
+
disabled: false,
|
98
|
+
};
|
99
|
+
WithAvatar.argTypes = {
|
100
|
+
iconStyle: {
|
101
|
+
options: ['avatar', 'icon', 'medium', 'large'],
|
102
|
+
control: { type: 'radio' },
|
103
|
+
},
|
104
|
+
};
|
105
|
+
|
106
|
+
export const TwoLine = TwoLineTemplate.bind({});
|
107
|
+
TwoLine.args = {
|
108
|
+
disabled: false,
|
109
|
+
};
|
110
|
+
|
111
|
+
export const ChecksAndRadios = CheckRadioTemplate.bind({});
|
112
|
+
ChecksAndRadios.args = {
|
113
|
+
disabled: false,
|
114
|
+
};
|
115
|
+
ChecksAndRadios.argTypes = {
|
116
|
+
listType: {
|
117
|
+
options: ['check', 'radio'],
|
118
|
+
control: { type: 'radio' },
|
119
|
+
},
|
120
|
+
};
|
package/src/list/list.ts
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
import { css, unsafeCSS } from 'lit';
|
2
|
+
import { customElement } from 'lit/decorators.js';
|
3
|
+
import { ListBase } from '@material/mwc-list/mwc-list-base';
|
4
|
+
import { styles as baseStyles } from '@material/mwc-list/mwc-list.css';
|
5
|
+
import styles from './list.scss?inline';
|
6
|
+
|
7
|
+
declare global {
|
8
|
+
interface HTMLElementTagNameMap {
|
9
|
+
'cv-list': CovalentList;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
@customElement('cv-list')
|
14
|
+
export class CovalentList extends ListBase {
|
15
|
+
static override styles = [
|
16
|
+
baseStyles,
|
17
|
+
css`
|
18
|
+
${unsafeCSS(styles)}
|
19
|
+
`,
|
20
|
+
];
|
21
|
+
}
|
22
|
+
|
23
|
+
export default CovalentList;
|
@@ -0,0 +1,159 @@
|
|
1
|
+
@use '@material/animation';
|
2
|
+
|
3
|
+
:host {
|
4
|
+
font-family: var(--mdc-typography-font-family);
|
5
|
+
font-size: var(--mdc-typography-body2-font-size);
|
6
|
+
font-weight: 600;
|
7
|
+
line-height: var(--mdc-typography-body2-line-height);
|
8
|
+
text-align: left;
|
9
|
+
border-radius: var(--cv-list-item-border-radius, 100px);
|
10
|
+
transition: border-radius 200ms animation.$standard-curve-timing-function,
|
11
|
+
width 200ms animation.$standard-curve-timing-function;
|
12
|
+
width: var(--cv-list-item-width, 100%);
|
13
|
+
color: var(--cv-theme-on-surface-variant);
|
14
|
+
|
15
|
+
::slotted(cv-icon[slot='graphic']) {
|
16
|
+
color: var(--cv-theme-on-surface-variant);
|
17
|
+
}
|
18
|
+
|
19
|
+
--mdc-list-item-graphic-margin: 4px;
|
20
|
+
}
|
21
|
+
|
22
|
+
::slotted(*) {
|
23
|
+
--cv-list-padding-right: 0;
|
24
|
+
--cv-list-padding-left: 0;
|
25
|
+
--cv-list-item-text-padding: 16px;
|
26
|
+
}
|
27
|
+
|
28
|
+
:host([activated]) {
|
29
|
+
color: var(--cv-theme-on-secondary-container);
|
30
|
+
|
31
|
+
::slotted(cv-icon[slot='graphic']) {
|
32
|
+
color: var(--cv-theme-on-secondary-container);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
:host([selected]:not([activated])) .expansion-header {
|
37
|
+
transition: background-color 250ms animation.$standard-curve-timing-function
|
38
|
+
color 250ms animation.$standard-curve-timing-function;
|
39
|
+
background-color: var(--cv-list-item-selected-background-color);
|
40
|
+
color: var(--cv-list-item-selected-color);
|
41
|
+
|
42
|
+
.mdc-deprecated-list-item__graphic {
|
43
|
+
--mdc-theme-text-icon-on-background: var(--cv-list-item-selected-color);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
:host([subnav]) {
|
48
|
+
--cv-list-item-text-padding: 16px;
|
49
|
+
|
50
|
+
height: 32px;
|
51
|
+
font-weight: var(--mdc-typography-body2-font-weight);
|
52
|
+
border-radius: var(--cv-list-item-border-radius, 100px);
|
53
|
+
padding: 0;
|
54
|
+
padding-right: var(--cv-list-padding-right, 12px);
|
55
|
+
padding-left: var(--cv-list-padding-left, 12px);
|
56
|
+
}
|
57
|
+
|
58
|
+
:host([graphic='avatar']) .mdc-deprecated-list-item__graphic {
|
59
|
+
--mdc-theme-text-icon-on-background: var(--cv-theme-on-surface);
|
60
|
+
|
61
|
+
margin-left: var(--cv-list-item-graphic-margin-left, 12px);
|
62
|
+
padding-left: 4px;
|
63
|
+
background-color: transparent;
|
64
|
+
}
|
65
|
+
|
66
|
+
:host([graphic='avatar']) {
|
67
|
+
padding: 0;
|
68
|
+
background-color: transparent;
|
69
|
+
}
|
70
|
+
|
71
|
+
:host([graphic='avatar']:not([twoline])) {
|
72
|
+
height: 48px;
|
73
|
+
}
|
74
|
+
|
75
|
+
:host([selected]),
|
76
|
+
:host([activated]),
|
77
|
+
:host([hasActivatedChild]) {
|
78
|
+
.mdc-deprecated-list-item__graphic.material-icons {
|
79
|
+
font-variation-settings: 'FILL' 1;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
:host([hasChildren]) {
|
84
|
+
flex-direction: column;
|
85
|
+
overflow: visible;
|
86
|
+
height: var(--cv-list-item-height, inherit) !important;
|
87
|
+
background: none;
|
88
|
+
padding: 0;
|
89
|
+
|
90
|
+
--mdc-list-side-padding: 0;
|
91
|
+
--cv-list-item-graphic-margin-left: 0;
|
92
|
+
|
93
|
+
::slotted(cv-list) {
|
94
|
+
padding-left: 32px;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
:host([hasChildren][open]:hover:not([activated])) {
|
99
|
+
.expansion-header {
|
100
|
+
--mdc-ripple-color: transparent;
|
101
|
+
|
102
|
+
&:hover {
|
103
|
+
--mdc-ripple-color: var(--mdc-theme-on-surface-variant);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
.expansion-header {
|
109
|
+
position: relative;
|
110
|
+
height: 48px;
|
111
|
+
width: 100%;
|
112
|
+
border-radius: var(--cv-list-item-border-radius, 100px);
|
113
|
+
overflow: hidden;
|
114
|
+
display: flex;
|
115
|
+
flex-shrink: 0;
|
116
|
+
align-items: center;
|
117
|
+
background-color: var(--cv-list-item-background-color);
|
118
|
+
color: var(--cv-list-item-text-color);
|
119
|
+
|
120
|
+
mwc-ripple {
|
121
|
+
border-radius: var(--cv-list-item-border-radius, 100px);
|
122
|
+
overflow: hidden;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
.expansion-header-inner {
|
127
|
+
padding: 0 16px;
|
128
|
+
}
|
129
|
+
|
130
|
+
.expansion-icon {
|
131
|
+
margin-right: var(--cv-list-item-expansion-icon-margin, 0);
|
132
|
+
font-size: var(--cv-list-item-expansion-icon-size, --mdc-icon-size);
|
133
|
+
color: var(
|
134
|
+
--cv-list-item-text-icon-on-background,
|
135
|
+
var(--mdc-theme-text-icon-on-background)
|
136
|
+
);
|
137
|
+
}
|
138
|
+
|
139
|
+
.expansion-panel {
|
140
|
+
display: block;
|
141
|
+
width: 100%;
|
142
|
+
max-height: var(--cv-list-menu-height, 0);
|
143
|
+
overflow: hidden;
|
144
|
+
transition: max-height 200ms animation.$acceleration-curve-timing-function;
|
145
|
+
|
146
|
+
--mdc-list-side-padding: 72px;
|
147
|
+
}
|
148
|
+
|
149
|
+
:host([open][hasChildren]:not([twoline])) {
|
150
|
+
height: inherit;
|
151
|
+
display: flex;
|
152
|
+
flex-direction: column;
|
153
|
+
border-radius: 0;
|
154
|
+
|
155
|
+
.expansion-panel {
|
156
|
+
transition-timing-function: animation.$deceleration-curve-timing-function;
|
157
|
+
max-height: var(--cv-list-menu-height, inherit);
|
158
|
+
}
|
159
|
+
}
|
@@ -0,0 +1,223 @@
|
|
1
|
+
import { css, html, nothing, unsafeCSS } from 'lit';
|
2
|
+
import {
|
3
|
+
customElement,
|
4
|
+
property,
|
5
|
+
queryAssignedElements,
|
6
|
+
} from 'lit/decorators.js';
|
7
|
+
import { CovalentListItem } from './list-item';
|
8
|
+
import { styles as controlStyle } from '@material/mwc-list/mwc-control-list-item.css';
|
9
|
+
import { styles as listItemStyle } from '@material/mwc-list/mwc-list-item.css';
|
10
|
+
import { RequestSelectedDetail } from '@material/mwc-list/mwc-list-item-base';
|
11
|
+
import styles from './list-item.scss?inline';
|
12
|
+
import navListStyles from './nav-list-item.scss?inline';
|
13
|
+
import CovalentList from './list';
|
14
|
+
|
15
|
+
declare global {
|
16
|
+
interface HTMLElementTagNameMap {
|
17
|
+
'cv-nav-list-item': CovalentNavRailListItem;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
@customElement('cv-nav-list-item')
|
22
|
+
export class CovalentNavRailListItem extends CovalentListItem {
|
23
|
+
static override styles = [
|
24
|
+
css`
|
25
|
+
${unsafeCSS(listItemStyle)}
|
26
|
+
`,
|
27
|
+
css`
|
28
|
+
${unsafeCSS(controlStyle)}
|
29
|
+
`,
|
30
|
+
css`
|
31
|
+
${unsafeCSS(styles)}
|
32
|
+
`,
|
33
|
+
css`
|
34
|
+
${unsafeCSS(navListStyles)}
|
35
|
+
`,
|
36
|
+
];
|
37
|
+
|
38
|
+
@queryAssignedElements({ slot: 'expansion-panel', flatten: true })
|
39
|
+
expansionPanelElements!: CovalentList[];
|
40
|
+
|
41
|
+
@property({ type: Boolean, reflect: true })
|
42
|
+
open = false;
|
43
|
+
|
44
|
+
@property({ type: Boolean, reflect: true })
|
45
|
+
hasChildren = false;
|
46
|
+
|
47
|
+
activated = false;
|
48
|
+
|
49
|
+
private lastKeySelected = 0;
|
50
|
+
|
51
|
+
private _toggleOpen() {
|
52
|
+
this.open = !this.open;
|
53
|
+
}
|
54
|
+
|
55
|
+
private _handleKeydown(event: KeyboardEvent) {
|
56
|
+
const firstEl = this.expansionPanelElements[0];
|
57
|
+
const nextIndex = firstEl ? firstEl?.getFocusedItemIndex() : 0;
|
58
|
+
const totalItems = firstEl?.items.length ?? 0;
|
59
|
+
|
60
|
+
if (!this.hasChildren) {
|
61
|
+
return;
|
62
|
+
}
|
63
|
+
|
64
|
+
if (event.code === 'Enter') {
|
65
|
+
event.preventDefault();
|
66
|
+
event.stopImmediatePropagation();
|
67
|
+
// Toggle only if target press is header else make sure the top headers is deselected
|
68
|
+
if ((event.target as CovalentNavRailListItem).hasChildren) {
|
69
|
+
this._toggleOpen();
|
70
|
+
} else {
|
71
|
+
this._deselectHeader(event);
|
72
|
+
}
|
73
|
+
return;
|
74
|
+
}
|
75
|
+
|
76
|
+
if (!this.open) {
|
77
|
+
return;
|
78
|
+
}
|
79
|
+
|
80
|
+
// Arrow up from top sub item
|
81
|
+
if (
|
82
|
+
event.code === 'ArrowUp' &&
|
83
|
+
nextIndex === 0 &&
|
84
|
+
this.lastKeySelected === 0 &&
|
85
|
+
!(event.target as CovalentNavRailListItem).hasChildren
|
86
|
+
) {
|
87
|
+
event.preventDefault();
|
88
|
+
event.stopImmediatePropagation();
|
89
|
+
firstEl.items[0].blur();
|
90
|
+
this.focus();
|
91
|
+
return;
|
92
|
+
}
|
93
|
+
// Arrow up from top sub item down
|
94
|
+
if (event.code === 'ArrowDown' && nextIndex === -1) {
|
95
|
+
event.preventDefault();
|
96
|
+
event.stopImmediatePropagation();
|
97
|
+
firstEl.focusItemAtIndex(0);
|
98
|
+
this.lastKeySelected = 0;
|
99
|
+
}
|
100
|
+
if (event.code === 'ArrowUp' && nextIndex !== -1) {
|
101
|
+
event.preventDefault();
|
102
|
+
event.stopImmediatePropagation();
|
103
|
+
firstEl.focusItemAtIndex(nextIndex);
|
104
|
+
this.lastKeySelected = nextIndex;
|
105
|
+
}
|
106
|
+
// Allow arrow up/down if within boundry
|
107
|
+
if (
|
108
|
+
(event.code === 'ArrowDown' || event.code === 'ArrowUp') &&
|
109
|
+
nextIndex !== -1 &&
|
110
|
+
this.lastKeySelected < totalItems - 1
|
111
|
+
) {
|
112
|
+
event.preventDefault();
|
113
|
+
event.stopImmediatePropagation();
|
114
|
+
firstEl.focusItemAtIndex(nextIndex);
|
115
|
+
this.lastKeySelected = nextIndex;
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
private _handleRequestSelected(event: Event) {
|
120
|
+
const ev = event as CustomEvent<RequestSelectedDetail>;
|
121
|
+
if (
|
122
|
+
this.hasChildren &&
|
123
|
+
ev.detail.selected === false &&
|
124
|
+
ev.detail.source === 'property'
|
125
|
+
) {
|
126
|
+
this._deselectChildren();
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
private _deselectChildren() {
|
131
|
+
this.expansionPanelElements.forEach((subnav) => {
|
132
|
+
subnav.items.forEach((items) => (items.selected = false));
|
133
|
+
});
|
134
|
+
}
|
135
|
+
|
136
|
+
private _deselectHeader(event: Event) {
|
137
|
+
event.preventDefault();
|
138
|
+
event.stopImmediatePropagation();
|
139
|
+
this.fireRequestSelected(false, 'interaction');
|
140
|
+
this.activated = false;
|
141
|
+
}
|
142
|
+
|
143
|
+
private _updateMaxHeight(open = this.open) {
|
144
|
+
const content = this.shadowRoot?.querySelector('.expansion-panel');
|
145
|
+
let contentHeight = '0';
|
146
|
+
|
147
|
+
if (open) {
|
148
|
+
contentHeight = content?.scrollHeight
|
149
|
+
? `${content.scrollHeight}px`
|
150
|
+
: 'inherit';
|
151
|
+
}
|
152
|
+
|
153
|
+
this.style.setProperty('--cv-list-menu-height', contentHeight);
|
154
|
+
}
|
155
|
+
|
156
|
+
renderExpansionItem() {
|
157
|
+
const text = this.renderText();
|
158
|
+
const graphic = this.graphic ? this.renderGraphic() : nothing;
|
159
|
+
const meta = this.renderMeta();
|
160
|
+
|
161
|
+
return html`
|
162
|
+
<div
|
163
|
+
@mousedown=${this._toggleOpen}
|
164
|
+
@touchstart="${this._toggleOpen}"
|
165
|
+
@keydown=${this._toggleOpen}
|
166
|
+
class="expansion-header"
|
167
|
+
>
|
168
|
+
${this.renderRipple()} ${graphic} ${text} ${meta}
|
169
|
+
</div>
|
170
|
+
<div class="expansion-panel" @click=${this._deselectHeader}>
|
171
|
+
<slot name="expansion-panel"></slot>
|
172
|
+
</div>
|
173
|
+
`;
|
174
|
+
}
|
175
|
+
|
176
|
+
override connectedCallback() {
|
177
|
+
super.connectedCallback();
|
178
|
+
|
179
|
+
this.addEventListener('keydown', this._handleKeydown);
|
180
|
+
this.addEventListener('request-selected', this._handleRequestSelected);
|
181
|
+
}
|
182
|
+
|
183
|
+
override disconnectedCallback() {
|
184
|
+
super.disconnectedCallback();
|
185
|
+
|
186
|
+
this.removeEventListener('keydown', this._handleKeydown);
|
187
|
+
this.addEventListener('request-selected', this._handleRequestSelected);
|
188
|
+
}
|
189
|
+
|
190
|
+
protected override renderMeta() {
|
191
|
+
const arrowIcon = this.open ? 'arrow_drop_up' : 'arrow_drop_down';
|
192
|
+
const arrow = this.hasChildren
|
193
|
+
? html`<cv-icon class="expansion-icon">${arrowIcon}</cv-icon>`
|
194
|
+
: '';
|
195
|
+
|
196
|
+
return html`<span class="mdc-deprecated-list-item__meta material-icons">
|
197
|
+
${arrow}
|
198
|
+
<slot name="meta"></slot>
|
199
|
+
</span>`;
|
200
|
+
}
|
201
|
+
|
202
|
+
override firstUpdated() {
|
203
|
+
super.firstUpdated();
|
204
|
+
|
205
|
+
if (this.hasChildren) {
|
206
|
+
this._updateMaxHeight();
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
override updated(changedProperties: Map<string | number | symbol, unknown>) {
|
211
|
+
super.updated(changedProperties);
|
212
|
+
|
213
|
+
if (changedProperties.has('open') && this.hasChildren) {
|
214
|
+
this._updateMaxHeight();
|
215
|
+
}
|
216
|
+
}
|
217
|
+
|
218
|
+
override render() {
|
219
|
+
return this.hasChildren ? this.renderExpansionItem() : super.render();
|
220
|
+
}
|
221
|
+
}
|
222
|
+
|
223
|
+
export default CovalentNavRailListItem;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { RadioListItemBase } from '@material/mwc-list/mwc-radio-list-item-base';
|
2
|
+
import { styles as controlStyle } from '@material/mwc-list/mwc-control-list-item.css';
|
3
|
+
import { styles } from '@material/mwc-list/mwc-list-item.css';
|
4
|
+
import covalentStyles from './list-item.scss?inline';
|
5
|
+
import { customElement } from 'lit/decorators.js';
|
6
|
+
import { css, unsafeCSS } from 'lit';
|
7
|
+
|
8
|
+
declare global {
|
9
|
+
interface HTMLElementTagNameMap {
|
10
|
+
'cv-radio-list-item': CovalentRadioListItem;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
@customElement('cv-radio-list-item')
|
15
|
+
export class CovalentRadioListItem extends RadioListItemBase {
|
16
|
+
static override styles = [
|
17
|
+
styles,
|
18
|
+
controlStyle,
|
19
|
+
css`
|
20
|
+
${unsafeCSS(covalentStyles)}
|
21
|
+
`,
|
22
|
+
];
|
23
|
+
}
|
24
|
+
|
25
|
+
export default CovalentRadioListItem;
|