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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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

              
                <!-- 
TODO:
Priority:
canvas translations

Ornamental:
-Warnings?
--too many elements?

 -->



<header class="main-header">
  <div class="title">Main Contact Form</div>
  <div class="button-group">
    <button class="btn btn-warning">Save as Form Template</button>
    <button class="btn btn-warning">Save</button>
  </div>
</header>
<div class="wrap">
  <div class="sidebar">
    <h2>Scuse Me, Young Man</h2>
    <h5>Drag items from here</h5>
    <br />
    <h4>Input Elements</h4>
    <ul id="form-input-els" class="options-pallat">
      <li class="form-item" data-form-el="input">
        <div class="inner">
          <i class="fa fa-bars"></i>
          <span class="inner-text">Text Field</span>
          <i class="fa fa-arrows"></i>
          <i class="fa fa-angle-right"></i>
        </div>
      </li>
      <li class="form-item" data-form-el="radio">
        <div class="inner">
          <i class="fa fa-bars"></i>
          <span class="inner-text">Radio Button Group</span>
          <i class="fa fa-arrows"></i>
          <i class="fa fa-angle-right"></i>
        </div>
      </li>
      <li class="form-item" data-form-el="checkbox">
        <div class="inner">
          <i class="fa fa-bars"></i>
          <span class="inner-text">Checkbox Group</span>
          <i class="fa fa-arrows"></i>
          <i class="fa fa-angle-right"></i>
        </div>
      </li>
      <li class="form-item" data-form-el="textarea">
        <div class="inner">
          <i class="fa fa-bars"></i>
          <span class="inner-text">Text Area</span>
          <i class="fa fa-arrows"></i>
          <i class="fa fa-angle-right"></i>
        </div>
      </li>
      <li class="form-item" data-form-el="select">
        <div class="inner">
          <i class="fa fa-bars"></i>
          <span class="inner-text">Select Dropdown</span>
          <i class="fa fa-arrows"></i>
          <i class="fa fa-angle-right"></i>
        </div>
      </li>
    </ul>
    <h4>UX Elements</h4>
    <ul id="form-ux-els" class="options-pallat">
      <li class="form-item" data-form-el="title">
        <div class="inner">
          <i class="fa fa-bars"></i>
          <span class="inner-text">Form Title</span>
          <i class="fa fa-arrows"></i>
          <i class="fa fa-angle-right"></i>
        </div>
      </li>
      <li class="form-item" data-form-el="section">
        <div class="inner">
          <i class="fa fa-bars"></i>
          <span class="inner-text">Form Section</span>
          <i class="fa fa-arrows"></i>
          <i class="fa fa-angle-right"></i>
        </div>
      </li>
      <li class="form-item" data-form-el="heading">
        <div class="inner">
          <i class="fa fa-bars"></i>
          <span class="inner-text">Form Heading</span>
          <i class="fa fa-arrows"></i>
          <i class="fa fa-angle-right"></i>
        </div>
      </li>
      <li class="form-item" data-form-el="content">
        <div class="inner">
          <i class="fa fa-bars"></i>
          <span class="inner-text">Description Text</span>
          <i class="fa fa-arrows"></i>
          <i class="fa fa-angle-right"></i>
        </div>
      </li>
    </ul>
  </div>
  <div class="main">
    <div class="drop-wrap">
      <header class="canvas-header">
        <div class="left-group">
          <h2 class="heading">Form Canvas</h2>
          <h5>Drop items here and edit</h5>
          <br />
        </div>
        <div class="right-group">
          <button class="btn btn-primary">Start From Template</button>
        </div>
      </header>
      <ul id="drop-canvas" class="form-canvas"></ul>
    </div>
    <div class="form-preview">
      <h2>Preview</h2>
    </div>
  </div>
</div>



              
            
!

CSS

              
                /////////////////////////////////////////////////////////
//META SHIT
/////////////////////////////////////////////////////////
//vars
@bg: #15A4D2;

//mixins
.center(@horizontal: true, @vertical: true) {
  position: absolute;
  & when ( @horizontal = true ) and ( @vertical = true ) {top: 50%;left: 50%;transform: translate(-50%, -50%);}
  & when ( @horizontal = true ) and ( @vertical = false ) {left: 50%;transform: translate(-50%, 0);}
  & when ( @horizontal = false ) and ( @vertical = true ) {top: 50%;transform: translate(0, -50%);}
}


/////////////////////////////////////////////////////////
//SCAFFOLDING
/////////////////////////////////////////////////////////
.main-header{
  height: 60px;
  width: 100%;
  background: lighten(desaturate(@bg, -10%),-30%);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 20px;
  justify-content: space-between;
  font-size: 26px;
}
.wrap {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 60px;
  left: 0;
  display: flex;
  .sidebar {
    flex-shrink: 0;
  }
  .main {
    width: 100%;
    display: flex;
    position: relative;
  }
}


/////////////////////////////////////////////////////////
//SIDEBAR
/////////////////////////////////////////////////////////
.sidebar {
  background: #15A4D2;
  color: white;
  padding: 20px;
}

.options-pallat {
  width: 350px;
  margin: 20px auto;
  padding: 0px;
  list-style: none;
}


/////////////////////////////////////////////////////////
//DROP WRAP
/////////////////////////////////////////////////////////
.drop-wrap{
  padding: 20px;
  border: solid #ebebeb 1px;
  width: 50%;
  background: #f0f0f0;
  
  display: flex;
  flex-flow: nowrap column;
  align-content: flex-start;
  
  position: absolute;
  top: 0;left: 0;bottom: 0;
  
  > * {width: 100%;}
  
  .canvas-header{
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  
  .form-canvas{
    margin: 0;
    padding: 20px;
    background: #fefefe;
    height: 100%;
    position: relative;

    &:empty:after{
      .center(true, false);
      top:50px;

      content: 'This is empty. Drag some stuff in!';
      color: #CCC;
      text-align: center;
      display: block;
      font-size: 30px
    }
    
  }
}

/////////////////////////////////////////////////////////
//FORM RENDER
/////////////////////////////////////////////////////////
.form-preview{
  padding: 20px;
  border: solid #ebebeb 1px;
  width: 50%;
  background: #fefefe;
  
  position: absolute;
  top: 0;right: 0;bottom: 0;
}

/////////////////////////////////////////////////////////
//FORM ITEM WITH STATES
/////////////////////////////////////////////////////////
.form-item {
  height: 80px;
  display: flex;
  position: relative;
  width: 100%;
  
  
  &:not(:first-child) .inner {border-top: fade(@bg/1.5, 15%) solid 1px;}
  
  .inner {
    width: 100%;
    display: flex;
    padding: 20px;
    align-items: center;
    background: @bg + #fff / 8;
    color: white;
    font-size: 20px;
    transition: all ease .15s;
  }
  
  
  //icons
  .fa-angle-right,
  .fa-bars,
  .fa-arrows {
    font-size: .675em;
    opacity: .5;
    cursor: grabbing;
    &:not(:active){cursor: grab;}
  }
  
  .fa-bars{
    padding-right: 15px;
  }
  
  .fa-angle-right,
  .fa-arrows{
    .center(false, true);
    right: 20px;
  }
  
  
  
  //STATES//
  &:not(.placed){
    cursor: grab;
    
    .fa-angle-right,
    .fa-bars{display: none;}
    
    &:active{cursor: grabbing;}
  }
  
  &.placed{
    .fa-angle-right,
    .fa-bars{display: block;}
    .fa-arrows{display: none;}
  }
  
  &.active{}
  
  &:hover{
    .inner{background: (@bg + #fff / 8)/1.025;}
  }
  
  
  
}








              
            
!

JS

              
                console.clear();

var addElTransform = function(el){
  $(el).siblings().removeClass('active');
  $(el).addClass('active placed');
  //make active (maybe remove active from others?)
  //give name
  //call type based config
}


var inputList = document.getElementById('form-input-els');
var uxList = document.getElementById('form-ux-els');
var dropCanvas = document.getElementById('drop-canvas');

var formInputSort = Sortable.create(inputList, {
  sort: false,
  animation: 150,
  group: {
    name: 'inputEls',
    pull: 'clone'
  },
});
var formUXSort = Sortable.create(uxList, {
  sort: false,
  animation: 150,
  group: {
    name: 'uxEls',
    pull: 'clone'
  },
});

var dropCanvas = Sortable.create(dropCanvas, {
  sort: true,
  animation: 150,
  ghostClass: "sortable-ghost",
  group: {
    name: 'canvas',
    put: ['inputEls', 'uxEls']
  },
  onAdd: function(event) {
    addElTransform(event.item);
    console.log(event)
    // var itemEl = event.item; // dragged HTMLElement
    // event.from; // previous list

  },
});


dropCanvas.option(
  onAdd, function(event) {
    addElTransform(event.item);
    console.log(event)
    // var itemEl = event.item; // dragged HTMLElement
    // event.from; // previous list

  },
  
)
              
            
!
999px

Console