@akonwi/mica 0.4.0 → 0.5.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/drawer.js CHANGED
@@ -16,7 +16,7 @@
16
16
  const SHEET = matchMedia("(max-width: 40rem)");
17
17
  const CLOSE_DISTANCE = 1 / 3; // of sheet height
18
18
  const CLOSE_VELOCITY = 0.6; // px/ms, downward flick
19
- const DRAWER = "dialog:is([data-drawer], .drawer)";
19
+ const DRAWER = "dialog[data-drawer]";
20
20
 
21
21
  document.documentElement.setAttribute("data-drawer-gestures", "");
22
22
 
package/mica.css CHANGED
@@ -298,8 +298,7 @@
298
298
  background: var(--neutral-4);
299
299
  }
300
300
 
301
- /* Class selectors remain aliases for the former class-based API. */
302
- &:where([data-variant="primary"], .primary) {
301
+ &:where([data-variant="primary"]) {
303
302
  background: var(--color-primary);
304
303
  border-color: transparent;
305
304
  color: var(--color-on-primary);
@@ -316,7 +315,7 @@
316
315
  secondary button when primary is near-black */
317
316
  }
318
317
 
319
- &:where([data-variant="danger"], .danger) {
318
+ &:where([data-variant="danger"]) {
320
319
  background: var(--color-danger);
321
320
  border-color: transparent;
322
321
  color: var(--color-on-danger);
@@ -335,7 +334,7 @@
335
334
  /* deliberately zero rest affordance — a ghost is invisible until
336
335
  hover/focus. use data-variant="ghost" for toolbars and icon rows,
337
336
  not as the lone action on a page. */
338
- &:where([data-variant="ghost"], .ghost) {
337
+ &:where([data-variant="ghost"]) {
339
338
  background: transparent;
340
339
  border-color: transparent;
341
340
 
@@ -348,11 +347,11 @@
348
347
  }
349
348
 
350
349
  /* sizes (shadcn: h-8 px-3 / h-10 px-6, text-sm throughout) */
351
- &:where([data-size="small"], .small) {
350
+ &:where([data-size="small"]) {
352
351
  block-size: var(--control-height-sm);
353
352
  padding-inline: var(--space-sm);
354
353
  }
355
- &:where([data-size="large"], .large) {
354
+ &:where([data-size="large"]) {
356
355
  block-size: var(--control-height-lg);
357
356
  padding-inline: var(--space-lg);
358
357
  }
@@ -572,7 +571,7 @@
572
571
  }
573
572
  }
574
573
 
575
- :where(input[type="checkbox"]:not(.switch, [role="switch"])) {
574
+ :where(input[type="checkbox"]:not([role="switch"])) {
576
575
  &:checked {
577
576
  background-image: var(--check-glyph);
578
577
  }
@@ -668,9 +667,8 @@
668
667
 
669
668
  /* switch: a checkbox wearing a track; the thumb is a positioned
670
669
  gradient (pseudo-elements don't render on inputs). square, per the
671
- design language — a solid linear-gradient block. .switch remains
672
- an alias for the former class-based API. */
673
- :where(input[type="checkbox"]:is([role="switch"], .switch)) {
670
+ design language — a solid linear-gradient block. */
671
+ :where(input[type="checkbox"][role="switch"]) {
674
672
  inline-size: 2.25rem;
675
673
  border-color: transparent;
676
674
  border-radius: var(--radius-sm);
@@ -691,8 +689,8 @@
691
689
  }
692
690
 
693
691
  /* disabled + on: desaturate toward neutral, same recipe as disabled
694
- .primary buttons — inert, not just faded (placed after the switch
695
- block so it wins its background-color at equal specificity) */
692
+ data-variant="primary" buttons — inert, not just faded (placed after
693
+ the switch block so it wins its background-color at equal specificity) */
696
694
  :where(input:is([type="checkbox"], [type="radio"])):disabled:is(
697
695
  :checked,
698
696
  :indeterminate
@@ -1082,9 +1080,8 @@
1082
1080
 
1083
1081
  /* drawer (shadcn sheet anatomy): inline-end panel, fade + 2.5rem
1084
1082
  nudge rather than a full slide; no section dividers; footer pinned
1085
- to the bottom with stacked actions. .drawer remains an alias for
1086
- the former class-based API. */
1087
- :where(dialog[data-drawer], dialog.drawer) {
1083
+ to the bottom with stacked actions. */
1084
+ :where(dialog[data-drawer]) {
1088
1085
  margin-inline: auto 0;
1089
1086
  margin-block: 0;
1090
1087
  /* full height WITHOUT an explicit block-size: the UA gives
@@ -1104,24 +1101,23 @@
1104
1101
  scale: 1;
1105
1102
  translate: 2.5rem 0;
1106
1103
  }
1107
- :where(dialog[data-drawer][open], dialog.drawer[open]) {
1104
+ :where(dialog[data-drawer][open]) {
1108
1105
  translate: 0 0;
1109
1106
  }
1110
1107
  /* unconditional (survives the exit, like the rest of composition) */
1111
- :where(dialog[data-drawer], dialog.drawer)
1112
- > :where(:not(header, footer, button.close)) {
1108
+ :where(dialog[data-drawer]) > :where(:not(header, footer, button.close)) {
1113
1109
  font-size: inherit; /* panel runs 12/relaxed throughout */
1114
1110
  }
1115
1111
  @starting-style {
1116
- :where(dialog[data-drawer][open], dialog.drawer[open]) {
1112
+ :where(dialog[data-drawer][open]) {
1117
1113
  translate: 2.5rem 0;
1118
1114
  }
1119
1115
  }
1120
1116
 
1121
- :where(dialog[data-drawer], dialog.drawer) > :where(header) {
1117
+ :where(dialog[data-drawer]) > :where(header) {
1122
1118
  border-block-end: 0;
1123
1119
  }
1124
- :where(dialog[data-drawer], dialog.drawer) > :where(footer) {
1120
+ :where(dialog[data-drawer]) > :where(footer) {
1125
1121
  margin-block-start: auto;
1126
1122
  flex-direction: column;
1127
1123
  align-items: stretch;
@@ -1136,7 +1132,7 @@
1136
1132
  nav bars). Explicit 100svh gapped behind the collapsed toolbar and
1137
1133
  100dvh lagged in the top layer — don't reintroduce heights here. */
1138
1134
  @media (max-width: 40rem) {
1139
- :where(dialog[data-drawer], dialog.drawer) {
1135
+ :where(dialog[data-drawer]) {
1140
1136
  inset-block: auto 0; /* release the UA's top anchor… */
1141
1137
  margin-block: 0; /* …so height resolves from content */
1142
1138
  block-size: auto; /* content height, like vaul */
@@ -1167,14 +1163,14 @@
1167
1163
  translate: 0 100%;
1168
1164
  opacity: 1;
1169
1165
  }
1170
- :where(dialog[data-drawer][open], dialog.drawer[open]) {
1166
+ :where(dialog[data-drawer][open]) {
1171
1167
  translate: 0 0;
1172
1168
  box-shadow:
1173
1169
  0 4rem 0 0 var(--color-surface-overlay),
1174
1170
  0 0 0 100vmax oklch(0 0 0 / 0.4);
1175
1171
  }
1176
1172
  @starting-style {
1177
- :where(dialog[data-drawer][open], dialog.drawer[open]) {
1173
+ :where(dialog[data-drawer][open]) {
1178
1174
  translate: 0 100%;
1179
1175
  box-shadow:
1180
1176
  0 4rem 0 0 var(--color-surface-overlay),
@@ -1183,7 +1179,7 @@
1183
1179
  }
1184
1180
  /* the box-shadow scrim replaces ::backdrop here; keep the native
1185
1181
  backdrop clear so they don't double up or flash on the iOS cut. */
1186
- :where(dialog[data-drawer][open], dialog.drawer[open])::backdrop {
1182
+ :where(dialog[data-drawer][open])::backdrop {
1187
1183
  background: oklch(0 0 0 / 0);
1188
1184
  }
1189
1185
 
@@ -1191,7 +1187,7 @@
1191
1187
  without its behavior would fake interactivity; TIERS.md).
1192
1188
  the handle is the first flex item of the open sheet. */
1193
1189
  :where(:root[data-drawer-gestures])
1194
- :where(dialog[data-drawer][open], dialog.drawer[open])::before {
1190
+ :where(dialog[data-drawer][open])::before {
1195
1191
  content: "";
1196
1192
  align-self: center;
1197
1193
  flex-shrink: 0;
@@ -1202,7 +1198,7 @@
1202
1198
  border-radius: var(--radius-full);
1203
1199
  }
1204
1200
  :where(:root[data-drawer-gestures])
1205
- :where(dialog[data-drawer], dialog.drawer) > :where(header) {
1201
+ :where(dialog[data-drawer]) > :where(header) {
1206
1202
  touch-action: none; /* the drag surface must own its touches */
1207
1203
  }
1208
1204
  }
@@ -1363,7 +1359,7 @@
1363
1359
  color: var(--color-on-accent);
1364
1360
  }
1365
1361
 
1366
- &:is([data-variant="danger"], .danger) {
1362
+ &:is([data-variant="danger"]) {
1367
1363
  color: var(--color-danger-text);
1368
1364
 
1369
1365
  &:hover:not(:disabled, [aria-disabled="true"]),
@@ -1508,14 +1504,13 @@
1508
1504
  color: var(--color-text-muted);
1509
1505
  }
1510
1506
 
1511
- /* Status classes remain aliases for the former class-based API. */
1512
- &:where([data-variant="success"], .success) {
1507
+ &:where([data-variant="success"]) {
1513
1508
  border-inline-start: 2px solid var(--color-success);
1514
1509
  }
1515
- &:where([data-variant="danger"], .danger) {
1510
+ &:where([data-variant="danger"]) {
1516
1511
  border-inline-start: 2px solid var(--color-danger);
1517
1512
  }
1518
- &:where([data-variant="warning"], .warn) {
1513
+ &:where([data-variant="warning"]) {
1519
1514
  border-inline-start: 2px solid var(--color-warn);
1520
1515
  }
1521
1516
  }
@@ -1893,11 +1888,9 @@
1893
1888
 
1894
1889
  & > * { margin-block: 0; }
1895
1890
 
1896
- & > :is(h1, [data-principal], .principal) { margin-block: auto; }
1891
+ & > :is(h1, [data-principal]) { margin-block: auto; }
1897
1892
 
1898
- /* An explicit marker wins over the h1 default. .principal remains
1899
- an alias for the former class-based API. */
1900
- &:has(> :is([data-principal], .principal))
1901
- > h1:not([data-principal], .principal) { margin-block: 0; }
1893
+ /* An explicit marker wins over the h1 default. */
1894
+ &:has(> [data-principal]) > h1:not([data-principal]) { margin-block: 0; }
1902
1895
  }
1903
1896
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akonwi/mica",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Custom elements. Native behavior. Nearly no JavaScript.",
5
5
  "keywords": [
6
6
  "css",
package/toast.js CHANGED
@@ -77,12 +77,8 @@ document.addEventListener(
77
77
  export function toast(title, { description = "", variant = "", duration } = {}) {
78
78
  const el = document.createElement("div");
79
79
  el.popover = "manual";
80
- // Keep the generated class for consumers of the former API while
81
- // emitting the attribute vocabulary used by declared toasts.
82
- el.className = `toast${variant ? ` ${variant}` : ""}`;
83
- if (variant) {
84
- el.setAttribute("data-variant", variant === "warn" ? "warning" : variant);
85
- }
80
+ el.className = "toast";
81
+ if (variant) el.setAttribute("data-variant", variant);
86
82
  el.setAttribute("role", "status");
87
83
  el.dataset.ephemeral = "";
88
84
  if (duration !== undefined) el.setAttribute("data-duration", String(duration));