Sweetlife Web Test v3@beta-1

In this example below you will see how to do a Sweetlife Web Test v3@beta-1 with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by leggomuhgreggo, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright leggomuhgreggo ©

Technologies

  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>Sweetlife Web Test v3@beta-1</title>
  
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">

  <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.4/css/bootstrap.min.css'>
<link rel='stylesheet prefetch' href='css/zxekbd.css'>

      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <div class="copy">
    <h1>Et Farum Quidem Rerum Facilis Est</h1>
    <hr />
    <p>Temporibus autem quibusdam et expedita distinctio. Facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Excepteur sint occaecat cupidatat non proident, sunt in culpa. Ut enim ad minim veniam, quis nostrud exercitation ullamco.
        Ut enim ad minim veniam, quis nostrud exercitation ullamco.</p>
    
    <button>Submit</button>
    <h2>Quis autem vel iure reprehenderit</h2>
    <p>Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit. Duis aute irure dolor in reprehenderit in voluptate velit. Totam rem aperiam. Sed ut perspiciatis unde omnis iste natus error sit voluptatem. Ut enim ad
        minim veniam, quis nostrud exercitation ullamco. Laboris nisi ut aliquip ex ea commodo consequat.</p>
    <ul>
        <li>Corrupti quos dolores et quas molestias excepturi sint occaecati.</li>
        <li>Architecto beatae vitae dicta sunt explicabo.</li>
        <li>Nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam.</li>
        <li>Corrupti quos dolores et quas molestias excepturi sint occaecati.</li>
    </ul>
    <h3>Excepteur Sint</h3>
    <p>Nihil molestiae consequatur, vel illum qui dolorem eum. Animi, id est laborum et dolorum fuga. Excepteur sint occaecat cupidatat non proident, sunt in culpa. Quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Inventore veritatis
        et quasi architecto beatae vitae dicta sunt explicabo.</p>
    <h4>Porro Quisquam</h4>
    <p>Nihil molestiae consequatur, vel illum qui dolorem eum. Nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam. Qui officia deserunt mollit anim id est laborum. Corrupti quos dolores et
        quas molestias excepturi sint occaecati.</p>
    <ol>
        <li>Et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque.</li>
        <li>Facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.</li>
        <li>Corrupti quos dolores et quas molestias excepturi sint occaecati.</li>
    </ol>
    <h5>Porro Quisquam</h5>
    <p>Architecto beatae vitae dicta sunt explicabo. Duis aute irure dolor in reprehenderit in voluptate velit. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat.</p>
    <h6>Itaque Earum Rerum</h6>
    <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco. Nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur,
        adipisci velit.</p>
  
    <hr>


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

    <p>Et harum quidem rerum facilis est et expedita distinctio. Ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. Facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Animi, id est
        laborum et dolorum fuga. Totam rem aperiam.</p>

    <blockquote>
        <p>A block quotation (also known as a long quotation or extract) is a quotation in a written document, that is set off from the main text as a paragraph, or block of text, and typically distinguished visually using indentation and a different typeface
            or smaller size quotation.</p>
    </blockquote>

    <p>Ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. Animi, id est laborum et dolorum fuga. Do eiusmod tempor incididunt ut labore et dolore magna aliqua. Inventore veritatis et quasi architecto beatae
        vitae dicta sunt explicabo. Ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.</p>


    <p><a href="#">This is a text link</a></p>
    <p><strong>Strong is used to indicate strong importance</strong></p>
    <p><em>This text has added emphasis</em></p>
    <p>The <b>b element</b> is stylistically different text from normal text, without any special importance</p>
    <p>The <i>i element</i> is text that is set off from the normal text</p>
    <p>The <u>u element</u> is text with an unarticulated, though explicitly rendered, non-textual annotation</p>
    <p><del>This text is deleted</del> and <ins>This text is inserted</ins></p>
    <p><s>This text has a strikethrough</s></p>
    <p>Superscript<sup>®</sup></p>
    <p>Subscript for things like H<sub>2</sub>O</p>
    <p><small>This small text is small for for fine print, etc.</small></p>
    <p>Abbreviation: <abbr title="HyperText Markup Language">HTML</abbr></p>
    <p>Keybord input: <kbd>Cmd</kbd></p>
    <p><q cite="https://developer.mozilla.org/en-US/docs/HTML/Element/q">This text is a short inline quotation</q></p>
    <p><cite>This is a citation</cite>
    </p>
    <p>The <dfn>dfn element</dfn> indicates a definition.</p>
    <p>The <mark>mark element</mark> indicates a highlight</p>
    <p><code>This is what inline code looks like.</code></p>
    <p><samp>This is sample output from a computer program</samp></p>
    <p>The <var>variarble element</var>, such as <var>x</var> = <var>y</var></p>

    <p>Time: <time datetime="2013-04-06T12:32+00:00">2 weeks ago</time></p>

    <pre><code class="language-javascript">P R E F O R M A T T E D T E X T
! " # $ % &amp; ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; &lt; = &gt; ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~ </code></pre>

    <hr>

    <ul>
        <li>This is a list item in an unordered list</li>
        <li>An unordered list is a list in which the sequence of items is not important. Sometimes, an unordered list is a bulleted list. And this is a long list item in an unordered list that can wrap onto a new line. </li>
        <li>
            Lists can be nested inside of each other
            <ul>
                <li>This is a nested list item</li>
                <li>This is another nested list item in an unordered list</li>
            </ul>
        </li>
        <li>This is the last list item</li>
    </ul>

    <p>Et harum quidem rerum facilis est et expedita distinctio. Corrupti quos dolores et quas molestias excepturi sint occaecati. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam. Do eiusmod tempor incididunt ut labore
        et dolore magna aliqua.</p>

    <ol>
        <li>This is a list item in an ordered list</li>
        <li>An ordered list is a list in which the sequence of items is important. An ordered list does not necessarily contain sequence characters.</li>
        <li>
            Lists can be nested inside of each other
            <ol>
                <li>This is a nested list item</li>
                <li>This is another nested list item in an ordered list</li>
            </ol>
        </li>
        <li>This is the last list item</li>
    </ol>

    <p>Facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Duis aute irure dolor in reprehenderit in voluptate velit. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit. Cupiditate non provident, similique sunt
        in culpa qui officia deserunt mollitia.</p>

    <dl>
        <dt>Definition List</dt>
        <dd>A number of connected items or names written or printed consecutively, typically one below the other.</dd>
        <dt>This is a term.</dt>
        <dd>This is the definition of that term, which both live in a <code>dl</code>.</dd>
        <dt>Here is another term.</dt>
        <dd>And it gets a definition too, which is this line.</dd>
        <dt>Here is term that shares a definition with the term below.</dt>
        <dd>And it gets a definition too, which is this line.</dd>
    </dl>

    <table>
        <caption>Table Caption</caption>
        <thead>
            <tr>
                <th>Table Heading 1</th>
                <th>Table Heading 2</th>
                <th>Table Heading 3</th>
                <th>Table Heading 4</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>Table Footer 1</th>
                <th>Table Footer 2</th>
                <th>Table Footer 3</th>
                <th>Table Footer 4</th>
            </tr>
        </tfoot>
        <tbody>
            <tr>
                <td>Table Cell 1</td>
                <td>Table Cell 2</td>
                <td>Table Cell 3</td>
                <td>Table Cell 4</td>
            </tr>
            <tr>
                <td>Table Cell 1</td>
                <td>Table Cell 2</td>
                <td>Table Cell 3</td>
                <td>Table Cell 4</td>
            </tr>
            <tr>
                <td>Table Cell 1</td>
                <td>Table Cell 2</td>
                <td>Table Cell 3</td>
                <td>Table Cell 4</td>
            </tr>
            <tr>
                <td>Table Cell 1</td>
                <td>Table Cell 2</td>
                <td>Table Cell 3</td>
                <td>Table Cell 4</td>
            </tr>
        </tbody>
    </table>

    <div class="vcard">
        <div class="org">Company Name</div>
        <div class="adr">
            <div class="street-address">1234 Main St.</div>
            <span class="locality">Anywhere</span>,
            <span class="postal-code">101010</span>,
            <abbr class="region" title="California">CA</abbr>
            <div class="country-name">U.S.A</div>
        </div>
        <div class="tel">+1.888.123.4567</div>
    </div>
</div>
  
  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/leggomuhgreggo/sweetlife-web-test-v3beta-1-GjExyQ */
.copy h1, .copy h2, .copy h3, .copy h4, .copy h5, .copy h6, .copy .h1, .copy .h2, .copy .h3, .copy .h4, .copy .h5, .copy .h6 {
  font-family: 'Sweetlife';
}

@font-face {
  font-family: 'Sweetlife';
  src: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/39469/SweetlifeMedium.woff2") format("woff2");
}
body .copy {
  font-family: "Sweetlife";
}

button {
  padding: 10px 20px;
  background: transparent;
  border-radius: 4px;
  border: solid black 2px;
  line-height: 1;
}

.demo.corrected button {
  top: 3;
}


/*Downloaded from https://www.codeseek.co/leggomuhgreggo/sweetlife-web-test-v3beta-1-GjExyQ */
console.clear();

var paragraphs = document.querySelectorAll('h1, h2, h3, p');

function updateInfo() {
    Array.prototype.forEach.call(paragraphs, function (p) {
        var styles = getComputedStyle(p);
        var lh = parseFloat(styles.lineHeight.replace('px', ''));
        var fs = parseFloat(styles.fontSize.replace('px', ''));
        var ratio = Math.round(lh / fs * 100) / 100;
        var roundedFs = Math.round(fs * 100) / 100;
        p.setAttribute('data-info', roundedFs + 'px / ' + ratio);
    });
}

updateInfo();

window.addEventListener('resize', function () {
    updateInfo();
    getCPL(paragraphs[1]);
});

function getCPL(el) {
    var span = document.createElement('span');
    var styles = window.getComputedStyle(el);
    var padding = parseFloat(styles.paddingLeft) + parseFloat(styles.paddingRight);
    var containerWidth = el.clientWidth - padding;
    var samples = 1;
    var aggregateCPL = 0;
    var text = 'born like this\ninto this\nas the chalk faces smile\nas Mrs. Death laughs\nas the elevators break\nas political landscapes dissolve\nas the supermarket bag boy holds a college degree\nas the oily fish spit out their oily prey\nas the sun is masked\n\nwe are \nborn like this\ninto this\ninto these carefully mad wars\ninto the sight of broken factory windows of emptiness\ninto bars where people no longer speak to each other\ninto fist fights that end as shootings and knifings...';

    document.body.appendChild(span);
    span.style.whiteSpace = 'nowrap';

    for (var j = 0; j < samples; j++) {
        var spanWidth = span.getBoundingClientRect().width;

        while (spanWidth < containerWidth) {
            span.innerHTML += text[aggregateCPL];
            spanWidth = span.getBoundingClientRect().width;
            aggregateCPL++;
        }

        span.innerHTML = '';
    }
    var avgCPL = aggregateCPL / samples;
    console.log(avgCPL);
};

Comments