@electrovir/color 1.7.12 → 2.0.0-beta.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/dist/demo/all-book-pages.js +1 -10
- package/dist/demo/top-level-pages.d.ts +0 -1
- package/dist/demo/top-level-pages.js +0 -4
- package/dist/demo/vir-demo.element.js +2 -2
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -10
- package/package.json +16 -18
- package/dist/data/local-storage.client.d.ts +0 -4
- package/dist/data/local-storage.client.js +0 -6
- package/dist/elements/vir-all-color-space-sliders.element.d.ts +0 -11
- package/dist/elements/vir-all-color-space-sliders.element.js +0 -53
- package/dist/elements/vir-all-spaces-color-picker.element.d.ts +0 -15
- package/dist/elements/vir-all-spaces-color-picker.element.js +0 -69
- package/dist/elements/vir-color-details.element.d.ts +0 -14
- package/dist/elements/vir-color-details.element.js +0 -151
- package/dist/elements/vir-color-format-sliders.element.d.ts +0 -14
- package/dist/elements/vir-color-format-sliders.element.js +0 -58
- package/dist/elements/vir-color-pair-contrast-summary.element.d.ts +0 -9
- package/dist/elements/vir-color-pair-contrast-summary.element.js +0 -307
- package/dist/elements/vir-color-pair.element.d.ts +0 -17
- package/dist/elements/vir-color-pair.element.js +0 -201
- package/dist/elements/vir-color-picker.element.d.ts +0 -20
- package/dist/elements/vir-color-picker.element.js +0 -272
- package/dist/elements/vir-color-slider.element.d.ts +0 -14
- package/dist/elements/vir-color-slider.element.js +0 -120
- package/dist/elements/vir-color-swatch.element.d.ts +0 -20
- package/dist/elements/vir-color-swatch.element.js +0 -48
- package/dist/elements/vir-contrast-indicator.element.d.ts +0 -10
- package/dist/elements/vir-contrast-indicator.element.js +0 -96
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import { virAllSpacesColorPickerBookPage } from '../elements/vir-all-spaces-color-picker.element.book.js';
|
|
2
|
-
import { virColorPairContrastSummaryBookPage } from '../elements/vir-color-pair-contrast-summary.element.book.js';
|
|
3
|
-
import { virColorPairBookPage } from '../elements/vir-color-pair.element.book.js';
|
|
4
|
-
import { virColorPickerBookPage } from '../elements/vir-color-picker.element.book.js';
|
|
5
1
|
import { colorExamplesPage } from './color-examples.book.js';
|
|
6
|
-
import {
|
|
2
|
+
import { examplesBookPage } from './top-level-pages.js';
|
|
7
3
|
export const allBookPages = [
|
|
8
|
-
elementsBookPage,
|
|
9
4
|
examplesBookPage,
|
|
10
5
|
colorExamplesPage,
|
|
11
|
-
virAllSpacesColorPickerBookPage,
|
|
12
|
-
virColorPairBookPage,
|
|
13
|
-
virColorPairContrastSummaryBookPage,
|
|
14
|
-
virColorPickerBookPage,
|
|
15
6
|
];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* node:coverage disable */
|
|
2
2
|
import { ElementBookApp } from 'element-book';
|
|
3
3
|
import { css, defineElement, html } from 'element-vir';
|
|
4
|
-
import { noNativeSpacing } from 'vira/dist/styles/native-styles.js';
|
|
5
4
|
import { allBookPages } from './all-book-pages.js';
|
|
6
5
|
export const VirDemo = defineElement()({
|
|
7
6
|
tagName: 'vir-demo',
|
|
@@ -21,7 +20,8 @@ export const VirDemo = defineElement()({
|
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
h1 {
|
|
24
|
-
|
|
23
|
+
padding: 0;
|
|
24
|
+
margin: 0;
|
|
25
25
|
font-size: 16px;
|
|
26
26
|
margin-bottom: 16px;
|
|
27
27
|
text-align: center;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,13 +3,3 @@ export * from './data/color-class/color-name-length.js';
|
|
|
3
3
|
export * from './data/color-class/color.js';
|
|
4
4
|
export * from './data/color-css.js';
|
|
5
5
|
export * from './data/contrast/contrast.js';
|
|
6
|
-
export * from './elements/vir-all-color-space-sliders.element.js';
|
|
7
|
-
export * from './elements/vir-all-spaces-color-picker.element.js';
|
|
8
|
-
export * from './elements/vir-color-details.element.js';
|
|
9
|
-
export * from './elements/vir-color-format-sliders.element.js';
|
|
10
|
-
export * from './elements/vir-color-pair-contrast-summary.element.js';
|
|
11
|
-
export * from './elements/vir-color-pair.element.js';
|
|
12
|
-
export * from './elements/vir-color-picker.element.js';
|
|
13
|
-
export * from './elements/vir-color-slider.element.js';
|
|
14
|
-
export * from './elements/vir-color-swatch.element.js';
|
|
15
|
-
export * from './elements/vir-contrast-indicator.element.js';
|
package/dist/index.js
CHANGED
|
@@ -3,13 +3,3 @@ export * from './data/color-class/color-name-length.js';
|
|
|
3
3
|
export * from './data/color-class/color.js';
|
|
4
4
|
export * from './data/color-css.js';
|
|
5
5
|
export * from './data/contrast/contrast.js';
|
|
6
|
-
export * from './elements/vir-all-color-space-sliders.element.js';
|
|
7
|
-
export * from './elements/vir-all-spaces-color-picker.element.js';
|
|
8
|
-
export * from './elements/vir-color-details.element.js';
|
|
9
|
-
export * from './elements/vir-color-format-sliders.element.js';
|
|
10
|
-
export * from './elements/vir-color-pair-contrast-summary.element.js';
|
|
11
|
-
export * from './elements/vir-color-pair.element.js';
|
|
12
|
-
export * from './elements/vir-color-picker.element.js';
|
|
13
|
-
export * from './elements/vir-color-slider.element.js';
|
|
14
|
-
export * from './elements/vir-color-swatch.element.js';
|
|
15
|
-
export * from './elements/vir-contrast-indicator.element.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@electrovir/color",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
4
|
"description": "A wrapper for culori with an extremely simple API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"color",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"@electrovir/color": "file:./"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@augment-vir/assert": "^32.
|
|
57
|
-
"@augment-vir/common": "^32.
|
|
58
|
-
"@augment-vir/web": "^32.
|
|
56
|
+
"@augment-vir/assert": "^32.3.0-beta.0",
|
|
57
|
+
"@augment-vir/common": "^32.3.0-beta.0",
|
|
58
|
+
"@augment-vir/web": "^32.3.0-beta.0",
|
|
59
59
|
"@electrovir/local-storage-client": "^0.1.1",
|
|
60
60
|
"apca-w3": "^0.1.9",
|
|
61
61
|
"color-name": "^2.1.1",
|
|
@@ -63,33 +63,33 @@
|
|
|
63
63
|
"object-shape-tester": "^6.15.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@augment-vir/test": "^32.
|
|
67
|
-
"@eslint/eslintrc": "^3.3.
|
|
66
|
+
"@augment-vir/test": "^32.3.0-beta.0",
|
|
67
|
+
"@eslint/eslintrc": "^3.3.7",
|
|
68
68
|
"@eslint/js": "10.0.1",
|
|
69
69
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
70
70
|
"@stylistic/eslint-plugin-ts": "^4.4.1",
|
|
71
71
|
"@types/color-name": "^2.0.0",
|
|
72
72
|
"@types/culori": "^4.0.1",
|
|
73
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
73
|
+
"@typescript-eslint/eslint-plugin": "^8.69.0",
|
|
74
74
|
"@web/dev-server-esbuild": "^2.0.0",
|
|
75
75
|
"@web/test-runner": "^1.0.0",
|
|
76
76
|
"@web/test-runner-commands": "^1.0.1",
|
|
77
77
|
"@web/test-runner-playwright": "^1.0.0",
|
|
78
78
|
"@web/test-runner-visual-regression": "^1.0.1",
|
|
79
|
-
"cspell": "^10.
|
|
79
|
+
"cspell": "^10.2.0",
|
|
80
80
|
"dependency-cruiser": "^18.2.0",
|
|
81
|
-
"element-book": "^
|
|
82
|
-
"element-vir": "
|
|
81
|
+
"element-book": "^27.0.0-beta.1",
|
|
82
|
+
"element-vir": "27.0.0-beta.3",
|
|
83
83
|
"esbuild": "^0.28.2",
|
|
84
84
|
"eslint": "^10.9.1",
|
|
85
85
|
"eslint-config-prettier": "^10.1.8",
|
|
86
|
-
"eslint-plugin-jsdoc": "^64.
|
|
86
|
+
"eslint-plugin-jsdoc": "^64.3.4",
|
|
87
87
|
"eslint-plugin-monorepo-cop": "^1.0.2",
|
|
88
88
|
"eslint-plugin-playwright": "^2.11.0",
|
|
89
89
|
"eslint-plugin-prettier": "^5.5.6",
|
|
90
90
|
"eslint-plugin-require-extensions": "^0.1.3",
|
|
91
91
|
"eslint-plugin-sonarjs": "^4.2.0",
|
|
92
|
-
"eslint-plugin-unicorn": "^
|
|
92
|
+
"eslint-plugin-unicorn": "^74.0.0",
|
|
93
93
|
"execute-in-browser": "^1.0.10",
|
|
94
94
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
95
95
|
"lit-css-vars": "^3.6.3",
|
|
@@ -106,15 +106,13 @@
|
|
|
106
106
|
"runstorm": "^1.0.6",
|
|
107
107
|
"typedoc": "^0.28.20",
|
|
108
108
|
"typescript": "^6.0.3",
|
|
109
|
-
"typescript-eslint": "^8.
|
|
110
|
-
"
|
|
111
|
-
"virmator": "^14.33.0",
|
|
109
|
+
"typescript-eslint": "^8.69.0",
|
|
110
|
+
"virmator": "^14.34.0",
|
|
112
111
|
"vite": "^8.2.2"
|
|
113
112
|
},
|
|
114
113
|
"peerDependencies": {
|
|
115
|
-
"element-vir": "^
|
|
116
|
-
"lit-css-vars": ">=3"
|
|
117
|
-
"vira": ">=28"
|
|
114
|
+
"element-vir": "^27.0.0-beta.3",
|
|
115
|
+
"lit-css-vars": ">=3"
|
|
118
116
|
},
|
|
119
117
|
"engines": {
|
|
120
118
|
"node": ">=22"
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { LocalStorageClient } from '@electrovir/local-storage-client';
|
|
2
|
-
export declare const colorLocalStorageClient: LocalStorageClient<{
|
|
3
|
-
lastFormat: import("object-shape-tester").Shape<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TLiteral<"hsl"> | import("@sinclair/typebox").TLiteral<"hwb"> | import("@sinclair/typebox").TLiteral<"lab"> | import("@sinclair/typebox").TLiteral<"lch"> | import("@sinclair/typebox").TLiteral<"oklab"> | import("@sinclair/typebox").TLiteral<"oklch"> | import("@sinclair/typebox").TLiteral<"rgb"> | import("@sinclair/typebox").TLiteral<"hex">)[]>>;
|
|
4
|
-
}>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { LocalStorageClient } from '@electrovir/local-storage-client';
|
|
2
|
-
import { enumShape } from 'object-shape-tester';
|
|
3
|
-
import { ColorFormatName } from './color-class/color-formats.js';
|
|
4
|
-
export const colorLocalStorageClient = new LocalStorageClient({
|
|
5
|
-
lastFormat: enumShape(ColorFormatName),
|
|
6
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Color } from '../data/color-class/color.js';
|
|
2
|
-
/**
|
|
3
|
-
* Color sliders for all color spaces.
|
|
4
|
-
*
|
|
5
|
-
* @category Elements
|
|
6
|
-
*/
|
|
7
|
-
export declare const VirAllColorSpaceSliders: import("element-vir").DeclarativeElementDefinition<"vir-all-color-space-sliders", {
|
|
8
|
-
color: Readonly<Color>;
|
|
9
|
-
}, {}, {
|
|
10
|
-
colorChange: import("element-vir").DefineEvent<string>;
|
|
11
|
-
}, "vir-all-color-space-sliders-", "vir-all-color-space-sliders-", readonly [], readonly []>;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/* node:coverage disable */
|
|
2
|
-
import { getObjectTypedKeys, getObjectTypedValues } from '@augment-vir/common';
|
|
3
|
-
import { css, defineElement, defineElementEvent, html, listen } from 'element-vir';
|
|
4
|
-
import { colorFormatsBySpace } from '../data/color-class/color-formats.js';
|
|
5
|
-
import { VirColorFormatSliders } from './vir-color-format-sliders.element.js';
|
|
6
|
-
/**
|
|
7
|
-
* Color sliders for all color spaces.
|
|
8
|
-
*
|
|
9
|
-
* @category Elements
|
|
10
|
-
*/
|
|
11
|
-
export const VirAllColorSpaceSliders = defineElement()({
|
|
12
|
-
tagName: 'vir-all-color-space-sliders',
|
|
13
|
-
styles: css `
|
|
14
|
-
:host {
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: column;
|
|
17
|
-
gap: 16px;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.color-space {
|
|
21
|
-
display: flex;
|
|
22
|
-
flex-wrap: wrap;
|
|
23
|
-
column-gap: 32px;
|
|
24
|
-
row-gap: 8px;
|
|
25
|
-
}
|
|
26
|
-
`,
|
|
27
|
-
events: {
|
|
28
|
-
colorChange: defineElementEvent(),
|
|
29
|
-
},
|
|
30
|
-
render({ inputs, dispatch, events }) {
|
|
31
|
-
const colorSpaceTemplates = getObjectTypedValues(colorFormatsBySpace).map((colorSpaceFormats) => {
|
|
32
|
-
const formatTemplates = getObjectTypedKeys(colorSpaceFormats).map((colorFormatName) => {
|
|
33
|
-
return html `
|
|
34
|
-
<${VirColorFormatSliders.assign({
|
|
35
|
-
color: inputs.color,
|
|
36
|
-
colorFormatName,
|
|
37
|
-
showFormatName: true,
|
|
38
|
-
})}
|
|
39
|
-
${listen(VirColorFormatSliders.events.colorChange, (event) => {
|
|
40
|
-
dispatch(new events.colorChange(event.detail));
|
|
41
|
-
})}
|
|
42
|
-
></${VirColorFormatSliders}>
|
|
43
|
-
`;
|
|
44
|
-
});
|
|
45
|
-
return html `
|
|
46
|
-
<section class="color-space">${formatTemplates}</section>
|
|
47
|
-
`;
|
|
48
|
-
});
|
|
49
|
-
return html `
|
|
50
|
-
${colorSpaceTemplates}
|
|
51
|
-
`;
|
|
52
|
-
},
|
|
53
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type ColorSyntaxName } from '../data/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 []>;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/* node:coverage disable */
|
|
2
|
-
import { css, defineElement, defineElementEvent, html, listen } from 'element-vir';
|
|
3
|
-
import { getColorSyntaxFromCssString, } from '../data/color-class/color-formats.js';
|
|
4
|
-
import { Color } from '../data/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({
|
|
57
|
-
color,
|
|
58
|
-
})}
|
|
59
|
-
${listen(VirAllColorSpaceSliders.events.colorChange, (event) => {
|
|
60
|
-
const colorSyntax = getColorSyntaxFromCssString(state.inputColorString || '#');
|
|
61
|
-
updateState({
|
|
62
|
-
overrideInputColor: colorSyntax,
|
|
63
|
-
});
|
|
64
|
-
dispatch(new events.colorChange(event.detail));
|
|
65
|
-
})}
|
|
66
|
-
></${VirAllColorSpaceSliders}>
|
|
67
|
-
`;
|
|
68
|
-
},
|
|
69
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A color swatch alongside the color in all of its different supported formats.
|
|
3
|
-
*
|
|
4
|
-
* @category Internal
|
|
5
|
-
*/
|
|
6
|
-
export declare const VirColorDetails: import("element-vir").DeclarativeElementDefinition<"vir-color-details", {
|
|
7
|
-
color: string;
|
|
8
|
-
/** Show a text input that triggers an event when it is edited, for changing the color. */
|
|
9
|
-
showInput: boolean;
|
|
10
|
-
}, {
|
|
11
|
-
inputColorString: undefined | string;
|
|
12
|
-
}, {
|
|
13
|
-
colorChange: import("element-vir").DefineEvent<string>;
|
|
14
|
-
}, "vir-color-details-", "vir-color-details-", readonly [], readonly []>;
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
/* node:coverage disable */
|
|
2
|
-
import { check } from '@augment-vir/assert';
|
|
3
|
-
import { getObjectTypedEntries, mapObject } from '@augment-vir/common';
|
|
4
|
-
import { css, defineElement, defineElementEvent, html, listen } from 'element-vir';
|
|
5
|
-
import { ViraInput } from 'vira/dist/elements/vira-input.element.js';
|
|
6
|
-
import { viraFontCssVars } from 'vira/dist/styles/font.js';
|
|
7
|
-
import { noNativeSpacing } from 'vira/dist/styles/native-styles.js';
|
|
8
|
-
import { defineTable } from 'vira/dist/util/define-table.js';
|
|
9
|
-
import { ColorSyntaxName } from '../data/color-class/color-formats.js';
|
|
10
|
-
import { Color } from '../data/color-class/color.js';
|
|
11
|
-
import { VirColorSwatch } from './vir-color-swatch.element.js';
|
|
12
|
-
const omittedColors = [
|
|
13
|
-
ColorSyntaxName.hex,
|
|
14
|
-
ColorSyntaxName.name,
|
|
15
|
-
];
|
|
16
|
-
/**
|
|
17
|
-
* A color swatch alongside the color in all of its different supported formats.
|
|
18
|
-
*
|
|
19
|
-
* @category Internal
|
|
20
|
-
*/
|
|
21
|
-
export const VirColorDetails = defineElement()({
|
|
22
|
-
tagName: 'vir-color-details',
|
|
23
|
-
styles: css `
|
|
24
|
-
:host {
|
|
25
|
-
display: flex;
|
|
26
|
-
gap: 16px;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
${VirColorSwatch} {
|
|
30
|
-
height: 200px;
|
|
31
|
-
width: 200px;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.swatch {
|
|
35
|
-
display: flex;
|
|
36
|
-
flex-direction: column;
|
|
37
|
-
gap: 8px;
|
|
38
|
-
align-items: center;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
${ViraInput} {
|
|
42
|
-
font-size: 14px;
|
|
43
|
-
font-family: ${viraFontCssVars['vira-monospace'].value};
|
|
44
|
-
max-width: 200px;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
td {
|
|
48
|
-
font-weight: bold;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
th {
|
|
52
|
-
padding: 4px 8px;
|
|
53
|
-
font-weight: normal;
|
|
54
|
-
text-align: right;
|
|
55
|
-
}
|
|
56
|
-
pre {
|
|
57
|
-
${noNativeSpacing};
|
|
58
|
-
font-family: ${viraFontCssVars['vira-monospace'].value};
|
|
59
|
-
}
|
|
60
|
-
`,
|
|
61
|
-
events: {
|
|
62
|
-
colorChange: defineElementEvent(),
|
|
63
|
-
},
|
|
64
|
-
state() {
|
|
65
|
-
return {
|
|
66
|
-
inputColorString: undefined,
|
|
67
|
-
};
|
|
68
|
-
},
|
|
69
|
-
render({ inputs, dispatch, events, state, updateState }) {
|
|
70
|
-
const color = new Color(inputs.color);
|
|
71
|
-
const colorStrings = mapObject(color.toFormattedStrings(), (key, value) => {
|
|
72
|
-
if (check.hasValue(omittedColors, key)) {
|
|
73
|
-
return undefined;
|
|
74
|
-
}
|
|
75
|
-
else if (key === 'hexString') {
|
|
76
|
-
return {
|
|
77
|
-
key: 'hex',
|
|
78
|
-
value,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
return {
|
|
83
|
-
key,
|
|
84
|
-
value,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
if (state.inputColorString == undefined) {
|
|
89
|
-
updateState({
|
|
90
|
-
inputColorString: inputs.color,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
const { rows } = defineTable({
|
|
94
|
-
headers: [
|
|
95
|
-
{
|
|
96
|
-
key: 'colorFormat',
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
key: 'formattedString',
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
originalData: getObjectTypedEntries(colorStrings),
|
|
103
|
-
dataMap: ([colorFormat, value,]) => {
|
|
104
|
-
return {
|
|
105
|
-
colorFormat: `${colorFormat}:`,
|
|
106
|
-
formattedString: html `
|
|
107
|
-
<pre>${value}</pre>
|
|
108
|
-
`,
|
|
109
|
-
};
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
const inputTemplate = inputs.showInput
|
|
113
|
-
? html `
|
|
114
|
-
<${ViraInput.assign({
|
|
115
|
-
value: state.inputColorString || '',
|
|
116
|
-
fitText: true,
|
|
117
|
-
})}
|
|
118
|
-
${listen(ViraInput.events.valueChange, (event) => {
|
|
119
|
-
updateState({
|
|
120
|
-
inputColorString: event.detail,
|
|
121
|
-
});
|
|
122
|
-
dispatch(new events.colorChange(event.detail));
|
|
123
|
-
})}
|
|
124
|
-
></${ViraInput}>
|
|
125
|
-
`
|
|
126
|
-
: '';
|
|
127
|
-
return html `
|
|
128
|
-
<div class="swatch">
|
|
129
|
-
<${VirColorSwatch.assign({
|
|
130
|
-
backgroundColor: inputs.color,
|
|
131
|
-
})}></${VirColorSwatch}>
|
|
132
|
-
${inputTemplate}
|
|
133
|
-
</div>
|
|
134
|
-
<table>
|
|
135
|
-
<tbody>
|
|
136
|
-
${rows.map((row) => {
|
|
137
|
-
const cells = row.cells.map((cell, index) => {
|
|
138
|
-
const element = index ? 'td' : 'th';
|
|
139
|
-
return html `
|
|
140
|
-
<${element}>${cell.content}</${element}>
|
|
141
|
-
`;
|
|
142
|
-
});
|
|
143
|
-
return html `
|
|
144
|
-
<tr>${cells}</tr>
|
|
145
|
-
`;
|
|
146
|
-
})}
|
|
147
|
-
</tbody>
|
|
148
|
-
</table>
|
|
149
|
-
`;
|
|
150
|
-
},
|
|
151
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type ColorFormatName } from '../data/color-class/color-formats.js';
|
|
2
|
-
import { type Color } from '../data/color-class/color.js';
|
|
3
|
-
/**
|
|
4
|
-
* Color sliders for all coordinates within a specific color format.
|
|
5
|
-
*
|
|
6
|
-
* @category Elements
|
|
7
|
-
*/
|
|
8
|
-
export declare const VirColorFormatSliders: import("element-vir").DeclarativeElementDefinition<"vir-color-format-sliders", {
|
|
9
|
-
color: Readonly<Color>;
|
|
10
|
-
colorFormatName: ColorFormatName;
|
|
11
|
-
showFormatName: boolean;
|
|
12
|
-
}, {}, {
|
|
13
|
-
colorChange: import("element-vir").DefineEvent<string>;
|
|
14
|
-
}, "vir-color-format-sliders-", "vir-color-format-sliders-", readonly [], readonly []>;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/* node:coverage disable */
|
|
2
|
-
import { getObjectTypedKeys } from '@augment-vir/common';
|
|
3
|
-
import { css, defineElement, defineElementEvent, html, listen, nothing } from 'element-vir';
|
|
4
|
-
import { noNativeSpacing } from 'vira/dist/styles/native-styles.js';
|
|
5
|
-
import { colorFormats, } from '../data/color-class/color-formats.js';
|
|
6
|
-
import { VirColorSlider } from './vir-color-slider.element.js';
|
|
7
|
-
/**
|
|
8
|
-
* Color sliders for all coordinates within a specific color format.
|
|
9
|
-
*
|
|
10
|
-
* @category Elements
|
|
11
|
-
*/
|
|
12
|
-
export const VirColorFormatSliders = defineElement()({
|
|
13
|
-
tagName: 'vir-color-format-sliders',
|
|
14
|
-
styles: css `
|
|
15
|
-
:host {
|
|
16
|
-
display: flex;
|
|
17
|
-
flex-direction: column;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
h3 {
|
|
21
|
-
${noNativeSpacing};
|
|
22
|
-
}
|
|
23
|
-
`,
|
|
24
|
-
events: {
|
|
25
|
-
colorChange: defineElementEvent(),
|
|
26
|
-
},
|
|
27
|
-
render({ inputs, dispatch, events }) {
|
|
28
|
-
const colorFormat = colorFormats[inputs.colorFormatName];
|
|
29
|
-
const coordinateTemplates = getObjectTypedKeys(colorFormat.coords).map((colorCoordinate) => {
|
|
30
|
-
return html `
|
|
31
|
-
<${VirColorSlider.assign({
|
|
32
|
-
color: inputs.color,
|
|
33
|
-
colorCoordinateName: colorCoordinate,
|
|
34
|
-
colorFormatName: inputs.colorFormatName,
|
|
35
|
-
})}
|
|
36
|
-
${listen(VirColorSlider.events.valueChange, (event) => {
|
|
37
|
-
const newColor = inputs.color.clone();
|
|
38
|
-
newColor.set({
|
|
39
|
-
[inputs.colorFormatName]: {
|
|
40
|
-
[colorCoordinate]: event.detail,
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
const newValue = newColor.toCss()[colorFormat.conversionFormat];
|
|
44
|
-
dispatch(new events.colorChange(newValue));
|
|
45
|
-
})}
|
|
46
|
-
></${VirColorSlider}>
|
|
47
|
-
`;
|
|
48
|
-
});
|
|
49
|
-
return html `
|
|
50
|
-
${inputs.showFormatName
|
|
51
|
-
? html `
|
|
52
|
-
<h3>${inputs.colorFormatName}</h3>
|
|
53
|
-
`
|
|
54
|
-
: nothing}
|
|
55
|
-
${coordinateTemplates}
|
|
56
|
-
`;
|
|
57
|
-
},
|
|
58
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A huge summary of a color pair's contrast levels, font sizes, font weights, etc.
|
|
3
|
-
*
|
|
4
|
-
* @category Elements
|
|
5
|
-
*/
|
|
6
|
-
export declare const VirColorPairContrastSummary: import("element-vir").DeclarativeElementDefinition<"vir-color-pair-contrast-summary", {
|
|
7
|
-
foregroundColor: string;
|
|
8
|
-
backgroundColor: string;
|
|
9
|
-
}, {}, {}, "vir-color-pair-contrast-summary-", "vir-color-pair-contrast-summary-", readonly [], readonly []>;
|