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.

            
               
<div class="colours">
  <div class="colour theme_one" role="button"> </div>
  <div class="colour theme_two" role="button"></div>
  <div class="colour theme_three" role="button"></div>
  <div class="colour theme_four" role="button"> </div>
  <div class="colour theme_five" role="button"></div>
  <div class="colour theme_six" role="button"></div>
</div>

div.stacks
  div.stack.theme_one
    div.lighten Text colour
    div.theme Text colour
    div.darken Text colour
  div.stack.theme_two
    div.lighten Text colour
    div.theme Text colour
    div.darken Text colour
  div.stack.theme_three
    div.lighten Text colour
    div.theme Text colour
    div.darken Text colour
  div.stack.theme_four
    div.lighten Text colour
    div.theme Text colour
    div.darken Text colour*
  div.stack.theme_five
    div.lighten Text colour
    div.theme Text colour
    div.darken Text colour
  div.stack.theme_six
    div.lighten Text colour
    div.theme Text colour
    div.darken Text colour
            
          
!
            
              //OK let's make our functions.First one is by Hugo Giraudel and gets us maps in maps in...

/// Map deep get
/// @author Hugo Giraudel
/// @access public
/// @param {Map} $map - Map
/// @param {Arglist} $keys - Key chain
/// @return {*} - Desired value
@function deep-get($map, $keys...) {
    @each $key in $keys {
        $map: map-get($map, $key);
    }
    @return $map;
}

// Now let's make one to flip the text colour
@function theme-text($color) {
  @if (lightness($color) > 55) {
    @return #222; // Lighter bg, return dark color
  } @else {
    @return #fff; // Darker bg, return light color
  }
}

//Now some mixins, first one is the themer I showed you already
@mixin themer($colour, $key) {
  --#{$key}: #{$colour};
  --#{$key}-event-up: #{lighten($colour, 20%)};
  --#{$key}-event-down: #{mix(#000, $colour, 5%)};
  --#{$key}-text: #{theme-text($colour)};
}

// Next one is gonna read from nested maps and pull out ALL those colours as variables so you can use them in DevTools on the palette view. Heavily cribbed from Sarah Dyan https://gist.github.com/sarahdayan/4d2cc04a636e8039f10a889a0e29fbd9
@mixin paletize($map, $join: '-', $base: 'colors') {
  @each $key, $value in $map {
    
      @if type-of($value) == 'map' {
        @include paletize($value, $base: '--#{$key}');
        
      }
      @else {
        #{$base}#{$key}: #{map-get($map, $key)};
 
      }
  }
}

// pull colors from JSON
$colors: (white: (_500: #fff), black: (_500: #000), grey: (_100: #f8f8f8, _200: #f1f1f1, _300: #ebebeb, _400: #d7d7d7, _500: #999999, _600: #888888, _700: #676767, _800: #4a4a4a, _900: #222222), positive: (_500: #03C29E, _600: #04AA8A), negative: (_500: #F55050, _600: #DD3939), brand: (_100: #FBD1EC, _200: #ED95CF, _500: #D00489, _600: #B60378), themes: (_one: #d00489, _two: #ffb834, _three: #f3923e, _four: #cf5747, _five: #9b3c62, _six: #dc5e7b));

// -----------------------
// NOW LET'S GENERATE SOME CSS
// -----------------------

//1. grab all the colours and names and sling them on root. We're not themeing these colours just yet,
:root { @include paletize($colors, $join: '-'); }

//2. now themes, set root to brand as backstop theme
:root {
   $brand: #d00489; // Not using your color function as its 
  @include themer($brand, 'brand');
}
//2. make any number of themes and assign to classes

 @each $key, $value in deep-get($colors, "themes") {
  .theme#{$key} {
    @include themer($value, "theme");
  }
}
// todo -- make theme from palette













//-----------------------ignore this, rest just functional display stuff
  body {background:#222; max-width:600px; margin:5vh auto}
// start
.colours {
  display: flex;
}
.colour {
  width: 100px;
  height: 100px;
  border-radius: 100%;
  background: var(--theme); 
  &:hover {background: var(--theme-event-up);}
  &:active, &:focus {background: var(--theme-event-down);}
  
}
.stacks {display:flex;}
.stack {
  flex-basis: calc(100% / 6);
display: flex;
  flex-flow: column;
  div {
    height: 2em;
    padding:.5em;
    background: var(--theme);
    color: var(--theme-text);
    &:hover {
      background: var(--theme-event-up);
    }
    &.lighten {background: var(--theme-event-up);}
    &.darken {background: var(--theme-event-down);}
  }
}


            
          
!
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