cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-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.

            
              header.demo-header
  h1 Cross-stich
  p
    | Little bits of 8-bit  
    | goodness generated  
    br
    | from a clutch of sass lists.
ul.icons
  each icon in ['hamburger','close','diamond','plus','heart','doublearr']
    li(class='icons--#{icon}')
            
          
!
            
              /**
 * Cross stitch: 
 * Pixel art out of box shadow magicerizer
 *
 * A small bit 'o' sass that
 * converts grouped lists into
 * box-shadow icons / pixel art.
 *
 * By @shadowmint and @jackarmley
 */

// -
// Build cross stitcher
// -

// Define function
// to build icon
@function makestitch($matrix,$size,$color){
    $l: length($matrix);
    $sh: '';
    $i: $l;
    @for $i from 1 through $l{
      $row: nth($matrix,$i);
      @for $j from 1 through length($row){
          $item: nth($row,$j);
          @if $item == x{
            $sh:  $sh + ($j*$size) + ' ' + ($i*$size) + ' ' + $color;
          }@else{
            $sh:  $sh + ($j*$size) + ' ' + ($i*$size) + ' ' + transparent;
          }
        @if not ($j == length($row) and $i == $l) {
          $sh: $sh + ',';
        }
      }
    }
    @return unquote($sh);
}

// Define mixin to set
// the icon's size and style
@mixin stitchicon($matrix,$size,$color,$radius:0){
  position:relative;
  width:($size * length(nth($matrix,1)));
  height:($size * length($matrix));
  &:after{
    content:' ';
    position:absolute;
    top:(-$size);
    left:(-$size);
    width:$size;
    height:$size;
    border-radius:$radius;
    box-shadow:makestitch($matrix,$size,$color);
  }
}

// -
// Set demo styles
// -

// Define icons:
// I'm making a map here, but the
// list for each icon could be put straight
// into the mixin
$icons:(
  hamburger:(
    (x x x x x)
    (o o o o o)
    (x x x x x)
    (o o o o o)
    (x x x x x)
  ),
  close:(
    (x o o o x)
    (o x o x o)
    (o o x o o)
    (o x o x o)
    (x o o o x)
  ),
  diamond:(
    (o o x o o)
    (o x o x o)
    (x o o o x)
    (o x o x o)
    (o o x o o)
  ),
  plus:(
    (o o x o o)
    (o o x o o)
    (x x x x x)
    (o o x o o)
    (o o x o o)
  ),
  heart:(
    (o x o x o)
    (x x x x x)
    (x x x x x)
    (o x x x o)
    (o o x o o)
  ),
  doublearr:(
    (o o x o o)
    (o x o x o)
    (x o x o x)
    (o x o x o)
    (x o o o x)
  )
);

// Set some vars
// to make things DRYer
$keycolor:#e62961;
$demoprop:(
    bodybg: #DFFF26,
    iconcolor: $keycolor,
    textcolor: $keycolor,
    iconsize: 8px,
    headerfont:'Yanone Kaffeesatz',
    bodyfont:'PT Sans'
);
// Make a getter
// to alias map-get
@function prop($value,$map:$demoprop){
    $value: map-get($map,$value);
    @return $value;
}

// Make everything pretty
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:700|PT+Sans);

html,
body{
  height:100%;
}
html{
  background:prop(bodybg);
}
body{
  box-sizing:border-box;
  width:100%;
  max-width:600px;
  margin:auto;
  padding:60px;
  color:prop(textcolor);
  font:normal normal 120%/1.5em prop(bodyfont), sans-serif;
}
.demo-header{
  margin-bottom:2em;
  text-align:center;
  h1{
    margin:0;
    color:#fff;
    font:700 3em/1.5em prop(headerfont);
    text-transform:uppercase;
    text-shadow:3px 3px 0 prop(iconcolor);
  }
}
.icons{
   margin:0;
    padding:0;
   list-style:none;
   text-align:center;
   @at-root{
     [class^="icons--"]{
       display:inline-block;
       margin:20px;
       border:25px solid transparent;
     }
   }
   @each $key,$value in $icons{
    &--#{$key}{
      @include stitchicon(
        $value,
        prop(iconsize),
        prop(iconcolor)
      );
    }
  }
}
            
          
!
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