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

              
                - const startingYear = 2010;
- const endingYear   = 2020;
- const monthsCount  = 12;
- const datePattern  = 'd M Y';
- const daysInWeek   = 7;
- const currentDate  = new Date();

//- 'id' and 'name' must be changeable (by form; for multiple datepicker)
- const idPrefix = 'cal_';
- const calName  = 'calendar';
- const dateName = 'calendar_date';
			
//- TODO: Make variable:'daysLabel' changeable by language
- const daysLabel = [
- 'Sun',
- 'Mon',
- 'Tue',
- 'Wed',
- 'Thu',
- 'Fri',
- 'Sat'
- ];
//- TODO: Make variable:'monthsLabel' changeable by language
- const monthsLabel = [
- 	'January',
- 	'February',
- 	'March',
- 	'April',
- 	'May',
- 	'June',
- 	'July',
- 	'August',
- 	'September',
- 	'October',
- 	'November',
- 	'December'
- ];

.calendar
	- for (var year = startingYear; year <= endingYear; year++)
		- for (var month = 0; month < monthsCount; month++)
			//- For the year/month picker
			input(
				type="radio"
				id=idPrefix + "year_select_" + year + "_" + month
				name=calName
			).cal-year-check
			input(
				type="radio"
				id=idPrefix + "month_select_" + year + "_" + month
				name=calName
				data-cal-year=year
			).cal-month-check
			.cal
				.cal-head
					.controls
						label(for=idPrefix + year + "_" + month).cal-change-year #{monthsLabel[month]} #{year}
							// Borrowed Google's 'Material Design Icons'
							svg(viewBox="0 0 24 24")
								path(d="M13,20H11V8L5.5,13.5L4.08,12.08L12,4.16L19.92,12.08L18.5,13.5L13,8V20Z")
					.controls
				.cal-body.year-picker
					- for (var yearPick = startingYear; yearPick <= endingYear; yearPick++)
						.cal-date
							label(for=idPrefix + "month_select_" + yearPick + "_" + month)
								span #{yearPick}
				- for (var yearPick = startingYear; yearPick <= endingYear; yearPick++)
					.cal-body.month-picker(data-cal-year=yearPick)
						- for (var monthPick = 0; monthPick < monthsCount; monthPick++)
							.cal-date
								label(for=idPrefix + yearPick + "_" + monthPick)
									span #{monthsLabel[monthPick]}
			//- For the actual calendar
			input(
				type="radio"
				id=idPrefix + year + "_" + month
				name=calName
				checked=currentDate.getFullYear() == year && currentDate.getMonth() == month
			).cal-check
			.cal
				.cal-head
					.controls
						label(for=idPrefix + "year_select_" + year + "_" + month).cal-change-year #{monthsLabel[month]} #{year}
							// Borrowed Google's 'Material Design Icons'
							svg(viewBox="0 0 24 24")
								path(d="M11,4H13V16L18.5,10.5L19.92,11.92L12,19.84L4.08,11.92L5.5,10.5L11,16V4Z")
					.controls
						- var lastMonth = new Date(year, month - 1);
						- var nextMonth = new Date(year, month + 1);
						label(for=idPrefix + lastMonth.getFullYear() + "_" + lastMonth.getMonth()).cal-change-month
							// Borrowed Google's 'Material Design Icons'
							svg(viewBox="0 0 24 24")
								path(d="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z")
						label(for=idPrefix + nextMonth.getFullYear() + "_" + nextMonth.getMonth()).cal-change-month
							// Borrowed Google's 'Material Design Icons'
							svg(viewBox="0 0 24 24")
								path(d="M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z")
				.cal-body
					- var firstDate = new Date(year, month, 1);
					- var lastDate  = new Date(year, (month + 1), 0);
					//- Days of week
					- for (var day = 0; day < daysInWeek; day++)
						.cal-day #{daysLabel[day]}
					//- Extra spaces before starting date
					- for (var date = 0; date < firstDate.getDay(); date++)
						.cal-date
					//- Actual date
					- for (var date = 1; date <= lastDate.getDate(); date++)
						//- TODO: Date pattern must be changeable
						.cal-date
							//- Name here must be changeable
							label
								input(
									type="radio"
									name=dateName
									value=year + "/" + month + "/" + date
									checked=currentDate.getFullYear() == year && currentDate.getMonth() == month && currentDate.getDate() == date
								)
								span #{date}
					//- Extra spaces after ending date
					- for (var date = lastDate.getDay() + 1; date < daysInWeek; date++)
						.cal-date

              
            
!

CSS

              
                // ----- About: Calendar
$starting-year: 2010;
$ending-year: 2020;
$months-count: 12;
$days-in-week: 7;

// ----- Global
$cell-size: 100%;

$hover-background-color: #efefef;

$primary-color: #ffffff;
$primary-background-color: #0681ff;

// ----- Styles
$calendar-background-color: #ffffff;
$calendar-width: 280px;
$calendar-box-shadow: 0 5px 10px 2px rgba(0, 0, 0, 0.5);

$cal-head-color: $primary-color;
$cal-head-background-color: $primary-background-color;
$cal-head-height: 50px;

$cal-head-controls-width: 30px;
$cal-head-controls-height: $cal-head-height;

$cal-change-month-width: $cal-head-controls-width;
$cal-change-month-height: $cal-head-controls-height;

$cal-change-month-active-background-color: darken($primary-background-color, 10%);

$cal-change-month-svg-fill: #ffffff;
$cal-change-month-svg-width: 24px;
$cal-change-month-svg-height: 24px;

$cal-change-year-height: $cal-head-controls-height;
$cal-change-year-padding: 0 8px;

$cal-change-year-svg-width: 12px;
$cal-change-year-svg-height: 12px;
$cal-change-year-svg-fill: #ffffff;

$cal-change-year-active-background-color: darken($primary-background-color, 10%);

$cal-day-background-color: #dfdfdf;
$cal-day-height: 30px;

$cal-date-height: 40px;

$cal-date-span-hover-background-color: $hover-background-color;
$cal-date-span-active-color: $primary-color;
$cal-date-span-active-background-color: $primary-background-color;
$cal-date-span-transition: background-color ease-out 150ms, color ease-out 150ms;

$cal-body-min-height: $cal-day-height + ($cal-date-height * 6);

// ----- SCSS codes
.calendar {
	background-color: $calendar-background-color;
	width: $calendar-width;
	margin: auto;
	user-select: none;
	box-shadow: $calendar-box-shadow;
	flex-grow: 0;
	flex-shrink: 0;
	.cal-check {
		display: none;
		&:checked + .cal {
			display: block;
		}
	}
	.cal-year-check {
		display: none;
		&:checked + .cal-month-check + .cal {
			display: block;
		}
	}
	@for $year from $starting-year through $ending-year {
		.cal-month-check[data-cal-year="#{$year}"] {
			display: none;
			&:checked + .cal {
				display: block;
				.year-picker {
					display: none;
				}
				.month-picker[data-cal-year="#{$year}"] {
					display: grid;
				}
			}
		}
	}
	.cal {
		display: none;
		.cal-head {
			color: $cal-head-color;
			background-color: $cal-head-background-color;
			width: 100%;
			height: $cal-head-height;
			display: flex;
			.controls {
				width: 50%;
				height: $cal-head-controls-height;
				line-height: $cal-head-controls-height;
				box-sizing: border-box;
				&:first-child {
					font-weight: bold;
					text-align: left;
				}
				&:last-child {
					display: flex;
					justify-content: flex-end;
				}
				.cal-change-year {
					height: $cal-change-year-height;
					line-height: $cal-change-year-height;
					padding: $cal-change-year-padding;
					display: inline-block;
					&:hover, &:active {
						background-color: $cal-change-year-active-background-color;
					}
					svg {
						width: $cal-change-year-svg-width;
						height: $cal-change-year-svg-height;
						fill: $cal-change-year-svg-fill;
						vertical-align: middle;
					}
				}
				.cal-change-month {
					text-align: center;
					width: $cal-change-month-width;
					height: $cal-change-month-height;
					line-height: $cal-change-month-height;
					display: flex;
					&:hover, &:active {
						background-color: $cal-change-month-active-background-color;
					}
					svg {
						width: $cal-change-month-svg-width;
						height: $cal-change-month-svg-height;
						fill: $cal-change-month-svg-fill;
						vertical-align: middle;
						margin: auto;
					}
				}
			}
		}
		.cal-body {
			min-height: $cal-body-min-height;
			display: grid;
			align-content: start;
			grid-template-columns: repeat(7, 1fr);
			&.year-picker {
				grid-template-columns: repeat(4, 1fr);
			}
			&.month-picker {
				display: none;
				grid-template-columns: repeat(3, 1fr);
			}
			.cal-day {
				background-color: $cal-day-background-color;
				height: $cal-day-height;
				line-height: $cal-day-height;
				text-align: center;
			}
			.cal-date {
				height: $cal-date-height;
				line-height: $cal-date-height;
				text-align: center;
				input[type="radio"] {
					display: none;
					&:checked + span {
						color: $cal-date-span-active-color;
						background-color: $cal-date-span-active-background-color;
					}
				}
				label, label span {
					text-align: center;
					display: block;
				}
				label span {
					transition: $cal-date-span-transition;
					&:hover {
						background-color: $cal-date-span-hover-background-color;
					}
				}
			}
		}
	}
}

// -----

html, body {
	width: 100%;
	height: 100%;
	padding: 0;
	margin: 0;
}

@import url("https://fonts.googleapis.com/css?family=Montserrat:400,400i,700");

body {
	background-color: #082946;
	display: flex;
	.calendar {
		font-family: Montserrat, sans-serif;
		font-size: 14px;
	}
}

              
            
!

JS

              
                
              
            
!
999px

Console