|
| 1 | +--- |
| 2 | +import { processSteps } from "./rehype-steps" |
| 3 | +
|
| 4 | +const content = await Astro.slots.render("default") |
| 5 | +const { html } = processSteps(content) |
| 6 | +--- |
| 7 | + |
| 8 | +<Fragment set:html={html} /> |
| 9 | + |
| 10 | +<style is:global> |
| 11 | + .sl-steps { |
| 12 | + --bullet-size: calc(1.75 * 1rem); |
| 13 | + --bullet-margin: 0.375rem; |
| 14 | + |
| 15 | + list-style: none; |
| 16 | + counter-reset: steps-counter var(--sl-steps-start, 0); |
| 17 | + padding-inline-start: 0; |
| 18 | + } |
| 19 | + |
| 20 | + .sl-steps > li { |
| 21 | + counter-increment: steps-counter; |
| 22 | + position: relative; |
| 23 | + padding-inline-start: calc(var(--bullet-size) + 1rem); |
| 24 | + /* HACK: Keeps any `margin-bottom` inside the `<li>`’s padding box to avoid gaps in the hairline border. */ |
| 25 | + padding-bottom: 1px; |
| 26 | + /* Prevent bullets from touching in short list items. */ |
| 27 | + min-height: calc(var(--bullet-size) + var(--bullet-margin)); |
| 28 | + } |
| 29 | + .sl-steps > li + li { |
| 30 | + /* Remove margin between steps. */ |
| 31 | + margin-top: 0; |
| 32 | + } |
| 33 | + |
| 34 | + /* Custom list marker element. */ |
| 35 | + .sl-steps > li::before { |
| 36 | + content: counter(steps-counter); |
| 37 | + position: absolute; |
| 38 | + top: 0; |
| 39 | + inset-inline-start: 0; |
| 40 | + width: var(--bullet-size); |
| 41 | + height: var(--bullet-size); |
| 42 | + line-height: var(--bullet-size); |
| 43 | + |
| 44 | + font-size: var(--sl-text-xs); |
| 45 | + font-weight: 600; |
| 46 | + text-align: center; |
| 47 | + color: hsl(0, 0%, 100%); |
| 48 | + background-color: hsl(224, 14%, 16%); |
| 49 | + border-radius: 99rem; |
| 50 | + box-shadow: inset 0 0 0 1px hsl(224, 10%, 23%); |
| 51 | + } |
| 52 | + |
| 53 | + /* Vertical guideline linking list numbers. */ |
| 54 | + .sl-steps > li:not(:last-of-type)::after { |
| 55 | + --guide-width: 1px; |
| 56 | + content: ""; |
| 57 | + position: absolute; |
| 58 | + top: calc(var(--bullet-size) + var(--bullet-margin)); |
| 59 | + bottom: var(--bullet-margin); |
| 60 | + inset-inline-start: calc((var(--bullet-size) - var(--guide-width)) / 2); |
| 61 | + width: var(--guide-width); |
| 62 | + background-color: #24262e; |
| 63 | + } |
| 64 | + |
| 65 | + /* Adjust first item inside a step so that it aligns vertically with the number |
| 66 | + even if using a larger font size (e.g. a heading) */ |
| 67 | + .sl-steps > li > :first-child { |
| 68 | + /* |
| 69 | + The `lh` unit is not yet supported by all browsers in our support matrix |
| 70 | + — see https://caniuse.com/mdn-css_types_length_lh |
| 71 | + In unsupported browsers we approximate this using our known line-heights. |
| 72 | + */ |
| 73 | + --lh: calc(1em * var(--sl-line-height)); |
| 74 | + --shift-y: calc(0.5 * (var(--bullet-size) - var(--lh))); |
| 75 | + transform: translateY(var(--shift-y)); |
| 76 | + margin-bottom: var(--shift-y); |
| 77 | + } |
| 78 | + .sl-steps > li > :first-child:where(h1, h2, h3, h4, h5, h6) { |
| 79 | + --lh: calc(1em * var(--sl-line-height-headings)); |
| 80 | + } |
| 81 | + @supports (--prop: 1lh) { |
| 82 | + .sl-steps > li > :first-child { |
| 83 | + --lh: 1lh; |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + .sl-steps .expressive-code { |
| 88 | + margin-top: 1rem; |
| 89 | + margin-bottom: 1.25rem; |
| 90 | + } |
| 91 | +</style> |
0 commit comments