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

              
                <body ng-app="app" ng-controller="myCtrl" ng-style="getBackground(color, 10)">

	<div class="container">

		<div class="pallette">
			<div class="card" ng-repeat="p in pallette" ng-style="getBackground(p, 0)">
				<button type="button" ng-click="removeCard($index)">x</button>
				<div class="label">
					<p ng-bind="'rgb(' + p + ')' "></p>
					<p ng-bind="rgbToHex(p[0], p[1], p[2])"></p>
				</div>
			</div>
		</div>

		<div id="color-picker">
			<div id="color" ng-style="getBackground(color, 0)"></div>
			<div id="slider-container">
				<div ng-repeat="s in color track by $index" class="slider-group">
					<p ng-bind="['R', 'G', 'B'][$index]"></p>
					<input tabindex="0" type="range" min="0" max="255" value="1" class="sli-{{$index}}" ng-model="color[$index]" />
					<p>{{s}}</p>
				</div>
			</div>
			<button type="button" ng-click="addCard(color)" ng-disabled="pallette.length >= 6">+</button>
		</div>

	</div>

	<label class="switch">
	  <input type="checkbox" ng-model="backLocked">
	  <div class="slider round"></div>
	</label>

</body>
              
            
!

CSS

              
                // ** general ------
* {
	box-sizing: border-box;
}

body {
	background: rgb(0, 104, 162);
}

.center {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	margin: auto;
}

.container {
	@extend .center;
	width: 280px;
	height: 510px;
}

// ** color picker ------
#color-picker {
	@extend .center;
	width: 100%;
	height: 100%;
	background: white;
	box-shadow: 0 5px 15px 6px rgba(0, 0, 0, 0.1);
	#color {
		position: relative;
		height: 60%;
		width: 100%;
		background: lightblue;
	}
	.slider-group {
		width: 100%;
		height: 60px;
		padding: 5px 20px;
		&:first-child {
			margin-top: 10px;
		}
		p,
		input {
			position: relative;
			display: inline-block;
		}
		p {
			width: 18%;
			text-align: center;
			font-family: verdana;
		}
		input {
			width: 60%;
			top: -5px;
		}
	}
	input[type=range] {
		-webkit-appearance: none;
		background: transparent;
	}
	input[type=range]:focus {
		outline: none;
	}
	input[type=range]::-webkit-slider-thumb {
		-webkit-appearance: none;
		height: 16px;
		width: 16px;
		border-radius: 50%;
		background: rgb(0, 158, 166);
		cursor: pointer;
		box-shadow: none;
		margin-top: -6px;
		&:focus {
			box-shadow: 0 0 0 5px rgba(0, 158, 166, 0.4);
		}
		&:hover {
			box-shadow: 0 0 0 1px rgba(0, 158, 166, 1);
		}
		&:active {
			box-shadow: 0 0 0 2px rgba(0, 158, 166, 1);
		}
	}
	input[type=range]::-webkit-slider-runnable-track {
		width: 100%;
		height: 2px;
		cursor: pointer;
		animate: 0.2s;
		background: rgb(0, 158, 166);
		border-radius: 5px;
	}
}

// ** switch ------
.switch {
	position: absolute;
	display: inline-block;
	width: 60px;
	height: 34px;
	top: 20px;
	right: 20px;
	input {
		display: none;
	}
	.slider {
		position: absolute;
		cursor: pointer;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background-color: rgba(255, 255, 255, 1);
		box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
		transition: .4s;
	}
	.slider:before {
		position: absolute;
		content: "";
		height: 26px;
		width: 26px;
		left: 4px;
		bottom: 4px;
		background-color: white;
		box-shadow: 0 1px 1px 1px rgba(0, 0, 0, 0.3);
		transition: .4s;
	}
	input:checked + .slider,
	input:focus + .slider {
		background-color: rgba(0, 211, 93, 1);
		&:before {
			border: none;
		}
	}
	input:checked + .slider:before {
		transform: translateX(26px);
	}
	.slider.round {
		border-radius: 34px;
	}
	.slider.round:before {
		border-radius: 50%;
	}
}

// ** button ------
button {
	width: 40px;
	height: 40px;
	border: none;
	background: white;
	box-shadow: 0 5px 15px 6px rgba(0, 0, 0, 0.1);
	font-size: 30px;
	transition: background .3s ease-out;
	position: absolute;
	left: 103%;
	bottom: 0;
	&:focus {
		outline: none;
	}
	&:hover {
		background: rgb(255,197,0);
	}
	&:active {
		transition: background .1s ease;
		background: rgb(229, 170, 0);
	}
	&[disabled] {
		background: lightgrey;
		box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2);
	}
}

// ** cards ------
@keyframes slideOut {
	0% {
		transform: translateX(100%) scale(0.95);
		box-shadow: none;
	}
	60% {
		transform: translateX(0) scale(0.95);
		box-shadow: none;
	}
	100% {
		transform: translateX(0) scale(1);
		box-shadow: 0 2px 10px 4px rgba(0, 0, 0, 0.1);
	}
}

@keyframes hideMe {
	0%,
	90% {
		opacity: 0
	}
	100% {
		opacity: 1
	}
}

$cHeight: 80;
.pallette {
	@extend .center;
	width: 160px;
	height: 100%;
	left: -455px;
	.card {
		position: absolute;
		left: 0;
		width: 100%;
		height: $cHeight + px;
		box-shadow: 0 2px 10px 4px rgba(0, 0, 0, 0.1);
		animation: hideMe .7s, slideOut 1.4s ease .6s;
		overflow: hidden;
		transition: box-shadow .3s ease, transform .3s ease, top .6s ease-in-out;
		&:hover {
			transform: scale(1.03);
			box-shadow: 0 5px 15px 6px rgba(0, 0, 0, 0.1);
			button {
				opacity: 1;
			}
			.label {
				transform: translateY(0);
			}
		}
		@for $i from 1 through 6 {
			&:nth-child(#{$i}) {
				top: ($i - 1) * ($cHeight + 6) + px;
			}
		}
		.label {
			font-size: 14px;
			position: absolute;
			bottom: 0;
			background: rgba(255, 255, 255, 1);
			width: 200%;
			height: 35%;
			text-align: center;
			line-height: 25px;
			transform: translateY(100%);
			transition: transform .3s ease-out .2s;
			p {
				@extend .center;
				width: 160px;
				height: 100%;
				margin: 0;
				left: -10px;
				&:last-of-type {
					background: rgb(41,39,41);
					color: white;
					transform: translateX(145px);
					transition: transform .5s ease-out .2s;
					// width: 170px;
					&:before{
						content: '#';
						font-weight: bold;
						position: absolute;
						left: 8px;
						top: 2px;
						transition: opacity .1s ease .6s;
					}
					&:hover{
						transform: translateX(10px);
						&:before {
							opacity: 0;
							transition: opacity .1s ease;
						}
					}
				}
			}
		}
		button {
			width: 25px;
			height: 25px;
			font-size: 20px;
			left: 0;
			top: 0;
			transition: opacity .5s ease-out .2s;
			box-shadow: none;
			padding-top: 1px;
			opacity: 0;
			&:hover {
				box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2);
				background: white;
			}
			&:active {
				box-shadow: none;
				background: white;
			}
		}
	}
}
              
            
!

JS

              
                var app = angular.module("app", []);
app.controller("myCtrl", function($scope) {
	$scope.color = [192, 155, 255];
	$scope.backLocked = false;
	$scope.pallette = [];
	var save = [];

	//		Set the background colour
	// ------------------------------
	$scope.getBackground = function(s, num) {
		if (num > 0 && $scope.backLocked || num === 0) {
			var c = [];
			for (var i = 0; i < s.length; i++) {
				s[i] = Number(s[i])
				var n = s[i] - num <= 0 ? 0 : s[i] - num;
				c.push(n);
			}
			if (num > 0) {
				save = c;
			}
			return {
				background: 'rgb(' + c + ')'
			};
		} else {
			return {
				background: 'rgb(' + save + ')'
			};
		}
	}

	//		add color card to palette
	// ------------------------------
	$scope.addCard = function(s) {
		var nCol = [s[0], s[1], s[2]],
			cardAdded = false;
		for (i = 0; i < $scope.pallette.length; i++) {
			var a = nCol.join(','),
				b = $scope.pallette[i].join(',');
			if (a === b) {
				cardAdded = true;
			}
		}
		if (!cardAdded) {
			$scope.pallette.unshift(nCol);
		}
	}

	//	  remove card from pallete
	// ------------------------------
	$scope.removeCard = function(n) {
		$scope.pallette.splice(n, 1);
	}

	//	  convert to hex
	// ------------------------------
	function componentToHex(c) {
		var hex = c.toString(16);
		return hex.length == 1 ? "0" + hex : hex;
	}
	$scope.rgbToHex = function(r, g, b) {
		return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
	}
});
              
            
!
999px

Console