style(body): add neutral figure, wide breakout, details, table header, and quote footer defaults
This commit is contained in:
@@ -101,7 +101,7 @@ export default defineNuxtPlugin(() => {
|
||||
- **Order:** sanitize first, expand/hydrate last. `JournalPostBody` and `JournalCategoryHeader` call `expandEmbeds(renderJournalBody(...))` / `expandEmbeds(sanitizeJournalHtml(...))` and wire `useJournalEmbedHydration`. The payload transforms (`toPostView`, `CategoryPage.vue`) only sanitize, so the SSR payload carries the clean `<figure>` markup.
|
||||
- **SSR static fallback & CLS reservation:** For client-hydrated providers (`component` or `mount`, without `renderSsr`), `expandEmbeds` preserves the SSR fallback `<img>` + `<figcaption>` intact, adds `journal-embed journal-embed--<provider>`, and applies validated `aspect-ratio` / `min-height` inline styles. Before swapping in the hydrated widget on the client, `hydrateEmbedFigure` measures the fallback box height and sets `min-height` to prevent cumulative layout shift (CLS).
|
||||
- **Lazy hydration, `prefers-reduced-motion`, and resilience:** `useJournalEmbedHydration` observes each validated `<figure data-embed>` with `IntersectionObserver` (default `rootMargin: '200px'`), passes a reactive `reducedMotion` ref synced with `window.matchMedia('(prefers-reduced-motion: reduce)')`, mounts Vue async components via `createVNode` + `render` inheriting `nuxtApp.vueApp._context` (so i18n, router, and Pinia work inside hydrated embeds) or invokes `mount(el, ctx)`, and cleans up on unmount or HTML updates. If dynamic import or mount throws, the error is caught and the SSR static fallback DOM remains intact.
|
||||
- **Styles:** `.journal-embed--youtube` and iframe embeds default to a `16 / 9` full-width frame; custom embeds render their fallback image, `<figcaption>`, and `.journal-embed__stage` naturally, adding `.journal-embed--hydrated` once mounted.
|
||||
- **Styles:** `.journal-embed--youtube` and iframe embeds default to a `16 / 9` full-width frame; custom embeds render their fallback image, `<figcaption>`, and `.journal-embed__stage` naturally, adding `.journal-embed--hydrated` once mounted. Inside `.journal-post-body`, `<figure>` / `<figcaption>`, `<details>` / `<summary>`, table `<th>` / `<caption>`, and `<blockquote><footer>` receive neutral `--journal-*` defaults, and `figure.journal-wide` breaks out up to `--journal-wide-width` on wide viewports.
|
||||
- **Content-Security-Policy:** The hydration runtime is strictly `script-src 'self'` compliant (no `eval`, no `new Function`, no inline `<script>`). Sites using the built-in YouTube iframe still need `frame-src https://www.youtube-nocookie.com`.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -148,6 +148,65 @@
|
||||
background: var(--journal-color-surface);
|
||||
}
|
||||
|
||||
.journal-post-body blockquote footer {
|
||||
margin-top: var(--journal-space-2);
|
||||
color: var(--journal-color-muted);
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.journal-post-body figure {
|
||||
margin: var(--journal-space-4) 0;
|
||||
}
|
||||
|
||||
.journal-post-body figure img {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.journal-post-body figcaption {
|
||||
margin-top: var(--journal-space-2);
|
||||
color: var(--journal-color-muted);
|
||||
font-size: 0.9em;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.journal-post-body figure.journal-wide {
|
||||
--journal-breakout-width: min(var(--journal-wide-width), calc(100vw - 2 * var(--journal-space-4)));
|
||||
width: var(--journal-breakout-width);
|
||||
max-width: none;
|
||||
margin-inline: calc((100% - var(--journal-breakout-width)) / 2);
|
||||
}
|
||||
|
||||
.journal-post-body figure.journal-wide img {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.journal-post-body details {
|
||||
margin: var(--journal-space-4) 0;
|
||||
padding: var(--journal-space-3) var(--journal-space-4);
|
||||
border: 1px solid var(--journal-color-border);
|
||||
border-radius: var(--journal-radius-md);
|
||||
background: var(--journal-color-surface);
|
||||
}
|
||||
|
||||
.journal-post-body summary {
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.journal-post-body summary:focus-visible {
|
||||
outline: 2px solid var(--journal-color-accent);
|
||||
outline-offset: 2px;
|
||||
border-radius: var(--journal-radius-sm);
|
||||
}
|
||||
|
||||
.journal-post-body details[open] > summary {
|
||||
margin-bottom: var(--journal-space-3);
|
||||
}
|
||||
|
||||
.journal-post-body details > :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.journal-post-body code {
|
||||
padding: 0 var(--journal-space-1);
|
||||
border-radius: var(--journal-radius-sm);
|
||||
@@ -180,6 +239,18 @@
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.journal-post-body th {
|
||||
background: var(--journal-color-surface);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.journal-post-body caption {
|
||||
margin-bottom: var(--journal-space-2);
|
||||
color: var(--journal-color-muted);
|
||||
font-size: 0.9em;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* Embeds expanded or hydrated from the Blog Editor's placeholders (app/utils/embeds.ts) */
|
||||
.journal-embed {
|
||||
display: block;
|
||||
|
||||
Reference in New Issue
Block a user