@vanilla-bean/components 1.0.2 → 1.1.1
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/Component/Component.js +5 -5
- package/Component/Component.scenarios.js +2 -2
- package/Component/Component.test.js +2 -2
- package/Component/observeElementConnection.js +1 -1
- package/README.md +1 -1
- package/components/BottomSheet/README.md +1 -1
- package/components/Button/Button.lld.md +1 -1
- package/components/Code/Code.lld.md +1 -1
- package/components/ColorPicker/ColorPicker.js +1 -1
- package/components/Dialog/Dialog.js +1 -1
- package/components/Dialog/Dialog.lld.md +1 -1
- package/components/Dialog/README.md +10 -10
- package/components/Form/Form.js +9 -9
- package/components/Form/Form.lld.md +2 -2
- package/components/Form/README.md +3 -3
- package/components/Input/README.md +7 -7
- package/components/Keyboard/Keyboard.lld.md +1 -1
- package/components/Menu/Menu.js +3 -3
- package/components/Notify/Notify.lld.md +2 -2
- package/components/Page/Page.lld.md +1 -1
- package/components/RadioButton/RadioButton.lld.md +1 -1
- package/components/Router/README.md +12 -12
- package/components/Select/README.md +5 -5
- package/components/Select/Select.js +1 -1
- package/components/Table/README.md +4 -4
- package/components/Table/Table.lld.md +1 -1
- package/components/TagList/TagList.lld.md +1 -1
- package/components/TooltipWrapper/TooltipWrapper.lld.md +2 -2
- package/components/Whiteboard/Whiteboard.lld.md +1 -1
- package/index.d.ts +4 -3
- package/package.json +1 -1
- package/theme/.test.js +20 -4
- package/theme/README.md +15 -8
- package/theme/button.js +1 -1
- package/theme/colors.js +9 -2
- package/theme/input.js +3 -3
- package/theme/page.js +6 -0
- package/theme/scrollbar.js +7 -3
- package/theme/table.js +2 -2
- package/utils/browser.js +1 -1
- package/Component/README.md +0 -455
- package/Elem/README.md +0 -373
- package/styled/README.md +0 -329
package/theme/.test.js
CHANGED
|
@@ -2,11 +2,14 @@ import { TinyColor } from '@ctrl/tinycolor';
|
|
|
2
2
|
import theme from '.';
|
|
3
3
|
|
|
4
4
|
const ORIGINAL_BLUE = 'hsl(209, 55%, 45%)';
|
|
5
|
+
const ORIGINAL_YELLOW = 'hsl(44, 55%, 45%)';
|
|
5
6
|
const ORIGINAL_GRAY = 'hsl(0, 0%, 45%)';
|
|
6
7
|
|
|
7
8
|
afterEach(() => {
|
|
8
9
|
theme.colors.blue = new TinyColor(ORIGINAL_BLUE);
|
|
10
|
+
theme.colors.yellow = new TinyColor(ORIGINAL_YELLOW);
|
|
9
11
|
theme.colors.gray = new TinyColor(ORIGINAL_GRAY);
|
|
12
|
+
theme.colors.selected = undefined;
|
|
10
13
|
});
|
|
11
14
|
|
|
12
15
|
describe('theme colors', () => {
|
|
@@ -16,11 +19,24 @@ describe('theme colors', () => {
|
|
|
16
19
|
expect(theme.colors.blue.toString()).not.toBe(before);
|
|
17
20
|
});
|
|
18
21
|
|
|
19
|
-
test('white derives from gray
|
|
22
|
+
test('white derives from gray - updates when gray is reassigned', () => {
|
|
20
23
|
const before = theme.colors.white.toString();
|
|
21
24
|
theme.colors.gray = new TinyColor('hsl(200, 30%, 45%)');
|
|
22
25
|
expect(theme.colors.white.toString()).not.toBe(before);
|
|
23
26
|
});
|
|
27
|
+
|
|
28
|
+
test('selected follows yellow - updates when yellow is reassigned', () => {
|
|
29
|
+
const custom = new TinyColor('hsl(120, 55%, 45%)');
|
|
30
|
+
theme.colors.yellow = custom;
|
|
31
|
+
expect(theme.colors.selected.toString()).toBe(custom.toString());
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('selected can be assigned independently of yellow', () => {
|
|
35
|
+
const custom = new TinyColor('hsl(280, 55%, 45%)');
|
|
36
|
+
theme.colors.selected = custom;
|
|
37
|
+
expect(theme.colors.selected.toString()).toBe(custom.toString());
|
|
38
|
+
expect(theme.colors.yellow.toString()).toBe(new TinyColor(ORIGINAL_YELLOW).toString());
|
|
39
|
+
});
|
|
24
40
|
});
|
|
25
41
|
|
|
26
42
|
describe('theme lazy strings', () => {
|
|
@@ -32,19 +48,19 @@ describe('theme lazy strings', () => {
|
|
|
32
48
|
|
|
33
49
|
test('theme.table reflects a color mutation', () => {
|
|
34
50
|
const before = theme.table;
|
|
35
|
-
theme.colors.
|
|
51
|
+
theme.colors.yellow = new TinyColor('hsl(120, 55%, 45%)');
|
|
36
52
|
expect(theme.table).not.toBe(before);
|
|
37
53
|
});
|
|
38
54
|
|
|
39
55
|
test('theme.scrollbar reflects a color mutation', () => {
|
|
40
56
|
const custom = new TinyColor('hsl(120, 55%, 45%)');
|
|
41
|
-
theme.colors.
|
|
57
|
+
theme.colors.yellow = custom;
|
|
42
58
|
expect(theme.scrollbar).toContain(custom.toString());
|
|
43
59
|
});
|
|
44
60
|
|
|
45
61
|
test('theme.input reflects a color mutation', () => {
|
|
46
62
|
const custom = new TinyColor('hsl(120, 55%, 45%)');
|
|
47
|
-
theme.colors.
|
|
63
|
+
theme.colors.yellow = custom;
|
|
48
64
|
expect(theme.input).toContain(custom.toString());
|
|
49
65
|
});
|
|
50
66
|
|
package/theme/README.md
CHANGED
|
@@ -15,10 +15,10 @@ That said, the theme system is layered. You can work at any layer depending on h
|
|
|
15
15
|
For one-off overrides on a specific component instance, pass `styles` as an option:
|
|
16
16
|
|
|
17
17
|
```js
|
|
18
|
-
// Object form
|
|
18
|
+
// Object form - applied as inline styles
|
|
19
19
|
new Button({ styles: { backgroundColor: '#your-brand', borderRadius: '4px' } });
|
|
20
20
|
|
|
21
|
-
// Function form
|
|
21
|
+
// Function form - receives theme, generates scoped CSS
|
|
22
22
|
new Dialog({
|
|
23
23
|
styles: ({ colors }) => `
|
|
24
24
|
border-color: ${colors.purple};
|
|
@@ -69,10 +69,10 @@ The theme singleton is imported once and shared across all `styled()` calls. Mut
|
|
|
69
69
|
import { theme } from '@vanilla-bean/components';
|
|
70
70
|
import { TinyColor } from '@ctrl/tinycolor';
|
|
71
71
|
|
|
72
|
-
// Replace the accent color
|
|
72
|
+
// Replace the accent color - affects every component that uses colors.teal
|
|
73
73
|
theme.colors.teal = new TinyColor('#3d7aed');
|
|
74
74
|
|
|
75
|
-
// Then import and use components as normal
|
|
75
|
+
// Then import and use components as normal - they'll use your teal
|
|
76
76
|
import { Button, Dialog } from '@vanilla-bean/components';
|
|
77
77
|
```
|
|
78
78
|
|
|
@@ -279,10 +279,16 @@ Special utility colors and WCAG compliance helpers:
|
|
|
279
279
|
```js
|
|
280
280
|
// Utility colors
|
|
281
281
|
colors.transparent; // Transparent - for overlays, hidden elements
|
|
282
|
-
colors.white; //
|
|
283
|
-
colors.black; //
|
|
284
|
-
colors.superWhite; // #
|
|
285
|
-
colors.vantablack; // #
|
|
282
|
+
colors.white; // Near-white derived from gray (gray lightened 45%) - text on dark backgrounds
|
|
283
|
+
colors.black; // Near-black derived from gray (gray darkened 35%) - backgrounds, text on light surfaces
|
|
284
|
+
colors.superWhite; // #ffffff - pure white constant, independent of gray
|
|
285
|
+
colors.vantablack; // #000000 - pure black constant, independent of gray
|
|
286
|
+
|
|
287
|
+
// Semantic accent - the "focused/selected/active" color (focus outlines,
|
|
288
|
+
// ::selection, hover highlights, checked controls, scrollbar thumbs).
|
|
289
|
+
// Follows colors.yellow unless assigned its own color:
|
|
290
|
+
colors.selected;
|
|
291
|
+
theme.colors.selected = new TinyColor('#3d7aed'); // decouple from yellow
|
|
286
292
|
|
|
287
293
|
// Accessibility functions
|
|
288
294
|
colors.mostReadable(baseColor, [colors.white, colors.black]);
|
|
@@ -566,6 +572,7 @@ interface ColorSystem {
|
|
|
566
572
|
transparent: TinyColor;
|
|
567
573
|
white: TinyColor;
|
|
568
574
|
black: TinyColor;
|
|
575
|
+
selected: TinyColor;
|
|
569
576
|
superWhite: TinyColor;
|
|
570
577
|
vantablack: TinyColor;
|
|
571
578
|
|
package/theme/button.js
CHANGED
|
@@ -6,7 +6,7 @@ export default ({ colors, fonts }) => `
|
|
|
6
6
|
text-decoration: none;
|
|
7
7
|
color: ${colors.white};
|
|
8
8
|
background-color: ${colors.blue};
|
|
9
|
-
outline-color: ${colors.lighter(colors.
|
|
9
|
+
outline-color: ${colors.lighter(colors.selected)};
|
|
10
10
|
text-align: center;
|
|
11
11
|
position: relative;
|
|
12
12
|
white-space: nowrap;
|
package/theme/colors.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { TinyColor, random, readability, isReadable, mostReadable } from '@ctrl/tinycolor';
|
|
2
2
|
|
|
3
|
+
let selectedOverride;
|
|
4
|
+
|
|
3
5
|
const colors = {
|
|
4
6
|
random,
|
|
5
7
|
readability,
|
|
6
8
|
isReadable,
|
|
7
9
|
mostReadable,
|
|
8
10
|
|
|
9
|
-
// Base colors — plain writable properties so theme.colors.X = new TinyColor(...) works
|
|
10
11
|
orange: new TinyColor('hsl(29, 55%, 45%)'),
|
|
11
12
|
gray: new TinyColor('hsl(0, 0%, 45%)'),
|
|
12
13
|
yellow: new TinyColor('hsl(44, 55%, 45%)'),
|
|
@@ -20,7 +21,6 @@ const colors = {
|
|
|
20
21
|
superWhite: new TinyColor('hsl(0, 100%, 100%)'),
|
|
21
22
|
vantablack: new TinyColor('hsl(0, 0%, 0%)'),
|
|
22
23
|
|
|
23
|
-
// Derived — getters so they recompute when gray is reassigned
|
|
24
24
|
get white() {
|
|
25
25
|
return colors.whiteish();
|
|
26
26
|
},
|
|
@@ -28,6 +28,13 @@ const colors = {
|
|
|
28
28
|
return colors.blackish();
|
|
29
29
|
},
|
|
30
30
|
|
|
31
|
+
get selected() {
|
|
32
|
+
return selectedOverride ?? colors.yellow;
|
|
33
|
+
},
|
|
34
|
+
set selected(color) {
|
|
35
|
+
selectedOverride = color;
|
|
36
|
+
},
|
|
37
|
+
|
|
31
38
|
whiteish: (color = colors.gray) => color.lighten(45),
|
|
32
39
|
lightest: color => color.lighten(40),
|
|
33
40
|
lighter: color => color.lighten(27),
|
package/theme/input.js
CHANGED
|
@@ -31,7 +31,7 @@ export const checkbox = ({ colors }) => `
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
&:checked:before {
|
|
34
|
-
box-shadow: inset 1em 1em ${colors.
|
|
34
|
+
box-shadow: inset 1em 1em ${colors.selected};
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
&:focus {
|
|
@@ -47,9 +47,9 @@ export default ({ colors }) => `
|
|
|
47
47
|
box-sizing: border-box;
|
|
48
48
|
width: 100%;
|
|
49
49
|
color: ${colors.light(colors.red)};
|
|
50
|
-
accent-color: ${colors.
|
|
50
|
+
accent-color: ${colors.selected};
|
|
51
51
|
background-color: ${colors.black};
|
|
52
|
-
outline-color: ${colors.lighter(colors.
|
|
52
|
+
outline-color: ${colors.lighter(colors.selected)};
|
|
53
53
|
padding: 2px 4px;
|
|
54
54
|
|
|
55
55
|
&:disabled {
|
package/theme/page.js
CHANGED
|
@@ -9,6 +9,7 @@ import _table from './table';
|
|
|
9
9
|
export default theme => `
|
|
10
10
|
html {
|
|
11
11
|
height: 100%;
|
|
12
|
+
color-scheme: ${colors.black.isDark() ? 'dark' : 'light'};
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
body {
|
|
@@ -25,6 +26,11 @@ export default theme => `
|
|
|
25
26
|
margin: 0;
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
::selection {
|
|
30
|
+
background: ${colors.lighter(colors.selected)};
|
|
31
|
+
color: ${colors.black};
|
|
32
|
+
}
|
|
33
|
+
|
|
28
34
|
* {
|
|
29
35
|
touch-action: manipulation;
|
|
30
36
|
-webkit-text-size-adjust: none;
|
package/theme/scrollbar.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export default ({ colors }) => `
|
|
2
|
+
html {
|
|
3
|
+
scrollbar-color: ${colors.alpha(colors.selected, 0.6)} ${colors.white.setAlpha(0.06)};
|
|
4
|
+
}
|
|
5
|
+
|
|
2
6
|
::-webkit-scrollbar {
|
|
3
7
|
width: 24px;
|
|
4
8
|
height: 24px;
|
|
@@ -10,15 +14,15 @@ export default ({ colors }) => `
|
|
|
10
14
|
}
|
|
11
15
|
::-webkit-scrollbar-thumb {
|
|
12
16
|
background: ${colors.white.setAlpha(0.06)};
|
|
13
|
-
-webkit-box-shadow: inset 0 0 2px 1px ${colors.
|
|
17
|
+
-webkit-box-shadow: inset 0 0 2px 1px ${colors.selected};
|
|
14
18
|
border-radius: 12px;
|
|
15
19
|
}
|
|
16
20
|
::-webkit-scrollbar-thumb:hover {
|
|
17
21
|
background: ${colors.white.setAlpha(0.09)};
|
|
18
|
-
-webkit-box-shadow: inset 0 0 3px 1px ${colors.
|
|
22
|
+
-webkit-box-shadow: inset 0 0 3px 1px ${colors.selected};
|
|
19
23
|
}
|
|
20
24
|
::-webkit-scrollbar-thumb:active {
|
|
21
25
|
background: ${colors.white.setAlpha(0.12)};
|
|
22
|
-
-webkit-box-shadow: inset 0 0 4px 2px ${colors.
|
|
26
|
+
-webkit-box-shadow: inset 0 0 4px 2px ${colors.selected};
|
|
23
27
|
}
|
|
24
28
|
`;
|
package/theme/table.js
CHANGED
|
@@ -42,12 +42,12 @@ export default ({ colors }) => `
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
tr:hover {
|
|
45
|
-
background-color: ${colors.blackish(colors.
|
|
45
|
+
background-color: ${colors.blackish(colors.selected)};
|
|
46
46
|
color: ${colors.lighter(colors.gray)};
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
td:hover, th:hover {
|
|
50
|
-
background-color: ${colors.
|
|
50
|
+
background-color: ${colors.selected.darken(32)};
|
|
51
51
|
color: ${colors.white};
|
|
52
52
|
}
|
|
53
53
|
`;
|
package/utils/browser.js
CHANGED
|
@@ -13,7 +13,7 @@ export const isDev = (() => {
|
|
|
13
13
|
(import.meta.env?.DEV === true || import.meta.env?.NODE_ENV === 'development')
|
|
14
14
|
)
|
|
15
15
|
return true;
|
|
16
|
-
// Bare browser import with no bundler
|
|
16
|
+
// Bare browser import with no bundler - treat localhost as dev so warnings surface
|
|
17
17
|
if (typeof location !== 'undefined' && (location.hostname === 'localhost' || location.hostname === '127.0.0.1'))
|
|
18
18
|
return true;
|
|
19
19
|
return false;
|