@jskit-ai/material-web 0.0.0-stage → 0.1.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,109 @@
1
+ // JSKIT's Material 3 component defaults, on top of Vuetify's md3 blueprint: full-shape filled buttons, elevated cards
2
+ // on surface-container-low with 12dp corners, outlined fields, 8dp chips that close with $close, 4dp menus and the
3
+ // inverse-surface snackbar, the Material switch, and the 16dp primary-container FAB. A number for `rounded` is an exact
4
+ // corner in dp. Dialog and bottom sheet corners, and the sizes props cannot set, are in material.css.
5
+ const materialDefaults = Object.freeze({
6
+ VAppBar: {
7
+ color: "surface",
8
+ flat: true,
9
+ height: 64
10
+ },
11
+ VBtn: {
12
+ color: "primary",
13
+ rounded: "pill",
14
+ variant: "flat"
15
+ },
16
+ VCard: {
17
+ color: "surface-container-low",
18
+ elevation: 1,
19
+ rounded: 12
20
+ },
21
+ VChip: {
22
+ closeIcon: "$close",
23
+ rounded: 8
24
+ },
25
+ // material.css gives the dialog's card 28dp corners, and none when the dialog is full-screen.
26
+ VDialog: {
27
+ VCard: {
28
+ color: "surface-container-high",
29
+ elevation: 3,
30
+ rounded: undefined
31
+ }
32
+ },
33
+ VBottomSheet: {
34
+ contentClass: "jskit-material-bottom-sheet",
35
+ VCard: {
36
+ color: "surface-container-low",
37
+ elevation: 1,
38
+ rounded: 0
39
+ }
40
+ },
41
+ VFab: {
42
+ color: "primary-container",
43
+ rounded: 16,
44
+ variant: "elevated"
45
+ },
46
+ VList: {
47
+ bgColor: "transparent"
48
+ },
49
+ VMenu: {
50
+ VList: {
51
+ bgColor: "surface-container",
52
+ elevation: 2,
53
+ rounded: 4
54
+ }
55
+ },
56
+ VSnackbar: {
57
+ color: "inverse-surface",
58
+ rounded: 4,
59
+ VBtn: {
60
+ color: "inverse-primary",
61
+ variant: "text"
62
+ }
63
+ },
64
+ VSwitch: {
65
+ color: "primary",
66
+ inset: "material"
67
+ },
68
+ VAutocomplete: {
69
+ hideDetails: "auto",
70
+ variant: "outlined"
71
+ },
72
+ VCombobox: {
73
+ hideDetails: "auto",
74
+ variant: "outlined"
75
+ },
76
+ VFileInput: {
77
+ hideDetails: "auto",
78
+ variant: "outlined"
79
+ },
80
+ VSelect: {
81
+ hideDetails: "auto",
82
+ variant: "outlined"
83
+ },
84
+ VTextarea: {
85
+ hideDetails: "auto",
86
+ variant: "outlined"
87
+ },
88
+ VTextField: {
89
+ hideDetails: "auto",
90
+ variant: "outlined"
91
+ },
92
+ VCheckbox: {
93
+ color: "primary"
94
+ },
95
+ VRadioGroup: {
96
+ color: "primary"
97
+ },
98
+ VTabs: {
99
+ color: "primary"
100
+ },
101
+ VToolbar: {
102
+ color: "surface"
103
+ },
104
+ VTooltip: {
105
+ location: "bottom"
106
+ }
107
+ });
108
+
109
+ export { materialDefaults };
@@ -0,0 +1,50 @@
1
+ import { md3 } from "vuetify/blueprints";
2
+ import { materialThemes } from "./colorSchemes.js";
3
+ import { materialDefaults } from "./defaults.js";
4
+ import { materialSymbols } from "./symbols.js";
5
+
6
+ // The default Material 3 seed, the baseline purple of the Material 3 guidelines.
7
+ const DEFAULT_SEED = "#6750A4";
8
+
9
+ /**
10
+ * An app's own icons as Vuetify aliases: `{ name: "<24x24 path data>" }` becomes `$name`.
11
+ * @param {Record<string, string>} icons
12
+ */
13
+ function appIconAliases(icons) {
14
+ const aliases = {};
15
+ for (const [name, path] of Object.entries(icons)) {
16
+ const glyph = String(path || "").trim();
17
+ if (!/^[A-Za-z][A-Za-z0-9]*$/u.test(name) || !glyph) {
18
+ throw new TypeError(`Theme icon "${name}" needs a camelCase name and the icon's 24x24 SVG path data.`);
19
+ }
20
+ aliases[name] = glyph.startsWith("svg:") ? glyph : `svg:${glyph}`;
21
+ }
22
+ return aliases;
23
+ }
24
+
25
+ /**
26
+ * Vuetify options for an exact Material 3 app: the md3 blueprint, light and dark schemes generated from the seed (with
27
+ * the app's own colours as harmonized custom colours), following the system's light or dark setting, Material Symbols
28
+ * Rounded behind every icon alias (plus the app's own), and JSKIT's Material 3 component defaults. Pass the result to
29
+ * createVuetify(); import "@jskit-ai/material-web/client/material.css" after "vuetify/styles".
30
+ * @param {{ seed?: string, colors?: Record<string, string>, icons?: Record<string, string> }} [theme]
31
+ */
32
+ function createMaterialVuetifyOptions({ seed = DEFAULT_SEED, colors = {}, icons = {} } = {}) {
33
+ return {
34
+ blueprint: md3,
35
+ defaults: materialDefaults,
36
+ icons: {
37
+ defaultSet: "svg",
38
+ aliases: {
39
+ ...materialSymbols,
40
+ ...appIconAliases(icons)
41
+ }
42
+ },
43
+ theme: {
44
+ defaultTheme: "system",
45
+ themes: materialThemes(seed, colors)
46
+ }
47
+ };
48
+ }
49
+
50
+ export { materialThemes, createMaterialVuetifyOptions };
@@ -0,0 +1,284 @@
1
+ /*
2
+ * JSKIT's Material 3 rules for Vuetify: the sizes and shapes component props cannot set, Roboto Flex, emphasized
3
+ * motion and reduced motion. Import it after "vuetify/styles". Component rules live in Vuetify's own
4
+ * vuetify-overrides cascade layer, so they beat Vuetify's component styles while an app's utility classes
5
+ * (rounded-0, bg-*, pa-*) and props still win without any rule forcing priority.
6
+ */
7
+ @layer vuetify-core, vuetify-components, vuetify-overrides, vuetify-utilities, vuetify-final;
8
+ @import "@fontsource-variable/roboto-flex/index.css";
9
+
10
+ :root {
11
+ --v-font-body: "Roboto Flex Variable", "Roboto Flex", Roboto, system-ui, sans-serif;
12
+ --md-sys-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
13
+ --md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0, 0, 1);
14
+ --md-sys-motion-easing-emphasized-decelerate: cubic-bezier(0.05, 0.7, 0.1, 1);
15
+ --md-sys-motion-easing-emphasized-accelerate: cubic-bezier(0.3, 0, 0.8, 0.15);
16
+ --md-sys-motion-duration-short4: 200ms;
17
+ --md-sys-motion-duration-medium2: 300ms;
18
+ --md-sys-motion-duration-medium4: 400ms;
19
+ --md-sys-motion-duration-long2: 500ms;
20
+ }
21
+
22
+ @layer vuetify-overrides {
23
+ /* Common buttons: 40dp tall, full shape, 24dp side padding (16dp beside an icon), a 48dp touch target. */
24
+ .v-btn--size-default:not(.v-btn--stacked, .v-btn--icon) {
25
+ --v-btn-height: 40px;
26
+ padding-inline: 24px;
27
+ }
28
+
29
+ .v-btn--size-default:not(.v-btn--stacked, .v-btn--icon):has(> .v-btn__prepend) {
30
+ padding-inline-start: 16px;
31
+ }
32
+
33
+ .v-btn--size-default:not(.v-btn--stacked, .v-btn--icon):has(> .v-btn__append) {
34
+ padding-inline-end: 16px;
35
+ }
36
+
37
+ .v-btn--size-default.v-btn--variant-text:not(.v-btn--stacked, .v-btn--icon) {
38
+ padding-inline: 12px;
39
+ }
40
+
41
+ /* Icon buttons: a 40dp state layer around a 24dp icon. */
42
+ .v-btn--icon.v-btn--size-default {
43
+ --v-btn-height: 28px;
44
+ }
45
+
46
+ .v-btn--icon.v-btn--size-default .v-icon {
47
+ font-size: 24px;
48
+ }
49
+
50
+ .v-btn--size-default:not(.v-btn--stacked) {
51
+ overflow: visible;
52
+ }
53
+
54
+ .v-btn--size-default:not(.v-btn--stacked)::before {
55
+ content: "";
56
+ height: max(100%, 48px);
57
+ left: 50%;
58
+ position: absolute;
59
+ top: 50%;
60
+ transform: translate(-50%, -50%);
61
+ width: max(100%, 48px);
62
+ }
63
+
64
+ /* Outlined buttons draw the outline role, chips outline-variant. */
65
+ .v-btn--variant-outlined:not([class*=" text-"]) {
66
+ border-color: rgb(var(--v-theme-outline));
67
+ color: rgb(var(--v-theme-primary));
68
+ }
69
+
70
+ .v-chip--variant-outlined:not([class*=" text-"]) {
71
+ border-color: rgb(var(--v-theme-outline-variant));
72
+ color: rgb(var(--v-theme-on-surface-variant));
73
+ }
74
+
75
+ .v-chip .v-chip__prepend .v-icon,
76
+ .v-chip .v-chip__append .v-icon,
77
+ .v-chip .v-chip__close .v-icon {
78
+ font-size: 18px;
79
+ }
80
+
81
+ /* Chips you press are 32dp tall with a 48dp touch target, drawn under the chip's content so it never covers it. */
82
+ .v-chip--link.v-chip--size-default {
83
+ isolation: isolate;
84
+ overflow: visible;
85
+ }
86
+
87
+ .v-chip--link.v-chip--size-default::after {
88
+ content: "";
89
+ height: max(100%, 48px);
90
+ left: 0;
91
+ position: absolute;
92
+ right: 0;
93
+ top: 50%;
94
+ transform: translateY(-50%);
95
+ z-index: -1;
96
+ }
97
+
98
+ /* Dialogs: 28dp corners and a headline-small title; full-screen dialogs are square. */
99
+ .v-dialog > .v-overlay__content > .v-card,
100
+ .v-dialog > .v-overlay__content > .v-sheet,
101
+ .v-dialog > .v-overlay__content > form > .v-card,
102
+ .v-dialog > .v-overlay__content > form > .v-sheet {
103
+ border-radius: 28px;
104
+ }
105
+
106
+ .v-dialog > .v-overlay__content > .v-card > .v-card-item .v-card-title,
107
+ .v-dialog > .v-overlay__content > .v-card > .v-card-title,
108
+ .v-dialog > .v-overlay__content > form > .v-card > .v-card-item .v-card-title,
109
+ .v-dialog > .v-overlay__content > form > .v-card > .v-card-title {
110
+ font-size: 1.5rem;
111
+ font-weight: 400;
112
+ letter-spacing: 0;
113
+ line-height: 2rem;
114
+ white-space: normal;
115
+ }
116
+
117
+ .v-dialog > .v-overlay__content > .v-card > .v-card-text,
118
+ .v-dialog > .v-overlay__content > form > .v-card > .v-card-text {
119
+ color: rgb(var(--v-theme-on-surface-variant));
120
+ }
121
+
122
+ .v-dialog--fullscreen > .v-overlay__content > .v-card,
123
+ .v-dialog--fullscreen > .v-overlay__content > .v-sheet,
124
+ .v-dialog--fullscreen > .v-overlay__content > form > .v-card,
125
+ .v-dialog--fullscreen > .v-overlay__content > form > .v-sheet {
126
+ border-radius: 0;
127
+ }
128
+
129
+ /* Bottom sheets: 28dp top corners. */
130
+ .jskit-material-bottom-sheet {
131
+ border-radius: 28px 28px 0 0;
132
+ overflow: hidden;
133
+ }
134
+
135
+ /* Plain tooltips: inverse surface, 4dp corners, body-small. */
136
+ .v-tooltip > .v-overlay__content {
137
+ background: rgb(var(--v-theme-inverse-surface));
138
+ border-radius: 4px;
139
+ color: rgb(var(--v-theme-inverse-on-surface));
140
+ font-size: 0.75rem;
141
+ letter-spacing: 0.0333333333em;
142
+ line-height: 1rem;
143
+ min-height: 24px;
144
+ padding: 4px 8px;
145
+ }
146
+
147
+ /* Dividers and table rules use outline-variant at full strength (the theme's border colour). Vuetify draws a
148
+ divider in the text colour, so one without a color prop takes outline-variant. */
149
+ .v-divider {
150
+ opacity: 1;
151
+ }
152
+
153
+ .v-divider:not([class*=" text-"]) {
154
+ color: rgb(var(--v-theme-outline-variant));
155
+ }
156
+
157
+ /* Motion: emphasized easing; entering elements decelerate, leaving ones accelerate. */
158
+ .v-navigation-drawer,
159
+ .v-bottom-navigation,
160
+ .v-app-bar {
161
+ transition-timing-function: var(--md-sys-motion-easing-emphasized);
162
+ }
163
+
164
+ .dialog-transition-enter-active,
165
+ .dialog-bottom-transition-enter-active,
166
+ .bottom-sheet-transition-enter-active,
167
+ .fade-transition-enter-active,
168
+ .scale-transition-enter-active,
169
+ .slide-y-transition-enter-active,
170
+ .slide-x-transition-enter-active,
171
+ .expand-transition-enter-active {
172
+ transition-duration: var(--md-sys-motion-duration-medium4);
173
+ transition-timing-function: var(--md-sys-motion-easing-emphasized-decelerate);
174
+ }
175
+
176
+ .dialog-transition-leave-active,
177
+ .dialog-bottom-transition-leave-active,
178
+ .bottom-sheet-transition-leave-active,
179
+ .fade-transition-leave-active,
180
+ .scale-transition-leave-active,
181
+ .slide-y-transition-leave-active,
182
+ .slide-x-transition-leave-active,
183
+ .expand-transition-leave-active {
184
+ transition-duration: var(--md-sys-motion-duration-short4);
185
+ transition-timing-function: var(--md-sys-motion-easing-emphasized-accelerate);
186
+ }
187
+ }
188
+
189
+ /*
190
+ * Vuetify names the utility class of an on-* colour role ".on-surface-variant", so color="on-surface-variant" on an
191
+ * icon or a text button would find no class. These text-on-* forms make it work.
192
+ */
193
+ @layer vuetify-utilities {
194
+ .text-on-background {
195
+ color: rgb(var(--v-theme-on-background));
196
+ }
197
+
198
+ .text-on-surface {
199
+ color: rgb(var(--v-theme-on-surface));
200
+ }
201
+
202
+ .text-on-surface-variant {
203
+ color: rgb(var(--v-theme-on-surface-variant));
204
+ }
205
+
206
+ .text-on-primary {
207
+ color: rgb(var(--v-theme-on-primary));
208
+ }
209
+
210
+ .text-on-primary-container {
211
+ color: rgb(var(--v-theme-on-primary-container));
212
+ }
213
+
214
+ .text-on-secondary {
215
+ color: rgb(var(--v-theme-on-secondary));
216
+ }
217
+
218
+ .text-on-secondary-container {
219
+ color: rgb(var(--v-theme-on-secondary-container));
220
+ }
221
+
222
+ .text-on-tertiary {
223
+ color: rgb(var(--v-theme-on-tertiary));
224
+ }
225
+
226
+ .text-on-tertiary-container {
227
+ color: rgb(var(--v-theme-on-tertiary-container));
228
+ }
229
+
230
+ .text-on-error {
231
+ color: rgb(var(--v-theme-on-error));
232
+ }
233
+
234
+ .text-on-error-container {
235
+ color: rgb(var(--v-theme-on-error-container));
236
+ }
237
+
238
+ .text-on-success {
239
+ color: rgb(var(--v-theme-on-success));
240
+ }
241
+
242
+ .text-on-success-container {
243
+ color: rgb(var(--v-theme-on-success-container));
244
+ }
245
+
246
+ .text-on-warning {
247
+ color: rgb(var(--v-theme-on-warning));
248
+ }
249
+
250
+ .text-on-warning-container {
251
+ color: rgb(var(--v-theme-on-warning-container));
252
+ }
253
+
254
+ .text-on-info {
255
+ color: rgb(var(--v-theme-on-info));
256
+ }
257
+
258
+ .text-on-info-container {
259
+ color: rgb(var(--v-theme-on-info-container));
260
+ }
261
+ }
262
+
263
+ /*
264
+ * A full-screen dialog's container is the surface, not the dialog's surface-container-high. Unlayered, so it
265
+ * outranks the bg-* class the dialog's card default sets.
266
+ */
267
+ .v-dialog--fullscreen > .v-overlay__content > .v-card,
268
+ .v-dialog--fullscreen > .v-overlay__content > form > .v-card {
269
+ background-color: rgb(var(--v-theme-surface));
270
+ color: rgb(var(--v-theme-on-surface));
271
+ }
272
+
273
+ /* Reduced motion: transitions and animations finish at once. Unlayered, so it outranks every layered rule. */
274
+ @media (prefers-reduced-motion: reduce) {
275
+ *,
276
+ *::before,
277
+ *::after {
278
+ animation-duration: 1ms;
279
+ animation-iteration-count: 1;
280
+ scroll-behavior: auto;
281
+ transition-delay: 0ms;
282
+ transition-duration: 1ms;
283
+ }
284
+ }