|
| 1 | +--- |
| 2 | +import { ChevronDown } from "@lucide/astro"; |
| 3 | +
|
| 4 | +interface Props { |
| 5 | + title: string; |
| 6 | + open?: boolean; |
| 7 | +} |
| 8 | +
|
| 9 | +const { title, open = false } = Astro.props; |
| 10 | +--- |
| 11 | + |
| 12 | +<div class="conversation-wrapper not-content"> |
| 13 | + <details class="conversation" open={open}> |
| 14 | + <summary> |
| 15 | + <span class="summary-label">Example conversation</span> |
| 16 | + <span class="summary-title">{title}</span> |
| 17 | + <ChevronDown class="chevron" aria-hidden="true" size={20} /> |
| 18 | + </summary> |
| 19 | + <div class="conversation-body"> |
| 20 | + <slot /> |
| 21 | + </div> |
| 22 | + </details> |
| 23 | +</div> |
| 24 | + |
| 25 | +<style> |
| 26 | + .conversation-wrapper { |
| 27 | + margin-block: 1.5rem; |
| 28 | + } |
| 29 | + |
| 30 | + .conversation { |
| 31 | + border: 1px solid var(--sl-color-gray-5); |
| 32 | + border-radius: 0.75rem; |
| 33 | + background: var(--sl-color-bg-nav); |
| 34 | + overflow: hidden; |
| 35 | + } |
| 36 | + |
| 37 | + summary { |
| 38 | + display: grid; |
| 39 | + grid-template-columns: 1fr auto; |
| 40 | + gap: 0.15rem 1rem; |
| 41 | + align-items: center; |
| 42 | + padding: 1rem 1.125rem; |
| 43 | + cursor: pointer; |
| 44 | + list-style: none; |
| 45 | + } |
| 46 | + |
| 47 | + summary::-webkit-details-marker { |
| 48 | + display: none; |
| 49 | + } |
| 50 | + |
| 51 | + summary:hover { |
| 52 | + background: var(--sl-color-gray-7); |
| 53 | + } |
| 54 | + |
| 55 | + summary:focus-visible { |
| 56 | + outline: 2px solid var(--sl-color-accent-high); |
| 57 | + outline-offset: -2px; |
| 58 | + } |
| 59 | + |
| 60 | + .summary-label { |
| 61 | + color: var(--sl-color-gray-3); |
| 62 | + font-size: var(--sl-text-xs); |
| 63 | + font-weight: 600; |
| 64 | + letter-spacing: 0.04em; |
| 65 | + line-height: 1.3; |
| 66 | + text-transform: uppercase; |
| 67 | + } |
| 68 | + |
| 69 | + .summary-title { |
| 70 | + grid-column: 1; |
| 71 | + font-size: var(--sl-text-lg); |
| 72 | + font-weight: 600; |
| 73 | + line-height: 1.4; |
| 74 | + } |
| 75 | + |
| 76 | + .chevron { |
| 77 | + grid-column: 2; |
| 78 | + grid-row: 1 / span 2; |
| 79 | + color: var(--sl-color-gray-3); |
| 80 | + transition: transform 160ms ease; |
| 81 | + } |
| 82 | + |
| 83 | + .conversation[open] .chevron { |
| 84 | + transform: rotate(180deg); |
| 85 | + } |
| 86 | + |
| 87 | + .conversation-body { |
| 88 | + display: grid; |
| 89 | + gap: 1rem; |
| 90 | + padding: 1.125rem; |
| 91 | + border-top: 1px solid var(--sl-color-gray-5); |
| 92 | + background: var(--sl-color-bg); |
| 93 | + } |
| 94 | + |
| 95 | + @media (min-width: 50rem) { |
| 96 | + summary { |
| 97 | + padding-inline: 1.25rem; |
| 98 | + } |
| 99 | + |
| 100 | + .conversation-body { |
| 101 | + padding: 1.25rem; |
| 102 | + } |
| 103 | + } |
| 104 | + |
| 105 | + @media (prefers-reduced-motion: reduce) { |
| 106 | + .chevron { |
| 107 | + transition: none; |
| 108 | + } |
| 109 | + } |
| 110 | +</style> |
0 commit comments