hugo-theme-termlite/assets/css/010_spacing.css
Eryn Wells efae2acdea Simplify figure styles and markup
Remove the .figure__container element. According to Tess, putting a <figcaption>
inside a child of a <figure> "doesn't obey the content model" or some shit.
Fiiiiine.

Getting small figures to lay out the way I want them to without the container
was a bit of a trick. Instead of letting the figure span the entire width of the
grid column, let it fit the size of its contents, and then set margin-inline to
auto so it centers.

Doing this also allowed me to remove the .figure--image, etc styles because the
styles and markup are a lot more similar among figures containing different
kinds of elements. Nice!
2024-11-25 15:48:04 -08:00

83 lines
1.7 KiB
CSS

{{- $base := (index . "Base") | default 1 -}}
{{- $unit := (index . "Unit") | default "rem" -}}
{{- $factor := (index . "Factor") | default 1.618 -}}
{{- $scale := partial "base/_size_scale.html" . }}
/***********
# SPACING
***********/
:root {
--space-base: {{ $base }}{{ $unit }};
{{- range $scale }}
--space-{{ .Name }}: calc(var(--space-base) * pow({{ $factor }}, {{ .Value }}));
{{- end }}
--fixed-space-base: 1rem;
{{- range $scale }}
--fixed-space-{{ .Name }}: calc(var(--fixed-space-base) * pow({{ $factor }}, {{ .Value }}));
{{- end }}
--space-paragraph: var(--space-m);
}
{{ range $scale }}
{{ printf "/* Spacing utility classes: %s */" .Name }}
.margin-block-start--{{ .Name }} { margin-block-start: var(--space-{{ .Name }}); }
.margin-block-end--{{ .Name }} { margin-block-end: var(--space-{{ .Name }}); }
.margin-inline-start--{{ .Name }} { margin-inline-start: var(--space-{{ .Name }}); }
.margin-inline-end--{{ .Name }} { margin-inline-end: var(--space-{{ .Name }}); }
{{ end }}
h1, h2, h3, h4, h5, h6 {
margin-block: var(--space-l) var(--space-m);
}
:is(h1, h2, h3, h4, h5, h6),
.page-header
{
+ :is(h1, h2, h3, h4, h5, h6),
+ :is(dl, ol, ul)
{
margin-block-start: 0;
}
}
hr {
margin-block: var(--space-l);
}
:is(dl, p, ol, ul) + :is(dl, p, ol, ul) {
margin-block-start: var(--space-paragraph);
}
/* Figures */
{{-
$elementsWithXLBlockMargins := delimit
(slice
"blockquote"
"table"
".codeblock"
".figure"
".highlight"
".instagram-media"
)
", "
-}}
p + :is({{ $elementsWithXLBlockMargins }}) {
margin-block-start: var(--space-xl);
}
:is({{ $elementsWithXLBlockMargins }}):has(+ p) {
margin-block-end: var(--space-xl);
}