@stackific/md3 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.
- package/LICENSE +201 -0
- package/NOTICE +17 -0
- package/README.md +316 -0
- package/THIRD-PARTY-NOTICES +40 -0
- package/dist/fonts/material-symbols-outlined.woff2 +0 -0
- package/dist/fonts/material-symbols-rounded.woff2 +0 -0
- package/dist/fonts/material-symbols-sharp.woff2 +0 -0
- package/dist/fonts/material-symbols-subset.woff2 +0 -0
- package/dist/md3.css +1 -0
- package/dist/md3.js +621 -0
- package/dist/shapes/arch.svg +1 -0
- package/dist/shapes/arrow.svg +1 -0
- package/dist/shapes/boom.svg +1 -0
- package/dist/shapes/bun.svg +1 -0
- package/dist/shapes/burst.svg +1 -0
- package/dist/shapes/circle.svg +1 -0
- package/dist/shapes/clamshell.svg +1 -0
- package/dist/shapes/diamond.svg +1 -0
- package/dist/shapes/fan.svg +1 -0
- package/dist/shapes/flower.svg +1 -0
- package/dist/shapes/gem.svg +1 -0
- package/dist/shapes/ghost-ish.svg +1 -0
- package/dist/shapes/heart.svg +1 -0
- package/dist/shapes/leaf-clover4.svg +1 -0
- package/dist/shapes/leaf-clover8.svg +1 -0
- package/dist/shapes/loading-indicator.svg +1 -0
- package/dist/shapes/oval.svg +1 -0
- package/dist/shapes/pentagon.svg +1 -0
- package/dist/shapes/pill.svg +1 -0
- package/dist/shapes/pixel-circle.svg +1 -0
- package/dist/shapes/pixel-triangle.svg +1 -0
- package/dist/shapes/puffy-diamond.svg +1 -0
- package/dist/shapes/puffy.svg +1 -0
- package/dist/shapes/semicircle.svg +1 -0
- package/dist/shapes/sided-cookie12.svg +1 -0
- package/dist/shapes/sided-cookie4.svg +1 -0
- package/dist/shapes/sided-cookie6.svg +1 -0
- package/dist/shapes/sided-cookie7.svg +1 -0
- package/dist/shapes/sided-cookie9.svg +1 -0
- package/dist/shapes/slanted.svg +1 -0
- package/dist/shapes/soft-boom.svg +1 -0
- package/dist/shapes/soft-burst.svg +1 -0
- package/dist/shapes/square.svg +1 -0
- package/dist/shapes/sunny.svg +1 -0
- package/dist/shapes/triangle.svg +1 -0
- package/dist/shapes/very-sunny.svg +1 -0
- package/dist/shapes/wavy-circle.svg +1 -0
- package/dist/shapes/wavy.svg +1 -0
- package/package.json +63 -0
- package/src/main.js +5 -0
- package/src/runtime/elements/dialogs.js +72 -0
- package/src/runtime/elements/fields.js +181 -0
- package/src/runtime/elements/menus.js +42 -0
- package/src/runtime/elements/pages.js +7 -0
- package/src/runtime/elements/progress.js +35 -0
- package/src/runtime/elements/sliders.js +78 -0
- package/src/runtime/elements/snackbars.js +27 -0
- package/src/runtime/helpers/ripples.js +46 -0
- package/src/runtime/md3.js +141 -0
- package/src/runtime/palette.js +64 -0
- package/src/runtime/settings/theme.js +194 -0
- package/src/runtime/utils.js +165 -0
- package/src/styles/_config.scss +142 -0
- package/src/styles/_mixins.scss +80 -0
- package/src/styles/elements/_badges.scss +65 -0
- package/src/styles/elements/_bars.scss +83 -0
- package/src/styles/elements/_buttons.scss +119 -0
- package/src/styles/elements/_cards.scss +32 -0
- package/src/styles/elements/_chips.scss +46 -0
- package/src/styles/elements/_dialogs.scss +143 -0
- package/src/styles/elements/_dividers.scss +46 -0
- package/src/styles/elements/_expansions.scss +19 -0
- package/src/styles/elements/_fields.scss +458 -0
- package/src/styles/elements/_grids.scss +35 -0
- package/src/styles/elements/_icons.scss +70 -0
- package/src/styles/elements/_layouts.scss +24 -0
- package/src/styles/elements/_lists.scss +76 -0
- package/src/styles/elements/_main-layouts.scss +45 -0
- package/src/styles/elements/_media.scss +104 -0
- package/src/styles/elements/_menus.scss +289 -0
- package/src/styles/elements/_navigations.scss +450 -0
- package/src/styles/elements/_overlays.scss +34 -0
- package/src/styles/elements/_pages.scss +28 -0
- package/src/styles/elements/_progress.scss +141 -0
- package/src/styles/elements/_selections.scss +248 -0
- package/src/styles/elements/_shapes.scss +151 -0
- package/src/styles/elements/_sliders.scss +336 -0
- package/src/styles/elements/_snackbars.scss +44 -0
- package/src/styles/elements/_tables.scss +67 -0
- package/src/styles/elements/_tabs.scss +49 -0
- package/src/styles/elements/_tooltips.scss +125 -0
- package/src/styles/helpers/_alignments.scss +29 -0
- package/src/styles/helpers/_blurs.scss +26 -0
- package/src/styles/helpers/_colors.scss +39 -0
- package/src/styles/helpers/_directions.scss +30 -0
- package/src/styles/helpers/_elevates.scss +20 -0
- package/src/styles/helpers/_forms.scss +76 -0
- package/src/styles/helpers/_margins.scss +39 -0
- package/src/styles/helpers/_opacities.scss +18 -0
- package/src/styles/helpers/_paddings.scss +35 -0
- package/src/styles/helpers/_positions.scss +44 -0
- package/src/styles/helpers/_responsive.scss +24 -0
- package/src/styles/helpers/_ripples.scss +40 -0
- package/src/styles/helpers/_scrolls.scss +7 -0
- package/src/styles/helpers/_shadows.scss +22 -0
- package/src/styles/helpers/_sizes.scss +34 -0
- package/src/styles/helpers/_spaces.scss +22 -0
- package/src/styles/helpers/_typography.scss +132 -0
- package/src/styles/helpers/_waves.scss +52 -0
- package/src/styles/helpers/_zoom.scss +18 -0
- package/src/styles/md3.scss +61 -0
- package/src/styles/settings/_fonts.scss +42 -0
- package/src/styles/settings/_globals.scss +104 -0
- package/src/styles/settings/_reset.scss +82 -0
- package/src/styles/settings/_theme.scss +126 -0
- package/src/styles/settings/_themes.scss +1525 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Stackific Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing permissions
|
|
201
|
+
and limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
@stackific/md3
|
|
2
|
+
Copyright 2026 Stackific Inc.
|
|
3
|
+
|
|
4
|
+
This product includes software developed by Stackific Inc.
|
|
5
|
+
(https://stackific.com).
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0. See LICENSE for details.
|
|
8
|
+
|
|
9
|
+
Portions of this workspace are derived from or vendor third-party
|
|
10
|
+
software. See THIRD-PARTY-NOTICES for the upstream projects, their
|
|
11
|
+
copyright notices, and the original license terms (which continue to
|
|
12
|
+
govern those portions).
|
|
13
|
+
|
|
14
|
+
Trademark notice:
|
|
15
|
+
"Stackific" is a trademark of Stackific Inc. Trademark rights are not
|
|
16
|
+
granted under the Apache License (see Section 6 of LICENSE). See the
|
|
17
|
+
root TRADEMARKS.md for usage guidelines.
|
package/README.md
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
# @stackific/md3
|
|
2
|
+
|
|
3
|
+
Material Design 3 framework — SCSS + plain JavaScript. No build step required. No React, Vue, or other framework lock-in. Drop it into any HTML page and write semantic markup.
|
|
4
|
+
|
|
5
|
+
- **Light + dark + auto** modes that follow OS preference, persist across reloads, and update live when the OS theme flips.
|
|
6
|
+
- **Multiple named brand themes** in a single bundle, swap with one attribute.
|
|
7
|
+
- **No JS framework required.** Works in plain HTML, also fine with React, Vue, Svelte, htmx, etc.
|
|
8
|
+
- **Runtime weight**: ~17 kB JS, ~22 kB CSS (gzipped) for the full default build.
|
|
9
|
+
- **Optional dynamic theming** from a hex / image / file via `material-dynamic-colors` (opt-in dependency).
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Quick start (CDN)
|
|
14
|
+
|
|
15
|
+
Paste into any HTML file:
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<!doctype html>
|
|
19
|
+
<html data-theme="stackific">
|
|
20
|
+
<head>
|
|
21
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@stackific/md3/dist/md3.css">
|
|
22
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@stackific/md3/dist/md3.js"></script>
|
|
23
|
+
</head>
|
|
24
|
+
<body>
|
|
25
|
+
<main class="responsive">
|
|
26
|
+
<h1>Hello, M3</h1>
|
|
27
|
+
<button>Click me</button>
|
|
28
|
+
<div class="field label">
|
|
29
|
+
<input type="text">
|
|
30
|
+
<label>Your name</label>
|
|
31
|
+
</div>
|
|
32
|
+
<label class="switch">
|
|
33
|
+
<input type="checkbox">
|
|
34
|
+
<span></span>
|
|
35
|
+
</label>
|
|
36
|
+
</main>
|
|
37
|
+
</body>
|
|
38
|
+
</html>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
That's it. You should see an M3-styled page that picks light or dark automatically from your OS preference.
|
|
42
|
+
|
|
43
|
+
## Install via npm
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
npm install @stackific/md3
|
|
47
|
+
# or: pnpm add @stackific/md3
|
|
48
|
+
# or: yarn add @stackific/md3
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
In your app entry:
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import "@stackific/md3"; // runtime — registers window.ui()
|
|
55
|
+
import "@stackific/md3/style"; // compiled CSS with M3 tokens + utilities
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The CSS includes all `@font-face` declarations for Material Symbols, so icons render without any Google Fonts import.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Theme + mode
|
|
63
|
+
|
|
64
|
+
Two HTML attributes drive everything:
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<html data-theme="stackific" data-mode="auto">
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
| Attribute | Values | Purpose |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| `data-theme` | any name listed in `$themes` | Which brand theme supplies the tokens |
|
|
73
|
+
| `data-mode` | `"auto"`, `"light"`, `"dark"` | Color mode preference |
|
|
74
|
+
|
|
75
|
+
`data-mode="auto"` is a real attribute state — CSS handles the `auto → dark` switch via `@media (prefers-color-scheme: dark)`, so the page tracks your OS preference live. No JavaScript needed for that to work.
|
|
76
|
+
|
|
77
|
+
### Switching at runtime
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
ui("mode", "dark"); // or "light", or "auto"
|
|
81
|
+
document.documentElement.dataset.theme = "another"; // pure attribute swap, no deps
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Mode is persisted to `localStorage` under the key `md3:mode` and restored on the next page load. Theme is persisted to `md3:theme`.
|
|
85
|
+
|
|
86
|
+
### Listing available themes
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
ui("themes"); // → ["stackific", "hello-pumpkin", "coral-bloom", ...]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Adding a brand theme
|
|
93
|
+
|
|
94
|
+
If you've cloned the source, `pnpm theme add acme '#ff5722'` bakes a new theme from a single hex color, then `pnpm build` makes it reachable as `<html data-theme="acme">`. See [Local development](#local-development) below for the full workflow.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Customize tokens
|
|
99
|
+
|
|
100
|
+
All M3 design tokens are CSS custom properties. Override at any scope — no rebuild required.
|
|
101
|
+
|
|
102
|
+
```css
|
|
103
|
+
/* whole site */
|
|
104
|
+
:root {
|
|
105
|
+
--primary: #ff5722;
|
|
106
|
+
--on-primary: #ffffff;
|
|
107
|
+
--primary-container: #ffe0d6;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* one card */
|
|
111
|
+
article.alert {
|
|
112
|
+
--surface-container-low: #fff3e0;
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Common tweaks:
|
|
117
|
+
|
|
118
|
+
```css
|
|
119
|
+
:root {
|
|
120
|
+
--size: 1.1rem; /* 10% larger everywhere */
|
|
121
|
+
--font: "Inter Variable", system-ui; /* body font */
|
|
122
|
+
--font-icon: "Material Symbols Rounded"; /* see icon styles below */
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Full token list
|
|
127
|
+
|
|
128
|
+
| Group | Tokens |
|
|
129
|
+
|---|---|
|
|
130
|
+
| Primary | `--primary`, `--on-primary`, `--primary-container`, `--on-primary-container` |
|
|
131
|
+
| Secondary | `--secondary`, `--on-secondary`, `--secondary-container`, `--on-secondary-container` |
|
|
132
|
+
| Tertiary | `--tertiary`, `--on-tertiary`, `--tertiary-container`, `--on-tertiary-container` |
|
|
133
|
+
| Error | `--error`, `--on-error`, `--error-container`, `--on-error-container` |
|
|
134
|
+
| Neutral | `--background`, `--on-background`, `--surface`, `--on-surface`, `--surface-variant`, `--on-surface-variant`, `--outline`, `--outline-variant`, `--shadow`, `--scrim` |
|
|
135
|
+
| Surface tonal | `--surface-dim`, `--surface-bright`, `--surface-container-lowest`, `--surface-container-low`, `--surface-container`, `--surface-container-high`, `--surface-container-highest` |
|
|
136
|
+
| Inverse | `--inverse-surface`, `--inverse-on-surface`, `--inverse-primary` |
|
|
137
|
+
| Structural | `--size`, `--font`, `--font-icon`, `--speed1`..`--speed4`, `--active`, `--overlay`, `--elevate1`..`--elevate3`, `--top`, `--bottom`, `--left`, `--right`, `--image` |
|
|
138
|
+
|
|
139
|
+
### Icon styles
|
|
140
|
+
|
|
141
|
+
Four Material Symbols variants are pre-bundled in `dist/fonts/`. Switch by changing one variable:
|
|
142
|
+
|
|
143
|
+
```css
|
|
144
|
+
:root {
|
|
145
|
+
--font-icon: "Material Symbols Rounded";
|
|
146
|
+
/* "Material Symbols Outlined" (default)
|
|
147
|
+
"Material Symbols Rounded"
|
|
148
|
+
"Material Symbols Sharp"
|
|
149
|
+
"Material Symbols Subset" (smaller; common icons only) */
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Runtime API
|
|
156
|
+
|
|
157
|
+
A single global function `ui()` (or named import `ui`) handles everything.
|
|
158
|
+
|
|
159
|
+
### Mode + theme
|
|
160
|
+
|
|
161
|
+
```js
|
|
162
|
+
ui("mode"); // → "auto" | "light" | "dark"
|
|
163
|
+
ui("mode", "dark"); // set mode; persisted to localStorage
|
|
164
|
+
ui("themes"); // → ["stackific", ...] list of baked themes
|
|
165
|
+
ui("theme", "stackific"); // swap to a baked theme (no extra deps)
|
|
166
|
+
await ui("theme", "#1447E6"); // generate a theme from a hex — needs MDC
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
`ui("theme", source)` accepts a baked theme name, hex string, image URL, `File`, or a pre-computed `{ light, dark }` object. **Only the hex/URL/File forms require [`material-dynamic-colors`](https://www.npmjs.com/package/material-dynamic-colors)** to be loaded in the page:
|
|
170
|
+
|
|
171
|
+
```js
|
|
172
|
+
import "material-dynamic-colors"; // once, at app entry
|
|
173
|
+
await ui("theme", "#1447E6"); // now works
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
The framework itself does not bundle MDC — install and import it yourself when you need dynamic generation.
|
|
177
|
+
|
|
178
|
+
### Component triggers
|
|
179
|
+
|
|
180
|
+
```js
|
|
181
|
+
ui("#my-dialog"); // toggle a <dialog>
|
|
182
|
+
ui("#my-snackbar"); // show snackbar for 6s
|
|
183
|
+
ui("#my-snackbar", 3000); // show for 3s
|
|
184
|
+
ui("#my-snackbar", -1); // show until clicked
|
|
185
|
+
ui("#my-page"); // activate a .page (tab-style content)
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
These are equivalent to clicking an element with `[data-ui="#id"]`.
|
|
189
|
+
|
|
190
|
+
### Utilities
|
|
191
|
+
|
|
192
|
+
```js
|
|
193
|
+
ui(); // re-scan the DOM (call after dynamically injecting markup)
|
|
194
|
+
ui("guid"); // → UUID-v4 string, handy for unique input ids
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Use Sass partials directly
|
|
200
|
+
|
|
201
|
+
If you'd rather not ship the full `dist/md3.css`, `@use` only the partials you need:
|
|
202
|
+
|
|
203
|
+
```scss
|
|
204
|
+
@use "@stackific/md3/src/styles/config";
|
|
205
|
+
@use "@stackific/md3/src/styles/elements/buttons";
|
|
206
|
+
@use "@stackific/md3/src/styles/elements/dialogs";
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Each partial depends only on `_config.scss` (plus the `sass:list` / `sass:map` modules). Element partials don't depend on each other, so you can take just buttons + dialogs + grids if that's all you need.
|
|
210
|
+
|
|
211
|
+
### Mixins you can compose
|
|
212
|
+
|
|
213
|
+
```scss
|
|
214
|
+
@use "@stackific/md3/src/styles/config" as *;
|
|
215
|
+
|
|
216
|
+
.banner-primary {
|
|
217
|
+
@include paired-color("primary"); // bg: var(--primary); color: var(--on-primary)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.banner-error-text {
|
|
221
|
+
@include text-color("error");
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.hero {
|
|
225
|
+
padding: 4rem 1rem;
|
|
226
|
+
@include breakpoint-up("m") {
|
|
227
|
+
padding: 6rem 2rem;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
| Mixin | Effect |
|
|
233
|
+
|---|---|
|
|
234
|
+
| `paired-color($role)` | `background-color: var(--$role); color: var(--on-$role)` |
|
|
235
|
+
| `text-color($role)` | `color: var(--$role)` |
|
|
236
|
+
| `border-color($role)` | `border-color: var(--$role)` |
|
|
237
|
+
| `breakpoint-up($name)` | `@media (min-width: …)` from `$breakpoints` |
|
|
238
|
+
| `breakpoint-down($name)` | `@media (max-width: …)` |
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Local development
|
|
243
|
+
|
|
244
|
+
These commands are for hacking on the framework itself, not for consumers of the published package.
|
|
245
|
+
|
|
246
|
+
```sh
|
|
247
|
+
git clone https://github.com/stackific/md3
|
|
248
|
+
cd md3
|
|
249
|
+
pnpm install
|
|
250
|
+
pnpm build # → dist/md3.css + dist/md3.js
|
|
251
|
+
pnpm demo # build + start the demo Vue app at http://localhost:5001
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Adding or removing a brand theme
|
|
255
|
+
|
|
256
|
+
```sh
|
|
257
|
+
pnpm theme add acme '#ff5722' # quote the hex
|
|
258
|
+
pnpm theme remove acme
|
|
259
|
+
pnpm build # re-emit dist/
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
`add` derives the M3 light + dark token sets and a 10-step tonal palette from the source color, then writes both:
|
|
263
|
+
|
|
264
|
+
- `src/styles/_config.scss` → upserts the entry in `$material-palette` so `.acme`, `.acme1`..`.acme10`, `.acme-text`, `.acme-border` utility classes become available.
|
|
265
|
+
- `src/styles/settings/_themes.scss` → upserts a named block in `$themes` so `<html data-theme="acme">` activates it.
|
|
266
|
+
|
|
267
|
+
`remove` strips both.
|
|
268
|
+
|
|
269
|
+
### Editing tokens directly
|
|
270
|
+
|
|
271
|
+
If you'd rather edit token values by hand instead of running `pnpm theme add`, the shape of `$themes` is:
|
|
272
|
+
|
|
273
|
+
```scss
|
|
274
|
+
$themes: (
|
|
275
|
+
"stackific": (
|
|
276
|
+
"light": ( "primary": #1c4bea, "on-primary": #ffffff, /* ... */ ),
|
|
277
|
+
"dark": ( "primary": #b9c3ff, /* ... */ ),
|
|
278
|
+
),
|
|
279
|
+
);
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Token keys are kebab-cased and match the CSS custom-property names verbatim.
|
|
283
|
+
|
|
284
|
+
### Configure which roles get utility classes
|
|
285
|
+
|
|
286
|
+
`src/styles/_config.scss` controls which M3 roles generate `.role`, `.role-text`, `.role-border`, `.role-container`, and `nav.role`/`menu.role` active-state recoloring:
|
|
287
|
+
|
|
288
|
+
```scss
|
|
289
|
+
$theme-roles-paired: ("primary", "secondary", "tertiary", "error", "background");
|
|
290
|
+
$theme-roles-with-edges: ("primary", "secondary", "tertiary", "error");
|
|
291
|
+
$theme-roles-container: ("primary", "secondary", "tertiary", "error");
|
|
292
|
+
$theme-roles-nav-active: ("primary", "secondary", "tertiary");
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Other things you can edit in SCSS
|
|
296
|
+
|
|
297
|
+
| File | What's there |
|
|
298
|
+
|---|---|
|
|
299
|
+
| `src/styles/_config.scss` | `$material-palette`, role lists, `$breakpoints`, mixins |
|
|
300
|
+
| `src/styles/settings/_themes.scss` | `$themes` (light/dark tokens per brand) |
|
|
301
|
+
| `src/styles/settings/_fonts.scss` | Material Symbols `@font-face` declarations |
|
|
302
|
+
| `src/styles/elements/_*.scss` | Per-component scales (`$-button-sizes`, `$-chip-sizes`, etc.) |
|
|
303
|
+
| `src/styles/elements/_shapes.scss` | `$-shapes` list of SVG-backed shape utilities |
|
|
304
|
+
|
|
305
|
+
## Publish
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
npm publish --access public --dry-run
|
|
309
|
+
npm publish --access public
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## License
|
|
315
|
+
|
|
316
|
+
Apache-2.0. See `LICENSE` and `NOTICE`. The published source includes patterns and SCSS structure derived from [beercss](https://github.com/beercss/beercss) (MIT) — full attribution in `THIRD-PARTY-NOTICES`.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
THIRD-PARTY NOTICES
|
|
2
|
+
===================
|
|
3
|
+
|
|
4
|
+
This repository incorporates material from the projects listed below. The
|
|
5
|
+
original license terms for each project are reproduced verbatim. Continued use
|
|
6
|
+
of those portions of the software remains subject to those terms.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
────────────────────────────────────────────────────────────────────────────
|
|
10
|
+
beercss/beercss
|
|
11
|
+
https://github.com/beercss/beercss
|
|
12
|
+
|
|
13
|
+
Vendored under `demo/` for use as the visual-fidelity test surface for
|
|
14
|
+
`@stackific/md3`. Patterns, selector vocabulary, and the SCSS authoring
|
|
15
|
+
structure of `@stackific/md3` are derived from this project.
|
|
16
|
+
────────────────────────────────────────────────────────────────────────────
|
|
17
|
+
|
|
18
|
+
MIT License
|
|
19
|
+
|
|
20
|
+
Copyright (c) 2021 Beer css!
|
|
21
|
+
|
|
22
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
23
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
24
|
+
in the Software without restriction, including without limitation the rights
|
|
25
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
26
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
27
|
+
furnished to do so, subject to the following conditions:
|
|
28
|
+
|
|
29
|
+
The above copyright notice and this permission notice shall be included in all
|
|
30
|
+
copies or substantial portions of the Software.
|
|
31
|
+
|
|
32
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
33
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
34
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
35
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
36
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
37
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
38
|
+
SOFTWARE.
|
|
39
|
+
|
|
40
|
+
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|