@use 'base'; @use 'colors'; @use 'layout'; @use 'typography'; // -------------------- // Site-wide components // -------------------- @mixin header-item { padding: 0 layout.$normal-gap; line-height: 3rem; } // 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 { &.horizontal { > ul { display: flex; margin-bottom: 0; } a { display: inline-block; @include header-item; } } > ul { margin: 0; padding: 0; list-style: none; } a { display: block; padding: layout.$small-gap; font-weight: typography.$emphasized-weight; text-align: center; text-decoration: none; text-transform: lowercase; } } .site-mobile-navigation { cursor: pointer; > summary { display: block; @include header-item; } &[open] { flex-basis: 100%; > summary { // The positioning requires that the header component has relative // positioning. position: absolute; top: 0; right: 0; color: colors.$blue-800; } } // This is the next site navigation block (the one that's visible on desktop), // while... + .site-navigation { display: none; } // ... this here is the one inside the mobile-only
block. > .site-navigation { &::before { content: ''; display: block; margin: 0 auto; width: calc(100% - #{2 * layout.$normal-gap}); height: 1px; background-color: colors.$gray-300; } } @media screen and (min-width: layout.$breakpoint) { display: none; + .site-navigation { display: block; } } } .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; // Relative positioning is required here so that we can fake the menu button's // location on mobile. position: relative; z-index: 10; background-color: colors.$main-background; @include colors.block-shadow; > .site-logo { flex-grow: 1; margin: 0; font-size: typography.$subheading-size; text-decoration: none; @include header-item; } } .site-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: layout.$normal-gap; } // ------------------------------ // 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.$subheading-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.$title-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; } } } // This is an HTML/CSS-only tabs component. It expects the following markup: // //
//
Other, totally novel content.
// Second //
Some content, including a heading.
// First //
// // The key thing here is that the container is a flexbox with that flows in // reverse row direction. That means that the first element in the container //
will be shown last, which means we can use the ~ and + selectors to // target all and the immediately following tabs and / or their corresponding // links. // The last tab in the DOM (which is shown first because of the reversed // flexbox) is shown by default, while the other ones are hidden. If one of the // tabs is targeted by the URL's hash, it is shown instead and the default tab // is hidden. .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; } } } } }