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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                .form.hidden
  .face
    %svg{viewbox: "-10 -10 620 620"}
      %g{stroke: "#4d4d4d", "stroke-width" => "20", id: "face"}
        %circle{cx: "300", cy: "300", r: "300"}

      %path{d: "M100,350 Q300,450 500,350 Q300,550 100,350 z", fill: "white", stroke: "#4d4d4d", "stroke-width" => "20", "stroke-linejoin" => "round", id: "mouth"}



      %g{fill: "#4d4d4d"}
        //%circle{cx: "300", cy: "200", r: "30"}
        //%circle{cx: "500", cy: "200", r: "30"}
        %path{d: "M285 200 a 30 30 0 1 0 -1 0 z", fill: "#4d4d4d", stroke: "#4d4d4d", "stroke-width" => "20", "stroke-linejoin" => "round", class: "eye--left"}
        %path{d: "M515 200 a 30 30 0 1 0 -1 0 z", fill: "#4d4d4d", stroke: "#4d4d4d", "stroke-width" => "20", "stroke-linejoin" => "round", class: "eye--right"}



  %h3.heading How do you feel about our customer service?

  .sliding-list
    %ul
      - ["Absolutely Terrible!", "Dissapointing", "Quite Bad hey", "Not impressed", "Nothing to be proud of", "Could have been better", "Satisfactory", "Ok, I guess", "Was Great", "Super Impressed!"].each do |i|
        %li #{i}

  %input.slider(type="range" min=0 max=99 value=80 oninput="updateSlider(value)")


%footer
  %a(href="https://twitter.com/code_dependant" class="twitter-follow-button" data-show-count="false")
    Follow @code_dependant
  %script !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');
              
            
!

CSS

              
                html, body
  height: 100%

body
  font-family: Lato, 'Helvetica Neue'
  background-color: rgb(245,245,242)
  text-align: center
  color: #4d4d4d
  margin: 3rem
    
.face
  width: 100%
  margin: 3rem auto
  max-width: 400px
  transition: .6s all

  svg
    width: 100%
    transition: 1.5s all cubic-bezier(.17,.67,.03,1)
    transform-origin: 50% 100%

    
    .form.hidden &
      opacity: 0
      transform: rotateX(75deg) rotateY(-30deg) translateX(50%) rotateZ(90deg)
      
        
.heading
  transition: .8s all ease .1s
  margin: 0
  margin-bottom: 1.5rem
    
  .form.hidden &
    transform: translateY(60px)
    opacity: 0
    
.sliding-list
  font-size: 2em
  height: 1.5em
  overflow: hidden
  margin-bottom: 1.5rem
  font-weight: 900
  transition: .8s all ease .2s
  .form.hidden &
    transform: translateY(60px)
    opacity: 0
  
  ul
    margin: 0
    padding: 0
    list-style: none
    transition: .3s transform
    text-align: center
      
  li
    line-height: 1.5em
    
.slider
  margin-bottom: 1.5rem
    
    
$track-width: 300px
$track-height: 20px
$track-border-radius: $track-height
$track-background-color: white
$track-focus-background-color: darken($track-background-color, 10%)
$thumb-size: $track-height
$thumb-background-color: #4d4d4d
  
input[type=range]
  -webkit-appearance: none
  //border: 1px solid white
  width: $track-width
  background: transparent
  transition: .8s all ease .3s
  .form.hidden &
    transform: translateY(60px)
    opacity: 0
    
    
  &::-webkit-slider-runnable-track
    width: $track-width
    height: $track-height+6px
    background: $track-background-color
    border: 3px solid $thumb-background-color
    border-radius: $track-border-radius
    
  &::-webkit-slider-thumb
    -webkit-appearance: none
    border: none
    height: $thumb-size
    width: $thumb-size
    border-radius: 50%
    background: $thumb-background-color
    cursor: pointer
    
  &:focus
    outline: none
    &::-webkit-slider-runnable-track
      background: $track-focus-background-color
      
  &::-moz-range-track
    width: $track-width
    height: $track-height
    background: $track-background-color
    border: 3px solid $thumb-background-color
    border-radius: $track-border-radius
    
  &::-moz-range-thumb
    border: none
    height: $thumb-size
    width: $thumb-size
    border-radius: 50%
    background: $thumb-background-color
    cursor: pointer
      
  &:-moz-focusring
    outline: 1px solid white
    outline-offset: -1px
    
  &::-ms-track
    width: $track-width
    height: $thumb-size
    background: $track-background-color
    border: none
    border-radius: $track-border-radius
    color: transparent
      
  &::-ms-fill-lower
    outline: none
    background: $track-background-color
    border-radius: $track-border-radius 0 0 $track-border-radius
    
  &::-ms-thumb
    border: none
    height: $thumb-size
    width: $thumb-size
    border-radius: 50%
    background: $thumb-background-color
      
  &:focus
    &::-ms-track
      background: $track-focus-background-color
      
    &::-ms-fill-lower
      background: $track-focus-background-color
      
      
footer
  position: fixed
  bottom: 1.5em
  right: 1.5em
  
              
            
!

JS

              
                $ ->
  document.querySelector(".form").classList.remove("hidden")
  
  input =
    rating: 80
    
  mouth =
    eyes:
      width: 30
      height: 30
    sides: 350
    middle:
      top: 450
      bottom: 550
    
      

  render = ->

    $("#mouth").attr("d", "M100,#{mouth.sides} Q300,#{mouth.middle.top} 500,#{mouth.sides} Q300,#{mouth.middle.bottom} 100,#{mouth.sides} z")

    $("#face").attr("fill", "hsl(#{Math.round(input.rating)}, 60%, 74%)")
    
    $(".eye--left").attr("d", "M185 200 a #{mouth.eyes.height} #{mouth.eyes.width} 0 1 0 -1 0 z")
    $(".eye--right").attr("d", "M415 200 a #{mouth.eyes.height} #{mouth.eyes.width} 0 1 0 -1 0 z")
    
  update = ->
    position = input.rating
    
    keyframes =
      0:
        eyes:
          width: 20
          height: 35
        sides: 444
        middle:
          top: 184
          bottom: 390
      25:
        eyes:
          width: 23
          height: 32
        sides: 423
        middle:
          top: 217
          bottom: 217
        eyes:
          width: 30
          height: 30
      50:
        eyes:
          width: 30
          height: 30
          
        sides: 400
        middle:
          top: 400
          bottom: 400
      75:
        eyes:
          width: 40
          height: 30
        sides: 350
        middle:
          top: 450
          bottom: 596
      100:
        eyes:
          width: 50
          height: 30
        sides: 360
        middle:
          top: 360
          bottom: 680
          
    
    for index in [0..Object.keys(keyframes).length-1]
      startKeyframePosition = parseFloat(Object.keys(keyframes)[index])
      endKeyframePosition = parseFloat(Object.keys(keyframes)[index+1])
      startKeyframeValue = keyframes[startKeyframePosition]
      endKeyframeValue = keyframes[endKeyframePosition]
      
      
      if startKeyframePosition <= position <= endKeyframePosition
        
        relativePosition =  (position - startKeyframePosition)/(endKeyframePosition - startKeyframePosition)
        setObjectKeyframe(relativePosition, mouth, startKeyframeValue, endKeyframeValue)
      
      render()

  setObjectKeyframe = (position, object, startKeyframeObject, endKeyframeObject)->
    for key in Object.keys(startKeyframeObject)
      startValue = startKeyframeObject[key]
      endValue = endKeyframeObject[key]
      if typeof startKeyframeObject[key] is "number"
        object[key] = (endValue - startValue) * position + startValue
      else if typeof startKeyframeObject[key] is "object"
        setObjectKeyframe(position, object[key], startValue, endValue)


        
  gui = new dat.GUI()
  gui.close()
  gui.add(mouth, "sides", 0, 500).onChange(render)
  gui.add(mouth.middle, "top", 0, 1000).onChange(render)
  gui.add(mouth.middle, "bottom", 0, 1000).onChange(render)
  gui.add(mouth.eyes, "height", 1, 50).onChange(render)
  gui.add(mouth.eyes, "width", 1, 50).onChange(render)
  gui.add(input, "rating", 0, 100).onChange(update)

  
    
  window.updateSlider = (value)->
    input.rating = value
    update()
    listIndex = ~~(value/10)
    document.querySelector(".sliding-list ul").style.transform = "translateY(#{-listIndex*1.5}em)"
    
  render()
  updateSlider(80)   
    
  

  
  
              
            
!
999px

Console