diff options
| author | Tomas Bankauskas <tbdizainas@gmail.com> | 2025-03-20 15:52:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-20 15:52:41 +0200 |
| commit | 5e1b4824fdab857bf5eb1bc40afab1e9b3dc545a (patch) | |
| tree | 78283952c019d5c0ede508c57640a31467b65bd2 /src/components | |
| parent | f8b333c690e13a594ff97043856a16f6c3f6fd48 (diff) | |
| parent | 8c543b6bb7ba29cfed559c3693b4149d1204ef78 (diff) | |
Merge pull request #183 from netlify-templates/tb/deved-130
removed daisyui
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/Alert.astro | 2 | ||||
| -rw-r--r-- | src/components/Card.astro | 26 | ||||
| -rw-r--r-- | src/components/Diff.astro | 94 | ||||
| -rw-r--r-- | src/components/Markdown.astro | 11 |
4 files changed, 97 insertions, 36 deletions
diff --git a/src/components/Alert.astro b/src/components/Alert.astro index 1a468fb..f8870e6 100644 --- a/src/components/Alert.astro +++ b/src/components/Alert.astro @@ -6,7 +6,7 @@ interface Props { const { class: className } = Astro.props; --- -<div class:list={['alert alert-info', className].join(' ')}> +<div class:list={['flex gap-4 p-4 rounded-sm bg-primary text-primary-content', className]}> <svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 fill-current shrink-0" viewBox="0 0 24 24"> <path d="M12 20.016q3.281 0 5.648-2.367t2.367-5.648-2.367-5.648-5.648-2.367-5.648 2.367-2.367 5.648 2.367 5.648 5.648 2.367zM12 2.016q4.125 0 7.055 2.93t2.93 7.055-2.93 7.055-7.055 2.93-7.055-2.93-2.93-7.055 2.93-7.055 7.055-2.93zM11.016 6.984h1.969v6h-1.969v-6zM11.016 15h1.969v2.016h-1.969v-2.016z" diff --git a/src/components/Card.astro b/src/components/Card.astro deleted file mode 100644 index da68297..0000000 --- a/src/components/Card.astro +++ /dev/null @@ -1,26 +0,0 @@ ---- -interface Props { - title?: string; - text?: string; - linkText?: string; - href?: string; -} - -const { title, text, linkText, href } = Astro.props; ---- - -<div class="bg-white text-neutral-600 card"> - <div class="card-body"> - {title && <h3 class="text-neutral-900 card-title">{title}</h3>} - {text && <p>{text}</p>} - { - linkText && href && ( - <div class="card-actions"> - <a href={href} class="link text-neutral-900"> - {linkText} - </a> - </div> - ) - } - </div> -</div> diff --git a/src/components/Diff.astro b/src/components/Diff.astro new file mode 100644 index 0000000..4c11962 --- /dev/null +++ b/src/components/Diff.astro @@ -0,0 +1,94 @@ +--- +interface Props { + class?: string; +} + +const { class: className } = Astro.props; +--- + +<figure class:list={['diff relative grid w-full overflow-hidden select-none', className]} tabindex="0"> + <div class="relative col-start-1 row-start-1 overflow-hidden border-r-2 z-1 border-r-white diff-item-1"> + <slot name="item-1" /> + </div> + <div class="relative col-start-1 row-start-1 diff-item-2" tabindex="0"> + <slot name="item-2" /> + </div> + <div class="relative h-2 col-start-1 row-start-1 overflow-hidden opacity-0 resize-x diff-resizer z-1 min-w-4 cursor-ew-resize top-1/2"></div> +</figure> + +<style> + .diff { + direction: ltr; + container-type: inline-size; + grid-template-columns: auto 1fr; + + &:focus-visible, + &:has(.diff-item-1:focus), + &:has(.diff-item-2:focus) { + outline: 2px solid var(--color-gray-400); + outline-offset: 1px; + } + &:focus-visible { + .diff-resizer { + min-width: 80cqi; + max-width: 80cqi; + } + } + &:has(.diff-item-2:focus) { + .diff-resizer { + min-width: 20cqi; + max-width: 20cqi; + } + } + } + + .diff-resizer { + width: 50cqi; + max-width: calc(100cqi - 1rem); + transform: scaleY(3) translate(0.35rem, 0.08rem); + transform-origin: 100% 100%; + clip-path: inset(calc(100% - 0.75rem) 0 0 calc(100% - 0.75rem)); + transition: + min-width 0.3s ease-out, + max-width 0.3s ease-out; + } + + .diff-item-2 { + &:after { + content: ''; + width: 1.25rem; + height: 1.875rem; + position: absolute; + top: 50%; + right: 1px; + bottom: 0; + translate: 50% -50%; + background: color-mix(in oklab, var(--color-white) 50%, transparent); + border-radius: 9999px; + border: 2px solid var(--color-white); + backdrop-filter: blur(8px); + pointer-events: none; + z-index: 2; + box-shadow: + inset 0 0 0 1px color-mix(in oklab, var(--color-gray-900) 5%, transparent), + 0 1px 3px 0 color-mix(in oklab, var(--color-gray-900) 20%, transparent); + } + @supports (-webkit-overflow-scrolling: touch) and (overflow: -webkit-paged-x) { + &:after { + content: none; + } + } + } + + .diff-item-1, + .diff-item-2 { + > * { + height: 100%; + width: 100cqi; + position: absolute; + top: 0; + left: 0; + pointer-events: none; + } + } +</style> diff --git a/src/components/Markdown.astro b/src/components/Markdown.astro index e8996c5..ce83e60 100644 --- a/src/components/Markdown.astro +++ b/src/components/Markdown.astro @@ -1,7 +1,7 @@ --- import { Marked } from 'marked'; import markedShiki from 'marked-shiki'; -import { getHighlighter } from 'shiki'; +import { highlighterPromise } from '../utils/highlighter'; interface Props { content: string; @@ -10,14 +10,7 @@ interface Props { const { content, class: className } = Astro.props; -// `getHighlighter` is async, it initializes the internal and -// loads the languages and themes specified. -// Then later you can use `highlighter.codeToHtml` synchronously -// with the loaded themes and languages. -const highlighter = await getHighlighter({ - langs: ['jsx', 'js'], - themes: ['min-dark'] -}); +const highlighter = await highlighterPromise; const html = await new Marked() .use( markedShiki({ |
