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

              
                - const DEFAULT_MIN = 0;
- const DEFAULT_VAL = 1;
- const DEFAULT_MAX = 1;

- let data = {
//- super values, max > 1
- 	'brightness': { step: .01, max: 10 }, 
- 	'contrast': { step: .01, max: 10 }, 
- 	'saturate': { step: .01, max: 10 }, 

//- in [0, 1] interval, default 0
- 	'grayscale': { step: .01, val: 0 }, 
- 	'invert': { step: .01, val: 0 }, 
- 	'sepia': { step: .01, val: 0 }, 

//- in [0, 1] interval, default 1
//- 	'opacity': { step: .01 }, 

//- others
- 	'blur': { val: 0, max: 10, unit: 'px' }, 
- 	'hue-rotate': { val: 0, max: 360, unit: 'deg' }
- };

- let fn = Object.keys(data);
- let has_o = fn.indexOf('opacity') !== -1;

body(style=`--n: ${fn.length}; --val: ${fn.map(f => `${f}(var(--${f}))`).join(' ')}`)
	style
		| body {
		- fn.forEach(f => {
			| --#{f}: #{(data[f].val || data[f].val === 0) ? data[f].val : DEFAULT_VAL}#{data[f].unit || ''};
		- })
		| }
	section
		article
			h3 Hello Gorgeous!
			p Remember all the blood we had...
	aside
		- fn.forEach(f => {
			- let val = (data[f].val || data[f].val === 0) ? data[f].val : DEFAULT_VAL;
			- let max = data[f].max || DEFAULT_MAX;
			form(style=`--min: 0; --val: var(--${f}); --max: ${max}`)
				input(id=f 
							type='range' 
							step=data[f].step 
							value=val
							max=max 
							data-unit=data[f].unit)
				label(for=f) #{f}
				button(data-var=f data-val=val disabled) Reset
		- })
		p
			strong Why #{has_o ? 'is' : 'are'} there no 
				code drop-shadow
				| #{has_o ? '' : ' and '}
				if !has_o
					code opacity
				|  filter#{has_o ? '' : 's'}?
			em Because #{has_o ? 'it is' : 'they are'} 
				a(href='https://twitter.com/anatudor/status/1270001307584270336' target='_blank') a mess
				| !
		p
			strong TODO:
			em Make it responsive, for fuck's sake! Allow changing the function order by dragging the panels above.
              
            
!

CSS

              
                $pad: .5em;
$rnd: 3px;

$lght: #e3e3e3;
$dark: #262626;

$lghter: #f7f7f7;
$darker: #0e0e0e;

$track-w: 14.5em;
$track-h: 2*$rnd;
$track-r: .5*$track-h;

$thumb-d: 1em;
$thumb-r: .5*$thumb-d;

$c: hotpink;
$t: .3s;

@mixin track() {
	border: none;
	width: 100%; height: $track-h;
	border-radius: $track-r;
	background: $lght
}

@mixin thumb($f: 0) {
	margin-top: calc(#{$f}*(#{$track-r} - #{$thumb-r}));
	border: none;
	width: $thumb-d; height: $thumb-d;
	border-radius: 50%;
	background: $c
}

* {
	--light: 0;
	--not-light: calc(1 - var(--light));
	--activ: 0;
	--not-activ: calc(1 - var(--activ));
	margin: 0;
	border: none;
	padding: 0;
	background: transparent;
	color: inherit;
	font: inherit
}

:focus { outline: solid 0 transparent }

body {
	--wide: 1;
	--c: #{$c};
	display: grid;
	grid-template-columns: 1fr repeat(var(--wide), $track-w + 4*$pad);
	height: 100vh;
	font: 1.25em/ 1.375 montserrat, trebuchet ms, sans-serif;
	
	@media (max-width: 665px) { font-size: 1em }
	
	@media (max-width: 540px) { --wide: 0 }
	
	@media (max-width: 280px) { font-size: .875em }
	
	@media (max-width: 250px) { font-size: .75em }
}

section {
	display: grid;
	padding: 2rem 0;
	background: url(https://images.unsplash.com/photo-1608830597604-619220679440?w=900) 50%/ cover
}

article {
	align-self: center;
	place-self: center;
	padding: $pad;
	padding: Min(9vmin, 9%);
	background: rgba($lghter, .25);
	font: 700 1.5em/ 1.25 parisienne, segoe script, comic sans ms, purisa, cursive;
	backdrop-filter: var(--val)
}

h3 {
	padding-bottom: $pad;
	font-size: 1.5em;
	font-weight: 900;
	text-align: center
}

aside {
	display: grid;
	grid-gap: $pad;
	grid-template-rows: repeat(var(--n), max-content);
	padding: $pad;
	background: $dark;
	color: $lght;
}

form {
	display: grid;
	grid-gap: $pad 2*$pad;
	grid-template-columns: 1fr max-content;
	justify-self: center;
	padding: $pad;
	border-radius: $rnd;
	box-shadow: 2px 2px 5px $darker;
	color: var(--c);
	
	> * { filter: grayScale(var(--not-light)) }
}

label, code {
	font: inherit 1em/ 1.375 ubuntu mono, consolas, monaco, monospace;
	
	&::after { content: '()' }
}

input {
	&, &::-webkit-slider-thumb, 
	&::-webkit-slider-runnable-track {
		-webkit-appearance: none
	}
	
	grid-row: 2;
	grid-column: 1/ -1;
	width: $track-w; height: $pad + $thumb-d;
	cursor: pointer;
	
	&::-webkit-slider-runnable-track {
		@include track()
	}
	
	&::-moz-range-track {
		@include track()
	}
	
	&::-webkit-slider-thumb {
		@include thumb(1)
	}
	
	&::-moz-range-thumb {
		@include thumb()
	}
	
	&::-ms-track {
		@include track();
		color: transparent
	}
	
	&::-ms-fill-lower { display: none }
	
	&::-ms-thumb {
		@include thumb()
	}
	
	&:hover, &:focus { &, & + label { --light: 1 } }
	&:active { --activ: 1 }
}

button {
	--p: var(--enabled, 0);
	--not-p: calc(1 - var(--p));
	align-self: center;
	position: relative;
	border: solid $rnd transparent;
	padding: 0 $pad;
	border-radius: 2*$rnd - 1px;
	box-shadow: 0 0 0 1px currentcolor;
	opacity: calc(1 - .8*var(--not-p));
	font-size: .8em;
	line-height: 1.25;
	cursor: pointer;
	pointer-events: var(--enabled, none);
	
	&::before {
		position: absolute;
		top: 0; right: 0; bottom: 0; left: 0;
		border-radius: $rnd;
		transform-origin: 0;
		transform: scalex(var(--activ));
		background: currentcolor;
		mix-blend-mode: difference;
		transition: transform .5*$t ease-out;
		content: ''
	}
	
	&:not([disabled]) { --enabled: 1 }
	
	&:hover, &:focus { --light: var(--p) }
	&:active { --activ: var(--p) }
}

strong, em { display: block }
strong { font-weight: 700 }
em { font-style: italic }

a { color: var(--c) }
              
            
!

JS

              
                function update(_el, _btn) {
	let def = _btn;
	_btn = _btn || _el.parentNode.querySelector('button');
	let val = +_btn.dataset.val;
	
	if(def) _el.value = val;
	_btn.disabled = +_el.value === +val;
	document.body.style.setProperty(
		`--${_el.id}`, 
		`${_el.value}${_el.dataset.unit || ''}`)
};

/* update filter on dragging slider handle */
addEventListener('input', e => { update(e.target) });

/* reset filter to initial value */
addEventListener('click', e => {
	e.preventDefault();
	let _tg = e.target, id = _tg.dataset.var;
	if(id) update(document.getElementById(id), _tg)
});
              
            
!
999px

Console