kempo-css 1.3.12 → 1.3.13
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/AGENTS.md +43 -0
- package/CHANGELOG.md +11 -0
- package/docs/components/ThemePropertyInput.js +117 -10
- package/package.json +1 -1
- package/.github/copilot-instructions.md +0 -165
- package/src/components/ThemePropertyInput.js +0 -154
package/AGENTS.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Code Contribution Guidelines
|
|
2
|
+
|
|
3
|
+
## Project Structure
|
|
4
|
+
|
|
5
|
+
- The actual CSS file (the main file for this project) is at `src/kempo.css`.
|
|
6
|
+
- All documnentation should be in the `docs/` directory. This directory is used by GitHub as the "GitHub Pages", so all links need to be relative, and there will be a build script which copies all code to the `docs/` directory.
|
|
7
|
+
- Components used in the docs / theme builder should live within the docs directory directly, as they are not part of the distributed code for this project.
|
|
8
|
+
- All tests should live in the `tests/` directory. These use the kempo-testing-framework, do not assume they are jest/enszyme or any other popular testing framework, instead read the existing tests or the docs (https://github.com/dustinpoissant/kempo-testing-framework/blob/main/README.md) to understand how these tests work.
|
|
9
|
+
|
|
10
|
+
### Minimal Comments, Empty Lines, and Spacing
|
|
11
|
+
|
|
12
|
+
Use minimal comments. Assume readers understand the language. Some exceptions include:
|
|
13
|
+
- complex logic
|
|
14
|
+
- anti-patterns
|
|
15
|
+
- code organization
|
|
16
|
+
|
|
17
|
+
Do not put random empty lines within code; put them where they make sense for readability, for example:
|
|
18
|
+
- above and below definitions for functions and classes.
|
|
19
|
+
- to help break up large sections of logic to be more readable. If there are 100 lines of code with no breaks, it gets hard to read.
|
|
20
|
+
- above multi-line comments to indicate the comment belongs to the code below
|
|
21
|
+
|
|
22
|
+
No empty lines in css.
|
|
23
|
+
|
|
24
|
+
End each file with an empty line.
|
|
25
|
+
|
|
26
|
+
End each line with a `;` when possible, even if it is optional.
|
|
27
|
+
|
|
28
|
+
## Development Workflow
|
|
29
|
+
|
|
30
|
+
### Local Development Server
|
|
31
|
+
- **DO NOT** start a development server - one is already running
|
|
32
|
+
- Default port: **8083**
|
|
33
|
+
- Base URL: `http://localhost:4048/`
|
|
34
|
+
- Documentation URLs follow the directory/file structure in `docs/`
|
|
35
|
+
- Use this server for all testing and verification
|
|
36
|
+
|
|
37
|
+
### Testing and Verification
|
|
38
|
+
- **ALWAYS** verify changes using the live documentation on the running server
|
|
39
|
+
- Use Chrome DevTools Protocol (chrome-devtools-mcp) for interactive testing
|
|
40
|
+
- **DO NOT** create one-off test files or framework-less tests
|
|
41
|
+
- Test components in their natural documentation environment
|
|
42
|
+
- Validate both functionality and visual appearance
|
|
43
|
+
- Always add to the changelog after each commit. Assume the next version incrament will be a patch version unless stated otherwise.
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.3.13] - 2026-03-12
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- Reorganized files
|
|
9
|
+
- Moved and updated .github/copilot-instructions.md -> AGENTS.md
|
|
10
|
+
|
|
11
|
+
## [1.3.12] - 2026-03-12
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- Updated github workflows
|
|
15
|
+
|
|
5
16
|
## [1.3.10] - 2026-02-26
|
|
6
17
|
|
|
7
18
|
### Changed
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
import ShadowComponent from
|
|
1
|
+
import ShadowComponent from 'https://cdn.jsdelivr.net/npm/kempo-ui@0.0.36/dist/components/ShadowComponent.js';
|
|
2
|
+
import { html, css } from 'https://cdn.jsdelivr.net/npm/kempo-ui@0.0.36/dist/lit-all.min.js';
|
|
3
|
+
|
|
4
|
+
export default class ThemePropertyInput extends ShadowComponent {
|
|
5
|
+
static properties = {
|
|
6
|
+
propName: { type: String, attribute: 'prop-name' },
|
|
7
|
+
value: { type: String },
|
|
8
|
+
availableProperties: { type: Array, attribute: 'available-properties' },
|
|
9
|
+
mode: { type: String },
|
|
10
|
+
initialColor: { type: String, attribute: 'initial-color' }
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
static styles = css`
|
|
2
14
|
:host {
|
|
3
15
|
display: block;
|
|
4
16
|
}
|
|
@@ -18,7 +30,95 @@ import ShadowComponent from"https://cdn.jsdelivr.net/npm/kempo-ui@0.0.36/dist/co
|
|
|
18
30
|
.value-input {
|
|
19
31
|
flex: 1;
|
|
20
32
|
}
|
|
21
|
-
`;
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
constructor() {
|
|
36
|
+
super();
|
|
37
|
+
this.propName = '';
|
|
38
|
+
this.value = '';
|
|
39
|
+
this.availableProperties = [];
|
|
40
|
+
this.mode = 'color';
|
|
41
|
+
this.initialColor = '';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
connectedCallback() {
|
|
45
|
+
super.connectedCallback();
|
|
46
|
+
|
|
47
|
+
if(this.value?.startsWith('var(')) {
|
|
48
|
+
this.mode = 'var';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
firstUpdated() {
|
|
53
|
+
this.attachColorPickerListener();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
updated(changedProperties) {
|
|
57
|
+
super.updated?.(changedProperties);
|
|
58
|
+
this.attachColorPickerListener();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
attachColorPickerListener() {
|
|
62
|
+
if(this.mode === 'color') {
|
|
63
|
+
const colorPicker = this.shadowRoot?.querySelector('k-color-picker');
|
|
64
|
+
if(colorPicker && !colorPicker._hasChangeListener) {
|
|
65
|
+
colorPicker._hasChangeListener = true;
|
|
66
|
+
colorPicker.addEventListener('change', this.handleColorChange);
|
|
67
|
+
colorPicker.addEventListener('input', this.handleColorChange);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/*
|
|
73
|
+
Event Handlers
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
handleModeChange = (e) => {
|
|
77
|
+
this.mode = e.target.value;
|
|
78
|
+
|
|
79
|
+
if(this.mode === 'var' && !this.value.startsWith('var(')) {
|
|
80
|
+
this.value = this.availableProperties[0] ? `var(${this.availableProperties[0]})` : '';
|
|
81
|
+
} else if(this.mode === 'color' && this.value.startsWith('var(')) {
|
|
82
|
+
this.value = this.initialColor || '#000000';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
this.emitChange();
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
handleVarInput = (e) => {
|
|
89
|
+
const varName = e.target.value;
|
|
90
|
+
this.value = varName.startsWith('var(') ? varName : `var(${varName})`;
|
|
91
|
+
this.emitChange();
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
handleColorChange = (e) => {
|
|
95
|
+
this.value = e.target.value;
|
|
96
|
+
this.emitChange();
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/*
|
|
100
|
+
Utility Functions
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
emitChange() {
|
|
104
|
+
this.dispatchEvent(new CustomEvent('value-change', {
|
|
105
|
+
detail: { propName: this.propName, value: this.value },
|
|
106
|
+
bubbles: true,
|
|
107
|
+
composed: true
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/*
|
|
112
|
+
Rendering
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
render() {
|
|
116
|
+
const datalistId = `${this.propName}-datalist`;
|
|
117
|
+
const varName = this.value?.startsWith('var(')
|
|
118
|
+
? this.value.slice(4, -1).trim()
|
|
119
|
+
: '';
|
|
120
|
+
|
|
121
|
+
return html`
|
|
22
122
|
<label>${this.propName}</label>
|
|
23
123
|
<div class="input-wrapper">
|
|
24
124
|
<select class="mode-select" .value=${this.mode} @change=${this.handleModeChange}>
|
|
@@ -26,22 +126,29 @@ import ShadowComponent from"https://cdn.jsdelivr.net/npm/kempo-ui@0.0.36/dist/co
|
|
|
26
126
|
<option value="color">Color</option>
|
|
27
127
|
</select>
|
|
28
128
|
|
|
29
|
-
${
|
|
129
|
+
${this.mode === 'var'
|
|
130
|
+
? html`
|
|
30
131
|
<input
|
|
31
132
|
class="value-input"
|
|
32
|
-
list=${
|
|
33
|
-
.value=${
|
|
133
|
+
list=${datalistId}
|
|
134
|
+
.value=${varName}
|
|
34
135
|
@input=${this.handleVarInput}
|
|
35
136
|
placeholder="--property-name"
|
|
36
137
|
/>
|
|
37
|
-
<datalist id=${
|
|
38
|
-
${this.availableProperties.map(
|
|
138
|
+
<datalist id=${datalistId}>
|
|
139
|
+
${this.availableProperties.map(prop => html`<option value=${prop}></option>`)}
|
|
39
140
|
</datalist>
|
|
40
|
-
|
|
141
|
+
`
|
|
142
|
+
: html`
|
|
41
143
|
<k-color-picker
|
|
42
144
|
class="value-input"
|
|
43
145
|
value=${this.value}
|
|
44
146
|
></k-color-picker>
|
|
45
|
-
`
|
|
147
|
+
`
|
|
148
|
+
}
|
|
46
149
|
</div>
|
|
47
|
-
|
|
150
|
+
`;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
customElements.define('k-theme-property-input', ThemePropertyInput);
|
package/package.json
CHANGED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
# Code Contribution Guidelines
|
|
2
|
-
|
|
3
|
-
## Project Structure
|
|
4
|
-
|
|
5
|
-
- All code should be in the `src/` directory, with the exception of npm scripts.
|
|
6
|
-
- All components should be in the `src/components/` directory.
|
|
7
|
-
- All utility function module files should be in the `src/utils/` directory.
|
|
8
|
-
- All documnentation should be in the `docs/` directory. This directory is used by GitHub as the "GitHub Pages", so all links need to be relative, and there will be a build script which copies all code to the `docs/` directory.
|
|
9
|
-
|
|
10
|
-
## Coding Style Guidelines
|
|
11
|
-
|
|
12
|
-
### Code Organization
|
|
13
|
-
Use multi-line comments to separate code into logical sections. Group related functionality together.
|
|
14
|
-
- Example: In Lit components, group lifecycle callbacks, event handlers, public methods, utility functions, and rendering logic separately.
|
|
15
|
-
|
|
16
|
-
```javascript
|
|
17
|
-
/*
|
|
18
|
-
Lifecycle Callbacks
|
|
19
|
-
*/
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### Avoid single-use variables/functions
|
|
23
|
-
Avoid defining a variable or function to only use it once; inline the logic where needed. Some exceptions include:
|
|
24
|
-
- recursion
|
|
25
|
-
- scope encapsulation (IIFE)
|
|
26
|
-
- context changes
|
|
27
|
-
|
|
28
|
-
### Minimal Comments, Empty Lines, and Spacing
|
|
29
|
-
|
|
30
|
-
Use minimal comments. Assume readers understand the language. Some exceptions include:
|
|
31
|
-
- complex logic
|
|
32
|
-
- anti-patterns
|
|
33
|
-
- code organization
|
|
34
|
-
|
|
35
|
-
Do not put random empty lines within code; put them where they make sense for readability, for example:
|
|
36
|
-
- above and below definitions for functions and classes.
|
|
37
|
-
- to help break up large sections of logic to be more readable. If there are 100 lines of code with no breaks, it gets hard to read.
|
|
38
|
-
- above multi-line comments to indicate the comment belongs to the code below
|
|
39
|
-
|
|
40
|
-
No empty lines in css.
|
|
41
|
-
|
|
42
|
-
End each file with an empty line.
|
|
43
|
-
|
|
44
|
-
End each line with a `;` when possible, even if it is optional.
|
|
45
|
-
|
|
46
|
-
Avoid unnecessary spacing, for example:
|
|
47
|
-
- after the word `if`
|
|
48
|
-
- within parentheses for conditional statements
|
|
49
|
-
|
|
50
|
-
```javascript
|
|
51
|
-
let count = 1;
|
|
52
|
-
|
|
53
|
-
const incrementOdd = (n) => {
|
|
54
|
-
if(n % 2 !== 0){
|
|
55
|
-
return n++;
|
|
56
|
-
}
|
|
57
|
-
return n;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
count = incrementOdd(count);
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### Prefer Arrow Functions
|
|
64
|
-
Prefer the use of arrow functions when possible, especially for class methods to avoid binding. Use normal functions if needed for preserving the proper context.
|
|
65
|
-
- For very basic logic, use implicit returns
|
|
66
|
-
- If there is a single parameter, omit the parentheses.
|
|
67
|
-
```javascript
|
|
68
|
-
const addOne = n => n + 1;
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### Module Exports
|
|
72
|
-
- If a module has only one export, use the "default" export, not a named export.
|
|
73
|
-
- Do not declare the default export as a const or give it a name; just export the value.
|
|
74
|
-
|
|
75
|
-
```javascript
|
|
76
|
-
export default (n) => n + 1;
|
|
77
|
-
```
|
|
78
|
-
- If a module has multiple exports, use named exports and do not use a "default" export.
|
|
79
|
-
|
|
80
|
-
### Code Reuse
|
|
81
|
-
Create utility functions for shared logic.
|
|
82
|
-
- If the shared logic is used in a single file, define a utility function in that file.
|
|
83
|
-
- If the shared logic is used in multiple files, create a utility function module file in `src/utils/`.
|
|
84
|
-
|
|
85
|
-
### Naming
|
|
86
|
-
Do not prefix identifiers with underscores.
|
|
87
|
-
- Never use leading underscores (`_`) for variable, property, method, or function names.
|
|
88
|
-
- Use clear, descriptive names without prefixes.
|
|
89
|
-
- When true privacy is needed inside classes, prefer native JavaScript private fields (e.g., `#myField`) instead of simulated privacy via underscores.
|
|
90
|
-
|
|
91
|
-
## Components
|
|
92
|
-
|
|
93
|
-
### Base Component Architecture
|
|
94
|
-
|
|
95
|
-
The project provides three base components for different rendering strategies. Choose the appropriate base component and extend it:
|
|
96
|
-
|
|
97
|
-
#### ShadowComponent
|
|
98
|
-
For components that need shadow DOM encapsulation and automatic `/kempo.css` stylesheet injection.
|
|
99
|
-
|
|
100
|
-
```javascript
|
|
101
|
-
import ShadowComponent from './ShadowComponent.js';
|
|
102
|
-
|
|
103
|
-
export default class MyComponent extends ShadowComponent {
|
|
104
|
-
render() {
|
|
105
|
-
return html`<p>Shadow DOM content with scoped styles</p>`;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
#### LightComponent
|
|
111
|
-
For components that render directly to light DOM without shadow DOM encapsulation.
|
|
112
|
-
|
|
113
|
-
```javascript
|
|
114
|
-
import LightComponent from './LightComponent.js';
|
|
115
|
-
|
|
116
|
-
export default class MyComponent extends LightComponent {
|
|
117
|
-
renderLightDom() {
|
|
118
|
-
return html`<p>Light DOM content</p>`;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
#### HybridComponent
|
|
124
|
-
For components that need both shadow DOM (with automatic `/kempo.css`) and light DOM rendering.
|
|
125
|
-
|
|
126
|
-
```javascript
|
|
127
|
-
import HybridComponent from './HybridComponent.js';
|
|
128
|
-
|
|
129
|
-
export default class MyComponent extends HybridComponent {
|
|
130
|
-
render() {
|
|
131
|
-
return html`<p>Shadow DOM content</p>`;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
renderLightDom() {
|
|
135
|
-
return html`<p>Light DOM content alongside natural children</p>`;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
**Important:** Always call `super.updated()` when overriding the `updated()` method in LightComponent or HybridComponent to ensure proper rendering.
|
|
141
|
-
|
|
142
|
-
### Component Architecture and Communication
|
|
143
|
-
|
|
144
|
-
- Use methods to cause actions; do not emit events to trigger logic. Events are for notifying that something already happened.
|
|
145
|
-
- Prefer `el.closest('ktf-test-framework')?.enqueueSuite({...})` over firing an `enqueue` event.
|
|
146
|
-
|
|
147
|
-
- Wrap dependent components inside a parent `ktf-test-framework` element. Children find it via `closest('ktf-test-framework')` and call its methods. The framework can query its subtree to orchestrate children.
|
|
148
|
-
|
|
149
|
-
- Avoid `window` globals and global custom events for coordination. If broadcast is needed, scope events to the framework element; reserve window events for global, non-visual concerns (e.g., settings changes).
|
|
150
|
-
|
|
151
|
-
## Development Workflow
|
|
152
|
-
|
|
153
|
-
### Local Development Server
|
|
154
|
-
- **DO NOT** start a development server - one is already running
|
|
155
|
-
- Default port: **8083**
|
|
156
|
-
- Base URL: `http://localhost:4048/`
|
|
157
|
-
- Documentation URLs follow the directory/file structure in `docs/` (e.g., `docs/components/color-picker.html` → `http://localhost:8083/components/color-picker.html`)
|
|
158
|
-
- Use this server for all testing and verification
|
|
159
|
-
|
|
160
|
-
### Testing and Verification
|
|
161
|
-
- **ALWAYS** verify changes using the live documentation on the running server
|
|
162
|
-
- Use Chrome DevTools Protocol (chrome-devtools-mcp) for interactive testing
|
|
163
|
-
- **DO NOT** create one-off test files or framework-less tests
|
|
164
|
-
- Test components in their natural documentation environment
|
|
165
|
-
- Validate both functionality and visual appearance
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import ShadowComponent from 'https://cdn.jsdelivr.net/npm/kempo-ui@0.0.36/dist/components/ShadowComponent.js';
|
|
2
|
-
import { html, css } from 'https://cdn.jsdelivr.net/npm/kempo-ui@0.0.36/dist/lit-all.min.js';
|
|
3
|
-
|
|
4
|
-
export default class ThemePropertyInput extends ShadowComponent {
|
|
5
|
-
static properties = {
|
|
6
|
-
propName: { type: String, attribute: 'prop-name' },
|
|
7
|
-
value: { type: String },
|
|
8
|
-
availableProperties: { type: Array, attribute: 'available-properties' },
|
|
9
|
-
mode: { type: String },
|
|
10
|
-
initialColor: { type: String, attribute: 'initial-color' }
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
static styles = css`
|
|
14
|
-
:host {
|
|
15
|
-
display: block;
|
|
16
|
-
}
|
|
17
|
-
label {
|
|
18
|
-
display: block;
|
|
19
|
-
margin-bottom: 0.25rem;
|
|
20
|
-
}
|
|
21
|
-
.input-wrapper {
|
|
22
|
-
display: flex;
|
|
23
|
-
gap: 0.5rem;
|
|
24
|
-
align-items: center;
|
|
25
|
-
}
|
|
26
|
-
.mode-select {
|
|
27
|
-
width: 100px;
|
|
28
|
-
flex-shrink: 0;
|
|
29
|
-
}
|
|
30
|
-
.value-input {
|
|
31
|
-
flex: 1;
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
constructor() {
|
|
36
|
-
super();
|
|
37
|
-
this.propName = '';
|
|
38
|
-
this.value = '';
|
|
39
|
-
this.availableProperties = [];
|
|
40
|
-
this.mode = 'color';
|
|
41
|
-
this.initialColor = '';
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
connectedCallback() {
|
|
45
|
-
super.connectedCallback();
|
|
46
|
-
|
|
47
|
-
if(this.value?.startsWith('var(')) {
|
|
48
|
-
this.mode = 'var';
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
firstUpdated() {
|
|
53
|
-
this.attachColorPickerListener();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
updated(changedProperties) {
|
|
57
|
-
super.updated?.(changedProperties);
|
|
58
|
-
this.attachColorPickerListener();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
attachColorPickerListener() {
|
|
62
|
-
if(this.mode === 'color') {
|
|
63
|
-
const colorPicker = this.shadowRoot?.querySelector('k-color-picker');
|
|
64
|
-
if(colorPicker && !colorPicker._hasChangeListener) {
|
|
65
|
-
colorPicker._hasChangeListener = true;
|
|
66
|
-
colorPicker.addEventListener('change', this.handleColorChange);
|
|
67
|
-
colorPicker.addEventListener('input', this.handleColorChange);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/*
|
|
73
|
-
Event Handlers
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
handleModeChange = (e) => {
|
|
77
|
-
this.mode = e.target.value;
|
|
78
|
-
|
|
79
|
-
if(this.mode === 'var' && !this.value.startsWith('var(')) {
|
|
80
|
-
this.value = this.availableProperties[0] ? `var(${this.availableProperties[0]})` : '';
|
|
81
|
-
} else if(this.mode === 'color' && this.value.startsWith('var(')) {
|
|
82
|
-
this.value = this.initialColor || '#000000';
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
this.emitChange();
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
handleVarInput = (e) => {
|
|
89
|
-
const varName = e.target.value;
|
|
90
|
-
this.value = varName.startsWith('var(') ? varName : `var(${varName})`;
|
|
91
|
-
this.emitChange();
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
handleColorChange = (e) => {
|
|
95
|
-
this.value = e.target.value;
|
|
96
|
-
this.emitChange();
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/*
|
|
100
|
-
Utility Functions
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
emitChange() {
|
|
104
|
-
this.dispatchEvent(new CustomEvent('value-change', {
|
|
105
|
-
detail: { propName: this.propName, value: this.value },
|
|
106
|
-
bubbles: true,
|
|
107
|
-
composed: true
|
|
108
|
-
}));
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/*
|
|
112
|
-
Rendering
|
|
113
|
-
*/
|
|
114
|
-
|
|
115
|
-
render() {
|
|
116
|
-
const datalistId = `${this.propName}-datalist`;
|
|
117
|
-
const varName = this.value?.startsWith('var(')
|
|
118
|
-
? this.value.slice(4, -1).trim()
|
|
119
|
-
: '';
|
|
120
|
-
|
|
121
|
-
return html`
|
|
122
|
-
<label>${this.propName}</label>
|
|
123
|
-
<div class="input-wrapper">
|
|
124
|
-
<select class="mode-select" .value=${this.mode} @change=${this.handleModeChange}>
|
|
125
|
-
<option value="var">Var</option>
|
|
126
|
-
<option value="color">Color</option>
|
|
127
|
-
</select>
|
|
128
|
-
|
|
129
|
-
${this.mode === 'var'
|
|
130
|
-
? html`
|
|
131
|
-
<input
|
|
132
|
-
class="value-input"
|
|
133
|
-
list=${datalistId}
|
|
134
|
-
.value=${varName}
|
|
135
|
-
@input=${this.handleVarInput}
|
|
136
|
-
placeholder="--property-name"
|
|
137
|
-
/>
|
|
138
|
-
<datalist id=${datalistId}>
|
|
139
|
-
${this.availableProperties.map(prop => html`<option value=${prop}></option>`)}
|
|
140
|
-
</datalist>
|
|
141
|
-
`
|
|
142
|
-
: html`
|
|
143
|
-
<k-color-picker
|
|
144
|
-
class="value-input"
|
|
145
|
-
value=${this.value}
|
|
146
|
-
></k-color-picker>
|
|
147
|
-
`
|
|
148
|
-
}
|
|
149
|
-
</div>
|
|
150
|
-
`;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
customElements.define('k-theme-property-input', ThemePropertyInput);
|