@shift-css/core 0.4.0 → 0.6.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,270 @@
1
+ :where([s-input]) {
2
+ --_input-bg: var(--s-surface-base);
3
+ --_input-border: var(--s-border-default);
4
+ --_input-text: var(--s-text-primary);
5
+ --_input-placeholder: var(--s-text-tertiary);
6
+ --_input-radius: var(--s-radius-md);
7
+ appearance: none;
8
+ width: 100%;
9
+ padding: var(--s-space-2) var(--s-space-3);
10
+ background-color: var(--_input-bg);
11
+ border: 2px solid var(--_input-border);
12
+ border-radius: var(--_input-radius);
13
+ color: var(--_input-text);
14
+ font-size: var(--s-text-sm);
15
+ line-height: var(--s-leading-normal);
16
+ transition: border-color var(--s-duration-150) var(--s-ease-out), box-shadow var(--s-duration-150) var(--s-ease-out);
17
+ display: block;
18
+
19
+ &::placeholder {
20
+ color: var(--_input-placeholder);
21
+ }
22
+
23
+ &:hover:not(:disabled):not(:focus-visible) {
24
+ --_input-border: var(--s-border-strong);
25
+ }
26
+
27
+ &:focus-visible {
28
+ --_input-border: var(--s-interactive-primary);
29
+ outline: 2px solid var(--s-focus-ring);
30
+ outline-offset: 2px;
31
+
32
+ @supports (color: oklch(from red l c h)) {
33
+ outline-color: oklch(from var(--s-interactive-primary) l c h / .3);
34
+ }
35
+ }
36
+
37
+ &:disabled {
38
+ opacity: .5;
39
+ cursor: not-allowed;
40
+ background-color: var(--s-surface-sunken);
41
+ }
42
+
43
+ &:invalid:not(:placeholder-shown), &[aria-invalid="true"] {
44
+ --_input-border: var(--s-state-danger);
45
+
46
+ &:focus-visible {
47
+ outline-color: var(--s-state-danger);
48
+ }
49
+ }
50
+ }
51
+
52
+ [s-input][s-size="sm"] {
53
+ padding: var(--s-space-1) var(--s-space-2);
54
+ font-size: var(--s-text-xs);
55
+ }
56
+
57
+ [s-input][s-size="lg"] {
58
+ padding: var(--s-space-3) var(--s-space-4);
59
+ font-size: var(--s-text-base);
60
+ }
61
+
62
+ textarea[s-input] {
63
+ resize: vertical;
64
+ min-height: 6rem;
65
+ }
66
+
67
+ select[s-input] {
68
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
69
+ background-repeat: no-repeat;
70
+ background-position: right var(--s-space-3) center;
71
+ padding-right: var(--s-space-10);
72
+ }
73
+
74
+ [s-input-group] {
75
+ display: flex;
76
+
77
+ & > [s-input] {
78
+ border-radius: 0;
79
+ flex: 1;
80
+ min-width: 0;
81
+
82
+ &:first-child {
83
+ border-radius: var(--s-radius-md) 0 0 var(--s-radius-md);
84
+ }
85
+
86
+ &:last-child {
87
+ border-radius: 0 var(--s-radius-md) var(--s-radius-md) 0;
88
+ }
89
+ }
90
+
91
+ & > [s-input-addon] {
92
+ padding: var(--s-space-2) var(--s-space-3);
93
+ background-color: var(--s-surface-sunken);
94
+ border: 2px solid var(--s-border-default);
95
+ color: var(--s-text-secondary);
96
+ font-size: var(--s-text-sm);
97
+ white-space: nowrap;
98
+ align-items: center;
99
+ display: flex;
100
+
101
+ &:first-child {
102
+ border-radius: var(--s-radius-md) 0 0 var(--s-radius-md);
103
+ border-right: none;
104
+ }
105
+
106
+ &:last-child {
107
+ border-radius: 0 var(--s-radius-md) var(--s-radius-md) 0;
108
+ border-left: none;
109
+ }
110
+ }
111
+ }
112
+
113
+ [s-field] {
114
+ gap: var(--s-space-1);
115
+ flex-direction: column;
116
+ display: flex;
117
+ }
118
+
119
+ [s-field-label] {
120
+ font-size: var(--s-text-sm);
121
+ font-weight: var(--s-font-medium);
122
+ color: var(--s-text-primary);
123
+ }
124
+
125
+ [s-field-hint] {
126
+ font-size: var(--s-text-xs);
127
+ color: var(--s-text-secondary);
128
+ }
129
+
130
+ [s-field-error] {
131
+ font-size: var(--s-text-xs);
132
+ color: var(--s-state-danger);
133
+ }
134
+
135
+ [s-checkbox], [s-radio] {
136
+ align-items: center;
137
+ gap: var(--s-space-2);
138
+ cursor: pointer;
139
+ display: inline-flex;
140
+
141
+ & input {
142
+ appearance: none;
143
+ border: 2px solid var(--s-border-default);
144
+ background-color: var(--s-surface-base);
145
+ cursor: pointer;
146
+ width: 1.25rem;
147
+ height: 1.25rem;
148
+ transition: background-color var(--s-duration-150) var(--s-ease-out), border-color var(--s-duration-150) var(--s-ease-out);
149
+
150
+ &:checked {
151
+ background-color: var(--s-interactive-primary);
152
+ border-color: var(--s-interactive-primary);
153
+ }
154
+
155
+ &:focus-visible {
156
+ outline: 2px solid var(--s-focus-ring);
157
+ outline-offset: 2px;
158
+ }
159
+
160
+ &:disabled {
161
+ opacity: .5;
162
+ cursor: not-allowed;
163
+ }
164
+ }
165
+ }
166
+
167
+ [s-checkbox] input {
168
+ border-radius: var(--s-radius-sm);
169
+
170
+ &:checked {
171
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
172
+ background-position: center;
173
+ background-repeat: no-repeat;
174
+ background-size: .75rem;
175
+ }
176
+ }
177
+
178
+ [s-radio] input {
179
+ border-radius: 50%;
180
+
181
+ &:checked {
182
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='white'%3E%3Ccircle cx='12' cy='12' r='5'/%3E%3C/svg%3E");
183
+ background-position: center;
184
+ background-repeat: no-repeat;
185
+ }
186
+ }
187
+
188
+ [s-toggle] {
189
+ align-items: center;
190
+ gap: var(--s-space-2);
191
+ cursor: pointer;
192
+ display: inline-flex;
193
+
194
+ & input {
195
+ appearance: none;
196
+ background-color: var(--s-border-default);
197
+ cursor: pointer;
198
+ width: 2.5rem;
199
+ height: 1.5rem;
200
+ transition: background-color var(--s-duration-200) var(--s-ease-out);
201
+ border-radius: 9999px;
202
+ position: relative;
203
+
204
+ &:after {
205
+ content: "";
206
+ background-color: var(--s-surface-base);
207
+ width: calc(1.5rem - 4px);
208
+ height: calc(1.5rem - 4px);
209
+ box-shadow: var(--s-shadow-sm);
210
+ transition: transform var(--s-duration-200) var(--s-ease-out);
211
+ border-radius: 50%;
212
+ position: absolute;
213
+ top: 2px;
214
+ left: 2px;
215
+ }
216
+
217
+ &:checked {
218
+ background-color: var(--s-interactive-primary);
219
+
220
+ &:after {
221
+ transform: translateX(1rem);
222
+ }
223
+ }
224
+
225
+ &:focus-visible {
226
+ outline: 2px solid var(--s-focus-ring);
227
+ outline-offset: 2px;
228
+ }
229
+
230
+ &:disabled {
231
+ opacity: .5;
232
+ cursor: not-allowed;
233
+ }
234
+ }
235
+ }
236
+
237
+ @supports (container-type: inline-size) {
238
+ @container surface style(--_surface-depth: 1) {
239
+ :where([s-input]) {
240
+ --_input-bg: var(--s-surface-sunken);
241
+ }
242
+
243
+ :where([s-checkbox]) input, :where([s-radio]) input {
244
+ background-color: var(--s-surface-sunken);
245
+ }
246
+ }
247
+
248
+ @container surface style(--_surface-depth: 2) {
249
+ :where([s-input]) {
250
+ --_input-bg: var(--s-surface-sunken);
251
+ --_input-border: var(--s-border-strong);
252
+ }
253
+
254
+ :where([s-checkbox]) input, :where([s-radio]) input {
255
+ background-color: var(--s-surface-sunken);
256
+ border-color: var(--s-border-strong);
257
+ }
258
+ }
259
+
260
+ @container surface style(--_surface-depth: -1) {
261
+ :where([s-input]) {
262
+ --_input-bg: var(--s-surface-raised);
263
+ --_input-border: var(--s-border-muted);
264
+ }
265
+
266
+ :where([s-checkbox]) input, :where([s-radio]) input {
267
+ background-color: var(--s-surface-raised);
268
+ }
269
+ }
270
+ }
@@ -0,0 +1,195 @@
1
+ :where([s-menu]) {
2
+ --_menu-bg: var(--s-surface-raised);
3
+ --_menu-border: var(--s-border-muted);
4
+ --_menu-radius: var(--s-radius-lg);
5
+ --_menu-shadow: var(--s-shadow-lg);
6
+ --_menu-min-width: 10rem;
7
+ --_menu-padding: var(--s-space-1);
8
+ --_menu-offset: var(--s-space-1);
9
+ }
10
+
11
+ [s-menu] {
12
+ anchor-scope: --menu-trigger;
13
+ display: inline-block;
14
+ position: relative;
15
+ }
16
+
17
+ [s-menu]::marker {
18
+ display: none;
19
+ }
20
+
21
+ [s-menu] ::-webkit-details-marker {
22
+ display: none;
23
+ }
24
+
25
+ [s-menu-trigger] {
26
+ cursor: pointer;
27
+ anchor-name: --menu-trigger;
28
+ list-style: none;
29
+ }
30
+
31
+ [s-menu-trigger]::-webkit-details-marker {
32
+ display: none;
33
+ }
34
+
35
+ [s-menu-items] {
36
+ z-index: 9999;
37
+ margin-top: var(--_menu-offset);
38
+ background-color: var(--_menu-bg);
39
+ border: 1px solid var(--_menu-border);
40
+ border-radius: var(--_menu-radius);
41
+ box-shadow: var(--_menu-shadow);
42
+ min-width: var(--_menu-min-width);
43
+ padding: var(--_menu-padding);
44
+ font-size: var(--s-text-sm);
45
+ color: var(--s-text-primary);
46
+ opacity: 0;
47
+ visibility: hidden;
48
+ transition: opacity var(--s-duration-150) var(--s-ease-out), transform var(--s-duration-150) var(--s-ease-out), visibility var(--s-duration-150);
49
+ flex-direction: column;
50
+ display: flex;
51
+ position: absolute;
52
+ top: 100%;
53
+ left: 0;
54
+ transform: scale(.95)translateY(-4px);
55
+ }
56
+
57
+ [s-menu][open] > [s-menu-items] {
58
+ opacity: 1;
59
+ visibility: visible;
60
+ transform: scale(1)translateY(0);
61
+ }
62
+
63
+ [s-menu="end"] > [s-menu-items] {
64
+ left: auto;
65
+ right: 0;
66
+ }
67
+
68
+ [s-menu="top"] > [s-menu-items] {
69
+ margin-top: 0;
70
+ margin-bottom: var(--_menu-offset);
71
+ top: auto;
72
+ bottom: 100%;
73
+ transform: scale(.95)translateY(4px);
74
+ }
75
+
76
+ [s-menu="top"][open] > [s-menu-items] {
77
+ transform: scale(1)translateY(0);
78
+ }
79
+
80
+ [s-menu="top-end"] > [s-menu-items] {
81
+ margin-top: 0;
82
+ margin-bottom: var(--_menu-offset);
83
+ inset: auto 0 100% auto;
84
+ transform: scale(.95)translateY(4px);
85
+ }
86
+
87
+ [s-menu="top-end"][open] > [s-menu-items] {
88
+ transform: scale(1)translateY(0);
89
+ }
90
+
91
+ @supports (anchor-scope: all) {
92
+ [s-menu-items] {
93
+ position-anchor: --menu-trigger;
94
+ inset: auto;
95
+ margin: 0;
96
+ position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
97
+ margin-block-start: var(--_menu-offset);
98
+ position: absolute;
99
+ inset-block-start: anchor(end);
100
+ inset-inline-start: anchor(start);
101
+ }
102
+
103
+ [s-menu="end"] > [s-menu-items] {
104
+ inset-inline-start: auto;
105
+ inset-inline-end: anchor(end);
106
+ }
107
+
108
+ [s-menu="top"] > [s-menu-items] {
109
+ margin-block-start: 0;
110
+ margin-block-end: var(--_menu-offset);
111
+ inset-block-start: auto;
112
+ inset-block-end: anchor(start);
113
+ }
114
+
115
+ [s-menu="top-end"] > [s-menu-items] {
116
+ margin-block-start: 0;
117
+ margin-block-end: var(--_menu-offset);
118
+ inset-block-start: auto;
119
+ inset-block-end: anchor(start);
120
+ inset-inline-start: auto;
121
+ inset-inline-end: anchor(end);
122
+ }
123
+ }
124
+
125
+ [s-menu-item] {
126
+ align-items: center;
127
+ gap: var(--s-space-2);
128
+ width: 100%;
129
+ padding: var(--s-space-2) var(--s-space-3);
130
+ border-radius: var(--s-radius-md);
131
+ color: var(--s-text-primary);
132
+ font-size: inherit;
133
+ text-align: start;
134
+ cursor: pointer;
135
+ transition: background-color var(--s-duration-100) var(--s-ease-out);
136
+ background: none;
137
+ border: none;
138
+ display: flex;
139
+ }
140
+
141
+ [s-menu-item]:hover {
142
+ background-color: var(--s-surface-sunken);
143
+ }
144
+
145
+ [s-menu-item]:focus-visible {
146
+ outline: 2px solid var(--s-focus-ring);
147
+ outline-offset: -2px;
148
+ }
149
+
150
+ [s-menu-item]:disabled {
151
+ opacity: .5;
152
+ cursor: not-allowed;
153
+ }
154
+
155
+ [s-menu-item][s-danger] {
156
+ color: var(--s-state-danger);
157
+ }
158
+
159
+ [s-menu-item][s-danger]:hover {
160
+ background-color: var(--s-state-danger-bg);
161
+ }
162
+
163
+ [s-menu-divider] {
164
+ height: 1px;
165
+ margin: var(--s-space-1) 0;
166
+ background-color: var(--s-border-muted);
167
+ border: none;
168
+ }
169
+
170
+ [s-menu-label] {
171
+ padding: var(--s-space-2) var(--s-space-3);
172
+ font-size: var(--s-text-xs);
173
+ font-weight: var(--s-font-semibold);
174
+ color: var(--s-text-secondary);
175
+ text-transform: uppercase;
176
+ letter-spacing: var(--s-tracking-wide);
177
+ display: block;
178
+ }
179
+
180
+ @media (prefers-reduced-motion: reduce) {
181
+ [s-menu-items] {
182
+ transition: none;
183
+ }
184
+ }
185
+
186
+ @media (forced-colors: active) {
187
+ [s-menu-items] {
188
+ border: 2px solid canvastext;
189
+ }
190
+
191
+ [s-menu-item]:hover {
192
+ color: highlighttext;
193
+ background-color: highlight;
194
+ }
195
+ }
@@ -0,0 +1,204 @@
1
+ dialog[s-modal]:not([open]) {
2
+ display: none;
3
+ }
4
+
5
+ :where(dialog[s-modal]) {
6
+ --_modal-bg: var(--s-surface-raised);
7
+ --_modal-border: var(--s-border-muted);
8
+ --_modal-radius: var(--s-radius-xl);
9
+ --_modal-shadow: var(--s-shadow-2xl);
10
+ --_modal-padding: var(--s-space-4);
11
+ --_modal-max-width: 32rem;
12
+ width: min(var(--_modal-max-width), calc(100vw - var(--s-space-4) * 2));
13
+ max-height: calc(100vh - var(--s-space-4) * 2);
14
+ max-width: var(--_modal-max-width);
15
+ background-color: var(--_modal-bg);
16
+ border-radius: var(--_modal-radius);
17
+ box-shadow: var(--_modal-shadow);
18
+ border: none;
19
+ margin: auto;
20
+ padding: 0;
21
+
22
+ &[open] {
23
+ flex-direction: column;
24
+ display: flex;
25
+ }
26
+
27
+ color: var(--s-text-primary);
28
+ }
29
+
30
+ dialog[s-modal][open] {
31
+ animation: s-modal-scale-in var(--s-duration-200) var(--s-ease-out);
32
+ }
33
+
34
+ dialog[s-modal]:focus-visible {
35
+ outline: 2px solid var(--s-focus-ring);
36
+ outline-offset: 2px;
37
+ }
38
+
39
+ @keyframes s-modal-scale-in {
40
+ from {
41
+ opacity: 0;
42
+ transform: scale(.95)translateY(-10px);
43
+ }
44
+
45
+ to {
46
+ opacity: 1;
47
+ transform: scale(1)translateY(0);
48
+ }
49
+ }
50
+
51
+ dialog[s-modal]::backdrop {
52
+ backdrop-filter: blur(4px);
53
+ animation: s-modal-backdrop-in var(--s-duration-200) var(--s-ease-out);
54
+ background: oklch(0% 0 0 / .5);
55
+
56
+ @supports (color: oklch(from red l c h)) {
57
+ background: oklch(from var(--s-primary-500) .1 .02 h / .5);
58
+ }
59
+ }
60
+
61
+ @keyframes s-modal-backdrop-in {
62
+ from {
63
+ opacity: 0;
64
+ }
65
+
66
+ to {
67
+ opacity: 1;
68
+ }
69
+ }
70
+
71
+ dialog[s-modal][s-size="sm"] {
72
+ --_modal-max-width: 25rem;
73
+ }
74
+
75
+ dialog[s-modal][s-size="lg"] {
76
+ --_modal-max-width: 43.75rem;
77
+ }
78
+
79
+ dialog[s-modal][s-size="full"] {
80
+ --_modal-max-width: 100vw;
81
+ --_modal-radius: 0;
82
+ width: 100vw;
83
+ height: 100vh;
84
+ max-height: 100vh;
85
+ }
86
+
87
+ dialog[s-modal][s-position="top"] {
88
+ margin-top: var(--s-space-8);
89
+ margin-bottom: auto;
90
+ }
91
+
92
+ dialog[s-modal][s-position="bottom"] {
93
+ margin-top: auto;
94
+ margin-bottom: var(--s-space-8);
95
+ }
96
+
97
+ dialog[s-modal][s-position="left"] {
98
+ border-radius: 0 var(--_modal-radius) var(--_modal-radius) 0;
99
+ margin-left: 0;
100
+ margin-right: auto;
101
+ }
102
+
103
+ @media (width >= 640px) {
104
+ dialog[s-modal][s-position="left"] {
105
+ margin-left: var(--s-space-8);
106
+ border-radius: var(--_modal-radius);
107
+ }
108
+ }
109
+
110
+ dialog[s-modal][s-position="right"] {
111
+ border-radius: var(--_modal-radius) 0 0 var(--_modal-radius);
112
+ margin-left: auto;
113
+ margin-right: 0;
114
+ }
115
+
116
+ @media (width >= 640px) {
117
+ dialog[s-modal][s-position="right"] {
118
+ margin-right: var(--s-space-8);
119
+ border-radius: var(--_modal-radius);
120
+ }
121
+ }
122
+
123
+ :where([s-modal-header]) {
124
+ justify-content: space-between;
125
+ align-items: center;
126
+ gap: var(--s-space-4);
127
+ padding: var(--_modal-padding, var(--s-space-4));
128
+ border-bottom: 1px solid var(--s-border-muted);
129
+ display: flex;
130
+
131
+ & > h1, & > h2, & > h3 {
132
+ font-size: var(--s-text-lg);
133
+ font-weight: var(--s-font-semibold);
134
+ color: inherit;
135
+ margin: 0;
136
+ line-height: 1.25;
137
+ }
138
+ }
139
+
140
+ :where([s-modal-body]) {
141
+ padding: var(--_modal-padding, var(--s-space-4));
142
+ overscroll-behavior: contain;
143
+ flex: 1;
144
+ overflow-y: auto;
145
+ }
146
+
147
+ :where([s-modal-footer]) {
148
+ justify-content: flex-end;
149
+ align-items: center;
150
+ gap: var(--s-space-3);
151
+ padding: var(--_modal-padding, var(--s-space-4));
152
+ border-top: 1px solid var(--s-border-muted);
153
+ display: flex;
154
+ }
155
+
156
+ :where([s-modal-close]) {
157
+ cursor: pointer;
158
+ border-radius: var(--s-radius-full);
159
+ min-width: 2.75rem;
160
+ min-height: 2.75rem;
161
+ font-size: var(--s-text-xl);
162
+ color: var(--s-text-secondary);
163
+ transition: background-color var(--s-duration-150) var(--s-ease-out), color var(--s-duration-150) var(--s-ease-out);
164
+ background: none;
165
+ border: none;
166
+ justify-content: center;
167
+ align-items: center;
168
+ padding: 0;
169
+ line-height: 1;
170
+ display: inline-flex;
171
+
172
+ &:hover {
173
+ background-color: var(--s-surface-sunken);
174
+ color: var(--s-text-primary);
175
+ }
176
+
177
+ &:focus-visible {
178
+ outline: 2px solid var(--s-focus-ring);
179
+ outline-offset: 2px;
180
+ }
181
+
182
+ &:active {
183
+ background-color: var(--s-border-default);
184
+ }
185
+ }
186
+
187
+ @media (forced-colors: active) {
188
+ dialog[s-modal] {
189
+ border: 2px solid canvastext;
190
+ }
191
+
192
+ dialog[s-modal]::backdrop {
193
+ backdrop-filter: none;
194
+ background: #000000bf;
195
+ }
196
+
197
+ [s-modal-header], [s-modal-footer] {
198
+ border-color: canvastext;
199
+ }
200
+
201
+ [s-modal-close] {
202
+ border: 1px solid buttontext;
203
+ }
204
+ }