JSFiddle - React, Tailwind, and code Playground

by redclover

HTML

<h1>Level 1 heading</h1>
<h2>Level 2 heading</h2>
<h3>Level 3 heading</h3>
<h4>Level 4 heading</h4>
<h5>Level 5 heading</h5>
<h6>Level 6 heading</h6>

<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>

SCSS

/*
 * Vars
 */
$base-size:   16;
$line-height: 24;
$h1-size:     36;
$h2-size:     30;
$h3-size:     24;
$h4-size:     20;
$h5-size:     16;
$h6-size:     14;

/*
 * Mixins
 */
@mixin font-size($font-size){
    font-size:$font-size + px;
    font-size:#{$font-size} / #{$base-size} + rem;
}

@mixin line-height($font-size, $base-line-height) {
  /* Sets the line-height to a multiple 
   * of $base-line-height that's not smaller than
   * $font-size
   */
   line-height: ceil($font-size / $base-line-height) * ($base-line-height / $font-size);
}

/*
 * Shared
 */
h1,h2,h3,h4,h5,h6,hgroup,
ul,ol,dl,
blockquote,p,address,
table,
form,
pre,
hr{
    margin-bottom:$line-height + px;
    margin-bottom:#{$line-height}/#{$base-size} + rem;
}

/*
 * Main
 */
html{
    font-size:#{$base-size} / 16 + em;
    line-height:#{$line-height} / #{$base-size};
    font-family:Georgia, serif;
}

/*
 * Headings
 */
h1,.alpha{
    @include font-size($h1-size);
    /**
     * Given the information we have, how would you generate the number below?
     */
    @include line-height($h1-size, $line-height);  /* 48px */
}
h2,.beta{
    @include font-size($h2-size);
    /**
     * Given the information we have, how would you generate the number below?
     */
    @include line-height($h2-size, $line-height);    /* 48px */
}
h3,.gamma{
    @include font-size($h3-size);
    /**
     * Given the information we have, how would you generate the number below?
     */
    @include line-height($h3-size, $line-height);      /* 24px */
}
h4,.delta{
    @include font-size($h4-size);
    /**
     * Given the information we have, how would you generate the number below?
     */
    @include line-height($h4-size, $line-height);;    /* 24px */
}
h5,.epsilon{
    @include font-size($h5-size);
    /**
     * Given the information we have, how would you generate the number below?
     */
    @include line-height($h5-size, $line-height);;    /* 24px */
}
h6,.zeta{
    @include font-size($h6-size);
    /**
     *...

JavaScript

/*
 * For vertical rhythm, all `line-height`s need to be a multiple of my
 * base `line-height` (24px). How do I do get these unitless numbers for
 * my headings using Sass? Can I?
 */