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

              
                <div id="mount"></div>
<a class="nl" href="https://nolaborables.com.ar">NoLaborables.com.ar</a>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Roboto+Condensed:400,300,700);

$color-inamovible: #e42355;
$color-nolaborable: #2394e4;
$color-trasladable: #e4c323;

html, body, div, span, h1, h2, h3, p, a, form, nav, li, ul {
	margin: 0;
	padding: 0;
	border: 0;
	outline: 0;
	vertical-align: baseline;
}

body {
  background: #249991;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight:100;
  line-height:1;
  font-size:20px;
  color:#222;
  text-align: center;
}

.container {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: center;
  margin-top: 20px;
}

section {
  width: 350px;
  height: 300px;
  padding: 20px;
}
 
.current-day,
section.holiday {
  background: #4ecdc4;
  color: #fff;
}

.current-day {  
  position: relative;
  overflow: hidden;
  
  h3 {
    text-transform: uppercase;
    margin: 0;
    font-size: 500px;
    font-weight: 600;
    color: #8ce5df;
    position: absolute;
    top: -70px;
    right: 0px;
    text-align: center;
    position: absolute;
    z-index: 1;
    
    -webkit-animation: hmoveWeek 120s linear infinite;
    animation: hmoveWeek 120s linear infinite;
  }
}

.current-day,
section.holiday {
  .day {
    font-size: 400px;
    font-weight: 700;
    color: #249991;
    position: absolute;
    bottom: -90px;
    right: 30px;
    text-align: right;
    /*text-shadow: 17px 0 0 rgba(53, 175, 166, 0.84);*/
    z-index: 2;
    letter-spacing: -40px;
    
     -webkit-animation: hmoveDay 120s linear infinite;
    animation: hmoveDay 120s linear infinite;
  }
}

section.holiday {
  position: relative;
  overflow: hidden;
  background: #249991;
    
  &.active {
    background: #4ecdc4;
    border-left: 10px solid #e42355;
    padding-left: 10px;
  }
  
  h3 {
    font-size: 2em;
    text-align: left;
    color: whitesmoke;
    font-style: italic;
    line-height: 1.2em;
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 5;
  }
  
  .type {
    font-size: 55px;
    font-weight: 700;
    color: #4ecdc4;
    position: absolute;
    bottom: -10px;
    left: 0;
    text-align: center;
    z-index: 3;
    text-transform: uppercase;
    background-color: rgba(36, 153, 145, 0.5);
    width: 100%;
    padding: 30px 0;
    
    .tag, .opt {
      position: absolute;
      font-size: 26px;
      color: #39b3ab;
    }
    
    .tag {
      left: 2px;
      top: -36px;
      font-size: 40px;
    }
    
    .opt {
      right: 0;
      top: -36px;
      font-style: italic;
      background-color: rgba(36, 153, 145, 0.5);
      color: #4ecdc4;
      padding: 5px;
    }
  }
  
  .day {
    text-shadow: none;
    color: #35afa6;
  }
  
}

.calendar-header {
  position: relative;
  
  .left, .right {
    color: #e42355;
    position: absolute;
    top: 0;
    padding: 20px;
    cursor: pointer;
    font-size: 40px;
    
    &:before {
      position: absolute;
      top: 0;
      left: 0;
    }
  }
  
  .left {
    left: 0;
    &:before {
      content: '<'
    }
  }
  .right {
    right: -20px;
    &:before {
      content: '>'
    }
  }
  
  h2 {
    margin: 0 0 20px 0; 
    text-align: center;
    color: #249991;
    font-weight: 100;
    margin: 10px 0 20px;
    text-transform: uppercase;
    font-size: 40px;
  }
}

.calendar {
  background: #f5f5f5;
  color: #ddd;
  min-width: 300px;
  
  .loading {
    margin-top: 60px;
    font-size: 30px;
    color: #333;
  }
  
  p {
    clear: both;
    text-align: right;
    margin: 0;
    padding-top: 10px;
    color: #8e8e8e;
    font-size: 18px;
  }

  ul {
    list-style-type: none;

    li {
      cursor: pointer;
      float: left;
      width: 12%;
      margin: 0.25em 1%;
      line-height: 1.5em;
      vertical-align: middle;

      font-size: 0.8em;
      font-weight: 700;
      color: #636362;
      
      &.blank {
        cursor: default;
      }
      
      &:hover {
        color: #e42355;
      }

      &:nth-child(-n+7) {
        color: #e42355;
        font-weight: 400;
        font-size: 1em;
      }

      &.holiday {
        // color: #e42355;
        position: relative;

        &:before {
          content: "";
          width: 1.70em;
          height: 1.70em;
          border-width: 0.2em;
          border-style: solid;
          position: absolute;
          border-radius: 100%;
          left: 0.15em;
          top: -0.30em;
          
          -webkit-transition: all 0.2s;
          transition: all 0.2s;
        }
        
        &.inamovible {
          &:before {
            border-color: $color-inamovible;
          }
        }
        
        &.nolaborable {
          &:before {
            border-color: $color-nolaborable;
          }
        }
        
        &.trasladable {
          &:before {
            border-color: $color-trasladable;
          }
        }
        
        &:hover {
          &:before {
            border-radius: 0;
            top: -0.50em;
            left: 0;
            width: 2em;
            height: 2em;
          }
        }
      }
      
      &.today {
        background-color: #4ecdc4;
        color: #fff;
        
        &.holiday {
          &.inamovible {
            background-color: $color-inamovible;
          }

          &.nolaborable {
            background-color: $color-nolaborable;
          }

          &.trasladable {
            background-color: $color-trasladable;
          }
          
          &:before {
            display: none;
          }
        }
      }
    }
  }
}

@-webkit-keyframes hmoveWeek {
  0% {-webkit-transform: translateX(60%);}
  50% {-webkit-transform: translateX(0%);}
  100% {-webkit-transform: translateX(60%);}
}

@keyframes hmoveWeek {
  0% {transform: translateX(60%);}
  50% {transform: translateX(0%);}
  100% {transform: translateX(60%);}
}

@-webkit-keyframes hmoveDay {
  0% {-webkit-transform: translateX(-25%);}
  50% {-webkit-transform: translateX(5%);}
  100% {-webkit-transform: translateX(-25%);}
}

@keyframes hmoveDay {
  0% {transform: translateX(-25%);}
  50% {transform: translateX(5%);}
  100% {transform: translateX(-25%);}
}

.nl {
  position: fixed;
  right: 0;
  bottom: 0;
  font-family: sans-serif;
  text-decoration: none;
  padding: 4px 8px 0 8px;
  color: #bbbbbb;
  background-color: #3a3a3a;
  font-size: 16px;
  z-index: 99999999;
}
              
            
!

JS

              
                const getURL = year => `https://nolaborables.com.ar/api/v2/feriados/${year}?formato=mensual&incluir=opcional`
const maxYear = 2019

const months = ['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre']

const days = ['Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes', 'Sabado', 'Domingo']
const numDays = (month, year) => new Date(year, month+1, 0).getDate()
const firstDay = (month, year) => new Date(year, month, 1).getDay()
const dayOfWeek = (day, month, year) => new Date(year, month, day).getDay()

const Holiday = ({day, tipo, motivo, original, opcional}) => {
  return (
    <div>
      <h3>{motivo}</h3>
      <p className="type">{tipo}
        <span className="tag">feriado</span>
        {opcional && <span className="opt">opcional</span>}
        {tipo === 'trasladable' && <span className="opt">{original}</span>}
      </p>
    </div>
  )
}

const Day = ({day, holiday, isToday, onClick}) => {
  if (!day) return <li className="blank" dangerouslySetInnerHTML={{__html: '&nbsp;'}}></li>
  
  let css = holiday ? `holiday ${holiday.tipo} ` : ''
  css += isToday ? 'today' : ''
  return (
    <li className={css} onClick={() => onClick(holiday)}>{day || '.'}</li>
  )
}

const CurrentDay = ({year, month, day}) => {
  const weekDay = dayOfWeek(day, month, year)
  return (
    <section className="current-day">
      <h3>{days[!weekDay ? 6 : weekDay-1]}</h3>
      <p className="day">{day}</p>
    </section>
  )
}

const Header = ({current, onChange}) => {
  const year = current.getFullYear()
  const month = current.getMonth()

  const onLeftClicked = () => {
    const nextMonth = month-1
    const moveYear = nextMonth < 0
    onChange(moveYear ? 11 : nextMonth, moveYear ? year-1 : year)
  }
  
  const onRightClicked = () => {
    const nextMonth = month+1
    const moveYear = nextMonth > 11
    onChange(moveYear ? 0 : nextMonth, moveYear ? year+1 : year)
  }
  
  const hideLeft = year === 2011 && month === 0
  const hideRight = year === maxYear && month === 11
  
  return (
    <div className="calendar-header">
      {!hideLeft && <a className="left" onClick={onLeftClicked}></a>}
      <h2>{months[month]} {year}</h2>
      {!hideRight && <a className="right" onClick={onRightClicked}></a>}
    </div>
  )
}

class Calendar extends React.Component {
  constructor(props){
    super(props)
    
    const today = new Date() 
    this.state = {
      loading: true,
      year: today.getFullYear(),
      month: today.getMonth(),
      today,
      holidays: [],
      allHolidays: {}
    }
  }
  
  componentDidMount() {
    this.loadHolidays()
  }
  
  setStateHolidays(data) {
    let newState = {holidays: data}
    const holiday = this.getHoliday(data, this.state.month, this.state.today.getDate())

    if (holiday) {
      newState = {...newState, selected: {holiday, day: this.state.day}}
    }

    this.setState(newState)
  }
  
  loadHolidays() {
    const cacheHolidays = this.state.allHolidays[this.state.year]
    if (cacheHolidays){
      this.setStateHolidays(cacheHolidays)
      return;
    }
    
    this.setState({loading: true})
    axios.get(getURL(this.state.year)).then(({data}) => {
      let yholidays = data.map(
        month => Object.keys(month).reduce((days, day) => ({
          ...days,
          [day]: Array.isArray(month[day]) ? month[day][0] : month[day]
        }), {})
      )
      
      this.setState({
        loading: false,
        allHolidays: {
          ...this.state.allHolidays,
          [this.state.year]: yholidays
        }
      }, () => this.setStateHolidays(yholidays))
    })
  }
  
  getHoliday(holidays, month, day){
    return _.get(holidays, `[${month}][${day}]`)
  }
  
  onChange(month, year) {
    const day = 1
    const today = new Date(year, month, day)
    this.setState({year, month, day, today}, () => this.loadHolidays(year))
  }
  
  getDays() {
    const {loading, holidays, month, year} = this.state
    const days = numDays(month, year)
    let fDay = firstDay(month, year) - 1
    fDay = fDay === -1 ? 6 : fDay 
    return _.times(fDay, _.constant(null)).concat(_.times(days, i => i+1))
  }
  
  render() {
    const {month, loading, holidays, year, today, selected} = this.state
    const current = (selected && selected.day) || today.getDate()
    const getHoliday = day => !loading ? _.get(holidays, `[${month}][${day}]`) : null
    
    const isToday = day => day === (new Date()).getDate() && month === (new Date()).getMonth() ? true : false
    
    return (
      <div className="container">
        <CurrentDay day={current} month={month} year={year} />
        <section className="calendar">
          {loading ? <div className="loading">Cargando feriados...</div> : 
          <div>
            <Header current={today} onChange={(m, y) => this.onChange(m, y)} /> 
            <ul>
              {days.map(day => <li>{day.substring(0, 2)}</li>)}
              {this.getDays().map(day => 
                <Day day={day} holiday={getHoliday(day)} isToday={isToday(day)}
                  onClick={holiday => this.setState({selected: {holiday, day}})}/>
              )}
            </ul>
          </div>
          }
        </section>
        <section className={"holiday " + (selected && selected.holiday ? "active" : "")}>
        {selected && selected.holiday &&
          <Holiday {...selected.holiday} />
        }
        </section>
      </div>
    )
  }
}
  
ReactDOM.render(<Calendar/>, document.getElementById('mount'));
              
            
!
999px

Console