JSFiddle - React, Tailwind, and code Playground

by someprimetime

HTML

<div id="main-container">
    <label for="js-prime-input">Enter a valid number to return all primes:</label>
    <form>
        <input id="js-prime-input" type="text" name="checker">
        <input class="btn" type="submit" value="Get primes!" id="js-prime-check" />
    </form>
    <div id="recursive-option">
        <label for="recursive-checkbox">Recursive</label>
        <input id="recursive-checkbox" type="checkbox" name="recursive">
    </div>
    <div id="error-container"></div>
    <div id="prime-results"></div>
</div>

SCSS

$REDFIN_SIGN_LOGO: '//b56a4b135274efeb1f5a-b4f1d8b499f2c23281383392e57b9506.r50.cf2.rackcdn.com/redfin_toggle_sign.png';

body {
    box-sizing: border-box;
    background: #f4f4f4;
    font: 12px normal 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

#main-container {
    background: #fff url($REDFIN_SIGN_LOGO) 10px 30px no-repeat;
    border: 1px solid #ddd;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
    float: left;
    margin: 0 auto;
    overflow: hidden;
    padding: 10px;
    width: 220px;
    word-wrap: break-word;
    
    &.cached {
        background-position: -275px 30px;
    }
    
    #js-prime-input {
        border: {
          radius: 3px;
          width: 1px;
          right-color: #ddd;
        }
        height: 16px;
        padding: 5px;
        width: 20px;
        margin-right: 5px;
    }
    
    form {
      margin: 15px 0 10px 0;
      text-align: center;
      left: 25px;
      position: relative;
      width: 100%;
    }
}

#recursive-checkbox {
    float: left;
}

#recursive-option {
    padding-top: 10px;

    label {
        cursor: pointer;
        vertical-align: middle;
        position: relative;
        top: 1px;
    }
}

#prime-results {
    display: none;
    border-top: 1px dashed #DDD;
    padding-top: 10px;
    margin-top: 10px;
    float: left;
    width: 100%;
    font-size: 16px;
}

#error-container {
    color: #a02021;
    text-align: center;
    margin-top: 10px;
}

.btn {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 0 rgba(0, 0, 0, 0.05);  
  background: #a02021;
  display: inline-block;
  border: {
      radius: 2px;
      width: 1px;
      style: solid;
      color: rgba(0, 0, 0, 0.15);
      top-color: rgba(0, 0, 0, 0.15);
      bottom-color: rgba(0, 0, 0, 0.3);
  }
  color: #fff;
  cursor: pointer;
  font: {
    family: inherit;
    size: 12px;
    weight: bold;
  }
  height: 30px;
  margin: 0;
  padding: 5px 10px;
  position: relative;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
 ...

JavaScript

var primeChecker = {
    /**
     * Memoize our previously hit primes
     */
    cache: {},

    /**
     * Cached DOM selectors
     */
    selectors: {
        mainContainer: document.getElementById('main-container'),
        inputLabel: document.getElementById('js-prime-input'),
        input: document.getElementById('js-prime-input'),
        submitBtn: document.getElementById('js-prime-check'),
        errorContainer: document.getElementById('error-container'),
        primeResultsContainer: document.getElementById('prime-results'),
        recursiveCheckbox: document.getElementById('recursive-checkbox')
    },

    /**
     * Append all successfully found primes to the container
     */
    appendResults: function (primes) {
        var toAppend = primes.join(' <p></p> *'),
            resultsContainer = this.selectors.primeResultsContainer;

        resultsContainer.style.display = 'block';
        resultsContainer.innerHTML = '*' + toAppend;
    },

    /**
     * Attach event listener for the click action of the "Get primes!" button
     */
    attachEventListeners: function () {
        var CLICK = 'click',
            self = this,
            primeCheckBtn = this.selectors.submitBtn,

            handleEventAction = function (evt) {
                evt.preventDefault();
                // Need to maintain context to `this` so we'll use call here
                self.handleSubmit.call(self, evt);
            };

        primeCheckBtn.addEventListener(CLICK, handleEventAction, false);
    },

    /**
     * Remove class on main container if no hit from cache
     */
    changeSignToDefault: function () {
        var mainContainer = this.selectors.mainContainer;

        mainContainer.className = '';
    },

    /**
     * Add class to main container to change background position if
     * we got a hit from our cache
     */
    changeSignToRed: function () {
        var mainContainer = this.selectors.mainContainer;

        mainContainer.className +=...