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. 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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div id="gemstones" data-state="sapphire"></div>
<div id="stone">
  <div class="cut">
    <div class="cut">
      <div class="cut">
        <div class="cut"></div>
      </div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=PT+Serif');
@import 'compass';

$gemstones:
  'garnet',
  'amethyst',
  'aquamarine',
  'diamond',
  'emerald',
  'alexandrite',
  'ruby',
  'peridot',
  'sapphire',
  'tourmaline',
  'topaz',
  'turquoise';

@each $gemstone in $gemstones {
  [data-state="#{$gemstone}"] .gemstone:not(##{$gemstone}) {
    display: none;
  }
}

$tan22p5: tan(22.5deg);
$cut: 5vmin;

@debug $tan22p5;

#stone {
  margin-top: 5vh;
  height: 2 * $cut / $tan22p5;
  width: 2 * $cut / $tan22p5;
  $r: 360deg / 8;
  
  .cut {
    transform: rotate(#{$r});
  }
  
  > .cut {
    transition-delay: 70ms;
    > .cut {
      transition-delay: 140ms;
      > .cut {
        transition-delay: 210ms;
        > .cut {
          transition-delay: 280ms;
        }
      }
    }
  }
}

.cut {
  width: 2 * $cut;
  height: 100%;
  left: calc(50% - #{$cut});
  background-color: var(--color);
  mix-blend-mode: screen; // I fucking love this property
  
  &, &:before, &:after {
    transition: all .6s cubic-bezier(.5, 0, .5, 1);
  }
  
  &:before, &:after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 100%;
  }
  
  &:before {
    box-shadow: 0 0 $cut * 2 var(--color);
    z-index: -1;
    opacity: 0.2;
  }
  
  &:after {
    border: 2px solid rgba(white, 0.5);
    mix-blend-mode: soft-light;
  }
}

span {
  display: inline-block;
  // will-change: transform;
}

.month {
  font-size: 3vmin;
  letter-spacing: 1vmin;
  text-transform: uppercase;
  opacity: 0.5;
}

.gem {
  font-size: 10vmin;
  font-family: PT Serif, serif;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background-color: #191919;
  color: white;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

*, *:before, *:after {
  box-sizing: border-box;
  position: relative;
}
              
            
!

JS

              
                const gemstones = {
  garnet: 'january',
  amethyst: 'february',
  aquamarine: 'march',
  diamond: 'april',
  emerald: 'may',
  alexandrite: 'june',
  ruby: 'july',
  peridot: 'august',
  sapphire: 'september',
  tourmaline: 'october',
  topaz: 'november',
  turquoise: 'december'
};
const colors = {
  garnet: '#8B0206',
  amethyst: '#694F91',
  aquamarine: '#7FC7F3',
  diamond: '#F1F9FF',
  emerald: '#04A24F',
  alexandrite: '#5D9094',
  ruby: '#F70004',
  peridot: '#B1E347',
  sapphire: '#2345B9',
  tourmaline: '#FC5191',
  topaz: '#F98603',
  turquoise: '#4DF5FF'
}

const gemstonesElm = document.getElementById('gemstones');
const stoneElm = document.getElementById('stone');

const letter = prefix => char => `<span data-flip-key="${prefix}-${char}">${char}</span>`;

function mapLetters(word, prefix) {
  const seen = {};

  return [...word].map(char => {
    let suffix = '';
    if (seen[char] !== undefined) {
      ++seen[char];
      return `<span data-flip-key="${prefix}-${char}-${seen[char]}">${char}</span>`;
    } else {
      seen[char] = 0;
      return `<span data-flip-key="${prefix}-${char}">${char}</span>`;
    }
  });
}

const gemstonesHTML = Object.keys(gemstones)
  .map(gemstone => {
    const month = gemstones[gemstone];

    return `
  <div class="gemstone" id="${gemstone}">
    <div class="month">
      ${mapLetters(month, 'month').join('')}
    </div>
    <div class="gem">
      ${mapLetters(gemstone, 'gem').join('')}
    </div>
  </div>
`
  })
  .join('\n');

gemstonesElm.innerHTML = gemstonesHTML;

// state machine
function cycle(states, action) {
  const statesMap = {};

  states.forEach((state, i) => {
    statesMap[state] = {
      [action]: states[i + 1] || states[0]
    };
  });

  return statesMap;
}

function transition(state, action) {
  return machine[state][action];
}

const machine = cycle(Object.keys(gemstones), 'CLICK');
let currentState = 'sapphire';

function update(state) {
  stoneElm.style
    .setProperty('--color', colors[state]);
  gemstonesElm.setAttribute('data-state', state);
}

// FLIPPING!
const flipping = new Flipping({
  parentElement: gemstonesElm,
  duration: 600
});

document.body.addEventListener('click', flipping.wrap(() => {
  currentState = transition(currentState, 'CLICK');
  update(currentState);
}));

update(currentState);
              
            
!
999px

Console