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 id="app">
	<Calendar />
</div>
<template id="calendar-template">
	  <div class="container">
    <div class="single-day-container">
      <div class="day-container">
        <div class="day-info">
          <div class="day-number">{{ selectedDay.number }}</div>
          <div class="day-name">{{ selectedDay.name }}</div>
        </div>
        <div class="day-data">
        </div>
      </div>
      <div class="event-container">
        <ul class="event-list">
          <li class="event-list-item" :class="{ 'active': dayEvent.isActive }" v-for="(dayEvent, index) in dayEvents" :key="`dayEvent-${index}`">
            <div class="event-dates">
              <span>{{ dayEvent.startDate | getTime }}</span>
              <span>{{ dayEvent.endDate | getTime }}</span>
            </div>
            <div class="event-details">
              {{ dayEvent.title }}
            </div>
          </li>
        </ul>
      </div>
    </div>
    <div class="calendar-container">
      <div class="calendar">
        <div class="header row flex-middle">
          <div class="col col-start">
            <div class="icon" @click="prevMonth">
              chevron_left
            </div>
          </div>
          <div class="col col-center">
						 <transition tag="div" :name="typeTransition">
            	<div :key="month" class="month-name">{{ month }}</div>
						</transition>
          </div>
          <div class="col col-end" @click="nextMonth">
            <div class="icon">chevron_right</div>
          </div>
        </div>
        <div class="days row">
          <div class="col col-center" v-for="(day, index) in dayNames" :key="`h-${index}`">
            <div class="day-name">{{ day }}</div>
          </div>
        </div>
        <div class="body">
          <div class="row" v-for="(row, index) in rows" :key="`r-${index}`">
            <div class="col cell" :class="[{'has-events': day.hasEvents}, day.type]" v-for="(day, index) in row.days" :key="`d-${index}`" @click="updateDate(day)">
							 <transition-group tag="div" :name="typeTransition">
              	<div :key="day.formattedDate" class="day-number">{{ day.formattedDate }}</div>
							</transition-group>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
              
            
!

CSS

              
                
.icon {
  font-family: "Material Icons", serif;
  font-style: normal;
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
  word-wrap: normal;
  white-space: nowrap;
  direction: ltr;
  text-rendering: optimizeLegibility;
  font-feature-settings: "liga";
  user-select: none;
}

/* VARIABLES */

$main-color: #3fdd86;
$text-color: #777777;
$text-color-light: #cccccc;
$bg-color: #a1eec4;
$hover-color: #f7f7f7;
$neutral-color: #ffffff;

/* GENERAL */

* {
  box-sizing: border-box;
}

body {
  font-family: "Montserrat", "Arial", sans-serif;
  font-size: 1rem;
  font-weight: 300;
  line-height: 1.5;
  color: $text-color;
  background: $bg-color;
}

/* GRID */

.row {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  width: 100%;
}

.col {
  flex-grow: 1;
  flex-basis: 0;
  max-width: 100%;
}

.col-start {
  justify-content: flex-start;
  text-align: left;
}

.col-center {
  justify-content: center;
  text-align: center;
}

.col-end {
  justify-content: flex-end;
  text-align: right;
}

/* Wrapper */

.container {
  display: flex;
  flex-direction: row;
  margin: 0 auto;
  margin-top: 5rem;
  max-width: 75rem;
  min-height: 700px;

  .single-day-container {
    flex-shrink: 1;
    flex-grow: 0;
    flex-basis: (100% / 3);
    max-width: (100% / 3);
    background-color: $main-color;
    padding: 4rem;
    display: flex;
    flex-direction: column;
  }

  .calendar-container {
    flex-shrink: 1;
    flex-grow: 0;
    flex-basis: (100% / 3) * 2;
    max-width: (100% / 3) * 2;
    background-color: $neutral-color;
    padding: 3rem;
  }
}

/* Calendar */
.calendar {
  display: block;
  position: relative;
  width: 100%;
  background: $neutral-color;

  .header {
    text-transform: capitalize;
    font-weight: 400;
    font-size: 120%;
    padding: 1.5em 0;
    align-items: center;

    .icon {
      cursor: pointer;
      user-select: none;
      transition: 0.15s ease-out;

      &:hover {
        transform: scale(1.75);
        transition: 0.25s ease-out;
        color: $main-color;
      }

      &:first-of-type {
        margin-left: 2rem;
      }

      &:last-of-type {
        margin-right: 2rem;
      }
    }

    .col {
      flex-shrink: 1;
      flex-basis: auto;
    }

    .month-name {
      font-size: 2rem;
      color: $main-color;
    }
  }

  .days {
    text-transform: uppercase;
    font-weight: 700;
    color: $main-color;
    padding: 0.75rem 0;

    .col {
      padding: 0 1.5rem;
    }

    .day-name {
      padding: 0.25rem 0;
    }

    & .selected {
      .day-name {
        font-weight: 700;
        border-bottom: 2px solid $main-color;
      }
    }
  }

  .body {
    .cell {
      position: relative;
      background: $neutral-color;
      padding: 1rem;
      display: flex;
      align-items: center;
      justify-content: center;

      :last-child {
        border-right: none;
      }

      &.has-events {
        &:after {
          position: absolute;
          content: '';
          width: 0.75rem;
          height: 0.75rem;
          background-color: $main-color;
          top: 8px;
          right: 23px;
          border-radius: 0.5rem;
          border: 3px solid $neutral-color;
        }
      }

      .day-number {
        line-height: 1;
        font-weight: 700;
        padding: 0.75rem;
        width: 42px;
        text-align: center;
        cursor: pointer;
        border-radius: 0.25rem;

        &:hover {
          background: $hover-color;
        }
      }
    }

    .col {
      flex-grow: 0;
      flex-basis: (100% / 7);
      width: (100% / 7);
    }

    .selected {
      & .day-number {
        background-color: $main-color;
        color: $neutral-color;

        &:hover {
          background-color: $main-color;
          color: $neutral-color;
        }
      }
    }

    .disabled {
      color: $text-color-light;
      pointer-events: none;
    }
  }
}

.day-container {
  display: flex;
  flex-direction: row;
  padding-bottom: 1rem;
  border-bottom: 2px solid $neutral-color;

  .day-info {
    color: $neutral-color;
    flex: 1;
    text-align: center;
    font-weight: 400;

    .day-number {
      font-size: 4rem;
      line-height: 1;
    }
  }

  .day-data {
    flex: 2;
  }
}

.event-container {
  .event-list {
    padding: 0;
    color: $neutral-color;
    font-size: 14px;

    .event-list-item {
      list-style: none;
      display: flex;
      flex-direction: row;
      margin-bottom: 0.75rem;
      align-items: center;
      position: relative;

      &:last-child {
        margin-bottom: 0;
      }

      .event-dates {
        min-width: 60px;

        span {
          text-align: right;
          display: block;
        }
      }

      .event-details {
        margin-left: 0.75rem;
        background-color: rgba($neutral-color, 0.2);
        flex: 1;
        padding: 0.5rem;
        border-radius: 0.25rem;
      }

      &.active {
        .event-details {
          background-color: rgba($neutral-color, 0.4);
        }
      }
    }
  }
}


.slide-left-enter-active,
.slide-left-leave-active,
.slide-right-enter-active,
.slide-right-leave-active {
  transition: all 0.25s ease-in-out;
}

.slide-left-leave-active,
.slide-right-leave-active {
  position: absolute;
}

.slide-left-enter,
.slide-right-leave-to {
  opacity: 0;
  transform: translateX(50px) translateZ(0);
}

.slide-left-leave-to,
.slide-right-enter {
  opacity: 0;
  transform: translateX(-50px) translateZ(0);
}
              
            
!

JS

              
                const eventList = [
		{
			startDate: "10/1/2020 10:00 AM",
			endDate: "10/1/2020 12:00 PM",
			allDay: false,
			title: "Lorem ipsum dolor sit amet",
			description: "Lorem ipsum dolor sit amet"
		},
		{
			startDate: "10/3/2020 00:00 AM",
			endDate: "10/4/2020 00:00 AM",
			allDay: true,
			title: "Lorem ipsum dolor sit amet",
			description: "Lorem ipsum dolor sit amet"
		},
		{
			startDate: "10/9/2020 10:30 AM",
			endDate: "10/9/2020 11:00 AM",
			allDay: false,
			title: "Lorem ipsum dolor sit amet",
			description: "Lorem ipsum dolor sit amet"
		},
		{
			startDate: "10/13/2020 10:00 AM",
			endDate: "10/13/2020 12:00 PM",
			allDay: false,
			title: "Lorem ipsum dolor sit amet",
			description: "Lorem ipsum dolor sit amet"
		},
		{
			startDate: "4/3/2020 2:00 PM",
			endDate: "4/3/2020 6:00 PM",
			allDay: false,
			title: "Lorem ipsum dolor sit amet",
			description: "Lorem ipsum dolor sit amet"
		},
		{
			startDate: "10/10/2020 11:00 AM",
			endDate: "10/10/2020 3:00 PM",
			allDay: false,
			title: "Lorem ipsum dolor sit amet",
			description: "Lorem ipsum dolor sit amet"
		},
		{
			startDate: "10/10/2020 3:15 PM",
			endDate: "10/10/2020 5:20 PM",
			allDay: false,
			title: "Lorem ipsum dolor sit amet",
			description: "Lorem ipsum dolor sit amet"
		},
		{
			startDate: "10/10/2020 9:00 AM",
			endDate: "10/10/2020 10:30 AM",
			allDay: false,
			title: "Lorem ipsum dolor sit amet",
			description: "Lorem ipsum dolor sit amet"
		}
	];
Vue.component("Calendar", {
	template: "#calendar-template",
	name: "Calendar",
	data() {
		return {
			currentMonth: new Date(),
			selectedDate: new Date(),
			events: eventList,
			transitionDirection: "",
			currentPage: {
				month: dateFns.getMonth(new Date()),
				year: dateFns.getYear(new Date())
			}
		};
	},
	watch: {
    currentPage(val, oldVal) {
      this.transitionDirection = this.getTransitionDirection(oldVal, val);
    }
  },
	methods: {
		nextMonth() {
      this.currentMonth = dateFns.addMonths(this.currentMonth, 1);
      this.updateCurrentPage(this.currentMonth);
    },

    prevMonth() {
      this.currentMonth = dateFns.subMonths(this.currentMonth, 1);
      this.updateCurrentPage(this.currentMonth);
    },

    updateDate(day) {
      this.selectedDate = day.day;
    },

    updateCurrentPage(date) {
      this.currentPage = {
        month: dateFns.getMonth(date),
        year: dateFns.getYear(date)
      };
    },

		findEvents(day, sort = false) {
			let hasEvents = this.events.reduce((list, ev) => {
				if (dateFns.isSameDay(day, new Date(ev.startDate))) {
					ev.isActive =
						ev.allDay ||
						dateFns.isWithinRange(
							new Date(),
							new Date(ev.startDate),
							new Date(ev.endDate)
						);
					list.push(ev);
				}
				return list;
			}, []);
			if (sort) {
				hasEvents.sort((a, b) => {
					const dateA = new Date(a.startDate);
					const dateB = new Date(b.startDate);
					return dateFns.compareAsc(dateA, dateB);
				});
			}
			return hasEvents;
		},

		getTransitionDirection(fromPage, toPage) {
			if (!fromPage || !toPage) return "";
			if (fromPage.year !== toPage.year)
				return fromPage.year < toPage.year ? "next" : "prev";
			if (fromPage.month !== toPage.month)
				return fromPage.month < toPage.month ? "next" : "prev";
			return "";
		}
	},
	computed: {
		selectedDay() {
			return {
				number: dateFns.format(this.selectedDate, "D"),
				name: dateFns.format(this.selectedDate, "dddd")
			};
		},

		month() {
			const dateFormat = "MMMM YYYY";
			return dateFns.format(this.currentMonth, dateFormat);
		},

		dayNames() {
			const dateFormat = "ddd";
			let startDate = dateFns.startOfISOWeek(this.currentMonth);

			const days = [];
			for (let i = 0; i < 7; i += 1) {
				days.push(dateFns.format(dateFns.addDays(startDate, i), dateFormat));
			}
			return days;
		},

		rows() {
			const monthStart = dateFns.startOfMonth(this.currentMonth);
			const monthEnd = dateFns.endOfMonth(monthStart);
			const startDate = dateFns.startOfISOWeek(monthStart);
			const endDate = dateFns.endOfISOWeek(monthEnd);

			const dateFormat = "D";
			const rows = [];

			let days = [];
			let day = startDate;
			let formattedDate = "";

			while (day <= endDate) {
				for (let i = 0; i < 7; i += 1) {
					formattedDate = dateFns.format(day, dateFormat);
					const dayInfo = {
						day,
						formattedDate,
						type: !dateFns.isSameMonth(day, monthStart)
							? "disabled"
							: dateFns.isSameDay(day, this.selectedDate) ? "selected" : "",
						hasEvents: this.findEvents(day).length > 0
					};
					days.push(dayInfo);
					day = dateFns.addDays(day, 1);
				}
				rows.push({ days: days });
				days = [];
			}
			return rows;
		},		
		dayEvents() {
      return this.findEvents(this.selectedDate, true);
    },

    typeTransition() {
      return `${
        this.transitionDirection === "next" ? "slide-left" : "slide-right"
      }`;
    }
	},
	filters: {
		getTime(value) {
			const dateFormat = "h:mm A";
			return dateFns.format(value, dateFormat);
		}
	}
});
new Vue({
	el: "#app"
});

              
            
!
999px

Console