@mirrordown/remd-tabs 0.0.0 → 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/dist/tabs.css ADDED
@@ -0,0 +1,369 @@
1
+ /*
2
+ Markdown Tabs — default stylesheet
3
+ ------------------------------------
4
+ All rules live inside @layer markdown-tabs so any unlayered consumer CSS
5
+ overrides them without needing !important.
6
+
7
+ Color tokens use light-dark() so they respond to the nearest `color-scheme`
8
+ ancestor. Set `color-scheme: light`, `color-scheme: dark`, or
9
+ `color-scheme: light dark` on :root (or a container) to control the mode.
10
+
11
+ To override public tokens, set them on .markdown-tabs or any ancestor:
12
+
13
+ .markdown-tabs { --markdown-tabs-accent: oklch(0.55 0.18 145); }
14
+
15
+ Panel switching uses two strategies, layered with @supports:
16
+
17
+ 1. Baseline (all :has() browsers): explicit :nth-of-type(N) rules for N=1–12.
18
+ 2. Enhanced (Chrome 138+, Safari 26.2+): sibling-index() inside :nth-of-type()
19
+ allows arbitrary tab counts with a single rule pair, replacing the N×2 block.
20
+ */
21
+
22
+ @layer markdown-tabs {
23
+ /* ── Container ──────────────────────────────────────────────────────────── */
24
+
25
+ .markdown-tabs {
26
+ --_tabs-accent: var(
27
+ --markdown-tabs-accent,
28
+ light-dark(oklch(0.55 0.15 250), oklch(0.68 0.17 250))
29
+ );
30
+ --_tabs-bg: var(--markdown-tabs-bg, transparent);
31
+ --_tabs-border: var(
32
+ --markdown-tabs-border,
33
+ light-dark(oklch(0.88 0.01 250), oklch(0.3 0.03 250))
34
+ );
35
+ --_tabs-label-color: var(--markdown-tabs-label-color, inherit);
36
+ --_tabs-label-hover-color: var(--markdown-tabs-label-hover-color, inherit);
37
+ --_tabs-label-active-color: var(
38
+ --markdown-tabs-label-active-color,
39
+ var(--_tabs-accent)
40
+ );
41
+ --_tabs-radius: var(--markdown-tabs-radius, 0.375rem);
42
+ --_tabs-strip-bg: var(--markdown-tabs-strip-bg, transparent);
43
+ --_tabs-hover-bg: var(
44
+ --markdown-tabs-hover-bg,
45
+ light-dark(oklch(0.88 0.04 250 / 0.8), oklch(0.32 0.05 250 / 0.7))
46
+ );
47
+
48
+ margin-block: 1rem;
49
+ border: 1px solid var(--_tabs-border);
50
+ border-radius: var(--_tabs-radius);
51
+ background: var(--_tabs-bg);
52
+ overflow: hidden;
53
+ }
54
+
55
+ /* ── Label strip ────────────────────────────────────────────────────────── */
56
+
57
+ .markdown-tabs-labels {
58
+ position: relative;
59
+ display: flex;
60
+ overflow-x: auto;
61
+ overflow-y: hidden;
62
+ background-color: var(--_tabs-strip-bg);
63
+ box-shadow: inset 0 -1px var(--_tabs-border);
64
+ }
65
+
66
+ /* Hide radio inputs without removing them from the DOM (needed for :has()) */
67
+ .markdown-tabs-labels input[type="radio"] {
68
+ position: fixed;
69
+ opacity: 0;
70
+ pointer-events: none;
71
+ }
72
+
73
+ /* ── Tab labels ─────────────────────────────────────────────────────────── */
74
+
75
+ label.markdown-tabs-label {
76
+ position: relative;
77
+ display: inline-flex;
78
+ align-items: center;
79
+ gap: 0.5rem;
80
+ padding: 0 0.75rem;
81
+ line-height: 3rem;
82
+ font-size: 0.875rem;
83
+ font-weight: 500;
84
+ color: var(--_tabs-label-color);
85
+ white-space: nowrap;
86
+ cursor: pointer;
87
+ user-select: none;
88
+ transition: color 0.25s ease;
89
+
90
+ &:hover {
91
+ color: var(--_tabs-label-hover-color);
92
+ }
93
+
94
+ /* Active indicator bar (pseudo-element on each label) */
95
+ &::after {
96
+ content: "";
97
+ position: absolute;
98
+ inset-inline: 0.5rem;
99
+ bottom: -1px;
100
+ height: 2px;
101
+ border-radius: 2px;
102
+ background-color: transparent;
103
+ transition: background-color 0.25s ease;
104
+ }
105
+ }
106
+
107
+ /* ── Follow-the-leader hover pill (CSS Anchor Positioning) ──────────────── */
108
+ /*
109
+ Requires: Chrome 125+, Edge 125+, Firefox 147+, Safari 26+.
110
+ Falls back to bare color change on hover in older browsers (no @supports guard
111
+ needed — anchor-name is simply ignored by non-supporting engines).
112
+
113
+ Each label registers itself as --tabs-hover when hovered. anchor-scope on the
114
+ strip limits visibility to that strip so multiple tab groups on the same page
115
+ don't interfere with each other. The ::before pill on the strip follows the
116
+ active anchor with position:absolute + anchor() coordinates.
117
+ */
118
+
119
+ @supports (anchor-name: --x) {
120
+ .markdown-tabs-labels {
121
+ anchor-scope: --tabs-hover;
122
+
123
+ &::before {
124
+ content: "";
125
+ position: absolute;
126
+ position-anchor: --tabs-hover;
127
+ top: anchor(top);
128
+ bottom: anchor(bottom);
129
+ left: anchor(left);
130
+ right: anchor(right);
131
+ background-color: var(--_tabs-hover-bg);
132
+ border-radius: var(--_tabs-radius);
133
+ pointer-events: none;
134
+ opacity: 0;
135
+ transition:
136
+ top 0.2s ease,
137
+ left 0.2s ease,
138
+ right 0.2s ease,
139
+ bottom 0.2s ease,
140
+ opacity 0.15s ease;
141
+ }
142
+
143
+ &:has(label:hover)::before {
144
+ opacity: 1;
145
+ }
146
+ }
147
+
148
+ label.markdown-tabs-label:hover {
149
+ anchor-name: --tabs-hover;
150
+ }
151
+ }
152
+
153
+ /* ── Panels ─────────────────────────────────────────────────────────────── */
154
+
155
+ .markdown-tabs-panels {
156
+ border-block-start: 1px solid var(--_tabs-border);
157
+ }
158
+
159
+ .markdown-tabs-panel {
160
+ display: none;
161
+ padding: 1.25rem 1.5rem;
162
+
163
+ > :first-child {
164
+ margin-block-start: 0;
165
+ }
166
+ > :last-child {
167
+ margin-block-end: 0;
168
+ }
169
+ }
170
+
171
+ /* ── Active tab — baseline: explicit :nth-of-type(N) for N = 1–12 ──────── */
172
+ /*
173
+ Supports up to 12 tabs per group. The :has() selector is Baseline 2024.
174
+ Browsers that support sibling-index() will use the @supports block below
175
+ instead, which handles any number of tabs.
176
+ */
177
+
178
+ .markdown-tabs:has(> .markdown-tabs-labels input:nth-of-type(1):checked) {
179
+ & > .markdown-tabs-labels > label.markdown-tabs-label:nth-of-type(1) {
180
+ color: var(--_tabs-label-active-color);
181
+ &::after {
182
+ background-color: var(--_tabs-accent);
183
+ }
184
+ }
185
+ & > .markdown-tabs-panels > .markdown-tabs-panel:nth-of-type(1) {
186
+ display: block;
187
+ }
188
+ }
189
+ .markdown-tabs:has(> .markdown-tabs-labels input:nth-of-type(2):checked) {
190
+ & > .markdown-tabs-labels > label.markdown-tabs-label:nth-of-type(2) {
191
+ color: var(--_tabs-label-active-color);
192
+ &::after {
193
+ background-color: var(--_tabs-accent);
194
+ }
195
+ }
196
+ & > .markdown-tabs-panels > .markdown-tabs-panel:nth-of-type(2) {
197
+ display: block;
198
+ }
199
+ }
200
+ .markdown-tabs:has(> .markdown-tabs-labels input:nth-of-type(3):checked) {
201
+ & > .markdown-tabs-labels > label.markdown-tabs-label:nth-of-type(3) {
202
+ color: var(--_tabs-label-active-color);
203
+ &::after {
204
+ background-color: var(--_tabs-accent);
205
+ }
206
+ }
207
+ & > .markdown-tabs-panels > .markdown-tabs-panel:nth-of-type(3) {
208
+ display: block;
209
+ }
210
+ }
211
+ .markdown-tabs:has(> .markdown-tabs-labels input:nth-of-type(4):checked) {
212
+ & > .markdown-tabs-labels > label.markdown-tabs-label:nth-of-type(4) {
213
+ color: var(--_tabs-label-active-color);
214
+ &::after {
215
+ background-color: var(--_tabs-accent);
216
+ }
217
+ }
218
+ & > .markdown-tabs-panels > .markdown-tabs-panel:nth-of-type(4) {
219
+ display: block;
220
+ }
221
+ }
222
+ .markdown-tabs:has(> .markdown-tabs-labels input:nth-of-type(5):checked) {
223
+ & > .markdown-tabs-labels > label.markdown-tabs-label:nth-of-type(5) {
224
+ color: var(--_tabs-label-active-color);
225
+ &::after {
226
+ background-color: var(--_tabs-accent);
227
+ }
228
+ }
229
+ & > .markdown-tabs-panels > .markdown-tabs-panel:nth-of-type(5) {
230
+ display: block;
231
+ }
232
+ }
233
+ .markdown-tabs:has(> .markdown-tabs-labels input:nth-of-type(6):checked) {
234
+ & > .markdown-tabs-labels > label.markdown-tabs-label:nth-of-type(6) {
235
+ color: var(--_tabs-label-active-color);
236
+ &::after {
237
+ background-color: var(--_tabs-accent);
238
+ }
239
+ }
240
+ & > .markdown-tabs-panels > .markdown-tabs-panel:nth-of-type(6) {
241
+ display: block;
242
+ }
243
+ }
244
+ .markdown-tabs:has(> .markdown-tabs-labels input:nth-of-type(7):checked) {
245
+ & > .markdown-tabs-labels > label.markdown-tabs-label:nth-of-type(7) {
246
+ color: var(--_tabs-label-active-color);
247
+ &::after {
248
+ background-color: var(--_tabs-accent);
249
+ }
250
+ }
251
+ & > .markdown-tabs-panels > .markdown-tabs-panel:nth-of-type(7) {
252
+ display: block;
253
+ }
254
+ }
255
+ .markdown-tabs:has(> .markdown-tabs-labels input:nth-of-type(8):checked) {
256
+ & > .markdown-tabs-labels > label.markdown-tabs-label:nth-of-type(8) {
257
+ color: var(--_tabs-label-active-color);
258
+ &::after {
259
+ background-color: var(--_tabs-accent);
260
+ }
261
+ }
262
+ & > .markdown-tabs-panels > .markdown-tabs-panel:nth-of-type(8) {
263
+ display: block;
264
+ }
265
+ }
266
+ .markdown-tabs:has(> .markdown-tabs-labels input:nth-of-type(9):checked) {
267
+ & > .markdown-tabs-labels > label.markdown-tabs-label:nth-of-type(9) {
268
+ color: var(--_tabs-label-active-color);
269
+ &::after {
270
+ background-color: var(--_tabs-accent);
271
+ }
272
+ }
273
+ & > .markdown-tabs-panels > .markdown-tabs-panel:nth-of-type(9) {
274
+ display: block;
275
+ }
276
+ }
277
+ .markdown-tabs:has(> .markdown-tabs-labels input:nth-of-type(10):checked) {
278
+ & > .markdown-tabs-labels > label.markdown-tabs-label:nth-of-type(10) {
279
+ color: var(--_tabs-label-active-color);
280
+ &::after {
281
+ background-color: var(--_tabs-accent);
282
+ }
283
+ }
284
+ & > .markdown-tabs-panels > .markdown-tabs-panel:nth-of-type(10) {
285
+ display: block;
286
+ }
287
+ }
288
+ .markdown-tabs:has(> .markdown-tabs-labels input:nth-of-type(11):checked) {
289
+ & > .markdown-tabs-labels > label.markdown-tabs-label:nth-of-type(11) {
290
+ color: var(--_tabs-label-active-color);
291
+ &::after {
292
+ background-color: var(--_tabs-accent);
293
+ }
294
+ }
295
+ & > .markdown-tabs-panels > .markdown-tabs-panel:nth-of-type(11) {
296
+ display: block;
297
+ }
298
+ }
299
+ .markdown-tabs:has(> .markdown-tabs-labels input:nth-of-type(12):checked) {
300
+ & > .markdown-tabs-labels > label.markdown-tabs-label:nth-of-type(12) {
301
+ color: var(--_tabs-label-active-color);
302
+ &::after {
303
+ background-color: var(--_tabs-accent);
304
+ }
305
+ }
306
+ & > .markdown-tabs-panels > .markdown-tabs-panel:nth-of-type(12) {
307
+ display: block;
308
+ }
309
+ }
310
+
311
+ /* ── Active tab — enhanced: sibling-index() for arbitrary tab counts ────── */
312
+ /*
313
+ sibling-index() resolves to each element's 1-based position among its
314
+ siblings. Used inside :nth-of-type() in a :has() argument, it lets a single
315
+ rule pair activate the correct label and panel for any number of tabs.
316
+
317
+ Supported: Chrome 138+, Edge 138+, Safari 26.2+
318
+ Not yet supported: Firefox (all versions as of 2026)
319
+
320
+ The @supports block overrides the baseline N×2 rules above for browsers
321
+ that understand sibling-index().
322
+ */
323
+
324
+ @supports (width: calc(1px * sibling-index())) {
325
+ .markdown-tabs-labels > label.markdown-tabs-label {
326
+ &:is(
327
+ .markdown-tabs:has(
328
+ > .markdown-tabs-labels input:nth-of-type(sibling-index()):checked
329
+ )
330
+ > .markdown-tabs-labels
331
+ > *
332
+ ) {
333
+ color: var(--_tabs-label-active-color);
334
+ &::after {
335
+ background-color: var(--_tabs-accent);
336
+ }
337
+ }
338
+ }
339
+
340
+ .markdown-tabs-panels > .markdown-tabs-panel {
341
+ &:is(
342
+ .markdown-tabs:has(
343
+ > .markdown-tabs-labels input:nth-of-type(sibling-index()):checked
344
+ )
345
+ > .markdown-tabs-panels
346
+ > *
347
+ ) {
348
+ display: block;
349
+ }
350
+ }
351
+ }
352
+
353
+ /* ── Nested tab groups ──────────────────────────────────────────────────── */
354
+
355
+ .markdown-tabs-panel > .markdown-tabs {
356
+ margin-block: 0;
357
+ }
358
+
359
+ /* ── Reduced motion ─────────────────────────────────────────────────────── */
360
+
361
+ @media (prefers-reduced-motion: reduce) {
362
+ label.markdown-tabs-label {
363
+ transition: none;
364
+ &::after {
365
+ transition: none;
366
+ }
367
+ }
368
+ }
369
+ }
package/package.json CHANGED
@@ -1,10 +1,44 @@
1
1
  {
2
2
  "name": "@mirrordown/remd-tabs",
3
- "version": "0.0.0",
3
+ "version": "0.1.0",
4
4
  "license": "MIT",
5
5
  "author": "Drake Costa <drake@saeris.io> (https://saeris.gg)",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/mirrordown/mirrordown.git"
9
+ },
10
+ "style": "./dist/tabs.css",
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "type": "module",
15
+ "exports": {
16
+ ".": {
17
+ "development": "./src/index.ts",
18
+ "types": "./dist/index.d.mts",
19
+ "import": "./dist/index.mjs"
20
+ },
21
+ "./*.css": "./dist/*.css"
22
+ },
23
+ "dependencies": {
24
+ "unist-util-visit": "catalog:"
25
+ },
26
+ "devDependencies": {
27
+ "@types/hast": "catalog:",
28
+ "@types/mdast": "catalog:",
29
+ "unified": "catalog:"
30
+ },
31
+ "peerDependencies": {
32
+ "unified": "^11.0.0"
33
+ },
34
+ "engines": {
35
+ "node": ">=24.0.0"
36
+ },
37
+ "bumpy": {
38
+ "buildCommand": "vp pack",
39
+ "publishCommand": [
40
+ "node ../../scripts/sync-jsr-version.mjs",
41
+ "npm publish --access public"
42
+ ]
9
43
  }
10
44
  }