homepage/styles/_components.scss
2021-07-08 15:51:22 +02:00

323 lines
6 KiB
SCSS

@use 'colors';
@use 'layout';
@use 'typography';
// --------------------
// Site-wide components
// --------------------
// CSS-Only navigation toggle. This works by hiding the navigation on small
// screens and only revealing it when the link has been clicked (and the URL
// hash points to #navigation). On larger screens, it is always shown and the
// toggle is hidden. This should probably be switched to a <details> element.
#navigation {
.site-navigation {
display: none;
}
&:target {
.navigation-toggle {
&.show {
display: none;
}
&.hide {
display: block;
}
}
.site-navigation {
display: block;
}
}
@media (screen and min-width: layout.$breakpoint) {
.site-navigation {
flex: 0;
display: block;
ul {
display: flex;
margin-bottom: 0;
a {
display: inline-block;
}
}
}
.navigation-toggle {
display: none;
}
}
}
// The site logo text. More specific styles for this element are also present
// underneath .site-header.
.site-logo {
margin: 0 layout.$normal-gap;
text-transform: lowercase;
}
// The navigation is present twice on the site: once in the header and once in
// the footer. The former also has some specific styles (see .site-header
// below).
.site-navigation {
flex-basis: 100%;
ul {
margin: 0;
padding: 0;
list-style: none;
}
a {
display: block;
font-size: typography.$large-size;
font-weight: typography.$emphasized-weight;
text-align: center;
text-decoration: none;
text-transform: lowercase;
}
}
.site-header {
display: flex;
// This container needs to wrap because when the navigation is open on small
// screens, we want it to overflow into its own line.
flex-wrap: wrap;
align-items: center;
position: relative;
z-index: 10;
background-color: colors.$main-background;
@include colors.block-shadow;
a {
padding: 0 layout.$normal-gap;
line-height: 3rem;
}
.site-logo {
flex-grow: 1;
padding: 0;
font-size: typography.$large-size;
text-decoration: none;
}
.site-navigation ul {
margin: 0 0 layout.$small-gap 0;
}
.navigation-toggle {
display: block;
padding: 0 layout.$normal-gap;
&.hide {
display: none;
}
}
}
.site-footer {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: layout.$normal-gap;
.content {
> p:first-child {
margin-top: 0;
}
> p:last-child {
margin-bottom: 0;
}
}
}
// ------------------------------
// Components on individual pages
// ------------------------------
// This is the wrapper element around individual .page-content blocks. The home
// page contains a few of these sections, while normal pages only contain one.
// Spanning the entire width, sections may have different themes.
.page-section {
padding: layout.$large-gap;
&.inverse {
color: colors.$gray-50;
background-color: colors.$blue-800;
h2:after {
background-color: colors.$gray-50;
}
}
&.footer {
background-color: colors.$teal-500;
}
}
.page-content {
margin: 0 auto;
max-width: 80rem;
}
// Banners can be put at the top of a page to draw attention. A banner has
// two children:
// - A .background element which contains an image to render behind the text
// - A .content which holds the actual text.
.page-banner {
display: flex;
flex-direction: column;
justify-content: space-around;
position: relative;
min-height: 60vh;
> .background {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow: hidden;
img {
width: 100%;
height: 100%;
object-fit: cover;
}
}
> .content {
display: flex;
flex-direction: column;
align-items: flex-start;
position: relative;
padding: layout.$normal-gap max(#{layout.$large-gap}, 15vw);
> div {
display: inline-block;
padding: layout.$small-gap layout.$normal-gap;
font-size: typography.$large-size;
background-color: colors.$yellow-600;
> p:first-child {
margin-top: 0;
}
> p:last-child {
margin-bottom: 0;
}
}
> .title {
padding: 0 layout.$normal-gap;
line-height: 5rem;
font-size: typography.$huge-size;
font-weight: typography.$emphasized-weight;
background-color: colors.$teal-500;
}
}
}
.boxes-module {
padding: layout.$large-gap;
background-color: colors.$teal-300;
.content,
.box {
&:not(:last-child) {
margin-bottom: layout.$large-gap;
}
}
.content {
> *:first-child {
margin-top: 0;
}
> *:last-child {
margin-bottom: 0;
}
}
.box {
margin: layout.$large-gap 0;
padding: layout.$large-gap;
background: colors.$gray-50;
@include colors.card-shadow;
h3 {
margin: 0;
text-transform: uppercase;
}
}
@media screen and (min-width: layout.$breakpoint) {
display: grid;
grid-template-columns: repeat(6, 1fr);
gap: layout.$large-gap;
.content,
.box {
grid-column: span 3;
margin: 0;
&:not(:last-child) {
margin-bottom: 0;
}
}
.box:not(.first) {
grid-column: span 2;
}
}
}
.tabs-widget {
display: flex;
flex-direction: row-reverse;
flex-wrap: wrap;
justify-content: center;
margin-top: #{-1 * layout.$large-gap};
> a {
display: block;
margin: 0 layout.$normal-gap;
text-decoration: none;
color: inherit;
}
> .tab {
flex: 100% 1;
order: -1;
display: none;
margin: layout.$large-gap 0;
padding: layout.$large-gap;
background: colors.$gray-50;
@include colors.card-shadow;
&:last-of-type,
&:target {
display: block;
+ a {
font-weight: typography.$emphasized-weight;
color: colors.$blue-800;
}
}
&:target {
~ .tab {
display: none;
+ a {
font-weight: inherit;
color: inherit;
}
}
}
}
}