Move some styles fron zen to base. Add margin-top and margin bottom classes for all spacing levels. Add footer component.

This commit is contained in:
Fredrik Jonsson 2023-03-15 15:46:09 +01:00
commit 1d6e50708a
18 changed files with 81 additions and 76 deletions

View file

@ -23,10 +23,6 @@ $max-page-width: $max-content-width !default;
--radius-#{$name}: #{$radius}; --radius-#{$name}: #{$radius};
} }
@each $name, $space in $spacing {
--space-#{$name}: #{$space};
}
--heading-line-height: #{$heading-line-height}; --heading-line-height: #{$heading-line-height};
--max-content-width: #{$max-content-width}; --max-content-width: #{$max-content-width};
--max-page-width: #{$max-page-width}; --max-page-width: #{$max-page-width};

View file

@ -115,23 +115,24 @@ $breakpoints: (
// Border radius. // Border radius.
// Use like this: var(--radius-m) // Use like this: var(--radius-m)
$border-radius: ( $border-radius: (
l: 1rem, xl: 1rem,
m: 0.3rem, l: 0.75rem,
s: 3px, m: 0.5rem,
s: 0.3rem,
xs: 0.125rem,
); );
// Spacing. // Spacing.
// Use like this: var(--space-m) // Generates mt-m (mt = margin-top) and mb-m (mb = margin-bottom) classes.
$spacing: ( $spacing: (
xxxl: 5rem, xxl: 3,
xxl: 3rem, xl: 2,
xl: 2rem, l: 1.5,
l: 1.5rem, m: 1,
m: 1rem, s: 0.75,
s: 0.75rem, xs: 0.5,
xs: 0.5rem, xxs: 0.3,
xxs: 0.4rem, 0: 0,
xxxs: 0.3rem,
); );
// The max content width. (Consider using one of the breakpoints.) // The max content width. (Consider using one of the breakpoints.)
@ -154,3 +155,7 @@ $indent-amount: 2rem;
// Control whether RTL styles are added. // Control whether RTL styles are added.
$include-rtl: false; $include-rtl: false;
// Show horizontal grid to help with debugging typography
$debug: true;
$debug-color: $grey-extra-light;

View file

@ -10,19 +10,8 @@ body {
background-color: var(--color-body-bg); background-color: var(--color-body-bg);
} }
.header {
padding-top: var(--gutters);
}
.footer { .footer {
@include margin-top(1.5);
@include padding(.3);
text-align: center;
border-top: 2px solid var(--color-brand); border-top: 2px solid var(--color-brand);
p {
margin: 0;
}
} }
// Apply smaller text to blocks, footer etc. // Apply smaller text to blocks, footer etc.
@ -78,19 +67,13 @@ article {
} }
} }
.tags {
ul {
margin: 0;
}
}
code { code {
font-size: var(--fs-xs); font-size: var(--fs-xs);
overflow-wrap: break-word; overflow-wrap: break-word;
} }
pre { pre {
border-radius: var(--radius-s); border-radius: var(--radius-xs);
padding: 5px; padding: 5px;
border: 1px solid var(--color-border-light); border: 1px solid var(--color-border-light);
background-color: var(--color-text-bg); background-color: var(--color-text-bg);
@ -110,10 +93,6 @@ article {
} }
} }
.title-submitted {
margin-bottom: .2rem;
}
.content-dates { .content-dates {
text-align: right; text-align: right;
} }
@ -129,14 +108,14 @@ img {
} }
&.left { &.left {
@include padding(0 .5 .5 0); padding: 0 .75rem .75rem 0;
margin: 0; margin: 0;
float: left; float: left;
clear: both; clear: both;
} }
&.right { &.right {
@include padding(0 0 .5 .5); padding: 0 0 .75rem .75rem;
margin: 0; margin: 0;
float: right; float: right;
clear: both; clear: both;
@ -167,13 +146,13 @@ figure {
&.left { &.left {
figcaption { figcaption {
@include padding(0 .5 .5 0); padding: 0 .75rem .75rem 0;
} }
} }
&.right { &.right {
figcaption { figcaption {
@include padding(0 0 .5 .5); padding: 0 0 .75rem .75rem;
} }
} }
} }
@ -189,11 +168,11 @@ figure {
// Navigation // Navigation
.main-menu { .main-menu {
@include margin-top(.5); margin-top: .75rem;
outline: 0; outline: 0;
li { li {
@include margin-bottom(.5); margin-bottom: .75rem;
padding: 0; padding: 0;
} }
@ -224,6 +203,7 @@ figure {
// Search // Search
.search-input { .search-input {
// Add vertical rhythm margins.
@include margin-block(1); @include margin-block(1);
} }
@ -235,18 +215,8 @@ figure {
// Form // Form
.content { .content {
label:has(+ :required) {
&::after {
content: '*';
color: var(--color-mark-highlight);
}
}
input, input,
textarea { textarea {
@include margin-bottom(.75);
width: 92%;
&:not(:placeholder-shown):valid { &:not(:placeholder-shown):valid {
background-color: var(--color-status-bg); background-color: var(--color-status-bg);
} }

View file

@ -15,20 +15,20 @@ button,
[type='reset'], [type='reset'],
[type='submit'] { [type='submit'] {
@extend %button--disabled; @extend %button--disabled;
@include margin-right(.75);
@include margin-bottom(.75);
@include padding(.2 1);
// Some styles don't apply to <a> links since they are inline elements by default. // Some styles don't apply to <a> links since they are inline elements by default.
display: inline-block; display: inline-block;
font-family: var(--ff-headings); font-family: var(--ff-headings);
text-decoration: none; text-decoration: none;
text-align: center; text-align: center;
margin-right: 1rem;
margin-bottom: 1rem;
padding: .2rem 1rem;
// Improve usability and consistency of cursor style between image-type `input` and others. // Improve usability and consistency of cursor style between image-type `input` and others.
cursor: pointer; cursor: pointer;
color: var(--color-button-text); color: var(--color-button-text);
background-color: var(--color-button); background-color: var(--color-button);
border: 0; border: 0;
border-radius: var(--radius-m); border-radius: var(--radius-s);
&:hover, &:hover,
&:focus, &:focus,
@ -44,10 +44,10 @@ button,
.button, .button,
%button { %button {
&--small { &--small {
@include margin-right(.3);
@include margin-bottom(.3);
@include padding(.1 .5);
font-size: var(--fs-xs); font-size: var(--fs-xs);
margin-right: .5rem;
margin-bottom: .5rem;
padding: .2rem .75rem;
} }
&--alt { &--alt {

View file

@ -0,0 +1,12 @@
// Branding footer
.footer,
%footer {
padding-block: var(--gutters);
background-color: var(--color-footer-bg);
text-align: center;
p {
margin: 0;
}
}

View file

@ -2,6 +2,7 @@
.header, .header,
%header { %header {
padding-block: var(--gutters);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: var(--gutters); gap: var(--gutters);
@ -24,6 +25,7 @@
// The name of the website. // The name of the website.
&__site-name { &__site-name {
margin: 0; margin: 0;
line-height: 1;
} }
// The link around the name of the website. // The link around the name of the website.

View file

@ -0,0 +1,9 @@
@each $name, $space in $spacing {
.mt--#{$name} {
@include margin-top($space);
}
.mb--#{$name} {
@include margin-bottom($space);
}
}

View file

@ -1,8 +1,12 @@
@mixin spacing($property, $spacing) { @mixin spacing($property, $spacing, $unit: 'rem') {
$converted-list: (); $converted-list: ();
@each $x in $spacing { @each $x in $spacing {
$spacing: #{$x * $base-line-height + 'rem'}; @if $x == 0 {
$unit: '';
}
$spacing: #{$x * $base-line-height + $unit};
$converted-list: join($converted-list, $spacing, $separator: space); $converted-list: join($converted-list, $spacing, $separator: space);
} }

View file

@ -48,13 +48,13 @@
} }
&__toggle { &__toggle {
@include padding(0 .2);
display: flex; display: flex;
align-items: center; align-items: center;
position: absolute; position: absolute;
top: var(--gutters); top: var(--gutters);
right: var(--gutters); right: var(--gutters);
margin: 0; margin: 0;
padding: 0 .3rem;
font-weight: var(--fw-bold); font-weight: var(--fw-bold);
background-color: var(--color-text-bg); background-color: var(--color-text-bg);
color: var(--color-text); color: var(--color-text);
@ -107,11 +107,11 @@
} }
&__sheet { &__sheet {
@include padding(1.5);
visibility: hidden; visibility: hidden;
background-color: var(--color-mobile-menu); background-color: var(--color-mobile-menu);
width: 90vw; width: 90vw;
height: 100vh; height: 100vh;
padding: 2.25rem;
transform: translateX(100vw); transform: translateX(100vw);
z-index: 21; z-index: 21;

View file

@ -16,7 +16,11 @@
// Reset browsers to some sane defaults. // Reset browsers to some sane defaults.
@import 'reset/reset'; @import 'reset';
// Base styles.
@import 'base/base';
// Layouts // Layouts
@ -37,6 +41,7 @@
@import 'components/disabled/disabled'; @import 'components/disabled/disabled';
@import 'components/flex-group/flex-group'; @import 'components/flex-group/flex-group';
@import 'components/flex-inline/flex-inline'; @import 'components/flex-inline/flex-inline';
@import 'components/footer/footer';
@import 'components/grid-group/grid-group'; @import 'components/grid-group/grid-group';
@import 'components/grid-stack/grid-stack'; @import 'components/grid-stack/grid-stack';
@import 'components/header/header'; @import 'components/header/header';
@ -48,7 +53,9 @@
@import 'components/messages/messages'; @import 'components/messages/messages';
@import 'components/meta/meta'; @import 'components/meta/meta';
@import 'components/responsive-video/responsive-video'; @import 'components/responsive-video/responsive-video';
@import 'components/spacing/spacing';
@import 'components/stretch/stretch'; @import 'components/stretch/stretch';
@import 'components/tags/tags';
@import 'components/visually-hidden/visually-hidden'; @import 'components/visually-hidden/visually-hidden';
// Navigation // Navigation

View file

@ -14,7 +14,7 @@
<body class="{{ if .IsPage }}single-page{{ else }}list-page{{ end }}{{ if .IsHome }} front{{ end }}{{ with $.Param "bodyclass" }} {{ . }}{{ end }}"> <body class="{{ if .IsPage }}single-page{{ else }}list-page{{ end }}{{ if .IsHome }} front{{ end }}{{ with $.Param "bodyclass" }} {{ . }}{{ end }}">
<div class="page layout__page{{ if $.Param "sidebar" }} layout__sidebar-second{{ end }}"> <div class="page layout__page{{ if $.Param "sidebar" }} layout__sidebar-second{{ end }}">
<header class="header layout__header"> <header class="header layout__header mb--m">
{{ if $.Param "logo" | default true -}} {{ if $.Param "logo" | default true -}}
<a href="{{ "" | relLangURL }}" title="Home" rel="home" class="header__logo"> <a href="{{ "" | relLangURL }}" title="Home" rel="home" class="header__logo">
<img src="{{ with $.Param "logopath" }}{{ . | relURL }}{{ else }}{{ "images/logo.png" | relURL }}{{ end }}"{{ with $.Param "logowidth" }} width="{{ . }}"{{ end }}{{ with $.Param "logoheight" }} height="{{ . }}"{{ end }} alt="Home" class="header__logo-image"> <img src="{{ with $.Param "logopath" }}{{ . | relURL }}{{ else }}{{ "images/logo.png" | relURL }}{{ end }}"{{ with $.Param "logowidth" }} width="{{ . }}"{{ end }}{{ with $.Param "logoheight" }} height="{{ . }}"{{ end }} alt="Home" class="header__logo-image">
@ -36,7 +36,7 @@
{{ if $.Param "sidebar" }}{{ partial "sidebar.html" . }}{{ end -}} {{ if $.Param "sidebar" }}{{ partial "sidebar.html" . }}{{ end -}}
<footer class="footer layout__footer"> <footer class="footer layout__footer mt--l">
{{ if $.Param "feedlinks" }}{{ partial "feedlinks.html" . }}{{ end -}} {{ if $.Param "feedlinks" }}{{ partial "feedlinks.html" . }}{{ end -}}
<p>{{ with $.Param "copyright" }}{{ . | markdownify }}{{ else }}<span>© {{ site.Title }}</span>{{ end }}</p> <p>{{ with $.Param "copyright" }}{{ . | markdownify }}{{ else }}<span>© {{ site.Title }}</span>{{ end }}</p>
{{ with $.Param "footer" }}<p>{{ . | markdownify }}</p>{{ end }} {{ with $.Param "footer" }}<p>{{ . | markdownify }}</p>{{ end }}

View file

@ -1,6 +1,6 @@
<article class="full-view{{ with .Section }} full-view--{{ . | urlize }}{{ end }}"> <article class="full-view{{ with .Section }} full-view--{{ . | urlize }}{{ end }}">
<header> <header>
<h1 class="title {{ if $.Param "submitted" | default false }}title-submitted{{ end }}"><a href="{{ .RelPermalink }}">{{ .Title }}</a></h1> <h1 class="title {{ if $.Param "submitted" | default false }}mb--xxs{{ end }}"><a href="{{ .RelPermalink }}">{{ .Title }}</a></h1>
{{ if $.Param "submitted" | default false }}{{ partial "submitted.html" . }}{{ end -}} {{ if $.Param "submitted" | default false }}{{ partial "submitted.html" . }}{{ end -}}
</header> </header>
<div class="content"> <div class="content">

View file

@ -2,7 +2,7 @@
<main class="main layout__main"> <main class="main layout__main">
<article class="single-view{{ with .Section }} single-view--{{ . | urlize }}{{ end }}"> <article class="single-view{{ with .Section }} single-view--{{ . | urlize }}{{ end }}">
<header> <header>
<h1 class="title {{ if $.Param "submitted" | default false }}title-submitted{{ end }}">{{ .Title }}</h1> <h1 class="title {{ if $.Param "submitted" | default false }}mb--xxs{{ end }}">{{ .Title }}</h1>
{{ if $.Param "submitted" | default false }}{{ partial "submitted.html" . }}{{ end -}} {{ if $.Param "submitted" | default false }}{{ partial "submitted.html" . }}{{ end -}}
{{ if .Params.tags }}{{ partial "tags.html" . }}{{ end -}} {{ if .Params.tags }}{{ partial "tags.html" . }}{{ end -}}
</header> </header>

View file

@ -1,6 +1,6 @@
<article class="list-view{{ with .Section }} list-view--{{ . | urlize }}{{ end }}"> <article class="list-view{{ with .Section }} list-view--{{ . | urlize }}{{ end }}">
<header> <header>
<h2 class="title {{ if $.Param "submitted" | default false }}title-submitted{{ end }}"><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2> <h2 class="title {{ if $.Param "submitted" | default false }}mb--xxs{{ end }}"><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ if $.Param "submitted" | default false }}{{ partial "submitted.html" . -}}{{ end }} {{ if $.Param "submitted" | default false }}{{ partial "submitted.html" . -}}{{ end }}
</header> </header>
<div class="content"> <div class="content">

View file

@ -1,6 +1,6 @@
<div class="tags meta"> <div class="tags meta">
{{ i18n "taxo_tags" }}: {{ i18n "taxo_tags" }}:
<ul class="flex-inline flex-inline--inline"> <ul>
{{ range (.GetTerms "tags") -}} {{ range (.GetTerms "tags") -}}
<li><a href="{{ .Permalink }}">{{ .LinkTitle }}</a></li> <li><a href="{{ .Permalink }}">{{ .LinkTitle }}</a></li>
{{ end -}} {{ end -}}

View file

@ -1,6 +1,6 @@
<article class="full-view{{ with .Section }} full-view--{{ . | urlize }}{{ end }}"> <article class="full-view{{ with .Section }} full-view--{{ . | urlize }}{{ end }}">
<header> <header>
<h1 class="title {{ if $.Param "submitted" | default false }}title-submitted{{ end }}"><a href="{{ .RelPermalink }}">{{ .Title }}</a></h1> <h1 class="title {{ if $.Param "submitted" | default false }}mb--xxs{{ end }}"><a href="{{ .RelPermalink }}">{{ .Title }}</a></h1>
{{ if $.Param "submitted" | default false }}{{ partial "submitted.html" . }}{{ end -}} {{ if $.Param "submitted" | default false }}{{ partial "submitted.html" . }}{{ end -}}
</header> </header>
{{ partial "podcast.html" . -}} {{ partial "podcast.html" . -}}

View file

@ -2,7 +2,7 @@
<main class="main layout__main"> <main class="main layout__main">
<article class="single-view{{ with .Section }} single-view--{{ . | urlize }}{{ end }}"> <article class="single-view{{ with .Section }} single-view--{{ . | urlize }}{{ end }}">
<header> <header>
<h1 class="title {{ if $.Param "submitted" | default false }}title-submitted{{ end }}">{{ .Title }}</h1> <h1 class="title {{ if $.Param "submitted" | default false }}mb--xxs{{ end }}">{{ .Title }}</h1>
{{ if $.Param "submitted" | default false }}{{ partial "submitted.html" . }}{{ end -}} {{ if $.Param "submitted" | default false }}{{ partial "submitted.html" . }}{{ end -}}
{{ if .Params.tags }}{{ partial "tags.html" . }}{{ end -}} {{ if .Params.tags }}{{ partial "tags.html" . }}{{ end -}}
</header> </header>

View file

@ -14,7 +14,7 @@
<template> <template>
<article class="search-result list-view"> <article class="search-result list-view">
<header> <header>
<h2 class="title title-submitted"><a href="#">Title here</a></h2> <h2 class="title mb--xxs"><a href="#">Title here</a></h2>
<div class="submitted"><time class="created-date">Date here</time></div> <div class="submitted"><time class="created-date">Date here</time></div>
</header> </header>
<div class="content">Summary here</div> <div class="content">Summary here</div>