vira 31.13.1 → 31.13.2

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.
@@ -58,7 +58,8 @@ export type ViraThemeByKeys = {
58
58
  };
59
59
  };
60
60
  /**
61
- * All {@link viraTheme} color pair grouped by their color name, pair name, and contrast level.
61
+ * All {@link viraTheme} color pair grouped by their color name, pair name, and contrast level. See
62
+ * {@link viraTheme} for extensive documentation on what the colors pairs mean.
62
63
  *
63
64
  * @category Internal
64
65
  */
@@ -28,7 +28,8 @@ export const ViraThemeColorName = arrayToObject(viraThemeColorNames, (colorKey)
28
28
  */
29
29
  export const allViraThemeKeys = getObjectTypedKeys(viraTheme.colors);
30
30
  /**
31
- * All {@link viraTheme} color pair grouped by their color name, pair name, and contrast level.
31
+ * All {@link viraTheme} color pair grouped by their color name, pair name, and contrast level. See
32
+ * {@link viraTheme} for extensive documentation on what the colors pairs mean.
32
33
  *
33
34
  * @category Internal
34
35
  */
@@ -1,5 +1,182 @@
1
1
  /**
2
- * A color theme from Vira.
2
+ * A color theme designed for straightforward accessible foreground and background color choices.
3
+ * All color pairs can be seen here: https://electrovir.github.io/vira/book/styles/vira-theme.
4
+ *
5
+ * ## Color Pairs
6
+ *
7
+ * Each color choice is stored in a color pair. Each color pair includes a foreground and a
8
+ * background color. Foreground and background color pairs are set to specific lightness levels to
9
+ * ensure a specific level of contrast, which you can choose from (as explained below). Most color
10
+ * pairs include a color interacting with the page default color pair. These page defaults depend on
11
+ * which theme you select: light mode or dark mode. The defaults are the following:
12
+ *
13
+ * - Light mode:
14
+ *
15
+ * - Foreground: black
16
+ * - Background: white
17
+ * - Dark mode:
18
+ *
19
+ * - Foreground: white
20
+ * - Background: black
21
+ *
22
+ * ## Choosing a Color
23
+ *
24
+ * Each color in the theme is a key following the pattern
25
+ * `vira-{colorName}-{pairType}-{contrastLevel}`. (Note that there is also `viraThemeByKeys`, which
26
+ * stores colors in nested objects, accessed with the pattern
27
+ * `viraThemeByKeys[colorName][pairType][contrastLevel]`.) The following steps explain how to select
28
+ * a color pair:
29
+ *
30
+ * 1. **Choose a color name.** Red, blue, etc. This is the color that you're trying to use.
31
+ *
32
+ * - Examples:
33
+ *
34
+ * - `viraTheme.colors['vira-red-foreground-body']`
35
+ * - `viraTheme.colors['vira-blue-foreground-body']`
36
+ * 2. **Choose a color pair type.** This determines where the color name you chose is placed in the
37
+ * color pair.
38
+ *
39
+ * - `foreground`: "Color in the foreground". In this color pair, the chosen color is the foreground
40
+ * and the page default background (white in light mode, black in dark mode) is the
41
+ * background. The lightness level of the foreground, the chosen color, varies based on the
42
+ * selected contrast level (in the next step).
43
+ *
44
+ * - Foreground: the chosen color (red, blue, etc.)
45
+ * - Background: the page default background (white in light mode, black in dark mode).
46
+ * - Example: `viraTheme.colors['vira-red-foreground-body']`
47
+ * - Example: `viraTheme.colors['vira-blue-foreground-body']`
48
+ * - `behind-fg`: "Color behind foreground". In this color pair, the chosen color is the background
49
+ * and the page default foreground (black in light mode, white in dark mode) is the
50
+ * background. The lightness level of the background, the chosen color, varies based on the
51
+ * selected contrast level (in the next step).
52
+ *
53
+ * - Foreground: the page default background (black in light mode, white in dark mode).
54
+ * - Background: the chosen color (red, blue, etc.)
55
+ * - Example: `viraTheme.colors['vira-red-behind-fg-body']`
56
+ * - Example: `viraTheme.colors['vira-blue-behind-fg-body']`
57
+ * - `behind-bg`: "Color behind background". In this color pair, the chosen color is the background
58
+ * and the page default background (white in light mode, black in dark mode) is the
59
+ * foreground. The lightness level of the background, the chosen color, varies based on the
60
+ * selected contrast level (in the next step).
61
+ *
62
+ * - Foreground: the page default background (white in light mode, black in dark mode)
63
+ * - Background: the chosen color (red, blue, etc.)
64
+ * - Example: `viraTheme.colors['vira-red-behind-bg-body']`
65
+ * - Example: `viraTheme.colors['vira-blue-behind-bg-body']`
66
+ * - `on-self`: "Color on self". In this color pair, both the foreground and the background are a
67
+ * shade of the chosen color. The lightness level of the background chosen color varies
68
+ * based on the selected contrast level (in the next step). The lightness of the foreground
69
+ * chosen color is fixed based on the current theme: a dark foreground in light mode, a
70
+ * light foreground in dark mode (to remain similar to the page default foreground color).
71
+ *
72
+ * - Foreground: the chosen color (red, blue, etc.)
73
+ * - Background: the chosen color (red, blue, etc.)
74
+ * - Example: `viraTheme.colors['vira-red-on-self-body']`
75
+ * - Example: `viraTheme.colors['vira-blue-on-self-body']`
76
+ * 3. **Choose a contrast level.** Choose a level of contrast based on what you are applying color to.
77
+ * In general, the `header` level of contrast gives a color shade that is not considered "light"
78
+ * or "dark". Any contrast level intended for smaller text elements (non-body, body, small-body)
79
+ * is a darker variant of that color. Any contrast level allowed on larger text elements
80
+ * (placeholder, decoration, invisible) is a lighter variant of that color. Also see
81
+ * https://electrovir.github.io/color/docs/variables/contrastLevels.html for more details on each
82
+ * contrast level.
83
+ *
84
+ * - `small-body`: Choose this for text or page elements that should be legible but are small in size
85
+ * (< 14px font size, similarly sized icons, etc.).
86
+ *
87
+ * - The color pair is chosen to ensure about Lc 90 contrast between the foreground and the
88
+ * background.
89
+ * - Example: `viraTheme.colors['vira-red-foreground-small-body']`: In light mode, this has a very
90
+ * dark red foreground.
91
+ * - Example: `viraTheme.colors['vira-blue-on-self-small-body']`: In light mode, a very light blue is
92
+ * used as the background color. (The foreground is a very dark blue.)
93
+ * - `body`: Chose this for text or page elements that should be legible and are a normal body text
94
+ * size (>= 14px font size).
95
+ *
96
+ * - The color pair is chosen to ensure about Lc 75 contrast between the foreground and the
97
+ * background.
98
+ * - Example: `viraTheme.colors['vira-red-foreground-body']`: In light mode, this has a dark red
99
+ * foreground (not as dark as the `small-body` variant).
100
+ * - Example: `viraTheme.colors['vira-blue-on-self-body']`: In light mode, a light blue background is
101
+ * used (but darker than the small-body contrast level). (The foreground is a very
102
+ * dark blue.)
103
+ * - `non-body`: Chose this for text or page elements that should be legible but are larger in size
104
+ * (>= 24px font size with normal font weight).
105
+ *
106
+ * - The color pair is chosen to ensure about Lc 60 contrast between the foreground and the
107
+ * background.
108
+ * - Example: `viraTheme.colors['vira-red-foreground-non-body']`: In light mode, this has slightly
109
+ * dark red foreground.
110
+ * - Example: `viraTheme.colors['vira-blue-on-self-non-body']`: In light mode, a light blue background
111
+ * is used (but darker than the small-body contrast level). (The foreground is a
112
+ * very dark blue.)
113
+ * - `header`: Chose this for text or page elements that are heading or heading sized elements (>=24px
114
+ * bolded text or >=36px normal weight text).
115
+ *
116
+ * - The color pair is chosen to ensure about Lc 45 contrast between the foreground and the
117
+ * background.
118
+ * - Example: `viraTheme.colors['vira-red-foreground-header']`: In light mode, this has a very vibrant
119
+ * red foreground.
120
+ * - Example: `viraTheme.colors['vira-blue-on-self-header']`: In light mode, a plain blue (not very
121
+ * dark or light) background is used.
122
+ * - `placeholder`: Chose this for text or page elements that are placeholders or disabled.
123
+ *
124
+ * - The color pair is chosen to ensure about Lc 30 contrast between the foreground and the
125
+ * background.
126
+ * - Example: `viraTheme.colors['vira-red-foreground-placeholder']`: In light mode, this has a light
127
+ * red foreground.
128
+ * - Example: `viraTheme.colors['vira-blue-on-self-placeholder']`: In light mode, a dark blue
129
+ * background is used. (The foreground is a very dark blue.)
130
+ * - `decoration`: Chose this for decorative page elements such as borders that, if not visible to the
131
+ * user (many users may not be able to distinguish this color pair's foreground from the
132
+ * background), do not reduce the usability of the page.
133
+ *
134
+ * - The color pair is chosen to ensure about Lc 15 contrast between the foreground and the
135
+ * background.
136
+ * - Example: `viraTheme.colors['vira-red-foreground-decoration']`: In light mode, this has a very
137
+ * light red foreground.
138
+ * - Example: `viraTheme.colors['vira-blue-on-self-decoration']`: In light mode, a darker blue
139
+ * background is used. (The foreground is a very dark blue.)
140
+ * - `invisible`: Choose this for decorative elements that are even harder-to-see (dimmer) than
141
+ * `decoration` elements. The foreground and background colors in a color pair in this
142
+ * contrast level should be treated as indistinguishable from each other to most of the
143
+ * human population.
144
+ *
145
+ * - The color pair is chosen to ensure Lc 0 contrast between the foreground and the background.
146
+ * - Example: `viraTheme.colors['vira-red-foreground-invisible']`: In light mode, this has an
147
+ * extremely light red foreground, essentially a pale pink.
148
+ * - Example: `viraTheme.colors['vira-blue-on-self-invisible']`: In light mode, an extremely dark blue
149
+ * background is used. (The foreground is a very dark blue.)
150
+ *
151
+ * There are also auxiliary contrast levels available which do not correspond to any specific
152
+ * element usage on a page:
153
+ *
154
+ * - `highest-contrast`: Maximum possible contrast between the foreground and background (from the
155
+ * color palette). In many color pairs, this will be the same as the `small-body` contrast
156
+ * level.
157
+ * - `lowest-contrast`: Minimum possible contrast between the foreground and background (from the
158
+ * color palette). In many color pairs, this will be the same as the `invisible` contrast
159
+ * level.
160
+ *
161
+ * ## Examples
162
+ *
163
+ * To style an error message (red body text):
164
+ *
165
+ * ```ts
166
+ * viraTheme.colors['vira-red-foreground-body'].foreground.value;
167
+ * ```
168
+ *
169
+ * To style a green banner with white text:
170
+ *
171
+ * ```ts
172
+ * viraTheme.colors['vira-green-behind-bg-body'].background.value;
173
+ * ```
174
+ *
175
+ * `viraThemeByKeys` for structured access:
176
+ *
177
+ * ```ts
178
+ * viraThemeByKeys.red.foreground.body;
179
+ * ```
3
180
  *
4
181
  * @category Color
5
182
  */
@@ -2,7 +2,184 @@ import { defineColorThemeOverride } from 'theme-vir/dist/color-theme/color-theme
2
2
  import { defineColorTheme } from 'theme-vir/dist/color-theme/color-theme.js';
3
3
  import { viraColorPalette } from './vira-color-palette.js';
4
4
  /**
5
- * A color theme from Vira.
5
+ * A color theme designed for straightforward accessible foreground and background color choices.
6
+ * All color pairs can be seen here: https://electrovir.github.io/vira/book/styles/vira-theme.
7
+ *
8
+ * ## Color Pairs
9
+ *
10
+ * Each color choice is stored in a color pair. Each color pair includes a foreground and a
11
+ * background color. Foreground and background color pairs are set to specific lightness levels to
12
+ * ensure a specific level of contrast, which you can choose from (as explained below). Most color
13
+ * pairs include a color interacting with the page default color pair. These page defaults depend on
14
+ * which theme you select: light mode or dark mode. The defaults are the following:
15
+ *
16
+ * - Light mode:
17
+ *
18
+ * - Foreground: black
19
+ * - Background: white
20
+ * - Dark mode:
21
+ *
22
+ * - Foreground: white
23
+ * - Background: black
24
+ *
25
+ * ## Choosing a Color
26
+ *
27
+ * Each color in the theme is a key following the pattern
28
+ * `vira-{colorName}-{pairType}-{contrastLevel}`. (Note that there is also `viraThemeByKeys`, which
29
+ * stores colors in nested objects, accessed with the pattern
30
+ * `viraThemeByKeys[colorName][pairType][contrastLevel]`.) The following steps explain how to select
31
+ * a color pair:
32
+ *
33
+ * 1. **Choose a color name.** Red, blue, etc. This is the color that you're trying to use.
34
+ *
35
+ * - Examples:
36
+ *
37
+ * - `viraTheme.colors['vira-red-foreground-body']`
38
+ * - `viraTheme.colors['vira-blue-foreground-body']`
39
+ * 2. **Choose a color pair type.** This determines where the color name you chose is placed in the
40
+ * color pair.
41
+ *
42
+ * - `foreground`: "Color in the foreground". In this color pair, the chosen color is the foreground
43
+ * and the page default background (white in light mode, black in dark mode) is the
44
+ * background. The lightness level of the foreground, the chosen color, varies based on the
45
+ * selected contrast level (in the next step).
46
+ *
47
+ * - Foreground: the chosen color (red, blue, etc.)
48
+ * - Background: the page default background (white in light mode, black in dark mode).
49
+ * - Example: `viraTheme.colors['vira-red-foreground-body']`
50
+ * - Example: `viraTheme.colors['vira-blue-foreground-body']`
51
+ * - `behind-fg`: "Color behind foreground". In this color pair, the chosen color is the background
52
+ * and the page default foreground (black in light mode, white in dark mode) is the
53
+ * background. The lightness level of the background, the chosen color, varies based on the
54
+ * selected contrast level (in the next step).
55
+ *
56
+ * - Foreground: the page default background (black in light mode, white in dark mode).
57
+ * - Background: the chosen color (red, blue, etc.)
58
+ * - Example: `viraTheme.colors['vira-red-behind-fg-body']`
59
+ * - Example: `viraTheme.colors['vira-blue-behind-fg-body']`
60
+ * - `behind-bg`: "Color behind background". In this color pair, the chosen color is the background
61
+ * and the page default background (white in light mode, black in dark mode) is the
62
+ * foreground. The lightness level of the background, the chosen color, varies based on the
63
+ * selected contrast level (in the next step).
64
+ *
65
+ * - Foreground: the page default background (white in light mode, black in dark mode)
66
+ * - Background: the chosen color (red, blue, etc.)
67
+ * - Example: `viraTheme.colors['vira-red-behind-bg-body']`
68
+ * - Example: `viraTheme.colors['vira-blue-behind-bg-body']`
69
+ * - `on-self`: "Color on self". In this color pair, both the foreground and the background are a
70
+ * shade of the chosen color. The lightness level of the background chosen color varies
71
+ * based on the selected contrast level (in the next step). The lightness of the foreground
72
+ * chosen color is fixed based on the current theme: a dark foreground in light mode, a
73
+ * light foreground in dark mode (to remain similar to the page default foreground color).
74
+ *
75
+ * - Foreground: the chosen color (red, blue, etc.)
76
+ * - Background: the chosen color (red, blue, etc.)
77
+ * - Example: `viraTheme.colors['vira-red-on-self-body']`
78
+ * - Example: `viraTheme.colors['vira-blue-on-self-body']`
79
+ * 3. **Choose a contrast level.** Choose a level of contrast based on what you are applying color to.
80
+ * In general, the `header` level of contrast gives a color shade that is not considered "light"
81
+ * or "dark". Any contrast level intended for smaller text elements (non-body, body, small-body)
82
+ * is a darker variant of that color. Any contrast level allowed on larger text elements
83
+ * (placeholder, decoration, invisible) is a lighter variant of that color. Also see
84
+ * https://electrovir.github.io/color/docs/variables/contrastLevels.html for more details on each
85
+ * contrast level.
86
+ *
87
+ * - `small-body`: Choose this for text or page elements that should be legible but are small in size
88
+ * (< 14px font size, similarly sized icons, etc.).
89
+ *
90
+ * - The color pair is chosen to ensure about Lc 90 contrast between the foreground and the
91
+ * background.
92
+ * - Example: `viraTheme.colors['vira-red-foreground-small-body']`: In light mode, this has a very
93
+ * dark red foreground.
94
+ * - Example: `viraTheme.colors['vira-blue-on-self-small-body']`: In light mode, a very light blue is
95
+ * used as the background color. (The foreground is a very dark blue.)
96
+ * - `body`: Chose this for text or page elements that should be legible and are a normal body text
97
+ * size (>= 14px font size).
98
+ *
99
+ * - The color pair is chosen to ensure about Lc 75 contrast between the foreground and the
100
+ * background.
101
+ * - Example: `viraTheme.colors['vira-red-foreground-body']`: In light mode, this has a dark red
102
+ * foreground (not as dark as the `small-body` variant).
103
+ * - Example: `viraTheme.colors['vira-blue-on-self-body']`: In light mode, a light blue background is
104
+ * used (but darker than the small-body contrast level). (The foreground is a very
105
+ * dark blue.)
106
+ * - `non-body`: Chose this for text or page elements that should be legible but are larger in size
107
+ * (>= 24px font size with normal font weight).
108
+ *
109
+ * - The color pair is chosen to ensure about Lc 60 contrast between the foreground and the
110
+ * background.
111
+ * - Example: `viraTheme.colors['vira-red-foreground-non-body']`: In light mode, this has slightly
112
+ * dark red foreground.
113
+ * - Example: `viraTheme.colors['vira-blue-on-self-non-body']`: In light mode, a light blue background
114
+ * is used (but darker than the small-body contrast level). (The foreground is a
115
+ * very dark blue.)
116
+ * - `header`: Chose this for text or page elements that are heading or heading sized elements (>=24px
117
+ * bolded text or >=36px normal weight text).
118
+ *
119
+ * - The color pair is chosen to ensure about Lc 45 contrast between the foreground and the
120
+ * background.
121
+ * - Example: `viraTheme.colors['vira-red-foreground-header']`: In light mode, this has a very vibrant
122
+ * red foreground.
123
+ * - Example: `viraTheme.colors['vira-blue-on-self-header']`: In light mode, a plain blue (not very
124
+ * dark or light) background is used.
125
+ * - `placeholder`: Chose this for text or page elements that are placeholders or disabled.
126
+ *
127
+ * - The color pair is chosen to ensure about Lc 30 contrast between the foreground and the
128
+ * background.
129
+ * - Example: `viraTheme.colors['vira-red-foreground-placeholder']`: In light mode, this has a light
130
+ * red foreground.
131
+ * - Example: `viraTheme.colors['vira-blue-on-self-placeholder']`: In light mode, a dark blue
132
+ * background is used. (The foreground is a very dark blue.)
133
+ * - `decoration`: Chose this for decorative page elements such as borders that, if not visible to the
134
+ * user (many users may not be able to distinguish this color pair's foreground from the
135
+ * background), do not reduce the usability of the page.
136
+ *
137
+ * - The color pair is chosen to ensure about Lc 15 contrast between the foreground and the
138
+ * background.
139
+ * - Example: `viraTheme.colors['vira-red-foreground-decoration']`: In light mode, this has a very
140
+ * light red foreground.
141
+ * - Example: `viraTheme.colors['vira-blue-on-self-decoration']`: In light mode, a darker blue
142
+ * background is used. (The foreground is a very dark blue.)
143
+ * - `invisible`: Choose this for decorative elements that are even harder-to-see (dimmer) than
144
+ * `decoration` elements. The foreground and background colors in a color pair in this
145
+ * contrast level should be treated as indistinguishable from each other to most of the
146
+ * human population.
147
+ *
148
+ * - The color pair is chosen to ensure Lc 0 contrast between the foreground and the background.
149
+ * - Example: `viraTheme.colors['vira-red-foreground-invisible']`: In light mode, this has an
150
+ * extremely light red foreground, essentially a pale pink.
151
+ * - Example: `viraTheme.colors['vira-blue-on-self-invisible']`: In light mode, an extremely dark blue
152
+ * background is used. (The foreground is a very dark blue.)
153
+ *
154
+ * There are also auxiliary contrast levels available which do not correspond to any specific
155
+ * element usage on a page:
156
+ *
157
+ * - `highest-contrast`: Maximum possible contrast between the foreground and background (from the
158
+ * color palette). In many color pairs, this will be the same as the `small-body` contrast
159
+ * level.
160
+ * - `lowest-contrast`: Minimum possible contrast between the foreground and background (from the
161
+ * color palette). In many color pairs, this will be the same as the `invisible` contrast
162
+ * level.
163
+ *
164
+ * ## Examples
165
+ *
166
+ * To style an error message (red body text):
167
+ *
168
+ * ```ts
169
+ * viraTheme.colors['vira-red-foreground-body'].foreground.value;
170
+ * ```
171
+ *
172
+ * To style a green banner with white text:
173
+ *
174
+ * ```ts
175
+ * viraTheme.colors['vira-green-behind-bg-body'].background.value;
176
+ * ```
177
+ *
178
+ * `viraThemeByKeys` for structured access:
179
+ *
180
+ * ```ts
181
+ * viraThemeByKeys.red.foreground.body;
182
+ * ```
6
183
  *
7
184
  * @category Color
8
185
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vira",
3
- "version": "31.13.1",
3
+ "version": "31.13.2",
4
4
  "description": "A simple and highly versatile design system using element-vir.",
5
5
  "keywords": [
6
6
  "design",