Skip to content

Instantly share code, notes, and snippets.

@gddabe
Last active September 23, 2020 13:47
Show Gist options
  • Save gddabe/c665cd6cb4d5b7e9a079dc6a1f2260b3 to your computer and use it in GitHub Desktop.
Save gddabe/c665cd6cb4d5b7e9a079dc6a1f2260b3 to your computer and use it in GitHub Desktop.
css starter for typography projects
:root {
/* main colors */
--color-primary: #286bf4;
--color-primary-light: color-mod(var(--color-primary) tint(15%));
--color-primary-dark: color-mod(var(--color-primary) shade(15%));
--color-primary-bg: color-mod(var(--color-primary) alpha(20%));
--color-accent: #f5414f;
--color-accent-light: color-mod(var(--color-accent) tint(15%));
--color-accent-dark: color-mod(var(--color-accent) shade(10%));
--color-accent-bg: color-mod(var(--color-accent) alpha(20%));
--color-text: var(--gray-10);
--color-text-heading: var(--black);
--color-text-subtle: var(--gray-6);
--color-link: var(--color-primary);
--color-link-visited: var(--color-primary-dark);
}
body {
color: var(--color-text);
}
h1,
h2,
h3,
h4,
form legend {
color: var(--color-text-heading);
}
a {
color: var(--color-text);
text-decoration: none;
// &:visited {
// color: var(--color-text);
// }
}
:root {
/* type scale */
--text-xs: calc(1em / (var(--text-scale-ratio) * var(--text-scale-ratio)));
--text-sm: calc(1em / var(--text-scale-ratio));
--text-md: calc(1em * var(--text-scale-ratio));
--text-lg: calc(1em * var(--text-scale-ratio) * var(--text-scale-ratio));
--text-xl: calc(
1em * var(--text-scale-ratio) * var(--text-scale-ratio) *
var(--text-scale-ratio)
);
--text-xxl: calc(
1em * var(--text-scale-ratio) * var(--text-scale-ratio) *
var(--text-scale-ratio) * var(--text-scale-ratio)
);
--text-xxxl: calc(
1em * var(--text-scale-ratio) * var(--text-scale-ratio) *
var(--text-scale-ratio) * var(--text-scale-ratio) *
var(--text-scale-ratio)
);
}
// @include breakpoint(md) {
// :root {
// --text-base-size: 1.25em;
// --text-scale-ratio: 1.25;
// }
// }
body {
font-size: calc(0.625 * var(--text-base-size));
font-family: var(--font-primary);
}
/* text size */
.text--xxxl {
font-size: var(--text-xxxl);
}
h1,
.text--xxl {
font-size: var(--text-xxl);
}
h2,
.text--xl {
font-size: var(--text-xl);
}
h3,
.text--lg {
font-size: var(--text-lg);
}
h4,
.text--md {
font-size: var(--text-md);
}
.text--sm,
small {
font-size: var(--text-sm);
}
.text--xs {
font-size: var(--text-xs);
}
b,
strong {
font-weight: bold;
}
.text-container {
em {
font-style: italic;
}
}
/* utility classes */
.truncate {
// truncate text if it exceeds parent
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
:root {
/* spacing values */
--space-unit: 1em;
--space-xxs: calc(0.25 * var(--space-unit));
--space-xs: calc(0.5 * var(--space-unit));
--space-sm: calc(0.75 * var(--space-unit));
--space-md: calc(1.25 * var(--space-unit));
--space-lg: calc(2 * var(--space-unit));
--space-xl: calc(3.25 * var(--space-unit));
--space-xxl: calc(5.25 * var(--space-unit));
/* fixed values - not affected by --space-unit or --text-base-size */
--space-unit-fixed: 1rem;
--space-xxs-fixed: calc(0.25 * var(--space-unit-fixed));
--space-xs-fixed: calc(0.5 * var(--space-unit-fixed));
--space-sm-fixed: calc(0.75 * var(--space-unit-fixed));
--space-md-fixed: calc(1.25 * var(--space-unit-fixed));
--space-lg-fixed: calc(2 * var(--space-unit-fixed));
--space-xl-fixed: calc(3.25 * var(--space-unit-fixed));
--space-xxl-fixed: calc(5.25 * var(--space-unit-fixed));
}
h1,
h2,
h3,
h4,
form legend {
margin-bottom: var(--space-xxs);
line-height: var(--heading-line-height);
}
p {
line-height: var(--body-line-height);
}
.text-container {
h2,
h3,
h4 {
margin-top: var(--space-sm);
}
ul,
ol,
p {
margin-bottom: var(--space-md);
}
ul li,
ol li {
line-height: var(--body-line-height);
}
}
@import "./reset.scss";
@import "./typography.scss";
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
// HTML5 display-role reset for older browsers
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
display: block;
}
body {
line-height: 1;
}
ol,
ul {
list-style: none;
}
blockquote,
q {
quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
content: "";
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
/* --------------------------------
https://medium.com/codyhouse/create-your-design-system-part-1-typography-7c630d9092bd
https://codyhouse.co/ds/globals/typography
-------------------------------- */
@import "./_colors.scss";
@import "./_spacing.scss";
@import "./_font.scss";
:root {
/* typography -> set font type */
--font-primary: Georgia, serif;
--font-secondary: sans-serif;
/* typography -> set base values */
--text-base-size: 1em;
--text-scale-ratio: 1.2;
/* spacing -> line-height */
--heading-line-height: 1.2;
--body-line-height: 1.5;
/* colors -> shades - generated using chroma.js - 12 steps */
--black: #1d1d21; // heading
--gray-10: #2e2e31; // normal text
--gray-6: #7b7a7d; // subtle
--gray-4: #a5a5a6;
--gray-3: #bbbbbc;
--gray-2: #d1d0d2;
--gray-1: #e8e7e8;
--white: white;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment