Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ add another resource


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


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.


Auto Save

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.


    %select.custom-date{name: 'select'}
      %option{value: 7} 7 Days
      %option{value: 30} 30 Days
      %option{value: 90, selected: true} 90 Days
      %option{value: 180} 180 Days
      %option{value: 365} 365 Days
      %option{id: 'custom'} Custom



                @import compass

@mixin reset
  // v2.0 | 20110126
  // License: none (public domain)
  html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6,
  p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del,
  dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt,
  var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label,
  legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside,
  canvas, details, embed, figure, figcaption, footer, header, hgroup,
  menu, nav, output, ruby, section, summary, time, mark, audio, video
    margin: 0
    padding: 0
    border: 0
    font-size: 100%
    font: inherit
    vertical-align: baseline
  // HTML5 display-role reset for older browsers
  article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section
    display: block
    line-height: 1
  ol, ul
    list-style: none
  blockquote, q
    quotes: none
  blockquote:before, blockquote:after, q:before, q:after
    content: ''
    content: none
    border-collapse: collapse
    border-spacing: 0
@mixin unselectable
  -moz-user-select: -moz-none
  -khtml-user-select: none
  -webkit-user-select: none
  -ms-user-select: none
  user-select: none
@mixin clearfloat
  &:before, &:after
    content: ""
    display: table
    clear: both
  zoom: 1
@mixin border-box
  -moz-box-sizing: border-box
  -webkit-box-sizing: border-box
  box-sizing: border-box
  *, *:before, *:after
    -moz-box-sizing: border-box
    -webkit-box-sizing: border-box
    box-sizing: border-box

html, body
  margin: 0
  padding: 0
  height: 100%
  padding: 12px
  -webkit-appearance: menulist-button
  width: 200px
  height: 25px
  font-family: "AvenirLTStd-Heavy", "Avenir LT Std 85 Heavy", "Open Sans", Helvetica, Arial, sans-serif

$outer-border-color: #d6d6d6
$outer-box-shadow: 0px 4px 10px 0 #828282

$bgcolor: #FFFFFF
$text-color: #444444
$border-color: #e0e0e0
$inactive-color: #e0e0e0
$selected-color: #2a91ca
$in-range-bgcolor: #ddf3fe
$preset-label-color: #bcbcbc
$month-picker-arrow-color: #afafaf

$light-gray: #cccccc
$lighter-gray: #efefef

$day-width: 30px
$day-height: 24px
$day-spacing: 3px

$calendar-width: ($day-width * 7) + ($day-spacing * 6)

  top: 30px
  @include border-box
  // display: none
  position: absolute
  z-index: 9999
  font-size: 12px
  color: $text-color
  background-color: $bgcolor
  margin: 15px 0
  padding: 18px 18px 38px
  text-transform: uppercase
  border: 1px solid $outer-border-color
  -webkit-border-radius: 12px
  -moz-border-radius: 12px
  border-radius: 12px
  -webkit-box-shadow: $outer-box-shadow
  -moz-box-shadow: $outer-box-shadow
  box-shadow: $outer-box-shadow
    text-decoration: none
    list-style: none
    padding: 0
    margin: 0
    position: relative
      position: relative
      height: 13px
      border-bottom: 3px solid $light-gray
      bottom: 21px
      &:before, &:after
        content: ''
        position: absolute
        height: 15px
        border-left: 3px solid $light-gray
        bottom: -9px
        left: 0
        left: auto
        right: 0
      position: relative
      z-index: 1
        position: relative
        width: 87px
        height: 36px
        display: inline-block
        color: $preset-label-color
        // IE8 has issues with mousehover when there is no bg color, and
        //  "background-color: transparent" doesn't work. I hate you IE8.
        background-image: url('data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==')
        text-align: center
        cursor: pointer
          margin-left: 3px
          z-index: 2
          cursor: pointer
          background-color: $border-color
          width: 12px
          height: 12px
          position: absolute
          bottom: 4px
          left: 37px
          -webkit-border-radius: 50%
          -moz-border-radius: 50%
          border-radius: 50%
          border: 2px solid $bgcolor
          -webkit-transition: all 0.15s ease
          -moz-transition: all 0.15s ease
          -o-transition: all 0.15s ease
          transition: all 0.15s ease
          color: $text-color
        &.drp-selected .drp-button, &:hover .drp-button
          background-color: $selected-color
          width: 16px
          height: 16px
          left: 35px
          bottom: 2px
    display: table-cell
    vertical-align: top
    width: $calendar-width
    padding-bottom: 8px
    border-bottom: 1px solid $border-color
      position: relative
      background-color: $lighter-gray
      height: 30px
      -webkit-border-radius: 20px
      -moz-border-radius: 20px
      border-radius: 20px
      margin-bottom: 3px
      line-height: 32px
        font-size: 14px
        text-align: center
        @include unselectable
        cursor: pointer
        position: absolute
        width: 28px
        height: 30px
        line-height: 32px
        text-align: center
        left: 0
        top: 0
        color: $month-picker-arrow-color
        left: auto
        right: 0px
        display: inline-block
        width: $day-width
        height: $day-height
        line-height: 26px
        margin: 0 0 $day-spacing $day-spacing
        text-align: center
          margin-left: 0
      @include clearfloat
        @include unselectable
        width: $day-width + $day-spacing
        height: $day-height
        border-right: solid $day-spacing $bgcolor
        float: left
        cursor: pointer
        line-height: 26px
        text-align: center
        margin: 0 0 $day-spacing 0
          width: $day-width
          border-right: none
          color: $selected-color
          background-color: $in-range-bgcolor
          border-color: $in-range-bgcolor
          border-color: $bgcolor
        &.drp-day-selected, &:hover
          color: $lighter-gray
          background-color: $selected-color
          color: $light-gray
            background-color: $bgcolor
            cursor: default
        background-color: transparent !important
        cursor: auto
    padding: 18px 0 10px
    border-top: 1px solid $border-color
      border-color: $in-range-bgcolor

    position: absolute
    bottom: 0px
    height: 34px
    width: inherit
    text-align: center
    color: $selected-color
    font-size: 16px
      font-size: 12px
      color: $text-color
      content: 'Start Date: '
      content: 'End Date: '

    display: table-cell
    position: relative
    width: 69px
    top: 8px
      content: ''
      position: absolute
      height: 90%
      border-left: 1px solid $border-color
      left: 34px
      content: 'To'
      position: absolute
      top: 80px
      color: $selected-color
      background-color: $bgcolor
      height: 38px
      width: 69px
      text-align: center
      font-size: 16px
      line-height: 41px
    position: absolute
    top: 0
    left: 30px
    &:before, &:after
      content: ""
      position: absolute
      border-style: solid
      bottom: 0
      left: 0
      border-width: 0 16px 16px
      border-color: $outer-border-color transparent
      left: 2px
      border-width: 0px 14px 14px
      border-color: $bgcolor transparent



                $ = jQuery
DAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
  <div class="drp-popup">
    <div class="drp-timeline">
      <ul class="drp-timeline-presets"></ul>
      <div class="drp-timeline-bar"></div>
    <div class="drp-calendars">
      <div class="drp-calendar drp-calendar-start">
        <div class="drp-month-picker">
          <div class="drp-arrow"><</div>
          <div class="drp-month-title"></div>
          <div class="drp-arrow drp-arrow-right">></div>
        <ul class="drp-day-headers"></ul>
        <ul class="drp-days"></ul>
        <div class="drp-calendar-date"></div>
      <div class="drp-calendar-separator"></div>
      <div class="drp-calendar drp-calendar-end">
        <div class="drp-month-picker">
          <div class="drp-arrow"><</div>
          <div class="drp-month-title"></div>
          <div class="drp-arrow drp-arrow-right">></div>
        <ul class="drp-day-headers"></ul>
        <ul class="drp-days"></ul>
        <div class="drp-calendar-date"></div>
    <div class="drp-tip"></div>

class DateRangePicker
  constructor: (@$select) ->
    @$dateRangePicker = $(TEMPLATE)
      .attr('tabindex', '-1')
      .before @$dateRangePicker
    @isHidden = true
    @customOptionIndex = @$select[0].length-1
    @setRange @$select.val()

  initBindings: ->
    self = @
    # Prevent the select dropdown from appearing
    @$select.on 'focus mousedown', (e) ->
      $select = @
      setTimeout ->
      , 0
      return false
    # show/hide logic for the popup
    @$ (evt) ->
    $('body').click (evt) ->
      if == self.$select[0] && self.isHidden
      else if !self.isHidden

    # Timeline buttons
    @$select.children().each ->
      self.$dateRangePicker.find('.drp-timeline-presets').append $("<li class='#{(@.selected && 'drp-selected') || ''}'>#{$(@).text()}<div class='drp-button'></div></li>")
    @$dateRangePicker.find('.drp-timeline-presets li').click (evt) ->
      presetIndex = $(@).index()
      self.$select[0].selectedIndex = presetIndex
      self.setRange self.$select.val()
      self.showCustomDate() if presetIndex == self.customOptionIndex
  hide: ->
    @isHidden = true
  show: ->
    @isHidden = false
  showCustomDate: ->
    @$dateRangePicker.find('.drp-timeline-presets li:last-child').addClass('drp-selected').siblings().removeClass('drp-selected')
    text = @formatDate(@startDate()) + ' - ' + @formatDate(@endDate())
    @$select.find('option:last-child').text text
    @$select[0].selectedIndex = @customOptionIndex
  formatDate: (d) ->
    "#{d.getMonth() + 1}/#{d.getDate()}/#{d.getFullYear().toString().substr(2,2)}"
  setRange: (daysTo) ->
    return false if isNaN daysTo
    # daysTo += 1

    endDate = new Date()
    startDate = new Date()
    # console.log(startDate.getDate())
    endDate.setTime(startDate.getTime() + daysTo*86400*1000)
    @startCalendar = new Calendar(@, @$dateRangePicker.find('.drp-calendar:first-child'), startDate, true)
    @endCalendar = new Calendar(@, @$dateRangePicker.find('.drp-calendar:last-child'), endDate, false)
  endDate: ->
  startDate: ->
  draw: ->

class Calendar
  constructor: (@dateRangePicker, @$calendar, @date, @isStartCalendar) ->
    self = @
    @_visibleMonth = @month()
    @_visibleYear = @year()
    @$title = @$calendar.find('.drp-month-title')
    @$dayHeaders = @$calendar.find('.drp-day-headers')
    @$days = @$calendar.find('.drp-days')
    @$dateDisplay = @$calendar.find('.drp-calendar-date')
    @$calendar.find('.drp-arrow').click (evt) ->
      if $(@).hasClass('drp-arrow-right') then self.showNextMonth() else self.showPreviousMonth()
      return false
  showPreviousMonth: ->
    if @_visibleMonth == 1
      @_visibleMonth = 12
      @_visibleYear -= 1
      @_visibleMonth -= 1
  showNextMonth: ->
    if @_visibleMonth == 12
      @_visibleMonth = 1
      @_visibleYear += 1
      @_visibleMonth += 1
  setDay: (day) ->
    @setDate(@visibleYear(), @visibleMonth(), day)
  setDate: (year, month, day) ->
    @date = new Date(year, month - 1, day)
  draw: ->
    # set month name
    @$title.text "#{@nameOfMonth(@visibleMonth())} #{@visibleYear()}"
    # populate day headers
    @$dayHeaders.append($("<li>#{day.substr(0,2)}</li>")) for day in DAYS
  dateIsSelected: (date) ->
    date.getTime() == @date.getTime()
  dateIsInRange: (date) ->
    date >= @dateRangePicker.startDate() && date <= @dateRangePicker.endDate()
  dayClass: (day, firstDayOfMonth, lastDayOfMonth) ->
    date = new Date(@visibleYear(), @visibleMonth()-1, day)
    classes = ''
    if @dateIsSelected(date)
      classes = 'drp-day-selected'
    else if @dateIsInRange(date)
      classes = 'drp-day-in-range'
      if date.getTime() == @dateRangePicker.endDate().getTime()
        classes += ' drp-day-last-in-range'
    else if @isStartCalendar
      if date > @dateRangePicker.endDate()
        classes += ' drp-day-disabled'
    else if date < @dateRangePicker.startDate()
      classes += ' drp-day-disabled'
    if (day+firstDayOfMonth-1)%7 == 0 || day == lastDayOfMonth
      classes += ' drp-day-last-in-row'

    return classes
  drawDays: ->
    self = @
    firstDayOfMonth = @firstDayOfMonth(@visibleMonth(), @visibleYear())
    lastDayOfMonth = @daysInMonth(@visibleMonth(), @visibleYear())
    @$days.append($("<li class='drp-day drp-day-empty'></li>")) for i in [1..firstDayOfMonth-1] by 1
    @$days.append($("<li class='drp-day #{@dayClass(i,firstDayOfMonth,lastDayOfMonth)}'>#{i}</li>")) for i in [1..lastDayOfMonth] by 1
    @$calendar.find('.drp-day').click (evt) ->
      return false if $(@).hasClass('drp-day-disabled')
      day = parseInt($(@).text(), 10)
      return false if isNaN(day)
  drawDateDisplay: ->
    @$dateDisplay.text [@month(), @day(), @year()].join('/')
  month: ->
    @date.getMonth() + 1
  day: ->
  dayOfWeek: ->
    @date.getDay() + 1
  year: ->
  visibleMonth: ->
  visibleYear: ->
  nameOfMonth: (month) ->
  firstDayOfMonth: (month, year) ->
    new Date(year, month - 1, 1).getDay() + 1
  daysInMonth: (month, year) ->
    month ||= @visibleMonth()
    year ||= @visibleYear()
    new Date(year, month, 0).getDate()

$.fn.dateRangePicker = ->
  new DateRangePicker(@)