Replace obsolete normalize with a lightweight reset.

This commit is contained in:
Fredrik Jonsson 2021-12-25 18:28:17 +01:00
commit a1e745c686
10 changed files with 220 additions and 703 deletions

View file

@ -0,0 +1,12 @@
// Reset browsers to some sane defaults.
// Broken into modular pieces to make it easier to edit.
@import 'document/document';
@import 'embedded/embedded';
@import 'forms/forms';
@import 'grouping/grouping';
@import 'interactive/interactive';
@import 'links/links';
@import 'sections/sections';
@import 'tables/tables';
@import 'text/text';

View file

@ -0,0 +1,35 @@
// stylelint-disable property-no-vendor-prefix
// Document
html {
// Change the default font family in all browsers (opinionated).
@include typeface(body);
// Correct the line height in all browsers.
@include define-type-sizing();
// Prevent adjustments of font size.
-webkit-text-size-adjust: none;
text-size-adjust: none;
// On short pages, we want any background gradients to fill the entire height
// of the browser.
min-height: 100%;
// Use the saner border-box model.
box-sizing: border-box;
// Use smooth scrolling.
scroll-behavior: smooth;
// Improve text rendering.
-webkit-font-smoothing: antialiased;
@include respond-to(xxl) {
@include define-type-sizing($base-font-size-2, $base-line-height-2);
}
}
// Use the saner border-box model for all elements.
*,
*::before,
*::after {
box-sizing: inherit;
}

View file

@ -0,0 +1,15 @@
// Embedded content
img,
picture,
video,
canvas,
svg {
display: block;
max-width: 100%;
}
img,
svg {
height: auto;
}

View file

@ -0,0 +1,25 @@
// Form defaults.
input,
button,
textarea,
select {
font: inherit;
max-width: 100%;
}
label {
display: block;
font-weight: bold;
}
fieldset {
border: 1px solid var(--color-border);
}
[type='search'] {
// Correct the odd appearance in Chrome and Safari.
-webkit-appearance: textfield;
// Correct the outline style in Safari.
outline-offset: -2px;
}

View file

@ -0,0 +1,78 @@
// Grouping content
// Block quotes
//
// The `<blockquote>` element is for quoting blocks of content from another
// source within your document. Wrap the `<blockquote>` around any <abbr
// title="HyperText Markup Language">HTML</abbr> as the quote. For straight
// quotes, we recommend a `<p>`.
//
// Optionally, add a `<footer>` to identify the source of the quote, wrapping
// the name of the source work in `<cite>`.
blockquote {
// Add vertical rhythm margins.
// Also indent the quote on both sides.
@include margin(1 $indent-amount);
}
// Lists
dl,
ol,
ul {
// Add vertical rhythm margins.
@include margin(1 0);
}
dd {
margin: 0 0 0 $indent-amount;
@include rtl {
margin: 0 $indent-amount 0 0;
}
}
ol,
ul {
padding: 0 0 0 $indent-amount;
@include rtl {
padding: 0 $indent-amount 0 0;
}
// Turn off margins on nested lists.
ol,
ul {
margin: 0;
}
}
// Figures
figure {
// Add vertical rhythm margins.
@include margin(1 0);
}
// Horizontal rule
hr {
@extend %divider;
height: 0;
}
// Paragraphs
p,
pre {
@include margin(.75 0);
}
// Preformatted text
pre {
@extend %monospace;
}

View file

@ -0,0 +1,21 @@
// Interactive
// Menu
menu {
// Set 1 unit of vertical rhythm on the top and bottom margin.
@include margin(1 0);
// Set consistent space for the list style image.
padding: 0 0 0 $indent-amount;
@include rtl {
padding: 0 $indent-amount 0 0;
}
// Turn off margins on nested lists.
menu &,
ol &,
ul & {
margin: 0;
}
}

View file

@ -0,0 +1,33 @@
// Links
//
// Hyperlinks are used to allow the user to navigate to other resources or to
// download a resource.
//
// The order of link states are based on Eric Meyer's article:
// http://meyerweb.com/eric/thoughts/2007/06/11/who-ordered-the-link-states
//
// :visited - A link that has already been visited.
// :hover - A link that is being hovered over.
// :focus - A link that has been given keyboard focus.
// :active - A link that is being actively clicked.
a,
%link {
color: var(--color-link);
}
// Any element can receive focus, but only links can be visited, so we can
// safely lower this selector's specificity. This also ensures visited links
// with additional styles won't have their styles overridden.
:visited {
color: var(--color-link-visited);
}
a:hover,
a:focus {
color: var(--color-link-hover);
}
a:active {
color: var(--color-link-active);
}

View file

@ -0,0 +1,112 @@
// Sections
// ==========================================================================
body {
// Output a horizontal grid to help with debugging typography. The
// $typey-debug variable will toggle its output.
@include typey-debug-grid();
// Remove the margin in all browsers (opinionated).
margin: 0;
padding: 0;
}
// Headings
//
// All HTML headings, `<h1>` through `<h6>`, are available. `%h1` through `%h6`
// classes are also available, for when you want to match the font styling of a
// heading but still want your text to be displayed inline.
// Correct the font size and margin on `h1` elements within `section` and
// `article` contexts in Chrome, Firefox, and Safari.
h1,
%h1 {
// Set the font-size and line-height while keeping a proper vertical rhythm.
@include type-layout(xxl, 1.5);
// Set 1 unit of vertical rhythm on the top and bottom margins.
@include margin-top(1, xxl);
@include margin-bottom(1, xxl);
}
h2,
%h2 {
@include type-layout(xl, 1.5);
@include margin-top(1, xl);
@include margin-bottom(1, xl);
}
h3,
%h3 {
@include type-layout(l, 1.5);
@include margin-top(1, l);
@include margin-bottom(1, l);
}
h4,
%h4 {
@include type-layout(m, 1);
@include margin-top(1, m);
@include margin-bottom(1, m);
}
h5,
%h5 {
@include type-layout(s, 1);
@include margin-top(1, s);
@include margin-bottom(1, s);
}
h6,
%h6 {
@include type-layout(xs, 1);
@include margin-top(1, xs);
@include margin-bottom(1, xs);
}
@include respond-to(s) {
h1,
%h1 {
// Set the font-size and line-height while keeping a proper vertical rhythm.
@include type-layout(xxl-2, 2);
// Set 1 unit of vertical rhythm on the top and bottom margins.
@include margin-top(1, xxl-2);
@include margin-bottom(1, xxl-2);
}
h2,
%h2 {
@include type-layout(xl-2, 1.5);
@include margin-top(1, xl-2);
@include margin-bottom(1, xl-2);
}
h3,
%h3 {
@include type-layout(l-2, 1.5);
@include margin-top(1, l-2);
@include margin-bottom(1, l-2);
}
h4,
%h4 {
@include type-layout(m-2, 1);
@include margin-top(1, m-2);
@include margin-bottom(1, m-2);
}
h5,
%h5 {
@include type-layout(s-2, 1);
@include margin-top(1, s-2);
@include margin-bottom(1, s-2);
}
h6,
%h6 {
@include type-layout(xs-2, 1);
@include margin-top(1, xs-2);
@include margin-bottom(1, xs-2);
}
}

View file

@ -0,0 +1,19 @@
// Tables
//
// The `<table>` element displays tabular data in rows, columns, and cells.
table {
// Add vertical rhythm margins.
@include margin(1 0);
// Remove most spacing between table cells.
border-collapse: collapse;
border-spacing: 0;
// Prevent cramped-looking tables
width: 100%;
}
td,
th {
// Remove most spacing between table cells.
padding: 0;
}

View file

@ -0,0 +1,38 @@
// Text-level semantics
//
// The elements in this section give semantics to inline text.
// Code
code,
kbd,
samp {
@extend %monospace;
}
// Small text
small {
// Add the correct font size in all browsers.
@include font-size(s);
}
// Superscript / Subscript
sub,
sup {
// Prevent `sub` and `sup` elements from affecting the line height in
// all browsers.
@include font-size(xs);
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -.25em;
}
sup {
top: -.5em;
}