# Blog foundations
> What @sdxc/ui/blog is for, the rules its parts share, and every variable it declares.

The parts a blog is built from: entries in a stream, a byline, tags and a tag cloud, a series, an archive, sidebar widgets, an author card, a sign-up form and the page a post reads in.

They take plain values, so posts can come from Markdown, a database or a CMS, and they draw on the server as links and forms that work with script off.

Import the components from `@sdxc/ui/blog` and the theme once from `@sdxc/ui/theme.css`.

## When to reach for it

- A home page that lists essays, notes and links in one feed, as cards, a log or a dense index.
- An article page with a byline, an outline beside the body and the post's series and tags.
- An archive by year, a tag page, and a sidebar of recent posts and a sign-up.

## Shared ideas

- **Pieces, not options.** Each component is a root and the parts you write inside it (`PostByline.Author`, `ArticleLayout.Rail`), so a blog arranges, leaves out or reorders pieces instead of setting props that move them. The root shares only data its parts need, such as a locale or an outline, and lays out whichever parts it gets.
- **Plain props.** Hrefs, dates and counts are values you pass and titles are children, so the parts read no post record and fit any content source.
- **Dates are calendar days.** A date arrives as a `YYYY-MM-DD` string, renders as `<time datetime>` and formats in UTC for the `locale` you pass, so a post dated the 12th reads the 12th everywhere.
- **Copy passed in.** Every word a reader sees is a part's children; where a part has a default ("min read", "Updated", "On this page"), it is English and your children replace it, so a translated blog sets its own words.
- **No script needed.** Every part is links and forms: the sign-up form posts, section headings and the outline rail stick through CSS, and a collapsible series is a `<details>`.

## CSS variables

Every custom property the namespace reads or declares. Reads the neutral role for text and hairlines, and brand for kinds, links, featured entries, widget rules and focus rings. Every inner part reads a custom property first, so a blog restyles one from the component's root. The roles are documented on Theming.

### Post entries

Set on a `PostEntry` through `mix` or `style`; `gutter` and `title-size` are declared by the entry per `layout`, so an inline `style` overrides them.

| Variable | Default | What it controls |
| --- | --- | --- |
| `--ui-post-entry-gap` | `0.5rem (row: 0.25rem)` | The space between the entry's parts. |
| `--ui-post-entry-gutter` | `6.5rem (row: 4.5rem)` | The width of the margin column the kind sits in. |
| `--ui-post-entry-title-size` | `1.375rem (row: 1.0625rem)` | The size of the entry's title; a featured entry sets a larger one. |
| `--ui-post-entry-title-font-family` | `inherit` | The title's typeface. |
| `--ui-post-entry-title-font-weight` | `600` | The title's weight. |
| `--ui-post-entry-title-fg` | `emphasis neutral text` | The title's colour, for a selected row. |
| `--ui-post-entry-lead-fg` | `neutral text` | The lead's colour. |
| `--ui-post-entry-kind-fg` | `brand text` | The kind's colour. |
| `--ui-post-entry-kind-font-family` | `inherit` | The kind's typeface. |
| `--ui-post-entry-kind-font-size` | ``--ui-text-xs`` | The kind's size. |
| `--ui-post-entry-kind-font-weight` | `600` | The kind's weight. |
| `--ui-post-entry-kind-letter-spacing` | ``--ui-tracking-wider`` | The kind's letter spacing. |
| `--ui-post-entry-kind-text-transform` | `uppercase` | The kind's case. |
| `--ui-post-entry-meta-fg` | `muted neutral text` | The meta row's text and middots. |
| `--ui-post-entry-meta-font-family` | `inherit` | The meta row's typeface. |
| `--ui-post-entry-meta-font-size` | ``--ui-text-sm`` | The meta row's size. |
| `--ui-post-entry-date-fg` | `muted neutral text` | The colour of `PostEntry.Date`. |
| `--ui-post-entry-date-font-family` | `inherit` | The date's typeface. |
| `--ui-post-entry-date-font-size` | ``--ui-text-sm`` | The date's size. |
| `--ui-post-entry-date-width` | `6.5rem` | The width of the date's column in a wide `row`. |
| `--ui-post-entry-featured-bg` | `brand tint` | A featured entry's surface. |
| `--ui-post-entry-featured-border-color` | `brand border` | A featured entry's border. |
| `--ui-post-entry-featured-edge-color` | `brand solid` | A featured entry's thick leading edge. |
| `--ui-post-entry-featured-edge-width` | `4px` | The width of a featured entry's leading edge. |
| `--ui-post-entry-title-hover-fg` | `brand text` | The title link's colour under the pointer. |
| `--ui-post-entry-title-hover-decoration-color` | `currentColor` | The title link's underline under the pointer. |

### Streams

Set on a `PostStream` (or one section); a page with a sticky bar of its own sets the offset to that bar's height.

| Variable | Default | What it controls |
| --- | --- | --- |
| `--ui-post-stream-gap` | `2.5rem (rows: 1.5rem)` | The space between entries, with the hairline drawn halfway. |
| `--ui-post-stream-offset` | `0px` | How far below the viewport's top a section heading sticks. |
| `--ui-post-stream-section-gap` | `3rem` | The space between sections. |
| `--ui-post-stream-entries-padding` | `1.25rem` | The space between a section's heading and its first entry. |
| `--ui-post-stream-rule-color` | `neutral border` | The hairline's colour. |
| `--ui-post-stream-rule-style` | `solid` | The hairline's style. |
| `--ui-post-stream-rule-width` | `1px` | The hairline's width; `0` drops it. |
| `--ui-post-stream-heading-font-family` | `inherit` | A section heading's typeface. |
| `--ui-post-stream-heading-font-size` | ``--ui-text-xs`` | A section heading's size. |
| `--ui-post-stream-heading-font-weight` | `600` | A section heading's weight. |
| `--ui-post-stream-heading-letter-spacing` | ``--ui-tracking-widest`` | A section heading's letter spacing. |
| `--ui-post-stream-heading-text-transform` | `uppercase` | A section heading's case. |
| `--ui-post-stream-heading-fg` | `muted neutral text` | A section heading's colour. |
| `--ui-post-stream-heading-bg` | ``--ui-bg`` | The surface entries scroll under. |
| `--ui-post-stream-heading-border-color` | `neutral border` | The rule under a section heading. |

### Tags

Set on a `TagList` or `TagCloud`. A chip is a `TagList` given a border, padding or background.

| Variable | Default | What it controls |
| --- | --- | --- |
| `--ui-tag-list-gap` | `0.75em` | The space between tags, and around a separator. |
| `--ui-tag-list-link-fg` | `muted neutral text` | A tag's colour. |
| `--ui-tag-list-link-hover-fg` | `brand text` | A tag's colour under the pointer. |
| `--ui-tag-list-link-font-family` | `inherit` | A tag's typeface. |
| `--ui-tag-list-link-font-size` | `inherit` | A tag's size. |
| `--ui-tag-list-link-font-weight` | `inherit` | A tag's weight. |
| `--ui-tag-list-link-text-transform` | `inherit` | A tag's case. |
| `--ui-tag-list-link-border` | `none` | A tag's border, as a shorthand. |
| `--ui-tag-list-link-radius` | ``--ui-radius-sm`` | A tag's corners. |
| `--ui-tag-list-link-padding` | `0` | A tag's padding. |
| `--ui-tag-list-link-bg` | `transparent` | A tag's background. |
| `--ui-tag-list-separator` | `none` | A quoted string set after every tag but the last, such as `","`, so it ends a line at a wrap. |
| `--ui-tag-list-separator-fg` | `muted neutral text` | The separator's colour. |
| `--ui-tag-cloud-link-fg` | `emphasis neutral text` | A cloud tag's colour. |
| `--ui-tag-cloud-link-hover-fg` | `brand text` | A cloud tag's colour under the pointer. |
| `--ui-tag-cloud-link-font-family` | `inherit` | A cloud tag's typeface. |
| `--ui-tag-cloud-link-border` | `none` | A cloud tag's chip border, as a shorthand. |
| `--ui-tag-cloud-link-radius` | `0` | A cloud tag's corners. |
| `--ui-tag-cloud-link-padding` | `0` | A cloud tag's padding, which turns it into a chip. |
| `--ui-tag-cloud-link-bg` | `transparent` | A cloud tag's background. |
| `--ui-tag-cloud-count-fg` | `muted neutral text` | The count beside each cloud tag. |

### Bylines and author cards

Set on a `PostByline` or an `AuthorCard`; the byline's separator falls between the parts inside `PostByline.Facts`.

| Variable | Default | What it controls |
| --- | --- | --- |
| `--ui-post-byline-separator` | `"·"` | A quoted string drawn between two facts; `""` draws none. |
| `--ui-post-byline-gap` | `0.5em` | The space on each side of that separator. |
| `--ui-author-card-name-font-family` | `inherit` | The name's typeface. |
| `--ui-author-card-name-font-size` | `inherit` | The name's size. |
| `--ui-author-card-name-font-weight` | `600` | The name's weight. |
| `--ui-author-card-rule-color` | `neutral border` | The rule a `plain` card opens on. |
| `--ui-author-card-rule-width` | `1px` | That rule's width; `0` drops it. |

### Series and archives

Set on a `SeriesNav` or an `ArchiveList`; an archive under a sticky header sets its scroll margin to the header's height.

| Variable | Default | What it controls |
| --- | --- | --- |
| `--ui-series-nav-bg` | `neutral tint` | The series box's surface. |
| `--ui-series-nav-border` | `1px solid neutral border` | The series box's border, as a shorthand. |
| `--ui-series-nav-radius` | ``--ui-radius-lg`` | The series box's corners. |
| `--ui-series-nav-label-fg` | `brand text` | The eyebrow's colour. |
| `--ui-series-nav-label-font-family` | `inherit` | The eyebrow's typeface. |
| `--ui-series-nav-label-text-transform` | `uppercase` | The eyebrow's case. |
| `--ui-series-nav-label-letter-spacing` | ``--ui-tracking-wide`` | The eyebrow's letter spacing. |
| `--ui-series-nav-title-font-family` | `inherit` | The series name's typeface. |
| `--ui-series-nav-title-font-size` | ``--ui-text-lg`` | The series name's size. |
| `--ui-series-nav-title-font-weight` | `700` | The series name's weight. |
| `--ui-series-nav-number-font-family` | `inherit` | The typeface of each part's number. |
| `--ui-series-nav-current-fg` | `emphasis neutral text` | The current part's title. |
| `--ui-series-nav-current-marker-fg` | `brand text` | The current part's number. |
| `--ui-archive-list-day-fg` | `muted neutral text` | Each entry's day. |
| `--ui-archive-list-day-font-family` | `inherit` | The day's typeface. |
| `--ui-archive-list-day-width` | `4.5rem` | The width of the day's column. |
| `--ui-archive-list-kind-fg` | `muted neutral text` | Each entry's kind. |
| `--ui-archive-list-kind-font-family` | `inherit` | The kind's typeface. |
| `--ui-archive-list-kind-font-size` | ``--ui-text-xs`` | The kind's size. |
| `--ui-archive-list-kind-letter-spacing` | ``--ui-tracking-wide`` | The kind's letter spacing. |
| `--ui-archive-list-title-font-family` | `inherit` | Each entry's title typeface. |
| `--ui-archive-list-title-font-size` | `inherit` | Each entry's title size. |
| `--ui-archive-list-heading-font-family` | `inherit` | A group heading's typeface. |
| `--ui-archive-list-heading-font-size` | ``--ui-text-xl`` | A group heading's size. |
| `--ui-archive-list-heading-font-weight` | `700` | A group heading's weight. |
| `--ui-archive-list-heading-fg` | `emphasis neutral text` | A group heading's colour. |
| `--ui-archive-list-heading-text-transform` | `none` | A group heading's case. |
| `--ui-archive-list-heading-letter-spacing` | ``--ui-tracking-tight`` | A group heading's letter spacing. |
| `--ui-archive-list-heading-border-color` | `strong neutral border` | The rule under a group heading; `transparent` hides it. |
| `--ui-archive-list-rule-color` | `neutral border` | The rule under each entry. |
| `--ui-archive-list-rule-style` | `solid` | That rule's style; `none` drops it. |
| `--ui-archive-list-scroll-margin` | `1rem` | How far a jumped-to group heading clears the top. |

### Widgets and articles

Set on a `Widget` or the sidebar around several; `ArticleLayout` sets its sticky offset from `stickyTop`, which its `.Bar`, `.Rail` and jumped-to headings clear.

| Variable | Default | What it controls |
| --- | --- | --- |
| `--ui-widget-heading-font-family` | `inherit` | A widget heading's typeface. |
| `--ui-widget-heading-font-size` | ``--ui-text-xs`` | A widget heading's size. |
| `--ui-widget-heading-font-weight` | `700` | A widget heading's weight. |
| `--ui-widget-heading-letter-spacing` | `0.08em` | A widget heading's letter spacing. |
| `--ui-widget-heading-text-transform` | `uppercase` | A widget heading's case. |
| `--ui-widget-heading-fg` | `emphasis neutral text` | A widget heading's colour. |
| `--ui-widget-rule-color` | `brand solid` | The rule above a widget heading. |
| `--ui-widget-rule-width` | `3px` | That rule's width; `0` drops it. |
| `--ui-article-sticky-top` | ``stickyTop` (0px)` | Where the outline bar and rail of `ArticleLayout` stick. |
