@rio-m3e/styles 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.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,6 @@
1
+ Rio
2
+ Copyright 2026 LegenLee
3
+
4
+ This product bundles material-color-utilities
5
+ (https://github.com/material-foundation/material-color-utilities),
6
+ Copyright 2021 Google LLC, licensed under the Apache License, Version 2.0.
package/README.md CHANGED
@@ -1,3 +1,12 @@
1
- # Temporary Holding Version
1
+ # @rio-m3e/styles
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Plain CSS for the components of [Rio](https://github.com/LegenLee/rio), a Material 3 Expressive implementation. It reads the `--rio-*` CSS variables that [`@rio-m3e/tokens`](https://www.npmjs.com/package/@rio-m3e/tokens) sets.
4
+
5
+ Framework adapters such as [`@rio-m3e/vue`](https://www.npmjs.com/package/@rio-m3e/vue) import these files for you. To use them directly, import them one by one:
6
+
7
+ ```ts
8
+ import '@rio-m3e/styles/button.css';
9
+ import '@rio-m3e/styles/base/ripple.css';
10
+ ```
11
+
12
+ Licensed under the Apache License 2.0.
package/css.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ // Empty declaration so side-effect imports like `import '@rio-m3e/styles/*.css'` pass type checking.
2
+ // TypeScript 6 turns on noUncheckedSideEffectImports by default.
3
+ export {};
package/package.json CHANGED
@@ -1,6 +1,31 @@
1
1
  {
2
2
  "name": "@rio-m3e/styles",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Framework-agnostic component styles for Rio",
5
+ "license": "Apache-2.0",
6
+ "author": "LegenLee",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/LegenLee/rio.git",
10
+ "directory": "packages/styles"
11
+ },
12
+ "files": [
13
+ "src",
14
+ "css.d.ts",
15
+ "NOTICE"
16
+ ],
17
+ "type": "module",
18
+ "sideEffects": [
19
+ "**/*.css"
20
+ ],
21
+ "exports": {
22
+ "./*.css": {
23
+ "types": "./css.d.ts",
24
+ "default": "./src/*.css"
25
+ },
26
+ "./package.json": "./package.json"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ }
6
31
  }
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Keyboard focus indicator: a ring around the element, shown only for keyboard-style focus
3
+ * (:focus-visible), so mouse and touch users don't see it.
4
+ *
5
+ * Every M3 component token so far uses `secondary` for the ring. A component that needs another
6
+ * color sets `--rio-focus-ring-color`. The ring follows the element's border radius.
7
+ */
8
+
9
+ .rio-focus-ring:focus-visible {
10
+ outline: var(--rio-state-focus-indicator-thickness) solid
11
+ var(--rio-focus-ring-color, var(--rio-color-secondary));
12
+ outline-offset: var(--rio-state-focus-indicator-outer-offset);
13
+ }
14
+
15
+ /* Draws the ring inside the element, for places where an outer ring would be clipped. */
16
+ .rio-focus-ring[data-focus-ring='inner']:focus-visible {
17
+ outline-offset: var(--rio-state-focus-indicator-inner-offset);
18
+ }
@@ -0,0 +1,21 @@
1
+ /*
2
+ * Reduced motion: when the user asks the OS to reduce motion, spatial motion (position, size,
3
+ * rotation, corner radius) becomes instant. Effects motion (color, opacity) keeps its short fades,
4
+ * which don't cause the discomfort reduced motion is meant to prevent. This is a Rio decision; the
5
+ * M3 pages Rio has read don't define reduced-motion behavior.
6
+ *
7
+ * Every element gets the override, with !important, so it beats the theme variables `applyTheme`
8
+ * sets inline on the root, and any subtree that swaps motion schemes. Components that use the
9
+ * motion tokens import this file. The ripple follows the same rule in JavaScript.
10
+ */
11
+
12
+ @media (prefers-reduced-motion: reduce) {
13
+ * {
14
+ --rio-motion-fast-spatial: 0ms !important;
15
+ --rio-motion-fast-spatial-duration: 0ms !important;
16
+ --rio-motion-default-spatial: 0ms !important;
17
+ --rio-motion-default-spatial-duration: 0ms !important;
18
+ --rio-motion-slow-spatial: 0ms !important;
19
+ --rio-motion-slow-spatial-duration: 0ms !important;
20
+ }
21
+ }
@@ -0,0 +1,63 @@
1
+ /*
2
+ * Press ripple, driven by `attachRipple` from `@rio-m3e/core`. It styles every element the
3
+ * primitive marks with `data-ripple`, so no class is needed. A class would also be fragile: Vue
4
+ * rewrites `class` when a `:class` binding changes, but leaves attributes it doesn't own alone.
5
+ *
6
+ * While pressed, the element has `data-pressed`, and the primitive animates the three registered
7
+ * properties below on `::after`. The ripple is a radial gradient in the content color
8
+ * (currentColor), so it stays inside the element's rounded corners without `overflow: hidden`. It
9
+ * sits under the content, above the state layer on `::before`. Fade timings follow Material Web's
10
+ * ripple.
11
+ */
12
+
13
+ @property --rio-ripple-x {
14
+ syntax: '<length>';
15
+ inherits: false;
16
+ initial-value: 0px;
17
+ }
18
+
19
+ @property --rio-ripple-y {
20
+ syntax: '<length>';
21
+ inherits: false;
22
+ initial-value: 0px;
23
+ }
24
+
25
+ @property --rio-ripple-radius {
26
+ syntax: '<length>';
27
+ inherits: false;
28
+ initial-value: 0px;
29
+ }
30
+
31
+ [data-ripple] {
32
+ position: relative;
33
+ isolation: isolate;
34
+ -webkit-tap-highlight-color: transparent;
35
+ }
36
+
37
+ [data-ripple]::after {
38
+ content: '';
39
+ position: absolute;
40
+ inset: 0;
41
+ z-index: -1;
42
+ border-radius: inherit;
43
+ background: radial-gradient(
44
+ circle var(--rio-ripple-radius) at var(--rio-ripple-x) var(--rio-ripple-y),
45
+ currentColor max(calc(100% - 70px), 65%),
46
+ transparent 100%
47
+ );
48
+ opacity: 0;
49
+ pointer-events: none;
50
+ transition: opacity 375ms linear;
51
+ }
52
+
53
+ [data-ripple][data-pressed]::after {
54
+ opacity: var(--rio-state-pressed-state-layer-opacity);
55
+ transition-duration: 105ms;
56
+ }
57
+
58
+ /* Forced colors replace backgrounds, so the ripple would only get in the way. */
59
+ @media (forced-colors: active) {
60
+ [data-ripple]::after {
61
+ display: none;
62
+ }
63
+ }
@@ -0,0 +1,13 @@
1
+ /*
2
+ * Shape morphing, driven by `attachShapeMorph` from `@rio-m3e/core`. A component sets
3
+ * `--rio-shape-morph-target` to the corner radius it wants in each state, and sets
4
+ * `border-radius` to the same value, so it still works without JavaScript. The primitive reads
5
+ * the target in px, which needs the registration below, and animates the inline radius with a
6
+ * spring. It marks the element with `data-shape-morph`.
7
+ */
8
+
9
+ @property --rio-shape-morph-target {
10
+ syntax: '<length>';
11
+ inherits: false;
12
+ initial-value: 0px;
13
+ }
@@ -0,0 +1,58 @@
1
+ /*
2
+ * State layer: a semi-transparent overlay in the content color at a fixed opacity per state.
3
+ *
4
+ * Put `rio-state-layer` on the interactive element and set its content color with `color`. The
5
+ * overlay uses `currentColor`, sits between the container background and the content, and shows
6
+ * one state at a time: later rules win, so pressed beats focus, and focus beats hover.
7
+ *
8
+ * Pressed is a flat overlay unless the element has a ripple (`attachRipple` from `@rio-m3e/core`
9
+ * marks it with `data-ripple`). Then the ripple on `::after` shows the press instead.
10
+ */
11
+
12
+ .rio-state-layer {
13
+ position: relative;
14
+ isolation: isolate;
15
+ }
16
+
17
+ .rio-state-layer::before {
18
+ content: '';
19
+ position: absolute;
20
+ inset: 0;
21
+ z-index: -1;
22
+ border-radius: inherit;
23
+ background-color: currentColor;
24
+ opacity: 0;
25
+ pointer-events: none;
26
+ transition: opacity var(--rio-motion-fast-effects);
27
+ }
28
+
29
+ /* Touch screens keep :hover after a tap, so only devices that can hover get a hover state. */
30
+ @media (hover: hover) {
31
+ .rio-state-layer:hover::before {
32
+ opacity: var(--rio-state-hover-state-layer-opacity);
33
+ }
34
+ }
35
+
36
+ .rio-state-layer:focus-visible::before {
37
+ opacity: var(--rio-state-focus-state-layer-opacity);
38
+ }
39
+
40
+ .rio-state-layer:not([data-ripple]):is(:active, [data-pressed])::before {
41
+ opacity: var(--rio-state-pressed-state-layer-opacity);
42
+ }
43
+
44
+ .rio-state-layer[data-dragged]::before {
45
+ opacity: var(--rio-state-dragged-state-layer-opacity);
46
+ }
47
+
48
+ /* Disabled elements don't change state, so they get no state layer at all. */
49
+ .rio-state-layer:is(:disabled, [aria-disabled='true'])::before {
50
+ opacity: 0;
51
+ }
52
+
53
+ /* Forced colors replace backgrounds, so the overlay would only get in the way. */
54
+ @media (forced-colors: active) {
55
+ .rio-state-layer::before {
56
+ display: none;
57
+ }
58
+ }
package/src/button.css ADDED
@@ -0,0 +1,258 @@
1
+ /*
2
+ * M3E common button.
3
+ *
4
+ * Values come from Material Web's component tokens (`_md-comp-button-*.scss`, Material 3
5
+ * v34.0.21). Label type styles per size come from Compose's `ButtonDefaults.textStyleFor`. The
6
+ * element carries `data-variant`, `data-size`, `data-shape`, and, for toggle buttons,
7
+ * `data-selected`, which `createButton` from `@rio-m3e/core` sets.
8
+ *
9
+ * Variant, size, shape, and toggle rules sit inside `:where()`, so they add no specificity. The
10
+ * disabled and pressed rules always win, and apps can override any of them with a single class.
11
+ */
12
+
13
+ .rio-button {
14
+ /* Size: small, the default */
15
+ --_height: 40px;
16
+ --_padding: 16px;
17
+ --_icon-size: 20px;
18
+ --_gap: 8px;
19
+ --_outline-width: 1px;
20
+ --_square: var(--rio-shape-corner-medium);
21
+ --_pressed: var(--rio-shape-corner-small);
22
+ --_selected-round: var(--rio-shape-corner-medium);
23
+ --_font: var(--rio-typescale-label-large);
24
+ --_tracking: var(--rio-typescale-label-large-tracking);
25
+
26
+ /* Round is half the height rather than corner-full (9999px), so it animates into other shapes. */
27
+ --_round: calc(var(--_height) / 2);
28
+ --_radius: var(--_round);
29
+
30
+ /* Color: filled, the default */
31
+ --_container: var(--rio-color-primary);
32
+ --_content: var(--rio-color-on-primary);
33
+ --_outline: transparent;
34
+ --_elevation: var(--rio-elevation-level0);
35
+ --_hover-elevation: var(--rio-elevation-level1);
36
+
37
+ display: inline-flex;
38
+ align-items: center;
39
+ justify-content: center;
40
+ gap: var(--_gap);
41
+ box-sizing: border-box;
42
+ block-size: var(--_height);
43
+ padding-inline: var(--_padding);
44
+ border: var(--_outline-width) solid var(--_outline);
45
+ /* The shape-morph primitive springs the inline radius toward this target. */
46
+ --rio-shape-morph-target: var(--_radius);
47
+ border-radius: var(--_radius);
48
+ background-color: var(--_container);
49
+ box-shadow: var(--_elevation);
50
+ color: var(--_content);
51
+ font: var(--_font);
52
+ letter-spacing: var(--_tracking);
53
+ white-space: nowrap;
54
+ vertical-align: middle;
55
+ cursor: pointer;
56
+ user-select: none;
57
+ /* No border-radius transition: corners move with the fast-spatial spring (see base/shape-morph.css). */
58
+ transition:
59
+ background-color var(--rio-motion-fast-effects),
60
+ color var(--rio-motion-fast-effects),
61
+ box-shadow var(--rio-motion-fast-effects);
62
+ }
63
+
64
+ /* Sizes */
65
+
66
+ .rio-button:where([data-size='xsmall']) {
67
+ --_height: 32px;
68
+ --_padding: 12px;
69
+ }
70
+
71
+ .rio-button:where([data-size='medium']) {
72
+ --_height: 56px;
73
+ --_padding: 24px;
74
+ --_icon-size: 24px;
75
+ --_square: var(--rio-shape-corner-large);
76
+ --_pressed: var(--rio-shape-corner-medium);
77
+ --_selected-round: var(--rio-shape-corner-large);
78
+ --_font: var(--rio-typescale-title-medium);
79
+ --_tracking: var(--rio-typescale-title-medium-tracking);
80
+ }
81
+
82
+ .rio-button:where([data-size='large']) {
83
+ --_height: 96px;
84
+ --_padding: 48px;
85
+ --_icon-size: 32px;
86
+ --_gap: 12px;
87
+ --_outline-width: 2px;
88
+ --_square: var(--rio-shape-corner-extra-large);
89
+ --_pressed: var(--rio-shape-corner-large);
90
+ --_selected-round: var(--rio-shape-corner-extra-large);
91
+ --_font: var(--rio-typescale-headline-small);
92
+ --_tracking: var(--rio-typescale-headline-small-tracking);
93
+ }
94
+
95
+ .rio-button:where([data-size='xlarge']) {
96
+ --_height: 136px;
97
+ --_padding: 64px;
98
+ --_icon-size: 40px;
99
+ --_gap: 16px;
100
+ --_outline-width: 3px;
101
+ --_square: var(--rio-shape-corner-extra-large);
102
+ --_pressed: var(--rio-shape-corner-large);
103
+ --_selected-round: var(--rio-shape-corner-extra-large);
104
+ --_font: var(--rio-typescale-headline-large);
105
+ --_tracking: var(--rio-typescale-headline-large-tracking);
106
+ }
107
+
108
+ /* Shapes. A selected toggle swaps them: round turns square-ish, square turns round. */
109
+
110
+ .rio-button:where([data-shape='square']) {
111
+ --_radius: var(--_square);
112
+ }
113
+
114
+ .rio-button:where([data-selected='true']) {
115
+ --_radius: var(--_selected-round);
116
+ }
117
+
118
+ .rio-button:where([data-shape='square'][data-selected='true']) {
119
+ --_radius: var(--_round);
120
+ }
121
+
122
+ /* Variants */
123
+
124
+ .rio-button:where([data-variant='tonal']) {
125
+ --_container: var(--rio-color-secondary-container);
126
+ --_content: var(--rio-color-on-secondary-container);
127
+ }
128
+
129
+ .rio-button:where([data-variant='outlined']) {
130
+ --_container: transparent;
131
+ --_content: var(--rio-color-on-surface-variant);
132
+ --_outline: var(--rio-color-outline-variant);
133
+ --_hover-elevation: var(--rio-elevation-level0);
134
+ }
135
+
136
+ .rio-button:where([data-variant='elevated']) {
137
+ --_container: var(--rio-color-surface-container-low);
138
+ --_content: var(--rio-color-primary);
139
+ --_elevation: var(--rio-elevation-level1);
140
+ --_hover-elevation: var(--rio-elevation-level2);
141
+ }
142
+
143
+ .rio-button:where([data-variant='text']) {
144
+ --_container: transparent;
145
+ --_content: var(--rio-color-primary);
146
+ --_hover-elevation: var(--rio-elevation-level0);
147
+ }
148
+
149
+ /* Icon buttons only (see icon-button.css): no container, like text, but it can toggle */
150
+ .rio-button:where([data-variant='standard']) {
151
+ --_container: transparent;
152
+ --_content: var(--rio-color-on-surface-variant);
153
+ }
154
+
155
+ /* Toggle buttons: unselected and selected colors, where they differ from the defaults above */
156
+
157
+ .rio-button:where([data-variant='filled'][data-selected='false']) {
158
+ --_container: var(--rio-color-surface-container);
159
+ --_content: var(--rio-color-on-surface-variant);
160
+ }
161
+
162
+ .rio-button:where([data-variant='tonal'][data-selected='true']) {
163
+ --_container: var(--rio-color-secondary);
164
+ --_content: var(--rio-color-on-secondary);
165
+ }
166
+
167
+ .rio-button:where([data-variant='outlined'][data-selected='true']) {
168
+ --_container: var(--rio-color-inverse-surface);
169
+ --_content: var(--rio-color-inverse-on-surface);
170
+ --_outline: transparent;
171
+ }
172
+
173
+ .rio-button:where([data-variant='elevated'][data-selected='true']) {
174
+ --_container: var(--rio-color-primary);
175
+ --_content: var(--rio-color-on-primary);
176
+ }
177
+
178
+ .rio-button:where([data-variant='standard'][data-selected='true']) {
179
+ --_content: var(--rio-color-primary);
180
+ }
181
+
182
+ /* Interaction: hover lifts one level, pressing returns to rest and morphs the corners */
183
+
184
+ @media (hover: hover) {
185
+ .rio-button:hover {
186
+ box-shadow: var(--_hover-elevation);
187
+ }
188
+ }
189
+
190
+ .rio-button[data-pressed] {
191
+ --rio-shape-morph-target: var(--_pressed);
192
+ border-radius: var(--_pressed);
193
+ box-shadow: var(--_elevation);
194
+ }
195
+
196
+ /* Disabled, native or soft */
197
+
198
+ .rio-button:is(:disabled, [aria-disabled='true']) {
199
+ --_container: color-mix(in srgb, var(--rio-color-on-surface) 10%, transparent);
200
+ --_content: color-mix(
201
+ in srgb,
202
+ var(--rio-color-on-surface) calc(var(--rio-state-disabled-state-layer-opacity) * 100%),
203
+ transparent
204
+ );
205
+ --_elevation: none;
206
+ --_hover-elevation: none;
207
+ cursor: default;
208
+ }
209
+
210
+ .rio-button:is(:disabled, [aria-disabled='true']):where(
211
+ [data-variant='outlined'],
212
+ [data-variant='text'],
213
+ [data-variant='standard']
214
+ ) {
215
+ --_container: transparent;
216
+ }
217
+
218
+ .rio-button:is(:disabled, [aria-disabled='true']):where(
219
+ [data-variant='outlined'][data-selected='true']
220
+ ) {
221
+ --_container: color-mix(in srgb, var(--rio-color-on-surface) 10%, transparent);
222
+ }
223
+
224
+ /*
225
+ * The state layer (::before) and the ripple (::after) cover the border too. With `inset: 0` they
226
+ * would stop at the padding box, inside the border, and look slightly smaller than the container.
227
+ * Every variant keeps a border, transparent unless outlined, because forced-colors mode paints
228
+ * transparent borders in a system color and keeps the button's edge visible.
229
+ */
230
+ .rio-button[data-variant]::before,
231
+ .rio-button[data-variant]::after {
232
+ inset: calc(-1 * var(--_outline-width));
233
+ }
234
+
235
+ /* Parts */
236
+
237
+ /* Extra small and small buttons are shorter than the spec's 48px minimum target. */
238
+ .rio-button__touch {
239
+ position: absolute;
240
+ inset-block-start: 50%;
241
+ inset-inline-start: 50%;
242
+ inline-size: max(100%, 48px);
243
+ block-size: max(100%, 48px);
244
+ translate: -50% -50%;
245
+ }
246
+
247
+ .rio-button__icon {
248
+ display: inline-flex;
249
+ flex: none;
250
+ inline-size: var(--_icon-size);
251
+ block-size: var(--_icon-size);
252
+ font-size: var(--_icon-size);
253
+ }
254
+
255
+ .rio-button__icon > :is(svg, img) {
256
+ inline-size: 100%;
257
+ block-size: 100%;
258
+ }
@@ -0,0 +1,84 @@
1
+ /*
2
+ * M3E icon button, layered on top of `button.css`. The root carries both `rio-button` and
3
+ * `rio-icon-button`, so it inherits the button's shapes (round, square, pressed, selected), shape
4
+ * morphing, colors (the `standard` variant lives in `button.css` with the others), disabled rules,
5
+ * state layer, ripple, and touch target. This file holds only what differs: the three widths, the
6
+ * icon sizes, and no elevation.
7
+ *
8
+ * Values come from Material Web's component tokens (`_md-comp-icon-button-*.scss`, Material 3
9
+ * v34.0.21). Every rule is `.rio-button.rio-icon-button`, so it beats `button.css` in any load
10
+ * order. None of them touch what the disabled and pressed rules set, so those still apply.
11
+ */
12
+
13
+ .rio-button.rio-icon-button {
14
+ /* Small, default width */
15
+ --_icon-size: 24px;
16
+ --_padding: 8px;
17
+ --_elevation: none;
18
+ --_hover-elevation: none;
19
+
20
+ inline-size: calc(var(--_icon-size) + 2 * var(--_padding));
21
+ padding: 0;
22
+ }
23
+
24
+ /* Sizes: icon size and the padding beside it for each width */
25
+
26
+ .rio-button.rio-icon-button:where([data-size='xsmall']) {
27
+ --_icon-size: 20px;
28
+ --_padding: 6px;
29
+ }
30
+
31
+ .rio-button.rio-icon-button:where([data-size='xsmall'][data-width='narrow']) {
32
+ --_padding: 4px;
33
+ }
34
+
35
+ .rio-button.rio-icon-button:where([data-size='xsmall'][data-width='wide']) {
36
+ --_padding: 10px;
37
+ }
38
+
39
+ .rio-button.rio-icon-button:where([data-size='small'][data-width='narrow']) {
40
+ --_padding: 4px;
41
+ }
42
+
43
+ .rio-button.rio-icon-button:where([data-size='small'][data-width='wide']) {
44
+ --_padding: 14px;
45
+ }
46
+
47
+ .rio-button.rio-icon-button:where([data-size='medium']) {
48
+ --_icon-size: 24px;
49
+ --_padding: 16px;
50
+ }
51
+
52
+ .rio-button.rio-icon-button:where([data-size='medium'][data-width='narrow']) {
53
+ --_padding: 12px;
54
+ }
55
+
56
+ .rio-button.rio-icon-button:where([data-size='medium'][data-width='wide']) {
57
+ --_padding: 24px;
58
+ }
59
+
60
+ .rio-button.rio-icon-button:where([data-size='large']) {
61
+ --_icon-size: 32px;
62
+ --_padding: 32px;
63
+ }
64
+
65
+ .rio-button.rio-icon-button:where([data-size='large'][data-width='narrow']) {
66
+ --_padding: 16px;
67
+ }
68
+
69
+ .rio-button.rio-icon-button:where([data-size='large'][data-width='wide']) {
70
+ --_padding: 48px;
71
+ }
72
+
73
+ .rio-button.rio-icon-button:where([data-size='xlarge']) {
74
+ --_icon-size: 40px;
75
+ --_padding: 48px;
76
+ }
77
+
78
+ .rio-button.rio-icon-button:where([data-size='xlarge'][data-width='narrow']) {
79
+ --_padding: 32px;
80
+ }
81
+
82
+ .rio-button.rio-icon-button:where([data-size='xlarge'][data-width='wide']) {
83
+ --_padding: 72px;
84
+ }
package/src/switch.css ADDED
@@ -0,0 +1,210 @@
1
+ /*
2
+ * M3 switch.
3
+ *
4
+ * Values come from Material Web's component tokens (`_md-comp-switch.scss`, Material 3 v34.0.21),
5
+ * which match the spec's measurements table. The handle's center and size are declared as targets
6
+ * for each state; `attachSwitchHandle` from `@rio-m3e/core` springs `--_handle-x` and
7
+ * `--_handle-size` toward them. Without JavaScript the handle simply jumps.
8
+ *
9
+ * The root carries `data-selected`, plus `data-pressed` (from the ripple), `data-dragging` (from
10
+ * the drag), and `data-icon` when the handle shows an icon. State rules sit inside `:where()` so
11
+ * the disabled rules always win.
12
+ */
13
+
14
+ @property --rio-switch-handle-x-target {
15
+ syntax: '<length>';
16
+ inherits: false;
17
+ initial-value: 0px;
18
+ }
19
+
20
+ @property --rio-switch-handle-size-target {
21
+ syntax: '<length>';
22
+ inherits: false;
23
+ initial-value: 0px;
24
+ }
25
+
26
+ @property --rio-switch-handle-x-off {
27
+ syntax: '<length>';
28
+ inherits: false;
29
+ initial-value: 0px;
30
+ }
31
+
32
+ @property --rio-switch-handle-x-on {
33
+ syntax: '<length>';
34
+ inherits: false;
35
+ initial-value: 0px;
36
+ }
37
+
38
+ .rio-switch {
39
+ --_track-width: 52px;
40
+ --_track-height: 32px;
41
+ --_outline-width: 2px;
42
+
43
+ /* The handle's center, measured from the track's starting edge */
44
+ --rio-switch-handle-x-off: calc(var(--_track-height) / 2);
45
+ --rio-switch-handle-x-on: calc(var(--_track-width) - var(--_track-height) / 2);
46
+ --rio-switch-handle-x-target: var(--rio-switch-handle-x-off);
47
+ --rio-switch-handle-size-target: 16px;
48
+ --_handle-x: var(--rio-switch-handle-x-target);
49
+ --_handle-size: var(--rio-switch-handle-size-target);
50
+
51
+ /* Colors: unselected */
52
+ --_track: var(--rio-color-surface-container-highest);
53
+ --_outline: var(--rio-color-outline);
54
+ --_handle: var(--rio-color-outline);
55
+ --_handle-active: var(--rio-color-on-surface-variant);
56
+ --_icon: var(--rio-color-surface-container-highest);
57
+ --_state-layer: var(--rio-color-on-surface);
58
+
59
+ position: relative;
60
+ display: inline-flex;
61
+ flex: none;
62
+ box-sizing: border-box;
63
+ inline-size: var(--_track-width);
64
+ block-size: var(--_track-height);
65
+ margin: 0;
66
+ padding: 0;
67
+ border: var(--_outline-width) solid var(--_outline);
68
+ border-radius: var(--rio-shape-corner-full);
69
+ background-color: var(--_track);
70
+ vertical-align: middle;
71
+ cursor: pointer;
72
+ /* Horizontal drags belong to the handle; vertical ones still scroll the page. */
73
+ touch-action: pan-y;
74
+ -webkit-tap-highlight-color: transparent;
75
+ transition:
76
+ background-color var(--rio-motion-fast-effects),
77
+ border-color var(--rio-motion-fast-effects);
78
+ }
79
+
80
+ /* States */
81
+
82
+ .rio-switch:where([data-selected='true']) {
83
+ --rio-switch-handle-x-target: var(--rio-switch-handle-x-on);
84
+ --rio-switch-handle-size-target: 24px;
85
+ --_track: var(--rio-color-primary);
86
+ --_outline: var(--rio-color-primary);
87
+ --_handle: var(--rio-color-on-primary);
88
+ --_handle-active: var(--rio-color-primary-container);
89
+ --_icon: var(--rio-color-primary);
90
+ --_state-layer: var(--rio-color-primary);
91
+ }
92
+
93
+ .rio-switch:where([data-icon]) {
94
+ --rio-switch-handle-size-target: 24px;
95
+ }
96
+
97
+ /* Pressing or dragging grows the handle */
98
+ .rio-switch:is([data-pressed], [data-dragging]) {
99
+ --rio-switch-handle-size-target: 28px;
100
+ }
101
+
102
+ /* Hovering, focusing, or pressing changes the handle's color */
103
+
104
+ @media (hover: hover) {
105
+ .rio-switch:hover .rio-switch__handle {
106
+ background-color: var(--_handle-active);
107
+ }
108
+
109
+ .rio-switch:hover .rio-switch__state::before {
110
+ opacity: var(--rio-state-hover-state-layer-opacity);
111
+ }
112
+ }
113
+
114
+ .rio-switch:is(:focus-visible, [data-pressed], [data-dragging]) .rio-switch__handle {
115
+ background-color: var(--_handle-active);
116
+ }
117
+
118
+ .rio-switch:focus-visible .rio-switch__state::before {
119
+ opacity: var(--rio-state-focus-state-layer-opacity);
120
+ }
121
+
122
+ /* Disabled, native or soft: the track at 12%, the unselected handle and the icons at 38% */
123
+
124
+ .rio-switch:is(:disabled, [aria-disabled='true']) {
125
+ --_track: color-mix(in srgb, var(--rio-color-surface-container-highest) 12%, transparent);
126
+ --_outline: color-mix(in srgb, var(--rio-color-on-surface) 12%, transparent);
127
+ --_handle: color-mix(in srgb, var(--rio-color-on-surface) 38%, transparent);
128
+ --_handle-active: var(--_handle);
129
+ --_icon: color-mix(in srgb, var(--rio-color-surface-container-highest) 38%, transparent);
130
+ cursor: default;
131
+ }
132
+
133
+ .rio-switch:is(:disabled, [aria-disabled='true']):where([data-selected='true']) {
134
+ --_track: color-mix(in srgb, var(--rio-color-on-surface) 12%, transparent);
135
+ --_outline: transparent;
136
+ --_handle: var(--rio-color-surface);
137
+ --_handle-active: var(--rio-color-surface);
138
+ --_icon: color-mix(in srgb, var(--rio-color-on-surface) 38%, transparent);
139
+ }
140
+
141
+ .rio-switch:is(:disabled, [aria-disabled='true']) .rio-switch__state::before {
142
+ opacity: 0;
143
+ }
144
+
145
+ /* Parts */
146
+
147
+ /* The 40px circle around the handle: the state layer on ::before, the ripple on ::after */
148
+ .rio-switch .rio-switch__state {
149
+ position: absolute;
150
+ inset-inline-start: calc(var(--_handle-x) - 20px - var(--_outline-width));
151
+ inset-block-start: calc(50% - 20px);
152
+ inline-size: 40px;
153
+ block-size: 40px;
154
+ border-radius: var(--rio-shape-corner-full);
155
+ color: var(--_state-layer);
156
+ pointer-events: none;
157
+ }
158
+
159
+ .rio-switch__state::before {
160
+ content: '';
161
+ position: absolute;
162
+ inset: 0;
163
+ border-radius: inherit;
164
+ background-color: currentColor;
165
+ opacity: 0;
166
+ pointer-events: none;
167
+ transition: opacity var(--rio-motion-fast-effects);
168
+ }
169
+
170
+ .rio-switch__handle {
171
+ position: absolute;
172
+ display: grid;
173
+ place-items: center;
174
+ inset-inline-start: calc(var(--_handle-x) - var(--_handle-size) / 2 - var(--_outline-width));
175
+ inset-block-start: calc(50% - var(--_handle-size) / 2);
176
+ inline-size: var(--_handle-size);
177
+ block-size: var(--_handle-size);
178
+ border-radius: var(--rio-shape-corner-full);
179
+ background-color: var(--_handle);
180
+ color: var(--_icon);
181
+ pointer-events: none;
182
+ transition: background-color var(--rio-motion-fast-effects);
183
+ }
184
+
185
+ .rio-switch__icon {
186
+ display: inline-flex;
187
+ inline-size: 16px;
188
+ block-size: 16px;
189
+ }
190
+
191
+ .rio-switch__icon > :is(svg, img) {
192
+ inline-size: 100%;
193
+ block-size: 100%;
194
+ }
195
+
196
+ /* The track is 32px tall, below the spec's 48px minimum target. */
197
+ .rio-switch__touch {
198
+ position: absolute;
199
+ inset-block-start: 50%;
200
+ inset-inline-start: 50%;
201
+ inline-size: max(100%, 48px);
202
+ block-size: max(100%, 48px);
203
+ translate: -50% -50%;
204
+ }
205
+
206
+ @media (forced-colors: active) {
207
+ .rio-switch__state::before {
208
+ display: none;
209
+ }
210
+ }