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

              
                div keyboard (tab) can be used too

h3 react version
#barhere

h3 static version (no js required)
.lifeline
    .progress(style='width: 50.9225%;')
    .event.active(tabindex='0', style='left:6.273062730627306%;')
      .tip
        .date sobota, 1. sierpie&nacute; 2015
        .name get money
      .element
        .fa.fa-dollar
    .event.active(tabindex='0', style='left:15.129151291512915%;')
      .tip
        .date wtorek, 25. sierpie&nacute; 2015
        .name twit your friends
      .element
        .fa.fa-twitter
    .event.active(tabindex='0', style='left:47.23247232472325%;')
      .tip
        .date sobota, 21. listopad 2015
        .name fall in love
      .element
        .fa.fa-heart
    .event(tabindex='0', style='left:100%;')
      .tip
        .date poniedzia&lstrok;ek, 11. kwiecie&nacute; 2016
        .name die happily
      .element
        .fa.fa-trophy

              
            
!

CSS

              
                @import "bourbon";

$bar-color-bg: black;
$bar-color: #4eabd3;
$greenish: lighten(desaturate(green,70%),40%);
$tooltip-border: $bar-color;

@mixin barbg(){
  @include background-image(
    linear-gradient(
      hsla(0, 100%, 100%, 0.75) 0%,
      hsla(0, 100%, 100%, 0.25) 5%,
      hsla(0, 100%, 100%, 0.08) 50%,
      transparent 100%
    ),
    linear-gradient($bar-color, darken($bar-color, 35%))
  );
}
@mixin barbg-no-white-top{
  @include background-image(
    linear-gradient(
      hsla(0, 100%, 100%, 0.25) 0%,
      hsla(0, 100%, 100%, 0.08) 50%,
      transparent 100%
    ),
    linear-gradient($bar-color, darken($bar-color, 35%))
  );
}
@mixin parent-attachment(){
  position: absolute;
  top: 0;
  left: 0;
}

.lifeline{
  & {
    .event{
      .element{
        color: white;
        font-size: 17px;
        background: $bar-color-bg;
        border-radius: 40px;
        width: 40px;
        height: 40px;
        transition: color 300ms;
        top: 0;
        left: 0;
        &:before{
          @include barbg-no-white-top();
          @include parent-attachment();
          opacity: 0;
          content:"";
          width: 100%;
          height: 100%;
          box-sizing: border-box;
          transform: scale(0.79);
          display: block;
          border-radius: 50%;
          transition: opacity 300ms;
        }
        & > *{
          line-height: 40px;
          text-align: center;
          width: 100%;
          position: relative;
        }
      }
      .tip{
        .date{
          text-transform: uppercase;
          font-weight: bold;
          font-size: .8em;
          border-bottom: 1px solid $tooltip-border;
          padding: 5px;
        }
        .name{
          padding: 5px;
        }
      }
      &.active{
        .element{
          color: $bar-color-bg;
          &:before{
            opacity: 1;
          }
        }
      }
    }
  }
  @media screen and (min-width: 480px){
    height: 22px;
    margin: 50px;
    border-radius: 5px;
    background: $bar-color-bg;
    position: relative;
    .progress{
      @include barbg();
      display: inline-block;
      height: 14px;
      margin: 4px;
      border-radius: 4px;
      transition: width 1s;
      transition-timing-function: ease-out;
    }
    .event{
      background: none;
      border: none;
      padding: 0;
      position: absolute;
      top: 50%;
      .element{
        cursor: pointer;
        position: relative;
        margin-left: -20px;
        margin-top: -20px;
      }
      .tip{
        z-index: 1000;
        background: white;  
        color: black;
        cursor: default;
        pointer-events: none;
        position: absolute;
        top: 30px;
        left: 0;
        transform: translate(-50%,0);
        width: 160px;
        text-align: center;
        border: 1px solid $tooltip-border;
        opacity: 0;
        transition: opacity 500ms, top 500ms;
        &:before{
          position: absolute;
          top: -5px;
          left: 50%;
          margin-left: -5px;
          display: block;
          border-width: 0 5px 5px 5px;
          border-style: solid;
          border-color: transparent transparent $tooltip-border transparent;
          content: "";
          width: 0;
          height: 0;
        }
        &:after{
          position: absolute;
          top: -4px;
          left: 50%;
          margin-left: -5px;
          display: block;
          border-width: 0 5px 5px 5px;
          border-style: solid;
          border-color: transparent transparent white transparent;
          content: "";
          width: 0;
          height: 0;
        }
      }
      &:last-child{
        .tip{
          transform: translate(-90%,0);
          &:before, &:after{
            left: 90%;
          }
        }
      }
      &:hover, &:focus{
        outline: none;
        .tip{
          pointer-events: all;
          opacity: 1;
          top: 40px;
        }
        .element{
          &:before{
            opacity: 1;
            background: $greenish;
          }
          color: white;
        }
      }
    } 
  }
  @media screen and (max-width: 480px){
    .event{
      position: relative;
      display: block;
      left: 0 !important;
      &:after{
        display: block;
        content:"";
        clear: both;
      }
      .tip{
        display: inline-block;
        position: relative;
        width: 100%;
        padding-left: 50px;
      }
      .element{
        display: inline-block;
        position: absolute;
        top: 5px;
        left: 5px;
      }
    }
  }
}
              
            
!

JS

              
                /**
 import moment from 'moment'
 import 'sugar'
 import React from 'react'
 import ReactDOM from 'react-dom'
 */

moment.locale(navigator.language)

let normalizeSorted = (numbersArray) => {
  let max = numbersArray.last()
  return max > numbersArray.first()
    ? numbersArray.map(n => n / max)
    : numbersArray
}

let interpolateDates = (datesArray) => {
  let momentDates = datesArray.map(d => moment(d))
  let firstDate = momentDates.first()
  let dayDiffs = momentDates.reduce(
    (daysDiff, date) => daysDiff.include(date.diff(firstDate, 'days')),
    []
  )
  return normalizeSorted(dayDiffs).from(1)
}

let easeOutApprox = x => 1 - Math.pow(1 - x, 1.685)

let data = [
  {
    data: "2015-08-01T12:44:03+00:00",
    nazwa: "get money",
    ikona: "dollar"
  }, {
    data: "2015-08-25T12:44:03+00:00",
    nazwa: "twit your friends",
    ikona: "twitter"
  }, {
    data: "2015-11-21T12:44:03+00:00",
    nazwa: "fall in love",
    ikona: "heart"
  }, {
    data: "2016-04-11T12:44:03+00:00",
    nazwa: "die happily",
    ikona: "trophy"
  }
]

class Bar extends React.Component {
  static defaultProps = {
    data: [],
    originDate: ""
  }

  state =
    {
      markPositions: [],
      percentage: 0
    }

  componentWillMount() {

    let dates = this.props.data.map(d => d.data)
    let newPercentage = interpolateDates([this.props.originDate, this.props.now, dates.last()]).first().cap(1)
    let markPositions = interpolateDates(dates.include(this.props.originDate, 0))
    let activeMarks = markPositions.filter(m => m <= newPercentage)

    setTimeout(()=>{
      this.setState({
        percentage: newPercentage
      })
    }, 1)

    normalizeSorted(activeMarks.include(0, 0)
      .include(newPercentage))
      .map(easeOutApprox)
      .map(n => n * 1000)
      .map(n => Math.max(0, n - 300))
      .from(1).to(-1)
      .each((time)=>{
        setTimeout(()=>{
          this.setState({
            activeMarks: this.state.activeMarks + 1
          })
        }, time)
      })

    this.setState({
      markPositions: markPositions,
      activeMarks: 0
    })
  }

  render() {
    return <div className="lifeline">
      <div
        className="progress"
        style={{width: `${this.state.percentage * 100}%`}}
      />
      {this.props.data.map((data, i)=>{
        return <div
          key={data.data}
          tabIndex="0"
          className={`event  ${i < this.state.activeMarks ? "active" : ""}`}
          style={{left: `${this.state.markPositions[i] * 100}%`}}
        >
          <div className="tip">
            <div className="date">
              {moment(data.data).format("dddd, Do MMMM YYYY")}
            </div>
            <div className="name">{data.nazwa}</div>
          </div>
          <div className="element">
            <span className={`fa fa-${data.ikona}`}/>
          </div>
        </div>
      })}
    </div>
  }
}

React.render(
  <Bar
    data={data}
    originDate="2015-07-15T12:44:03+00:00"
    now="2015-12-01T12:44:03+00:00"
  />,
  document.getElementById('barhere')
)
              
            
!
999px

Console