|
| 1 | +// UI components |
| 2 | +// Import: #import "/components/ui.typ" as ui |
| 3 | + |
| 4 | +#import "/utils/tola.typ": cls |
| 5 | +#import "/components/layout.typ" as layout |
| 6 | + |
| 7 | +/// Navigation link |
| 8 | +#let nav-link(href, label) = html.a( |
| 9 | + class: "text-muted hover:text-accent transition-colors", |
| 10 | + href: href, |
| 11 | +)[#label] |
| 12 | + |
| 13 | +/// Tag badge |
| 14 | +#let tag(name) = html.span( |
| 15 | + class: "px-2 py-1 text-xs bg-surface rounded text-accent", |
| 16 | +)[#name] |
| 17 | + |
| 18 | +/// Card container |
| 19 | +#let card(title: none, body) = html.div(class: "p-4 bg-surface rounded-lg")[ |
| 20 | + #if title != none { html.h3(class: "font-semibold text-accent mb-2")[#title] } |
| 21 | + #body |
| 22 | +] |
| 23 | + |
| 24 | +/// Post card for blog listings |
| 25 | +#let post-card(post) = { |
| 26 | + let date = post.at("date", default: "") |
| 27 | + html.a( |
| 28 | + class: "block mb-6 p-4 border border-white/10 rounded-lg bg-surface/50 hover:bg-surface transition-colors no-underline group", |
| 29 | + href: post.permalink, |
| 30 | + )[ |
| 31 | + #html.h3(class: "text-xl font-semibold mb-2 group-hover:text-accent transition-colors")[ |
| 32 | + #post.title |
| 33 | + ] |
| 34 | + |
| 35 | + #layout.flex-row( |
| 36 | + gap: 4, |
| 37 | + html.span(class: "text-sm text-muted")[#date], |
| 38 | + ..post.at("tags", default: ()).map(t => tag(t)), |
| 39 | + ) |
| 40 | + |
| 41 | + #if post.at("summary", default: none) != none { |
| 42 | + html.p(class: "mt-2 text-muted")[#post.at("summary")] |
| 43 | + } |
| 44 | + ] |
| 45 | +} |
| 46 | + |
| 47 | +/// Side-by-side showcase card: source code + rendered output. |
| 48 | +#let showcase-demo( |
| 49 | + title: none, |
| 50 | + description: none, |
| 51 | + code: none, |
| 52 | + preview: none, |
| 53 | + code-label: "Typst Code", |
| 54 | + preview-label: "Rendered Output", |
| 55 | +) = { |
| 56 | + assert(title != none, message: "showcase-demo: `title` is required") |
| 57 | + assert(code != none, message: "showcase-demo: `code` is required") |
| 58 | + assert(preview != none, message: "showcase-demo: `preview` is required") |
| 59 | + |
| 60 | + html.section( |
| 61 | + class: "my-8 rounded-lg border border-white/10 bg-gradient-to-br from-slate-900/80 via-slate-900/50 to-cyan-950/20 p-4 sm:p-6", |
| 62 | + )[ |
| 63 | + #html.div(class: "mb-4")[ |
| 64 | + #html.h3(class: "text-lg sm:text-xl font-semibold text-cyan-300")[ |
| 65 | + #title |
| 66 | + ] |
| 67 | + #if description != none { |
| 68 | + html.p(class: "mt-1 text-sm text-slate-300")[ |
| 69 | + #description |
| 70 | + ] |
| 71 | + } |
| 72 | + ] |
| 73 | + |
| 74 | + #html.div(class: "grid gap-4")[ |
| 75 | + #html.div(class: "rounded-lg border border-white/10 bg-slate-950/70 overflow-hidden")[ |
| 76 | + #html.div(class: "border-b border-white/10 px-3 py-2 text-xs uppercase tracking-wide text-slate-400")[ |
| 77 | + #code-label |
| 78 | + ] |
| 79 | + #html.div(class: "p-3 text-sm")[ |
| 80 | + #code |
| 81 | + ] |
| 82 | + ] |
| 83 | + |
| 84 | + #html.div(class: "rounded-lg border border-cyan-500/30 bg-surface/40 overflow-hidden")[ |
| 85 | + #html.div(class: "border-b border-cyan-500/20 px-3 py-2 text-xs uppercase tracking-wide text-cyan-300")[ |
| 86 | + #preview-label |
| 87 | + ] |
| 88 | + #html.div(class: "p-3 text-sm")[ |
| 89 | + #preview |
| 90 | + ] |
| 91 | + ] |
| 92 | + ] |
| 93 | + ] |
| 94 | +} |
0 commit comments