kemet-ui 0.2.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +6323 -831
- package/dist/components/kemet-accordion/kemet-accordion-panel.js +178 -0
- package/dist/components/kemet-accordion/kemet-accordion.js +139 -0
- package/dist/components/kemet-badge/kemet-badge.js +102 -0
- package/dist/components/kemet-button/kemet-button.js +230 -0
- package/dist/components/kemet-carousel/kemet-carousel-current.js +36 -0
- package/dist/components/kemet-carousel/kemet-carousel-first.js +47 -0
- package/dist/components/kemet-carousel/kemet-carousel-last.js +47 -0
- package/dist/components/{kemet-carousel-link.js → kemet-carousel/kemet-carousel-link.js} +7 -2
- package/dist/components/{kemet-carousel-next.js → kemet-carousel/kemet-carousel-next.js} +3 -2
- package/dist/components/{kemet-carousel-prev.js → kemet-carousel/kemet-carousel-prev.js} +2 -1
- package/dist/components/kemet-carousel/kemet-carousel-slide.js +51 -0
- package/dist/components/kemet-carousel/kemet-carousel-total.js +36 -0
- package/dist/components/kemet-carousel/kemet-carousel.js +492 -0
- package/dist/components/kemet-checkbox/kemet-checkbox.js +298 -0
- package/dist/components/kemet-combo/kemet-combo.js +207 -0
- package/dist/components/kemet-count/kemet-count.js +112 -0
- package/dist/components/{kemet-draggable.js → kemet-draggable/kemet-draggable.js} +19 -6
- package/dist/components/{kemet-drawer.js → kemet-drawer/kemet-drawer.js} +38 -15
- package/dist/components/{kemet-drawer.styles.js → kemet-drawer/kemet-drawer.styles.js} +6 -0
- package/dist/components/kemet-field/kemet-field.js +233 -0
- package/dist/components/{kemet-flipcard-trigger.js → kemet-flipcard/kemet-flipcard-trigger.js} +4 -5
- package/dist/components/{kemet-flipcard.js → kemet-flipcard/kemet-flipcard.js} +26 -3
- package/dist/components/{kemet-icon.js → kemet-icon/kemet-icon.js} +19 -3
- package/dist/components/kemet-input/kemet-input.js +650 -0
- package/dist/components/kemet-modal/kemet-modal-close.js +38 -0
- package/dist/components/kemet-modal/kemet-modal.js +140 -0
- package/dist/components/{kemet-modal.styles.js → kemet-modal/kemet-modal.styles.js} +14 -2
- package/dist/components/{kemet-popover-close.js → kemet-popover/kemet-popover-close.js} +1 -1
- package/dist/components/{kemet-popover.effects.styles.js → kemet-popover/kemet-popover.effects.styles.js} +0 -0
- package/dist/components/{kemet-popover.js → kemet-popover/kemet-popover.js} +75 -12
- package/dist/components/{kemet-popover.tooltip.styles.js → kemet-popover/kemet-popover.tooltip.styles.js} +0 -0
- package/dist/components/kemet-radio/kemet-radio.js +214 -0
- package/dist/components/kemet-radio/kemet-radios.js +218 -0
- package/dist/components/{kemet-rotator.js → kemet-rotator/kemet-rotator.js} +23 -4
- package/dist/components/{kemet-scroll-link.js → kemet-scroll-link/kemet-scroll-link.js} +21 -2
- package/dist/components/{kemet-scroll-nav.js → kemet-scroll-nav/kemet-scroll-nav.js} +25 -2
- package/dist/components/{kemet-scroll-snap-paginator.js → kemet-scroll-snap/kemet-scroll-snap-paginator.js} +68 -26
- package/dist/components/{kemet-scroll-snap-slide.js → kemet-scroll-snap/kemet-scroll-snap-slide.js} +23 -13
- package/dist/components/{kemet-scroll-snap.js → kemet-scroll-snap/kemet-scroll-snap.js} +31 -16
- package/dist/components/kemet-select/kemet-option.js +45 -0
- package/dist/components/kemet-select/kemet-select.js +365 -0
- package/dist/components/{kemet-svg.js → kemet-svgs/kemet-svg.js} +18 -2
- package/dist/components/{kemet-svgs.js → kemet-svgs/kemet-svgs.js} +7 -3
- package/dist/components/{kemet-tab-panel.js → kemet-tabs/kemet-tab-panel.js} +15 -1
- package/dist/components/{kemet-tab.js → kemet-tabs/kemet-tab.js} +48 -1
- package/dist/components/kemet-tabs/kemet-tabs.js +556 -0
- package/dist/components/kemet-tabs/kemet-tabs.styles.js +200 -0
- package/dist/components/kemet-textarea/kemet-textarea.js +395 -0
- package/dist/components/kemet-toggle/kemet-toggle.js +225 -0
- package/dist/kemet-components.cjs +7251 -2465
- package/dist/kemet-components.js +7237 -2440
- package/dist/kemet-components.min.js +1641 -355
- package/dist/styles/components/_config.scss +4 -0
- package/dist/styles/components/accordion.scss +9 -0
- package/dist/styles/{scss/components → components}/drawer.scss +2 -2
- package/dist/styles/components/modal.scss +8 -0
- package/dist/styles/components/scrollsnap.scss +11 -0
- package/dist/styles/core/_config.scss +354 -0
- package/dist/styles/{scss/core → core}/_helpers.scss +113 -2
- package/dist/styles/{scss/core → core}/attributes.scss +16 -0
- package/dist/styles/core/base.scss +38 -0
- package/dist/styles/{scss/core → core}/layout.scss +6 -5
- package/dist/styles/kemet.components.css +12 -339
- package/dist/styles/kemet.components.css.map +1 -1
- package/dist/styles/{scss/kemet.components.scss → kemet.components.scss} +0 -3
- package/dist/styles/kemet.core.css +2371 -503
- package/dist/styles/kemet.core.css.map +1 -1
- package/dist/styles/kemet.core.scss +3 -0
- package/dist/utilities/controllers/forms.js +121 -0
- package/package.json +37 -57
- package/dist/components/kemet-accordion.js +0 -106
- package/dist/components/kemet-carousel-slide.js +0 -83
- package/dist/components/kemet-carousel.js +0 -236
- package/dist/components/kemet-modal-close.js +0 -19
- package/dist/components/kemet-modal.js +0 -75
- package/dist/components/kemet-ratio.js +0 -61
- package/dist/components/kemet-tabs.js +0 -350
- package/dist/styles/scss/components/_config.scss +0 -29
- package/dist/styles/scss/components/accordion.scss +0 -58
- package/dist/styles/scss/components/carousel.scss +0 -64
- package/dist/styles/scss/components/flipcard.scss +0 -14
- package/dist/styles/scss/components/modal.scss +0 -12
- package/dist/styles/scss/components/scrollsnap.scss +0 -68
- package/dist/styles/scss/components/tabs.scss +0 -73
- package/dist/styles/scss/core/_config.scss +0 -197
- package/dist/styles/scss/kemet.core.scss +0 -4
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { html, css, LitElement } from 'lit';
|
|
2
|
+
import '../kemet-icon/kemet-icon.js';
|
|
3
|
+
|
|
4
|
+
export default class KemetAccordionPanel extends LitElement {
|
|
5
|
+
static get styles() {
|
|
6
|
+
return [
|
|
7
|
+
css`
|
|
8
|
+
*,
|
|
9
|
+
*::before,
|
|
10
|
+
*::after {
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
:host {
|
|
15
|
+
display: block;
|
|
16
|
+
padding: 1.5rem 1rem;
|
|
17
|
+
border-bottom: 1px solid var(--kemet-color-primary);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.trigger {
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
display: grid;
|
|
23
|
+
gap: 1rem;
|
|
24
|
+
grid-template-columns: 1fr auto;
|
|
25
|
+
width: 100%;
|
|
26
|
+
text-align: left;
|
|
27
|
+
padding: 0;
|
|
28
|
+
border: none;
|
|
29
|
+
background: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.body {
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
transition: all var(--kemet-accordion-panel-transition-speed, 300ms) ease;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
::slotted([slot='body']) {
|
|
38
|
+
padding: 1rem 0;
|
|
39
|
+
}
|
|
40
|
+
`,
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static get properties() {
|
|
45
|
+
return {
|
|
46
|
+
/**
|
|
47
|
+
* Determines the opened state of the panel
|
|
48
|
+
*/
|
|
49
|
+
opened: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
reflect: true,
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Sets the max height of the panel's body
|
|
55
|
+
*/
|
|
56
|
+
maxHeight: {
|
|
57
|
+
type: String,
|
|
58
|
+
attribute: 'max-height',
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* Uniquely identifies a panel for accessibility purposes
|
|
62
|
+
*/
|
|
63
|
+
slug: {
|
|
64
|
+
type: String,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
constructor() {
|
|
70
|
+
super();
|
|
71
|
+
|
|
72
|
+
// managed properties
|
|
73
|
+
this.opened = undefined;
|
|
74
|
+
this.maxHeight = '0px';
|
|
75
|
+
this.slug = 'panel';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
firstUpdated() {
|
|
79
|
+
this.focusableSelector = 'body, a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]';
|
|
80
|
+
this.bodyElement = this.querySelector('[slot="body"]');
|
|
81
|
+
this.bodyElementFirst = this.bodyElement.querySelector(':first-child');
|
|
82
|
+
this.bodyElementLast = this.bodyElement.querySelector(':last-child');
|
|
83
|
+
|
|
84
|
+
if (this.bodyElementFirst) this.bodyElementFirst.style.marginTop = 0;
|
|
85
|
+
if (this.bodyELementLast) this.bodyElementLast.style.marginBottom = 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
updated(prevProps) {
|
|
89
|
+
if (!prevProps.get('opened') && this.opened === true) {
|
|
90
|
+
this.maxHeight = `${this.bodyElement.offsetHeight}px`;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Fires when a panel is opened
|
|
94
|
+
*/
|
|
95
|
+
this.dispatchEvent(
|
|
96
|
+
new CustomEvent('kemet-accordion-panel-opened', {
|
|
97
|
+
bubbles: true,
|
|
98
|
+
composed: true,
|
|
99
|
+
detail: this,
|
|
100
|
+
}),
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (prevProps.get('opened') && this.opened === false) {
|
|
105
|
+
this.maxHeight = '0px';
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Fires when a panel is closed
|
|
109
|
+
*/
|
|
110
|
+
this.dispatchEvent(
|
|
111
|
+
new CustomEvent('kemet-accordion-panel-closed', {
|
|
112
|
+
bubbles: true,
|
|
113
|
+
composed: true,
|
|
114
|
+
detail: this,
|
|
115
|
+
}),
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
this.a11y();
|
|
120
|
+
this.focusableBodyElements();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
render() {
|
|
124
|
+
return html`
|
|
125
|
+
<button
|
|
126
|
+
class="trigger"
|
|
127
|
+
part="trigger"
|
|
128
|
+
@click=${() => this.toggle()}
|
|
129
|
+
@keydown=${event => this.handleKeyDown(event)}
|
|
130
|
+
>
|
|
131
|
+
<slot name="trigger"></slot>
|
|
132
|
+
<slot name="icon"></slot>
|
|
133
|
+
</button>
|
|
134
|
+
<section class="body" part="body" style="max-height:${this.maxHeight};">
|
|
135
|
+
<slot name="body"></slot>
|
|
136
|
+
</section>
|
|
137
|
+
`;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
toggle() {
|
|
141
|
+
this.opened = !this.opened;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
focusableBodyElements() {
|
|
145
|
+
const focusableElements = this.bodyElement.querySelectorAll(this.focusableSelector);
|
|
146
|
+
|
|
147
|
+
if (this.opened) {
|
|
148
|
+
focusableElements.forEach((element) => {
|
|
149
|
+
element.removeAttribute('tabindex');
|
|
150
|
+
});
|
|
151
|
+
} else {
|
|
152
|
+
focusableElements.forEach((element) => {
|
|
153
|
+
element.setAttribute('tabindex', '-1');
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
a11y() {
|
|
159
|
+
const trigger = this.shadowRoot.querySelector('.trigger');
|
|
160
|
+
const body = this.shadowRoot.querySelector('.body');
|
|
161
|
+
|
|
162
|
+
trigger.setAttribute('id', `${this.slug}-button`);
|
|
163
|
+
trigger.setAttribute('aria-controls', `${this.slug}-content`);
|
|
164
|
+
|
|
165
|
+
body.setAttribute('id', `${this.slug}-content`);
|
|
166
|
+
body.setAttribute('aria-labelledby', `${this.slug}-button`);
|
|
167
|
+
body.setAttribute('aria-hidden', `${!this.opened}`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
handleKeyDown(event) {
|
|
171
|
+
if (event.key === 'Space' || event.key === 'Enter') {
|
|
172
|
+
this.toggle();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// eslint-disable-next-line no-unused-expressions
|
|
178
|
+
customElements.get('kemet-accordion-panel') || customElements.define('kemet-accordion-panel', KemetAccordionPanel);
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { html, css, LitElement } from 'lit';
|
|
2
|
+
|
|
3
|
+
export default class KemetAccordion extends LitElement {
|
|
4
|
+
static get styles() {
|
|
5
|
+
return [
|
|
6
|
+
css`
|
|
7
|
+
:host {
|
|
8
|
+
display: block;
|
|
9
|
+
}
|
|
10
|
+
`,
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static get properties() {
|
|
15
|
+
return {
|
|
16
|
+
/**
|
|
17
|
+
* The index value for the most recently opened panel
|
|
18
|
+
*/
|
|
19
|
+
currentPanel: {
|
|
20
|
+
type: Number,
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* Support for closing all inactive panels when one is opened
|
|
24
|
+
*/
|
|
25
|
+
togglePanels: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
attribute: 'toggle-panels',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
constructor() {
|
|
33
|
+
super();
|
|
34
|
+
|
|
35
|
+
// managed properties
|
|
36
|
+
this.togglePanels = false;
|
|
37
|
+
this.currentPanel = undefined;
|
|
38
|
+
|
|
39
|
+
// bindings
|
|
40
|
+
this.addEventListener('kemet-accordion-panel-opened', this.handlePanelOpened.bind(this));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
firstUpdated() {
|
|
44
|
+
this.onKeyDown = event => this.handleKeyDown(event);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
render() {
|
|
48
|
+
return html`<slot @slotchange=${event => this.handleSlotChange(event)}></slot>`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
handleSlotChange() {
|
|
52
|
+
this.panels = this.querySelectorAll('kemet-accordion-panel');
|
|
53
|
+
|
|
54
|
+
this.panels.forEach((panel) => {
|
|
55
|
+
panel.removeEventListener('keydown', this.onKeyDown);
|
|
56
|
+
panel.addEventListener('keydown', this.onKeyDown);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
handlePanelOpened(event) {
|
|
61
|
+
if (this.togglePanels) {
|
|
62
|
+
this.panels.forEach((panel) => {
|
|
63
|
+
if (panel !== event.detail) {
|
|
64
|
+
panel.opened = false;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
navigatePanels(direction) {
|
|
71
|
+
switch (direction) {
|
|
72
|
+
case 'home':
|
|
73
|
+
this.currentPanel = 0;
|
|
74
|
+
break;
|
|
75
|
+
case 'end':
|
|
76
|
+
this.currentPanel = this.panels.length - 1;
|
|
77
|
+
break;
|
|
78
|
+
case 'next':
|
|
79
|
+
this.currentPanel += 1;
|
|
80
|
+
break;
|
|
81
|
+
case 'prev':
|
|
82
|
+
this.currentPanel -= 1;
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
85
|
+
this.currentPanelFocus = 0;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (this.currentPanel > this.panels.length - 1) this.currentPanel = 0;
|
|
90
|
+
if (this.currentPanel < 0) this.currentPanel = this.panels.length - 1;
|
|
91
|
+
|
|
92
|
+
this.panels[this.currentPanel].shadowRoot.querySelector('button').focus();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
handleKeyDown(event) {
|
|
96
|
+
switch (event.key) {
|
|
97
|
+
case 'Enter':
|
|
98
|
+
case 'Space':
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
event.target.click();
|
|
101
|
+
break;
|
|
102
|
+
case 'ArrowLeft':
|
|
103
|
+
case 'ArrowUp':
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
this.navigatePanels('prev');
|
|
106
|
+
break;
|
|
107
|
+
case 'ArrowRight':
|
|
108
|
+
case 'ArrowDown':
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
this.navigatePanels('next');
|
|
111
|
+
break;
|
|
112
|
+
case 'End':
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
this.navigatePanels('end');
|
|
115
|
+
break;
|
|
116
|
+
case 'Home':
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
this.navigatePanels('home');
|
|
119
|
+
break;
|
|
120
|
+
default:
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
expandAll() {
|
|
126
|
+
this.panels.forEach((panel) => {
|
|
127
|
+
panel.opened = true;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
collapseAll() {
|
|
132
|
+
this.panels.forEach((panel) => {
|
|
133
|
+
panel.opened = false;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// eslint-disable-next-line no-unused-expressions
|
|
139
|
+
customElements.get('kemet-accordion') || customElements.define('kemet-accordion', KemetAccordion);
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { html, css, LitElement } from 'lit';
|
|
2
|
+
|
|
3
|
+
export default class KemetBadge extends LitElement {
|
|
4
|
+
static get styles() {
|
|
5
|
+
return [
|
|
6
|
+
css`
|
|
7
|
+
:host {
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
padding: var(--kemet-badge-padding, 10px);
|
|
12
|
+
line-height: 1;
|
|
13
|
+
color: var(--kemet-color-white);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
:host([status='primary']) {
|
|
17
|
+
background-color: var(--kemet-color-primary);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
:host([status='success']) {
|
|
21
|
+
background-color: var(--kemet-color-success);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:host([status='standard']) {
|
|
25
|
+
background-color: var(--kemet-color-gray6);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:host([status='warning']) {
|
|
29
|
+
background-color: var(--kemet-color-warning);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:host([status='error']) {
|
|
33
|
+
background-color: var(--kemet-color-error);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
:host([circle]) {
|
|
37
|
+
border-radius: 50%;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
:host([pill]) {
|
|
41
|
+
border-radius: 99rem;
|
|
42
|
+
}
|
|
43
|
+
`,
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static get properties() {
|
|
48
|
+
return {
|
|
49
|
+
/**
|
|
50
|
+
* The status of the badge
|
|
51
|
+
*/
|
|
52
|
+
status: {
|
|
53
|
+
type: String,
|
|
54
|
+
reflect: true,
|
|
55
|
+
},
|
|
56
|
+
/**
|
|
57
|
+
* Displays the badge in a circle
|
|
58
|
+
*/
|
|
59
|
+
circle: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
reflect: true,
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* Rounds the corners on the badge
|
|
65
|
+
*/
|
|
66
|
+
pill: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
reflect: true,
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* Padding on the badge as a circle
|
|
72
|
+
*/
|
|
73
|
+
circlePadding: {
|
|
74
|
+
type: Number,
|
|
75
|
+
attribute: 'circle-padding',
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
constructor() {
|
|
81
|
+
super();
|
|
82
|
+
|
|
83
|
+
this.status = 'primary';
|
|
84
|
+
this.pill = false;
|
|
85
|
+
this.circle = false;
|
|
86
|
+
this.circlePadding = 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
render() {
|
|
90
|
+
return html`<slot @slotchange=${() => this.handleSlotChange()}></slot>`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
handleSlotChange() {
|
|
94
|
+
if (this.circle) {
|
|
95
|
+
this.style.height = `${this.offsetWidth + this.circlePadding}px`;
|
|
96
|
+
this.style.width = `${this.offsetWidth + this.circlePadding}px`;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// eslint-disable-next-line no-unused-expressions
|
|
102
|
+
customElements.get('kemet-badge') || customElements.define('kemet-badge', KemetBadge);
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { html, css, LitElement } from 'lit';
|
|
2
|
+
import '../kemet-icon/kemet-icon.js';
|
|
3
|
+
import { FormSubmitController } from '../../utilities/controllers/forms.js';
|
|
4
|
+
|
|
5
|
+
export default class KemetButton extends LitElement {
|
|
6
|
+
static get styles() {
|
|
7
|
+
return [
|
|
8
|
+
css`
|
|
9
|
+
:host {
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
display: inline-flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
font-size: var(--kemet-button-font-size, inherit);
|
|
15
|
+
color: var(--kemet-button-color, var(--kemet-color-white));
|
|
16
|
+
width: var(--kemet-button-width, auto);
|
|
17
|
+
height: var(--kemet-button-height, auto);
|
|
18
|
+
border: var(--kemet-button-border, 0);
|
|
19
|
+
border-radius: var(--kemet-button-border-radius, 0);
|
|
20
|
+
transition: filter var(--kemet-button-transition-speed, 300ms) ease;
|
|
21
|
+
background-color: var(--kemet-button-background-color, var(--kemet-color-primary));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:host(:hover:not([disabled])) {
|
|
25
|
+
filter: brightness(var(--kemet-button-hover-brightness, 1.25));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:host([disabled]) {
|
|
29
|
+
opacity: var(--kemet-button-disabled-opacity, 0.5);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.button {
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
text-decoration: none;
|
|
35
|
+
display: flex;
|
|
36
|
+
gap: var(--kemet-button-gap, 0.5rem);
|
|
37
|
+
align-items: center;
|
|
38
|
+
color: inherit;
|
|
39
|
+
font-size: inherit;
|
|
40
|
+
padding: var(--kemet-button-padding, 1rem 1.25rem);
|
|
41
|
+
border: 0;
|
|
42
|
+
background: none;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
:host([disabled]) .button {
|
|
46
|
+
cursor: not-allowed;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
:host([type='text']) {
|
|
50
|
+
--kemet-button-color: var(--kemet-color-primary);
|
|
51
|
+
--kemet-button-background-color: none;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
:host([type='text']:hover) {
|
|
55
|
+
text-decoration: var(--kemet-button-hover-decoration, underline);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
:host([type='circle']) {
|
|
59
|
+
--kemet-button-border-radius: 50%;
|
|
60
|
+
--kemet-button-width: var(--kemet-button-circle-size, 50px);
|
|
61
|
+
--kemet-button-height: var(--kemet-button-circle-size, 50px);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
:host([type='rounded']) {
|
|
65
|
+
--kemet-button-border-radius: var(--kemet-button-rounded-amount, 6px);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
:host([type='pill']) {
|
|
69
|
+
--kemet-button-border-radius: 10rem;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
:host([outlined]) {
|
|
73
|
+
--kemet-button-color: var(--kemet-color-primary);
|
|
74
|
+
--kemet-button-background-color: var(--kemet-color-white);
|
|
75
|
+
--kemet-button-border: var(--kemet-button-border-width, 1px) var(--kemet-button-border-style, solid) var(--kemet-button-border-color, var(--kemet-color-primary));
|
|
76
|
+
}
|
|
77
|
+
`,
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static get properties() {
|
|
82
|
+
return {
|
|
83
|
+
/**
|
|
84
|
+
* Determines whether or not the button is active
|
|
85
|
+
*/
|
|
86
|
+
active: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
reflect: true,
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* Is true when the button is hovered
|
|
92
|
+
*/
|
|
93
|
+
hover: {
|
|
94
|
+
type: Boolean,
|
|
95
|
+
reflect: true,
|
|
96
|
+
},
|
|
97
|
+
/**
|
|
98
|
+
* Is true when the button is focused
|
|
99
|
+
*/
|
|
100
|
+
focused: {
|
|
101
|
+
type: Boolean,
|
|
102
|
+
reflect: true,
|
|
103
|
+
},
|
|
104
|
+
/**
|
|
105
|
+
* The url a button should link too
|
|
106
|
+
*/
|
|
107
|
+
link: {
|
|
108
|
+
type: String,
|
|
109
|
+
},
|
|
110
|
+
/**
|
|
111
|
+
* Outline style for a button
|
|
112
|
+
*/
|
|
113
|
+
outlined: {
|
|
114
|
+
type: Boolean,
|
|
115
|
+
reflect: true,
|
|
116
|
+
},
|
|
117
|
+
/**
|
|
118
|
+
* Determines whether not a button is disabled
|
|
119
|
+
*/
|
|
120
|
+
disabled: {
|
|
121
|
+
type: Boolean,
|
|
122
|
+
reflect: true,
|
|
123
|
+
},
|
|
124
|
+
/**
|
|
125
|
+
* Controls the type of button
|
|
126
|
+
* standard | text | circle | rounded | pill
|
|
127
|
+
*/
|
|
128
|
+
type: {
|
|
129
|
+
type: String,
|
|
130
|
+
reflect: true,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
constructor() {
|
|
136
|
+
super();
|
|
137
|
+
|
|
138
|
+
this.addEventListener('click', this.handleClick.bind(this));
|
|
139
|
+
this.addEventListener('mouseover', this.handleMouseOver.bind(this));
|
|
140
|
+
this.addEventListener('mouseout', this.handleMouseOut.bind(this));
|
|
141
|
+
this.addEventListener('blur', this.handleBlur.bind(this));
|
|
142
|
+
this.addEventListener('keyup', event => this.handleKeyUp(event));
|
|
143
|
+
|
|
144
|
+
this.type = 'standard';
|
|
145
|
+
this.outline = false;
|
|
146
|
+
this.disable = false;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Used only for form reactive controller
|
|
150
|
+
*/
|
|
151
|
+
this.formSubmitController = new FormSubmitController(this);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
render() {
|
|
155
|
+
if (this.link && !this.disabled) {
|
|
156
|
+
return html`
|
|
157
|
+
<a href=${this.link} class="button" role="button" part="button">
|
|
158
|
+
<slot name="left"></slot>
|
|
159
|
+
<slot></slot>
|
|
160
|
+
<slot name="right"></slot>
|
|
161
|
+
</a>
|
|
162
|
+
`;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return html`
|
|
166
|
+
<button class="button" part="button" ?disabled=${this.disabled} aria-disabled=${this.disabled ? 'true' : 'false'}>
|
|
167
|
+
<slot name="left"></slot>
|
|
168
|
+
<slot></slot>
|
|
169
|
+
<slot name="right"></slot>
|
|
170
|
+
</button>
|
|
171
|
+
`;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Sets hover to true onMouseOver
|
|
176
|
+
* @private
|
|
177
|
+
*/
|
|
178
|
+
handleMouseOver() {
|
|
179
|
+
this.hover = true;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Sets hover to false onMouseOut
|
|
184
|
+
* @private
|
|
185
|
+
*/
|
|
186
|
+
handleMouseOut() {
|
|
187
|
+
this.hover = false;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Handles click behavior
|
|
192
|
+
* @private
|
|
193
|
+
*/
|
|
194
|
+
handleClick() {
|
|
195
|
+
this.hover = false;
|
|
196
|
+
this.active = true;
|
|
197
|
+
|
|
198
|
+
setTimeout(() => {
|
|
199
|
+
this.active = false;
|
|
200
|
+
}, 300);
|
|
201
|
+
|
|
202
|
+
if (this.shadowRoot.querySelector('button')) {
|
|
203
|
+
this.formSubmitController.submit(this);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Handles blur
|
|
209
|
+
* @private
|
|
210
|
+
*/
|
|
211
|
+
handleBlur() {
|
|
212
|
+
this.focused = false;
|
|
213
|
+
this.active = false;
|
|
214
|
+
this.hover = false;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Handles keyup
|
|
219
|
+
* @private
|
|
220
|
+
* @param {object} event - event object
|
|
221
|
+
*/
|
|
222
|
+
handleKeyUp(event) {
|
|
223
|
+
if (event.key === 'Tab') {
|
|
224
|
+
this.focused = true;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// eslint-disable-next-line no-unused-expressions
|
|
230
|
+
customElements.get('kemet-button') || customElements.define('kemet-button', KemetButton);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { html, css, LitElement } from 'lit';
|
|
2
|
+
|
|
3
|
+
export class KemetCarouselCurrent extends LitElement {
|
|
4
|
+
static get styles() {
|
|
5
|
+
return [
|
|
6
|
+
css`
|
|
7
|
+
:host {
|
|
8
|
+
display: inline-block;
|
|
9
|
+
}
|
|
10
|
+
`,
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static get properties() {
|
|
15
|
+
return {
|
|
16
|
+
current: {
|
|
17
|
+
type: Number,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
firstUpdated() {
|
|
23
|
+
this.carousel = this.closest('kemet-carousel');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
updated() {
|
|
27
|
+
this.current = this.carousel.index + 1;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
render() {
|
|
31
|
+
return html`${this.current}`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// eslint-disable-next-line no-unused-expressions
|
|
36
|
+
customElements.get('kemet-carousel-current') || customElements.define('kemet-carousel-current', KemetCarouselCurrent);
|