cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              - var schemes = ['primary', 'secondary', 'action', 'mono', 'info', 'success', 'warning', 'alert'];
- var tones = ['lightest', 'lighter', 'light', 'dark', 'darker', 'darkest'];

each scheme in schemes
  .swatch(class="_#{scheme}")
    .swatch__base
    .swatch__all-tones
      each tone in tones
        .swatch__tone(class='_tone-#{tone}')
            
          
!
            
              @import 'bourbon';

// The base colors to generate all the different tones
// Fun fact: these colors are from the 1st generation pokemon starters (Pikachu included). 
$g-primary-color: #f6bd20;
$g-secondary-color: #9c5200;
$g-action-color: #c52018;
$g-mono-color: #737383;
$g-info-color: #8bc5cd;
$g-success-color: #73ac31;
$g-warning-color: #ff9441;
$g-alert-color: #e63900;


$g-shade-1: 20%;
$g-shade-2: 40%;
$g-shade-3: 60%;


// Map for storing all color variables
// Different tones can be generated or set manually here
$color-map: (
  primary: (
    lightest: tint($g-primary-color, $g-shade-3),
    lighter: tint($g-primary-color, $g-shade-2),
    light: tint($g-primary-color, $g-shade-1),
    base: $g-primary-color,
    dark: shade($g-primary-color, $g-shade-1),
    darker: shade($g-primary-color, $g-shade-2),
    darkest: shade($g-primary-color, $g-shade-3)
  ),

  secondary: (
    lightest: tint($g-secondary-color, $g-shade-3),
    lighter: tint($g-secondary-color, $g-shade-2),
    light: tint($g-secondary-color, $g-shade-1),
    base: $g-secondary-color,
    dark: shade($g-secondary-color, $g-shade-1),
    darker: shade($g-secondary-color, $g-shade-2),
    darkest: shade($g-secondary-color, $g-shade-3)
  ),

  action: (
    lightest: tint($g-action-color, $g-shade-3),
    lighter: tint($g-action-color, $g-shade-2),
    light: tint($g-action-color, $g-shade-1),
    base: $g-action-color,
    dark: shade($g-action-color, $g-shade-1),
    darker: shade($g-action-color, $g-shade-2),
    darkest: shade($g-action-color, $g-shade-3)
  ),

  mono: (
    lightest: #fffefc,
    lighter: tint($g-mono-color, $g-shade-2),
    light: tint($g-mono-color, $g-shade-1),
    base: $g-mono-color,
    dark: shade($g-mono-color, $g-shade-1),
    darker: shade($g-mono-color, $g-shade-2),
    darkest: shade($g-mono-color, $g-shade-3)
  ),

  info: (
    lightest: tint($g-info-color, $g-shade-3),
    lighter: tint($g-info-color, $g-shade-2),
    light: tint($g-info-color, $g-shade-1),
    base: $g-info-color,
    dark: shade($g-info-color, $g-shade-1),
    darker: shade($g-info-color, $g-shade-2),
    darkest: shade($g-info-color, $g-shade-3)
  ),

  success: (
    lightest: tint($g-success-color, $g-shade-3),
    lighter: tint($g-success-color, $g-shade-2),
    light: tint($g-success-color, $g-shade-1),
    base: $g-success-color,
    dark: shade($g-success-color, $g-shade-1),
    darker: shade($g-success-color, $g-shade-2),
    darkest: shade($g-success-color, $g-shade-3)
  ),

  warning: (
    lightest: tint($g-warning-color, $g-shade-3),
    lighter: tint($g-warning-color, $g-shade-2),
    light: tint($g-warning-color, $g-shade-1),
    base: $g-warning-color,
    dark: shade($g-warning-color, $g-shade-1),
    darker: shade($g-warning-color, $g-shade-2),
    darkest: shade($g-warning-color, $g-shade-3)
  ),

  alert: (
    lightest: tint($g-alert-color, $g-shade-3),
    lighter: tint($g-alert-color, $g-shade-2),
    light: tint($g-alert-color, $g-shade-1),
    base: $g-alert-color,
    dark: shade($g-alert-color, $g-shade-1),
    darker: shade($g-alert-color, $g-shade-2),
    darkest: shade($g-alert-color, $g-shade-3)
  )
);






// This is the function to pull colors out. It's here instead of on the functions sheet so the below color values can be set.
@function color($color, $tone: 'base') {
  @if map-has-key($color-map, $color) {
    @return map-get(map-get($color-map, $color), $tone);
  }
}

// Mixin to use with the breakpoint map, sets any styles to be used above a certain screen width
@mixin larger-than($width) {
  @media (min-width: $width) {
    @content;
  }
}

// For making contrasting font colors with backgrounds
@mixin contra-color($color, $light: #FFF, $dark: #000) {
   background-color: $color;
   
   @if (lightness($color) > 50) {
      color: $dark;
   } @else {
      color: $light;
   }
};





// The variables for styling the color swatches themselves

$modular-scale-ratio: $minor-third;
$modular-scale-base: 1rem;

$swatch-bp-small: em(480px);
$swatch-bp-medium: em(787px);

$swatches-per-row: 3;
$swatches-tones-per-row: 3;

$swatch-base-height: 130px;
$swatch-tone-height: 70px;

$swatch-hex-position: null null 0.5em 0.5em;
$swatch-shade-position: 0.5em null null 0.5em;

$swatch-light-text: color(mono, lightest);
$swatch-dark-text: color(mono, darkest);

$swatch-base__shade-font-size: modular-scale(3);
$swatch-base__hex-font-size: modular-scale(1);

$swatch-tone__shade-font-size: modular-scale(0);
$swatch-tone__hex-font-size: modular-scale(-1);


// Mixin for generating the common swatch colors
@mixin swatch__color-scheme-generator($u-color, $shade, $base: false) {
  @include contra-color($u-color, $swatch-light-text, $swatch-dark-text);
  position: relative;

  @if ($base == true) {
    font-size: $swatch-base__shade-font-size;
	 text-transform: uppercase;

    &::after { font-size: $swatch-base__hex-font-size; }
  } @else {
    font-size: $swatch-tone__shade-font-size;
	 text-transform: capitalize;

    &::after { font-size: $swatch-tone__hex-font-size; }
  }

  &::before {
    @include position(absolute, $swatch-shade-position);
    content: quote(inspect($shade));
  }

  &::after {
    @include position(absolute, $swatch-hex-position);
    content: quote(inspect($u-color));

    text-transform: uppercase;
  }
}

.swatch {
	@include clearfix();
	margin-bottom: 0.5em;
	display: block;
	
	font-family: 'Open Sans', 'Helvetica', sans-serif;
	
	@include larger-than($swatch-bp-small) {
		@include padding(null 0.5em);
		width: 50%;
		float: left;
		display: inline-block;
		box-sizing: border-box;
	}
	
	@include larger-than($swatch-bp-medium) {
		width: (100% / $swatches-per-row);
	}
}

// The base color for every scheme
.swatch__base {
  @include size(100% $swatch-base-height);
}

// Container for both light and dark tones
.swatch__all-tones {
  @include size(100% $swatch-tone-height);
  @include clearfix();
}

// Every light and dark tone of the base color
.swatch__tone {
  @include size(100%);
  display: inline-block;
  margin: 0;
  float: left;

  @include larger-than($swatch-bp-small) {
    width: percentage(1/$swatches-tones-per-row);
  }
}

// Loops through the sass map to generate the specific color scheme colors

@each $palette, $tones in $color-map {
	$base-color: map-get($tones, base);
	
	.swatch._#{$palette} {
		.swatch__base { @include swatch__color-scheme-generator($base-color, $palette, $base: true); }
		
		@each $tone-name, $tone-value in $tones {
			._tone-#{$tone-name} { @include swatch__color-scheme-generator($tone-value, $tone-name); }
		}
	}
}


            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console