123

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <h1>Palette</h1>
<p>Change the first value hue of the variable $first-color. This will generate complementary, analogous, darker and lighter color in a harmonious way. <br>This code is based on <em>Practical Color Theory for People Who Code</em>, <a href="https://medium.com/learning-lab/how-i-learnt-about-color-theories-and-made-my-best-color-palettes-in-one-month-a461604ca669" target="_blank">read more</a>.</p>

<div class="palette">
  <div class="color color-1">
  </div>
  <div class="color color-2">
  </div>  
  <div class="color color-3">
  </div>
  <div class="color color-4">
  </div>  
  <div class="color color-5">
  </div>
  <div class="color color-6">
  </div>
  <div class="color color-7">
  </div>
  <div class="color color-8">
  </div>  
  <div class="color color-9">
  </div>
  <div class="color color-10">
  </div>  
  <div class="color color-11">
  </div>
  <div class="color color-12">
  </div>
  <div class="color color-13">
  </div>
  <div class="color color-14">
  </div>  
  <div class="color color-15">
  </div>
  <div class="color color-16">
  </div>
  <div class="color color-17">
  </div>
  <div class="color color-18">
  </div>  
  <div class="color color-19">
  </div>
</div>
            
          
!
            
              //Pick a color
$first-color: hsl(195, 100%, 50%);

// Find the complement
$second-color: complement($first-color);

//Check if you have a cool color on your hands. Cool colors will overpower warm colors when mixing.

@function is-cool-color($color) {
	@return hue($color) < 310 and hue($color) > 140;
}

@function is-high-key-value($color) {
	@return hue($color) > 20 and hue($color) < 190;
}

@function is-highest-key-value($color) {
	@return hue($color) > 30 and hue($color) <90;
}

//Establish a relationship (similar lighting conditions) between colors.

@function harmonious-mix($mix, $base) {
	@if (is-cool-color($mix)){
		@if is-high-key-value($base) {
			@return mix($mix, $base, 11%);
		}
		@else {
			@return mix($mix, $base, 16%);
		}
	}
	@else {
		@if is-high-key-value($base) {
			@return mix($mix, $base, 13%);
		}
		@else {
			@return mix($mix, $base, 23%);
		}
	}
}

@function mix-neutral($color) {
	@if (is-highest-key-value($color)) {
		@if is-high-key-value(complement($color)) {
			@return mix(complement($color), $color, 19%);
		}
		@else {
			@return mix(complement($color), $color, 13%);
		}
	}
	@else if (is-high-key-value($color)) {
		@if is-high-key-value(complement($color)) {
			@return mix(complement($color), $color, 31%);
		}
		@else {
			@return mix(complement($color), $color, 23%);
		}
	}
	@else {
		@if is-highest-key-value(complement($color)) {
			@return mix(complement($color), $color, 31%);
		}
		@if is-high-key-value(complement($color)) {
			@return mix(complement($color), $color, 26%);
		}
		@else {
			@return mix(complement($color), $color, 23%);
		}
	}
}

@function pick-contrast-of($color) {
	@if is-high-key-value($color){
		@if lightness($color) < 30% {
			@return lighten(complement($color), 86);
		}
		@else if lightness($color) > 70% {
			@return darken(complement($color), 68);
		}
		@else {
			@return darken(complement($color), 53);
		}
} @else {
	@if lightness($color) < 30% {
			@return lighten(complement($color), 86);
		}
		@else if lightness($color) > 70% {
			@return darken(complement($color), 68);
		}
		@else {
			@return lighten(complement($color), 53);
		}
	}
}

$primary-color: harmonious-mix($second-color, $first-color);
$complementary-color: harmonious-mix($first-color, $second-color);

$analogous-color: adjust-hue($complementary-color, -40);
$complementary-analogous: mix($analogous-color, $complementary-color, 66);

// Complementary Neutrals, highlight, midtone, shadow

$complementary-neutral: mix-neutral($complementary-color);
$complementary-neutral-light: lighten($complementary-neutral, 33);
$complementary-neutral-dark: darken($complementary-neutral, 33);

// Primary neutrals, highlight, midtone, shadow`

$primary-neutral: mix-neutral($primary-color);
$primary-neutral-light: lighten($primary-neutral, 33);
$primary-neutral-dark: darken($primary-neutral, 33);

// Primary tint and shade

$primary-light: mix($primary-neutral-light, $primary-color, 45%);
$primary-dark: mix($primary-neutral-dark, $primary-color, 45%);

$complementary-light: mix($complementary-neutral-light, $complementary-color, 45%);

// Pure neutrals, highlight, midtone, shadow

$white: lighten($primary-neutral-light, 15);
$neutral-gray: grayscale($primary-neutral);
$primary-gray: mix($primary-color, $complementary-color, 30);
$complementary-gray: mix($complementary-color, $primary-color, 63);
$black: grayscale($complementary-neutral-dark);

// Analogous Colors

$analogous-color: adjust-hue($complementary-color, -40);
$complementary-analogous: mix($analogous-color, $complementary-color, 66);


// CSS classes

.palette {
  width: 100%;
  display: inline-block;
}

.color {
  height: 50px;
  width: 50px;
  float: left;
}

.color-1 {
  background-color: $primary-color;
}

.color-2 {
  background-color: $complementary-color;
}

.color-3 {
  background-color: $analogous-color;
}

.color-4 {
  background-color: $complementary-analogous;
}

.color-4 {
  background-color: $complementary-neutral;
}

.color-5 {
  background-color: $complementary-neutral-light;
}

.color-6 {
  background-color: $complementary-neutral-dark;
}

.color-7 {
  background-color: $primary-neutral;
}

.color-8 {
  background-color: $primary-neutral-light;
}

.color-9 {
  background-color: $primary-neutral-dark;
}

.color-10 {
  background-color: $primary-light;
}

.color-11 {
  background-color: $primary-dark;
}

.color-12 {
  background-color: $complementary-light;
}

.color-13 {
  background-color: $white;
}

.color-14 {
  background-color: $neutral-gray;
}

.color-15 {
  background-color: $primary-gray;
}

.color-16 {
  background-color: $complementary-gray;
}

.color-17 {
  background-color: $black;
}

.color-18 {
  background-color: $analogous-color;
}

.color-19 {
  background-color: $complementary-analogous;
}

// Main
body {
  padding: 15px;
  background-color: #333;
  color: #fff;
}

a {
  color: #e9a138;
}

h1 {
  
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console