@electrovir/color 1.3.0 → 1.4.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.
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ColorSyntaxName } from '../color-class/color-formats.js';
|
|
2
|
+
/**
|
|
3
|
+
* A color picker element that shows sliders for all supported color spaces at once, as well as all
|
|
4
|
+
* the values for all supported color spaces in a table.
|
|
5
|
+
*
|
|
6
|
+
* @category Elements
|
|
7
|
+
*/
|
|
8
|
+
export declare const VirAllSpacesColorPicker: import("element-vir").DeclarativeElementDefinition<"vir-all-spaces-color-picker", {
|
|
9
|
+
color: string;
|
|
10
|
+
}, {
|
|
11
|
+
inputColorString: undefined | string;
|
|
12
|
+
overrideInputColor: undefined | ColorSyntaxName;
|
|
13
|
+
}, {
|
|
14
|
+
colorChange: import("element-vir").DefineEvent<string>;
|
|
15
|
+
}, "vir-all-spaces-color-picker-", "vir-all-spaces-color-picker-", readonly [], readonly []>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/* node:coverage disable */
|
|
2
|
+
import { css, defineElement, defineElementEvent, html, listen } from 'element-vir';
|
|
3
|
+
import { getColorSyntaxFromCssString } from '../color-class/color-formats.js';
|
|
4
|
+
import { Color } from '../color-class/color.js';
|
|
5
|
+
import { VirAllColorSpaceSliders } from './vir-all-color-space-sliders.element.js';
|
|
6
|
+
import { VirColorDetails } from './vir-color-details.element.js';
|
|
7
|
+
/**
|
|
8
|
+
* A color picker element that shows sliders for all supported color spaces at once, as well as all
|
|
9
|
+
* the values for all supported color spaces in a table.
|
|
10
|
+
*
|
|
11
|
+
* @category Elements
|
|
12
|
+
*/
|
|
13
|
+
export const VirAllSpacesColorPicker = defineElement()({
|
|
14
|
+
tagName: 'vir-all-spaces-color-picker',
|
|
15
|
+
styles: css `
|
|
16
|
+
:host {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
gap: 16px;
|
|
20
|
+
}
|
|
21
|
+
`,
|
|
22
|
+
events: {
|
|
23
|
+
colorChange: defineElementEvent(),
|
|
24
|
+
},
|
|
25
|
+
state() {
|
|
26
|
+
return {
|
|
27
|
+
inputColorString: undefined,
|
|
28
|
+
overrideInputColor: undefined,
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
render({ inputs, dispatch, events, state, updateState }) {
|
|
32
|
+
const color = new Color(inputs.color);
|
|
33
|
+
if (state.overrideInputColor) {
|
|
34
|
+
updateState({
|
|
35
|
+
inputColorString: color.toCss()[state.overrideInputColor],
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (state.inputColorString == undefined) {
|
|
39
|
+
updateState({
|
|
40
|
+
inputColorString: inputs.color,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return html `
|
|
44
|
+
<${VirColorDetails.assign({
|
|
45
|
+
color: inputs.color,
|
|
46
|
+
showInput: true,
|
|
47
|
+
})}
|
|
48
|
+
${listen(VirColorDetails.events.colorChange, (event) => {
|
|
49
|
+
updateState({
|
|
50
|
+
inputColorString: event.detail,
|
|
51
|
+
overrideInputColor: undefined,
|
|
52
|
+
});
|
|
53
|
+
dispatch(new events.colorChange(event.detail));
|
|
54
|
+
})}
|
|
55
|
+
></${VirColorDetails}>
|
|
56
|
+
<${VirAllColorSpaceSliders.assign({ color })}
|
|
57
|
+
${listen(VirAllColorSpaceSliders.events.colorChange, (event) => {
|
|
58
|
+
const colorSyntax = getColorSyntaxFromCssString(state.inputColorString || '#');
|
|
59
|
+
updateState({
|
|
60
|
+
overrideInputColor: colorSyntax,
|
|
61
|
+
});
|
|
62
|
+
dispatch(new events.colorChange(event.detail));
|
|
63
|
+
})}
|
|
64
|
+
></${VirAllColorSpaceSliders}>
|
|
65
|
+
`;
|
|
66
|
+
},
|
|
67
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,11 @@ export * from './color-class/color-name-length.js';
|
|
|
3
3
|
export * from './color-class/color.js';
|
|
4
4
|
export * from './contrast/contrast.js';
|
|
5
5
|
export * from './elements/vir-all-color-space-sliders.element.js';
|
|
6
|
+
export * from './elements/vir-all-spaces-color-picker.element.js';
|
|
7
|
+
export * from './elements/vir-color-details.element.js';
|
|
6
8
|
export * from './elements/vir-color-format-sliders.element.js';
|
|
9
|
+
export * from './elements/vir-color-pair-contrast-summary.element.js';
|
|
7
10
|
export * from './elements/vir-color-pair.element.js';
|
|
8
11
|
export * from './elements/vir-color-slider.element.js';
|
|
12
|
+
export * from './elements/vir-color-swatch.element.js';
|
|
9
13
|
export * from './elements/vir-contrast-indicator.element.js';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,11 @@ export * from './color-class/color-name-length.js';
|
|
|
3
3
|
export * from './color-class/color.js';
|
|
4
4
|
export * from './contrast/contrast.js';
|
|
5
5
|
export * from './elements/vir-all-color-space-sliders.element.js';
|
|
6
|
+
export * from './elements/vir-all-spaces-color-picker.element.js';
|
|
7
|
+
export * from './elements/vir-color-details.element.js';
|
|
6
8
|
export * from './elements/vir-color-format-sliders.element.js';
|
|
9
|
+
export * from './elements/vir-color-pair-contrast-summary.element.js';
|
|
7
10
|
export * from './elements/vir-color-pair.element.js';
|
|
8
11
|
export * from './elements/vir-color-slider.element.js';
|
|
12
|
+
export * from './elements/vir-color-swatch.element.js';
|
|
9
13
|
export * from './elements/vir-contrast-indicator.element.js';
|