@electrovir/color 1.7.10 → 1.7.12
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/data/color-class/color.d.ts +3 -3
- package/dist/data/color-class/color.js +9 -9
- package/dist/data/contrast/contrast.js +6 -4
- package/dist/demo/vir-demo.element.js +3 -1
- package/dist/elements/vir-color-details.element.js +22 -16
- package/dist/elements/vir-color-pair-contrast-summary.element.js +58 -46
- package/dist/elements/vir-color-pair.element.js +78 -74
- package/dist/elements/vir-color-picker.element.js +84 -80
- package/dist/elements/vir-color-slider.element.js +25 -23
- package/package.json +38 -39
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
-
import { type
|
|
1
|
+
import { type PartialWithUndefined, type RequireExactlyOne } from '@augment-vir/common';
|
|
2
|
+
import { type Color as CuloriColor } from 'culori';
|
|
3
3
|
import { ColorFormatName, ColorSyntaxName, type ColorCoordsByFormat, type ColorValue, type HexColor } from './color-formats.js';
|
|
4
4
|
/**
|
|
5
5
|
* An update to an existing {@link Color} instance. Used in {@link Color.set}.
|
|
@@ -43,7 +43,6 @@ export type SerializedColor = AllColorsValues & {
|
|
|
43
43
|
* @category Color
|
|
44
44
|
*/
|
|
45
45
|
export declare class Color {
|
|
46
|
-
#private;
|
|
47
46
|
constructor(
|
|
48
47
|
/** Any valid CSS color string or an object of color coordinate values. */
|
|
49
48
|
initValue: string | Readonly<ColorUpdate>);
|
|
@@ -67,6 +66,7 @@ export declare class Color {
|
|
|
67
66
|
toString(): string;
|
|
68
67
|
/** The color syntax the this color was set with. */
|
|
69
68
|
protected originalColorSyntax: ColorSyntaxName;
|
|
69
|
+
protected internalColor: CuloriColor;
|
|
70
70
|
/** All current color values. These are updated whenever {@link Color.set} is called. */
|
|
71
71
|
protected readonly _allColors: {
|
|
72
72
|
names: string[];
|
|
@@ -42,7 +42,7 @@ export class Color {
|
|
|
42
42
|
*/
|
|
43
43
|
static deserialize(input) {
|
|
44
44
|
const parsed = JSON.parse(input);
|
|
45
|
-
const newColor = new Color(
|
|
45
|
+
const newColor = new Color(parsed.hexString);
|
|
46
46
|
getObjectTypedEntries(parsed).forEach(([key, value,]) => {
|
|
47
47
|
if (key === 'originalColorSyntax') {
|
|
48
48
|
newColor.originalColorSyntax = assertWrap.isEnumValue(value, ColorSyntaxName, 'Cannot deserialize: invalid color syntax.');
|
|
@@ -55,7 +55,7 @@ export class Color {
|
|
|
55
55
|
}
|
|
56
56
|
/** Get the distance from this Color class instance to the given CSS color string. */
|
|
57
57
|
getRgbDistance(distanceFrom) {
|
|
58
|
-
return distanceRgb(this
|
|
58
|
+
return distanceRgb(this.internalColor, distanceFrom);
|
|
59
59
|
}
|
|
60
60
|
/** Get the closest named CSS color to this Color class instance's current color. */
|
|
61
61
|
getClosestNamedColor() {
|
|
@@ -84,7 +84,7 @@ export class Color {
|
|
|
84
84
|
}
|
|
85
85
|
/** The color syntax the this color was set with. */
|
|
86
86
|
originalColorSyntax = ColorSyntaxName.hex;
|
|
87
|
-
|
|
87
|
+
internalColor = assertWrap.isDefined(parse('black'));
|
|
88
88
|
/** All current color values. These are updated whenever {@link Color.set} is called. */
|
|
89
89
|
_allColors = {
|
|
90
90
|
names: ['black'],
|
|
@@ -146,7 +146,7 @@ export class Color {
|
|
|
146
146
|
throw new Error(`Unable to parse invalid color string: '${cssColorString}'`);
|
|
147
147
|
}
|
|
148
148
|
this.originalColorSyntax = getColorSyntaxFromCssString(cssColorString);
|
|
149
|
-
this
|
|
149
|
+
this.internalColor = newColor;
|
|
150
150
|
this.pullFromInternalColor();
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
@@ -186,15 +186,15 @@ export class Color {
|
|
|
186
186
|
getEnumValues(ColorFormatName).forEach((colorFormatName) => {
|
|
187
187
|
const colorFormatDefinition = colorFormats[colorFormatName];
|
|
188
188
|
const mappedColorFormatName = colorFormatDefinition.conversionFormat;
|
|
189
|
-
const originalColorDefinition = check.isKeyOf(this
|
|
190
|
-
? colorFormats[this
|
|
189
|
+
const originalColorDefinition = check.isKeyOf(this.internalColor.mode, colorFormats)
|
|
190
|
+
? colorFormats[this.internalColor.mode]
|
|
191
191
|
: undefined;
|
|
192
192
|
const converted = clampGamut(colorFormatDefinition.colorSpace === originalColorDefinition?.colorSpace
|
|
193
193
|
? mappedColorFormatName
|
|
194
|
-
: 'rgb')(converter(mappedColorFormatName)(this
|
|
194
|
+
: 'rgb')(converter(mappedColorFormatName)(this.internalColor));
|
|
195
195
|
/* node:coverage ignore next 5: technically this shouldn't happen, idk how to manually trigger it. */
|
|
196
196
|
if (!converted) {
|
|
197
|
-
assert.never(`Failed to convert color '${JSON.stringify(this
|
|
197
|
+
assert.never(`Failed to convert color '${JSON.stringify(this.internalColor)}' to '${colorFormatName}'.`);
|
|
198
198
|
}
|
|
199
199
|
getObjectTypedKeys(this[colorFormatName]).forEach((coordName) => {
|
|
200
200
|
const coordValue = converted[coordName];
|
|
@@ -206,7 +206,7 @@ export class Color {
|
|
|
206
206
|
}
|
|
207
207
|
});
|
|
208
208
|
});
|
|
209
|
-
this._allColors.hexString = formatHex(this
|
|
209
|
+
this._allColors.hexString = formatHex(this.internalColor);
|
|
210
210
|
this._allColors.names = findMatchingColorNames(this.rgb);
|
|
211
211
|
this._allColors[ColorSyntaxName.name] = this._allColors.names[0] || '';
|
|
212
212
|
}
|
|
@@ -30,10 +30,12 @@ export const FontWeightName = mapObjectValues(fontWeightByName, (key) => key);
|
|
|
30
30
|
*
|
|
31
31
|
* @category Internal
|
|
32
32
|
*/
|
|
33
|
-
export const fontWeightToName = Object.fromEntries(Object.entries(fontWeightByName).map(([key, value,]) =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
export const fontWeightToName = Object.fromEntries(Object.entries(fontWeightByName).map(([key, value,]) => {
|
|
34
|
+
return [
|
|
35
|
+
value,
|
|
36
|
+
key,
|
|
37
|
+
];
|
|
38
|
+
}));
|
|
37
39
|
/** Cache for contrast calculations to avoid redundant computation. */
|
|
38
40
|
const contrastCache = new Map();
|
|
39
41
|
/**
|
|
@@ -36,7 +36,9 @@ export const VirDemo = defineElement()({
|
|
|
36
36
|
basePath: 'color',
|
|
37
37
|
},
|
|
38
38
|
})}>
|
|
39
|
-
<h1 slot=${ElementBookApp.slotNames
|
|
39
|
+
<h1 slot=${ElementBookApp.slotNames['element-book-app-nav-header']}>
|
|
40
|
+
@electrovir/color
|
|
41
|
+
</h1>
|
|
40
42
|
</${ElementBookApp}>
|
|
41
43
|
`;
|
|
42
44
|
},
|
|
@@ -78,30 +78,36 @@ export const VirColorDetails = defineElement()({
|
|
|
78
78
|
value,
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
else {
|
|
82
|
+
return {
|
|
83
|
+
key,
|
|
84
|
+
value,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
85
87
|
});
|
|
86
88
|
if (state.inputColorString == undefined) {
|
|
87
89
|
updateState({
|
|
88
90
|
inputColorString: inputs.color,
|
|
89
91
|
});
|
|
90
92
|
}
|
|
91
|
-
const { rows } = defineTable(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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 `
|
|
102
107
|
<pre>${value}</pre>
|
|
103
108
|
`,
|
|
104
|
-
|
|
109
|
+
};
|
|
110
|
+
},
|
|
105
111
|
});
|
|
106
112
|
const inputTemplate = inputs.showInput
|
|
107
113
|
? html `
|
|
@@ -123,43 +123,50 @@ export const VirColorPairContrastSummary = defineElement()({
|
|
|
123
123
|
background: new Color(inputs.backgroundColor).toCss().rgb,
|
|
124
124
|
foreground: new Color(inputs.foregroundColor).toCss().rgb,
|
|
125
125
|
});
|
|
126
|
-
const { rows: colorPairRows } = defineTable(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
126
|
+
const { rows: colorPairRows } = defineTable({
|
|
127
|
+
headers: [
|
|
128
|
+
{
|
|
129
|
+
key: 'colorLayer',
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
key: 'colorValue',
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
originalData: getObjectTypedEntries({
|
|
136
|
+
'Foreground:': new Color(inputs.foregroundColor).toFormattedStrings().hexString,
|
|
137
|
+
'Background:': new Color(inputs.backgroundColor).toFormattedStrings().hexString,
|
|
138
|
+
'Contrast:': `${contrast.contrast} Lc`.padEnd(9, ' '),
|
|
139
|
+
}),
|
|
140
|
+
dataMap: ([colorLayer, value,]) => {
|
|
141
|
+
return {
|
|
142
|
+
colorLayer,
|
|
143
|
+
colorValue: html `
|
|
141
144
|
<pre>${value}</pre>
|
|
142
145
|
`,
|
|
143
|
-
|
|
144
|
-
});
|
|
145
|
-
const { rows: weightRows } = defineTable([
|
|
146
|
-
{
|
|
147
|
-
key: 'weight',
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
key: 'size',
|
|
146
|
+
};
|
|
151
147
|
},
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
148
|
+
});
|
|
149
|
+
const { rows: weightRows } = defineTable({
|
|
150
|
+
headers: [
|
|
151
|
+
{
|
|
152
|
+
key: 'weight',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
key: 'size',
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
originalData: Object.entries(contrast.fontSizes).map(([weight, size,]) => {
|
|
159
|
+
return {
|
|
160
|
+
weight: Number(weight),
|
|
161
|
+
size,
|
|
162
|
+
};
|
|
163
|
+
}),
|
|
164
|
+
dataMap: ({ size, weight }) => {
|
|
165
|
+
return {
|
|
166
|
+
size: `${round(size, {
|
|
167
|
+
digits: 1,
|
|
168
|
+
})}px`,
|
|
169
|
+
weight: html `
|
|
163
170
|
<span
|
|
164
171
|
style=${css `
|
|
165
172
|
font-weight: ${weight};
|
|
@@ -168,20 +175,25 @@ export const VirColorPairContrastSummary = defineElement()({
|
|
|
168
175
|
${weight}
|
|
169
176
|
</span>
|
|
170
177
|
`,
|
|
171
|
-
|
|
172
|
-
});
|
|
173
|
-
const { rows: levelRows } = defineTable([
|
|
174
|
-
{
|
|
175
|
-
key: 'boundaryLc',
|
|
178
|
+
};
|
|
176
179
|
},
|
|
177
|
-
|
|
178
|
-
|
|
180
|
+
});
|
|
181
|
+
const { rows: levelRows } = defineTable({
|
|
182
|
+
headers: [
|
|
183
|
+
{
|
|
184
|
+
key: 'boundaryLc',
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
key: 'levelName',
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
originalData: contrastLevels,
|
|
191
|
+
dataMap: (contrastLevel) => {
|
|
192
|
+
return {
|
|
193
|
+
boundaryLc: `${contrastLevel.min} Lc`,
|
|
194
|
+
levelName: contrastLevelLabel[contrastLevel.name],
|
|
195
|
+
};
|
|
179
196
|
},
|
|
180
|
-
], contrastLevels, (contrastLevel) => {
|
|
181
|
-
return {
|
|
182
|
-
boundaryLc: `${contrastLevel.min} Lc`,
|
|
183
|
-
levelName: contrastLevelLabel[contrastLevel.name],
|
|
184
|
-
};
|
|
185
197
|
});
|
|
186
198
|
return html `
|
|
187
199
|
<div class="color-overlay">
|
|
@@ -19,96 +19,100 @@ export const VirColorPair = defineElement()({
|
|
|
19
19
|
};
|
|
20
20
|
},
|
|
21
21
|
hostClasses: {
|
|
22
|
-
'vir-color-pair-no-contrast-tips': ({ inputs, state }) =>
|
|
22
|
+
'vir-color-pair-no-contrast-tips': ({ inputs, state }) => {
|
|
23
|
+
return !inputs.showContrast && !state.forceShowEverything;
|
|
24
|
+
},
|
|
23
25
|
},
|
|
24
|
-
styles: ({ hostClasses }) =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
styles: ({ hostClasses }) => {
|
|
27
|
+
return css `
|
|
28
|
+
:host {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
align-items: center;
|
|
32
|
+
max-width: 100%;
|
|
33
|
+
}
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
.color-preview {
|
|
36
|
+
${noNativeFormStyles};
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
font-size: 32px;
|
|
39
|
+
padding-left: 12px;
|
|
40
|
+
padding-right: 0;
|
|
41
|
+
border: 1px solid #ccc;
|
|
42
|
+
border-radius: 8px;
|
|
43
|
+
display: flex;
|
|
44
|
+
gap: 8px;
|
|
45
|
+
align-items: baseline;
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
& b {
|
|
48
|
+
margin: 12px 0;
|
|
49
|
+
font-weight: bold;
|
|
50
|
+
text-decoration: underline;
|
|
51
|
+
}
|
|
49
52
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
${hostClasses['vir-color-pair-no-contrast-tips'].selector} {
|
|
58
|
-
& .needed-size-wrapper {
|
|
59
|
-
display: none;
|
|
53
|
+
& .square {
|
|
54
|
+
margin: 12px 0;
|
|
55
|
+
width: 24px;
|
|
56
|
+
height: 24px;
|
|
57
|
+
background-color: currentColor;
|
|
58
|
+
}
|
|
60
59
|
}
|
|
60
|
+
${hostClasses['vir-color-pair-no-contrast-tips'].selector} {
|
|
61
|
+
& .needed-size-wrapper {
|
|
62
|
+
display: none;
|
|
63
|
+
}
|
|
61
64
|
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
& .color-preview {
|
|
66
|
+
padding: 4px 24px;
|
|
67
|
+
}
|
|
64
68
|
}
|
|
65
|
-
}
|
|
66
69
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
.needed-size-wrapper {
|
|
71
|
+
align-self: stretch;
|
|
72
|
+
width: 56px;
|
|
73
|
+
position: relative;
|
|
74
|
+
overflow: hidden;
|
|
75
|
+
border-left: 1px solid #ccc;
|
|
76
|
+
}
|
|
74
77
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
.needed-size {
|
|
79
|
+
top: 0;
|
|
80
|
+
height: 100%;
|
|
81
|
+
display: flex;
|
|
82
|
+
align-items: center;
|
|
83
|
+
left: 6px;
|
|
84
|
+
position: absolute;
|
|
82
85
|
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
& span {
|
|
87
|
+
margin: 0 auto;
|
|
88
|
+
}
|
|
85
89
|
}
|
|
86
|
-
}
|
|
87
90
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
.css-var-names {
|
|
92
|
+
font-family: ${viraFontCssVars['vira-monospace'].value};
|
|
93
|
+
display: flex;
|
|
94
|
+
max-width: 100%;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
opacity: 0.6;
|
|
97
|
+
margin-top: 4px;
|
|
98
|
+
}
|
|
96
99
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
p {
|
|
101
|
+
${noNativeSpacing};
|
|
102
|
+
display: flex;
|
|
103
|
+
gap: 0;
|
|
104
|
+
flex-wrap: wrap;
|
|
102
105
|
|
|
103
|
-
|
|
104
|
-
|
|
106
|
+
& span:last-child {
|
|
107
|
+
margin-left: 1ex;
|
|
108
|
+
}
|
|
105
109
|
}
|
|
106
|
-
}
|
|
107
110
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
${VirContrastIndicator} {
|
|
112
|
+
margin-top: 1px;
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
115
|
+
},
|
|
112
116
|
render({ state, updateState, inputs }) {
|
|
113
117
|
const colorRows = [
|
|
114
118
|
'foreground',
|
|
@@ -17,10 +17,12 @@ import { Color } from '../data/color-class/color.js';
|
|
|
17
17
|
import { colorLocalStorageClient } from '../data/local-storage.client.js';
|
|
18
18
|
import { VirColorFormatSliders } from './vir-color-format-sliders.element.js';
|
|
19
19
|
import { VirColorSwatch } from './vir-color-swatch.element.js';
|
|
20
|
-
const colorFormatOptions = getObjectTypedValues(ColorFormatName).map((formatName) =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const colorFormatOptions = getObjectTypedValues(ColorFormatName).map((formatName) => {
|
|
21
|
+
return {
|
|
22
|
+
value: formatName,
|
|
23
|
+
label: formatName.toUpperCase(),
|
|
24
|
+
};
|
|
25
|
+
});
|
|
24
26
|
/**
|
|
25
27
|
* A color picker element with a swatch that opens a popup with color format sliders.
|
|
26
28
|
*
|
|
@@ -49,98 +51,100 @@ export const VirColorPicker = defineElement()({
|
|
|
49
51
|
hostClasses: {
|
|
50
52
|
'vir-color-picker-always-show': ({ inputs }) => !!inputs.alwaysShowPicker,
|
|
51
53
|
},
|
|
52
|
-
styles: ({ cssVars, hostClasses }) =>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
${hostClasses['vir-color-picker-always-show'].selector} {
|
|
58
|
-
flex-direction: column;
|
|
59
|
-
align-items: center;
|
|
60
|
-
gap: 4px;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
button {
|
|
64
|
-
${noNativeFormStyles}
|
|
65
|
-
cursor: pointer;
|
|
66
|
-
display: flex;
|
|
67
|
-
}
|
|
54
|
+
styles: ({ cssVars, hostClasses }) => {
|
|
55
|
+
return css `
|
|
56
|
+
:host {
|
|
57
|
+
display: inline-flex;
|
|
58
|
+
}
|
|
68
59
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
60
|
+
${hostClasses['vir-color-picker-always-show'].selector} {
|
|
61
|
+
flex-direction: column;
|
|
62
|
+
align-items: center;
|
|
63
|
+
gap: 4px;
|
|
64
|
+
}
|
|
74
65
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
66
|
+
button {
|
|
67
|
+
${noNativeFormStyles}
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
display: flex;
|
|
70
|
+
}
|
|
80
71
|
|
|
81
|
-
|
|
82
|
-
width:
|
|
83
|
-
height:
|
|
72
|
+
${ViraPopUpTrigger} {
|
|
73
|
+
width: 100%;
|
|
74
|
+
height: 100%;
|
|
84
75
|
box-sizing: border-box;
|
|
85
76
|
}
|
|
86
|
-
}
|
|
87
77
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
justify-content: center;
|
|
94
|
-
gap: 2px;
|
|
95
|
-
align-items: center;
|
|
78
|
+
.swatch-wrapper {
|
|
79
|
+
display: flex;
|
|
80
|
+
flex-direction: column;
|
|
81
|
+
gap: 4px;
|
|
82
|
+
align-items: center;
|
|
96
83
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
84
|
+
& ${VirColorSwatch} {
|
|
85
|
+
width: ${cssVars['vir-color-picker-swatch-width'].value};
|
|
86
|
+
height: ${cssVars['vir-color-picker-swatch-height'].value};
|
|
87
|
+
box-sizing: border-box;
|
|
88
|
+
}
|
|
100
89
|
}
|
|
101
90
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
91
|
+
.code-button {
|
|
92
|
+
font-family: ${viraFontCssVars['vira-monospace'].value};
|
|
93
|
+
font-size: 12px;
|
|
94
|
+
color: #666;
|
|
95
|
+
display: flex;
|
|
96
|
+
justify-content: center;
|
|
97
|
+
gap: 2px;
|
|
98
|
+
align-items: center;
|
|
105
99
|
|
|
106
|
-
|
|
107
|
-
|
|
100
|
+
& ${ViraIcon} {
|
|
101
|
+
width: 18px;
|
|
102
|
+
aspect-ratio: 1;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&:hover {
|
|
106
|
+
color: #000;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
&:active {
|
|
110
|
+
color: dodgerblue;
|
|
111
|
+
}
|
|
108
112
|
}
|
|
109
|
-
}
|
|
110
113
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
.picker {
|
|
115
|
+
display: flex;
|
|
116
|
+
flex-direction: column;
|
|
117
|
+
gap: 4px;
|
|
118
|
+
padding: 16px;
|
|
119
|
+
background: white;
|
|
120
|
+
border: 1px solid #ccc;
|
|
121
|
+
border-radius: 8px;
|
|
122
|
+
}
|
|
120
123
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
.pop-up .picker {
|
|
125
|
+
${viraShadows.menuShadow}
|
|
126
|
+
}
|
|
124
127
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
128
|
+
.raw-input-wrapper {
|
|
129
|
+
text-align: left;
|
|
130
|
+
display: flex;
|
|
131
|
+
align-items: center;
|
|
132
|
+
justify-content: center;
|
|
133
|
+
gap: 8px;
|
|
134
|
+
font-size: 12px;
|
|
135
|
+
${viraFormCssVars['vira-form-border-color'].name}: #ddd;
|
|
136
|
+
color: #666;
|
|
134
137
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
& ${ViraInput} {
|
|
139
|
+
flex-grow: 1;
|
|
140
|
+
width: unset;
|
|
141
|
+
color: inherit;
|
|
142
|
+
height: 20px;
|
|
143
|
+
border: none;
|
|
144
|
+
}
|
|
141
145
|
}
|
|
142
|
-
|
|
143
|
-
|
|
146
|
+
`;
|
|
147
|
+
},
|
|
144
148
|
events: {
|
|
145
149
|
colorChange: defineElementEvent(),
|
|
146
150
|
},
|
|
@@ -17,32 +17,34 @@ export const VirColorSlider = defineElement()({
|
|
|
17
17
|
cssVars: {
|
|
18
18
|
'vir-color-slider-gradient': 'black',
|
|
19
19
|
},
|
|
20
|
-
styles: ({ cssVars }) =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
styles: ({ cssVars }) => {
|
|
21
|
+
return css `
|
|
22
|
+
:host {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
font-family: ${viraFontCssVars['vira-monospace'].value};
|
|
26
|
+
gap: 2px;
|
|
27
|
+
}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
input[type='range'] {
|
|
30
|
+
flex-grow: 1;
|
|
31
|
+
appearance: none;
|
|
32
|
+
background: ${cssVars['vir-color-slider-gradient'].value};
|
|
33
|
+
height: 9px;
|
|
34
|
+
border-radius: 4px;
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
}
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
${ViraInput} {
|
|
39
|
+
width: 76px;
|
|
40
|
+
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
.coordinate {
|
|
43
|
+
font-size: 18px;
|
|
44
|
+
margin-top: -4px;
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
},
|
|
46
48
|
events: {
|
|
47
49
|
valueChange: defineElementEvent(),
|
|
48
50
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@electrovir/color",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.12",
|
|
4
4
|
"description": "A wrapper for culori with an extremely simple API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"color",
|
|
@@ -53,67 +53,66 @@
|
|
|
53
53
|
"@electrovir/color": "file:./"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@augment-vir/assert": "^
|
|
57
|
-
"@augment-vir/common": "^
|
|
58
|
-
"@augment-vir/web": "^
|
|
59
|
-
"@electrovir/local-storage-client": "^0.1.
|
|
56
|
+
"@augment-vir/assert": "^32.2.3",
|
|
57
|
+
"@augment-vir/common": "^32.2.3",
|
|
58
|
+
"@augment-vir/web": "^32.2.3",
|
|
59
|
+
"@electrovir/local-storage-client": "^0.1.1",
|
|
60
60
|
"apca-w3": "^0.1.9",
|
|
61
|
-
"color-name": "^2.1.
|
|
61
|
+
"color-name": "^2.1.1",
|
|
62
62
|
"culori": "^4.0.2",
|
|
63
|
-
"object-shape-tester": "^6.
|
|
64
|
-
"type-fest": "^5.6.0"
|
|
63
|
+
"object-shape-tester": "^6.15.0"
|
|
65
64
|
},
|
|
66
65
|
"devDependencies": {
|
|
67
|
-
"@augment-vir/test": "^
|
|
68
|
-
"@eslint/eslintrc": "^3.3.
|
|
66
|
+
"@augment-vir/test": "^32.2.3",
|
|
67
|
+
"@eslint/eslintrc": "^3.3.6",
|
|
69
68
|
"@eslint/js": "10.0.1",
|
|
70
69
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
71
70
|
"@stylistic/eslint-plugin-ts": "^4.4.1",
|
|
72
71
|
"@types/color-name": "^2.0.0",
|
|
73
72
|
"@types/culori": "^4.0.1",
|
|
74
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
75
|
-
"@web/dev-server-esbuild": "^
|
|
76
|
-
"@web/test-runner": "^0.
|
|
77
|
-
"@web/test-runner-commands": "^0.
|
|
78
|
-
"@web/test-runner-playwright": "^0.
|
|
79
|
-
"@web/test-runner-visual-regression": "^0.
|
|
80
|
-
"cspell": "^10.
|
|
81
|
-
"dependency-cruiser": "^
|
|
82
|
-
"element-book": "^26.17.
|
|
83
|
-
"element-vir": "^26.17.
|
|
84
|
-
"esbuild": "^0.28.
|
|
85
|
-
"eslint": "^10.
|
|
73
|
+
"@typescript-eslint/eslint-plugin": "^8.68.0",
|
|
74
|
+
"@web/dev-server-esbuild": "^2.0.0",
|
|
75
|
+
"@web/test-runner": "^1.0.0",
|
|
76
|
+
"@web/test-runner-commands": "^1.0.1",
|
|
77
|
+
"@web/test-runner-playwright": "^1.0.0",
|
|
78
|
+
"@web/test-runner-visual-regression": "^1.0.1",
|
|
79
|
+
"cspell": "^10.1.1",
|
|
80
|
+
"dependency-cruiser": "^18.2.0",
|
|
81
|
+
"element-book": "^26.17.5",
|
|
82
|
+
"element-vir": "^26.17.3",
|
|
83
|
+
"esbuild": "^0.28.2",
|
|
84
|
+
"eslint": "^10.9.1",
|
|
86
85
|
"eslint-config-prettier": "^10.1.8",
|
|
87
|
-
"eslint-plugin-jsdoc": "^
|
|
86
|
+
"eslint-plugin-jsdoc": "^64.2.1",
|
|
88
87
|
"eslint-plugin-monorepo-cop": "^1.0.2",
|
|
89
|
-
"eslint-plugin-playwright": "^2.
|
|
88
|
+
"eslint-plugin-playwright": "^2.11.0",
|
|
90
89
|
"eslint-plugin-prettier": "^5.5.6",
|
|
91
90
|
"eslint-plugin-require-extensions": "^0.1.3",
|
|
92
|
-
"eslint-plugin-sonarjs": "^4.0
|
|
93
|
-
"eslint-plugin-unicorn": "^
|
|
94
|
-
"execute-in-browser": "^1.0.
|
|
91
|
+
"eslint-plugin-sonarjs": "^4.2.0",
|
|
92
|
+
"eslint-plugin-unicorn": "^73.0.0",
|
|
93
|
+
"execute-in-browser": "^1.0.10",
|
|
95
94
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
96
|
-
"lit-css-vars": "^3.6.
|
|
97
|
-
"markdown-code-example-inserter": "^3.0.
|
|
98
|
-
"npm-check-updates": "^
|
|
95
|
+
"lit-css-vars": "^3.6.3",
|
|
96
|
+
"markdown-code-example-inserter": "^3.0.6",
|
|
97
|
+
"npm-check-updates": "^23.1.0",
|
|
99
98
|
"prettier": "~3.3.3",
|
|
100
|
-
"prettier-plugin-interpolated-html-tags": "^2.0.
|
|
99
|
+
"prettier-plugin-interpolated-html-tags": "^2.0.2",
|
|
101
100
|
"prettier-plugin-jsdoc": "^1.8.1",
|
|
102
|
-
"prettier-plugin-multiline-arrays": "^4.1.
|
|
101
|
+
"prettier-plugin-multiline-arrays": "^4.1.11",
|
|
103
102
|
"prettier-plugin-organize-imports": "^4.3.0",
|
|
104
103
|
"prettier-plugin-packagejson": "^3.0.2",
|
|
105
104
|
"prettier-plugin-sort-json": "^4.2.0",
|
|
106
105
|
"prettier-plugin-toml": "^2.0.6",
|
|
107
|
-
"runstorm": "^1.0.
|
|
108
|
-
"typedoc": "^0.28.
|
|
106
|
+
"runstorm": "^1.0.6",
|
|
107
|
+
"typedoc": "^0.28.20",
|
|
109
108
|
"typescript": "^6.0.3",
|
|
110
|
-
"typescript-eslint": "^8.
|
|
111
|
-
"vira": "^31.
|
|
112
|
-
"virmator": "^14.
|
|
113
|
-
"vite": "^8.
|
|
109
|
+
"typescript-eslint": "^8.68.0",
|
|
110
|
+
"vira": "^31.31.6",
|
|
111
|
+
"virmator": "^14.33.0",
|
|
112
|
+
"vite": "^8.2.2"
|
|
114
113
|
},
|
|
115
114
|
"peerDependencies": {
|
|
116
|
-
"element-vir": "
|
|
115
|
+
"element-vir": "^26",
|
|
117
116
|
"lit-css-vars": ">=3",
|
|
118
117
|
"vira": ">=28"
|
|
119
118
|
},
|