Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <section class="picker-container">

  <div class="question-container">

    <div class="question-group">
      Do you have a preferred form factor?

      <div class="answer-group">
        <label>
          N/A
          <input type="radio" name="formFactor" data-answer="none">
        </label>
        <label>
          Standard ATX
          <input type="radio" name="formFactor" data-answer="formFactor.ATX">
        </label>
        <label>
          microATX
          <input type="radio" name="formFactor" data-answer="formFactor.microATX">
        </label>
        <label>
          Mini-ITX
          <input type="radio" name="formFactor" data-answer="formFactor.miniITX">
        </label>
      </div>
      <!-- .answer-group -->

    </div>
    <!-- .question-group -->

    <div class="question-group">
      Do you plan to utilize USB 3.1 devices?

      <div class="answer-group">
        <label>
          N/A
          <input type="radio" name="USB31" data-answer="none">
        </label>
        <label>
          Type A &amp; Type C
          <input type="radio" name="USB31" data-answer="USB31.typeC">
        </label>
        <label>
          Type A Only
          <input type="radio" name="USB31" data-answer="USB31.typeA">
        </label>
      </div>
      <!-- .answer-group -->

    </div>
    <!-- .question-group -->

    <div class="question-group">
      Are you planning to use DDR3 or DDR4 memory?

      <div class="answer-group">
        <label>
          N/A
          <input type="radio" name="memory" data-answer="none">
        </label>
        <label>
          DDR3
          <input type="radio" name="memory" data-answer="memory.DDR3">
        </label>
        <label>
          DDR4
          <input type="radio" name="memory" data-answer="memory.DDR4">
        </label>
      </div>
      <!-- .answer-group -->

    </div>
    <!-- .question-group -->

    <div class="question-group">
      Do you plan to overclock this PC?

      <div class="answer-group">
        <label>
          No
          <input type="radio" name="overclock" data-answer="none">
        </label>
        <label>
          Yes, and I prefer automatic overclocking
          <input type="radio" name="overclock" data-answer="overclock.yesAuto">
        </label>
        <label>
          Yes, but I prefer manual tuning
          <input type="radio" name="overclock" data-answer="overclock.yesManual">
        </label>
      </div>
      <!-- .answer-group -->

    </div>
    <!-- .question-group -->

    <div class="question-group">
      Would you use a dedicated water pump header (for self-contained or custom water cooling)?

      <div class="answer-group">
        <label>
          Yes/No
          <input type="checkbox" name="waterPump" data-answer="waterPump.yes">
        </label>
      </div>
      <!-- .answer-group -->

    </div>
    <!-- .question-group -->

    <div class="question-group">
      Do you plan to run NVIDIA SLI?

      <div class="answer-group">
        <label>
          No
          <input type="radio" name="SLI" data-answer="none">
        </label>
        <label>
          2-Way SLI
          <input type="radio" name="SLI" data-answer="SLI.twoWay">
        </label>
        <label>
          3-Way / 4-Way SLI
          <input type="radio" name="SLI" data-answer="SLI.threeWay">
        </label>
      </div>
      <!-- .answer-group -->

    </div>
    <!-- .question-group -->

    <div class="question-group">
      Do you need onboard Wi-Fi?

      <div class="answer-group">
        <label>
          Yes/No
          <input type="checkbox" name="WiFi" data-answer="WiFi">
        </label>
      </div>
      <!-- .answer-group -->

    </div>
    <!-- .question-group -->

    <div class="question-group">
      Do you have a preferred color scheme?

      <div class="answer-group">
        <label>
          No
          <input type="radio" name="colorScheme" data-answer="memory.no">
        </label>
        <label>
          Red/Black
          <input type="radio" name="colorScheme" data-answer="colorScheme.redBlack">
        </label>
        <label>
          White/Black
          <input type="radio" name="colorScheme" data-answer="colorScheme.whiteBlack">
        </label>
        <label>
          Military
          <input type="radio" name="colorScheme" data-answer="colorScheme.military">
        </label>
      </div>
      <!-- .answer-group -->

    </div>
    <!-- .question-group -->

  </div>
  <!-- .question-container -->

</section>
<!-- .picker-container -->

<hr>

<div class="picker-object" data-picker="object" data-motherboard-name="mobo-1">Motherboard 1</div>

<div class="picker-object" data-picker="object" data-motherboard-name="mobo-2">Motherboard 2</div>

<div class="picker-object" data-picker="object" data-motherboard-name="mobo-3">Motherboard 3</div>

<div class="picker-not-applicable" data-picker="not-applicable">No motherboards fit your criteria... yet.</div>
              
            
!

CSS

              
                $red:     #FF4136 !default;
$green: #2ECC40 !default;

.picker-object {
  &.is-active {
    background-color: $green;
  }
  &.is-off {
    background-color: $red;
  }
}

.picker-not-applicable {
  background-color: $red;
  &.is-active {
    background-color: $green;
  }
}

label {
  border: 1px solid black;
  padding: 2px;
  margin: 2px;
  cursor: pointer;
}
              
            
!

JS

              
                ;
(function() {

  var PickerModel = function() {

    return {

      'motherboards': {

        'mobo-1': {

          'commercial': false,
          'formFactor': {
            'ATX': false,
            'microATX': true,
            'miniITX': false
          },
          'PCIe': {
            'dualM2': false,
            'singleM2': true,
            'u2': false,
            'NVMe': true
          },
          'USB31': {
            'typeC': true,
            'typeA': true
          },
          'memory': {
            'DDR4': true,
            'DDR3': false
          },
          'overclock': {
            'yesAuto': true,
            'yesManual': true,
            'no': true
          },
          'waterPump': {
            'yes': true,
            'no': true
          },
          'SLI': {
            'twoWay': true,
            'threeWay': false
          },
          'WiFi': false,
          'colorScheme': {
            'redBlack': true,
            'whiteBlack': false,
            'military': false
          }

        }, // mobo-1

        'mobo-2': {

          'commercial': false,
          'formFactor': {
            'ATX': true,
            'microATX': false,
            'miniITX': false
          },
          'PCIe': {
            'dualM2': false,
            'singleM2': true,
            'u2': false,
            'NVMe': true
          },
          'USB31': {
            'typeC': true,
            'typeA': true
          },
          'memory': {
            'DDR4': true,
            'DDR3': false
          },
          'overclock': {
            'yesAuto': true,
            'yesManual': true,
            'no': true
          },
          'waterPump': {
            'yes': true,
            'no': true
          },
          'SLI': {
            'twoWay': true,
            'threeWay': false
          },
          'WiFi': false,
          'colorScheme': {
            'redBlack': true,
            'whiteBlack': false,
            'military': false
          }

        }, // mobo-2

        'mobo-3': {

          'commercial': false,
          'formFactor': {
            'ATX': true,
            'microATX': false,
            'miniITX': false
          },
          'PCIe': {
            'dualM2': false,
            'singleM2': true,
            'u2': false,
            'NVMe': true
          },
          'USB31': {
            'typeC': true,
            'typeA': true
          },
          'memory': {
            'DDR4': true,
            'DDR3': false
          },
          'overclock': {
            'yesAuto': true,
            'yesManual': true,
            'no': true
          },
          'waterPump': {
            'yes': true,
            'no': true
          },
          'SLI': {
            'twoWay': true,
            'threeWay': false
          },
          'WiFi': false,
          'colorScheme': {
            'redBlack': true,
            'whiteBlack': false,
            'military': false
          }

        }

      } // mobo-3

    };

  };

  var Picker = function() {

    var model = new PickerModel();
    this.motherboards = model.motherboards;

    this.pickerObject = '[data-picker=object]';
    this.naObject = '[data-picker=not-applicable]';
    this.activeClass = 'is-active';
    this.activeSelector = '.' + this.activeClass;
    this.offClass = 'is-off';
    this.offSelector = '.' + this.offClass;

    this.motherboardLabel = 'motherboard-name';

  };

  Picker.prototype = {

    findActiveObjects: function() {

      var self = this,
        answers = [];

      $('input:checked').each(function() {
        answers.push($(this).data('answer'));
      });

      this.setActiveInactive(answers);

      if (this.countActive() === 0) {
        $(this.naObject).addClass(this.activeClass);
      } else {
        $(this.naObject).removeClass(this.activeClass);
      }

    },

    setActiveInactive: function(currentAnswers) {

      var self = this;

      $(self.pickerObject).each(function() {

        var thisName = $(this).data(self.motherboardLabel),
          thisMotherboard = self.motherboards[thisName],
          checkAnswers = [];

        for (var i = 0; i < currentAnswers.length; i++) {

          var item = currentAnswers[i];

          checkAnswers.push(self.getObjectValue(thisMotherboard, item));

        }

        if (checkAnswers.indexOf(false) !== -1 && checkAnswers.length > 0) {
          // If any answer is false
          $(this).removeClass(self.activeClass).addClass(self.offClass);
        } else if (checkAnswers.length === 0) {
          // If checkAnswers array is empty, remove all classes
          $(self.pickerObject).removeClass(self.activeClass + ' ' + self.offClass);
        } else {
          // If everything is true, set active
          $(this).removeClass(self.offClass).addClass(self.activeClass);
        }

      });

    },

    countActive: function() {

      if ($(this.pickerObject + this.offSelector).length) {

        // if any off classes exist, return number of on classes
        // to be used to show nothing exists message

        return $(this.pickerObject + this.activeSelector).length;

      }

    },

    getObjectValue: function(obj, str) {

      var strSplit = str.split('.');

      for (var i = 0; i < strSplit.length; i++) {

        var item = strSplit[i];

        if (item in obj) {
          obj = obj[item];
        } else {
          return;
        }

      }

      return obj;

    }

  };

  $(function() {

    var picker = new Picker();

    $('input').on('click', function() {

      picker.findActiveObjects();

    });

  });

})();
              
            
!
999px

Console