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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <!--PEN CODE-->
<div id="weather-app" class="weather-app">
	<i id="weather-icon" class="wi wi-fw weather-icon wi-day-sunny"></i>
	<div class="date-time">
		<div id="time" class="time">1:30<span>PM</span></div>
		<div id="date" class="date">
			<div id="day" class="day">Sun</div>
			<div id="monDate" class="monDate">Sep 13</div>
		</div>
	</div>

	<div class="location-weather">
		<label for="xBxHack">
			<i id="set-icon" class="fa set-icon fa-ellipsis-v"></i>
		</label>
		<div class="weather-status">
			<input type="checkbox" id="xBxHack">
			<div id="city" class="city">San Diego</div>
			<input id="userCity" class="userCity" type="text" placeholder="Enter City">
			<div id="forcast" class="forcast">Sky Is Clear</div>
		</div>
		<div class="weather-temp">
			<div id="temperature" class="temperature">84</div>
			<div class="high-low">
				<div id="high" class="high">92</div>
				<div id="low" class="low">79</div>
			</div>
		</div>
	</div>
</div>

<center>
	<p>Design Inspired by <a href="http://www.chynodeluxe.com/codepen/img/weather-widget.png" target="_blank">EZ Weather App Skin</a></p>
	<p>Uses <a href="http://openweathermap.org/" target="_blank">Open Weather Map API</a></p>
</center>
<!--END PEN CODE-->
              
            
!

CSS

              
                $black: #444;
$white: #fff;
$grey: #999;
$blue: #1E90FF; 

@mixin degree {
	content: "\00b0";
	font-size: .7em;
	font-family: Roboto;
	line-height: 1.25em;
	vertical-align: text-top;
}

body {
	background: #f1f1f1;
	margin-top: 2rem;
}

/*PEN STYLES*/

.weather-app {
	background: $white;
	color: $black;
	max-width: 375px;
	margin: 0 auto;
	box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
	border-radius: 6px;
	box-sizing: border-box;
	padding: 10px;
	overflow: hidden;
	position: relative;

	.date-time {
		margin-top: 20px;
		margin-bottom: 15px;
		border-bottom: 1px solid darken($grey, 1.5);
		padding-bottom: 15px;
		position: relative;
		overflow: hidden;
		font-size: 94%;
	}

	.time {
		font: 5.5em/.8em "Roboto";
		float: left;
		overflow: hidden;

		span {
			font-size: .15em;
			font-weight: bold;
			line-height: 1.25em;
			vertical-align: top;
		}
	}

	.date {
		float: left;
		margin-left: 2.25%;
		margin-top: 30px;

		.day {
			font-family: "Roboto";
			font-weight: bold;
		}
	}

	.weather-icon {
		color: $grey;
		font-size: 2.25em;
		line-height: 1.5em;
		z-index: 1;

		/*POSITION*/
		position: absolute;
		right: 5px;
		top: 5px;
	}

	.location-weather,
	.weather-temp {
		font-size: 90%;
	}

	.location-weather {
		/*POSITION*/
		position: relative;

		label {
			position: absolute;
			left: -1px;
			top: -5px;

			/*TRANSITION*/
			transition: left .3s ease;

			&.hovered > .set-icon {
				color: $grey;
			}

			&:hover, &.hovered {
				left: 1px;

				~ .weather-status {
					margin-left: 10px;
					max-width: 208px;
				}
			}
		}

		.set-icon {
			color: darken($grey, 1.4);
			cursor: pointer;
			font-size: 1.5em;
			float: left;
			line-height: 1.5em;
			padding: 0 5px 0 0;

			/*TRANSITION*/
			transition: color .2s ease;

			&:hover {
				color: $grey;
			}
		}

		.weather-status {
			float: left;
			overflow: hidden;
			margin-left: 8px;
			max-width: 210px;
			width: 65%;
			position: relative;

			/*TRANSITION*/
			transition: all .3s ease;
		}

		.userCity {
			border: none;
			box-sizing: border-box;
			border-bottom: 1px solid $blue;
			font-size: 1.25em;
			padding: 0 0 5px 5px;
			width: 100%;
			visibility: hidden;

			/*POSITION*/
			position: absolute;
			top: 0;

			&:focus {
				outline: none;
				visibility: visible;
			}
		}

		#xBxHack {
			display: none;

			&:checked {
				& ~ {
					.userCity {
						visibility: visible;
					}

					.city, .forcast {
						visibility: hidden;
					}
				}
			}
		}

		.city {
			font-family: Roboto;
			font-weight: bold;
			font-size: 1.25em;
			line-height: .9em;
			cursor: pointer;
		}

		.forcast {
			font-size: .9em;
			color: $grey;
			text-transform: capitalize;
		}
	}

	.weather-temp {
		float: right;
		overflow: hidden;
		margin-top: -1px;

		.temperature {
			color: $blue;
			float: left;
			font-family: Roboto;
			font-weight: bold;
			font-size: 2.7em;
			line-height: 1em;
			margin-right: 5px;
			margin-top: -5px;

			&:after {
				@include degree;
			}
		}

		.high-low {
			color: $grey;
			font-family: Roboto;
			line-height: 1.2em;
			float: right;
			text-align: right;

			.high,
			.low {
				&:after {
					@include degree;
				}
			}
		}
	}

	@media screen and (min-width: 380px) {
		.weather-icon {
			color: $white;

			&:after {
				background: $black;
				border-radius: 50%;
				border: 3px solid $blue;
				content: "";
				height: 160px;
				width: 160px;
				position: absolute;
				top: -90px;
				right: -90px;
				z-index: -1;
			}
		}

		.date-time {
			font-size: 100%;
		}

		.location-weather {
			label:hover {
				~ .weather-status {
					max-width: 233px;
				}
			}

			.weather-status {
				max-width: 235px;
				width: 100%;
			}
		}

		.high-low {
			.high,
			.low {
				&:before {
					font-size: .7em;
					font-weight: bold;
					text-transform: uppercase;
					vertical-align: middle;
					text-align: left;
				}
			}

			.high {
				&:before {
					content: "high: ";
				}
			}

			.low {
				&:before {
					content: "low: ";
				}
			}
		}
	}
}

              
            
!

JS

              
                var weatherModule = (function() {
	"use strict";
	var owm = {
		init: function() {
			this.cacheDom();
			this.bindEvents();
			this.callAPI();
		},
		cacheDom: function() {
			this.xBx = $("#xBxHack");
			this.user_input = $("#userCity");
			this.forcast = $("#forcast");
			this.city = $("#city");
			this.temp = $("#temperature");
			this.tempHigh = $("#high");
			this.tempLow = $("#low");
			this.set_icon = $("#set-icon").parent();
			this.weat_icon = $("#weather-icon");
			this.weat_icon_class = function(time_of_day) {
				var iconClass = "wi-owm-";

				if (time_of_day === "PM") {
					iconClass += "night-";
				} else {
					iconClass += "day-";
				}
				return iconClass;
			};
		},
		bindEvents: function() {
			this.city.click(this.events.checkBox.bind(this));
			this.city.hover(this.events.hover.bind(this));
			this.set_icon.click(this.events.checkBox.bind(this));
			this.user_input.keypress(this.events.enterKey.bind(this));
			this.user_input.blur(this.events.resetCheckBox.bind(this));
		},
		events: {
			checkBox: function(e) {
				e.preventDefault();
				this.xBx.prop("checked", true);
				this.user_input.focus();
			},
			resetCheckBox: function(e) {
				e.preventDefault();
				if (e.type === "keypress") {
					this.user_input.blur();
				}
				this.user_input.val("");
				this.xBx.prop("checked", false);
			},
			hover: function(e) {
				this.set_icon.toggleClass("hovered");
			},
			enterKey: function(e) {
				if (e.which === 13 || e.keyCode === 13) {
					e.preventDefault();
					this.callAPI(this.user_input.val());
					this.events.resetCheckBox.apply(this, [e]);
				}
			}
		},
		callAPI: function(url) {
			var apiUrl =
				"//api.openweathermap.org/data/2.5/weather?APPID=d65a9694ae6425d1e080326aab19db69&units=imperial&q=";
			if (url === undefined || url === "") {
				url =
					"//api.openweathermap.org/data/2.5/weather?APPID=d65a9694ae6425d1e080326aab19db69&units=imperial&q=san%20diego";
			} else {
				while (url.charAt(0) === " ") {
					url = url.substr(1);
				}
				apiUrl += encodeURIComponent(url);
				url = apiUrl.toLowerCase();
			}
			$.getJSON(url, this.parseData.bind(this));
		},
		parseData: function(json) {
			this.data = {
				name: json.name,
				weather: {
					description: json.weather[0].description,
					id: json.weather[0].id
				},
				temp: {
					current: Math.floor(json.main.temp),
					high: Math.floor(json.main.temp_max),
					low: Math.floor(json.main.temp_min)
				}
			};
			this.renderHTML();
		},
		renderHTML: function() {
			this.city.html(this.data.name);
			this.forcast.html(this.data.weather.description);
			this.temp.html(this.data.temp.current);
			this.tempHigh.html(this.data.temp.high);
			this.tempLow.html(this.data.temp.low);
			//DELETE CLASSES
			this.weat_icon.removeClass();
			//RESET CLASSES
			this.weat_icon.addClass("wi wi-fw weather-icon ");
			//ADD NEW CLASS
			this.weat_icon.addClass(this.weat_icon_class() + this.data.weather.id);
		}
	};
	owm.init();
	return {
		time_of_day: owm.weat_icon_class
	};
})();
var timeModule = (function() {
	"use strict";
	var dateTime = {
		init: function() {
			this.cacheDom();
			this.render();
			this.refresh();
		},
		cacheDom: function() {
			this.date = new Date();
			this.time = $("#time");
			this.day = $("#day");
			this.month = $("#monDate");
		},
		refresh: function() {
			setInterval(function() {
				dateTime.date = new Date();
				dateTime.render();
			}, 1000);
		},
		render: function() {
			var currentMonth = [
					"Jan",
					"Feb",
					"Mar",
					"Apr",
					"May",
					"Jun",
					"Jul",
					"Aug",
					"Sep",
					"Oct",
					"Nov",
					"Dec"
				],
				currentDay = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
				month = this.date.getMonth(),
				date = this.date.getDate(),
				hour = this.date.getHours(),
				minutes = this.date.getMinutes(),
				day = this.date.getDay(),
				amPM;

			/* CHECK TIME
						--------------------------------*/
			//IF MIDNIGHT
			if (hour === 0) {
				//HOUR EQUALS 12
				hour = 12;
			}
			//CHANGE 24 HOUR TO 12 HOUR
			if (hour > 12) {
				//MINUS 12
				hour -= 12;
				//CHANGE TO PM
				amPM = "PM";
			} else {
				//CHANGE TO AM
				amPM = "AM";
			}
			//IF HOUR IS LESS THAN 10
			if (hour < 10) {
				//ADD 0 TO HOUR
				hour = "0" + hour;
			}
			//GET MINUTES
			//IF MINUTES LESS THAN 10
			if (minutes < 10) {
				//ADD 0 TO MINUTES
				minutes = "0" + minutes;
			}
			//RENDER TIME
			this.time.html(hour + ":" + minutes + "<span>" + amPM + "</span>");
			//SET TIME OF DAT
			weatherModule.time_of_day(amPM);
			//RENDER DAY
			this.day.html(currentDay[day]);
			//RENDER DATE
			this.month.html(currentMonth[month] + " " + date);
		}
	};
	dateTime.init();
})();

              
            
!
999px

Console