Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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

              
                //- BUILDING BLOX -----------------------

mixin box(className, attr)
  .box(class=className data-name=className)&attributes(attributes)= attr
    - const faces = ['front','back','left','right','top','bottom']
    each face in faces
      div(class='face face__' + face)

mixin scene(className)
  .scene(class=className data-name=className)
    block 
    
//- ICONS ----------------------------
    
mixin svg(icon)
  case icon
    when 'play'
      svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" title="play")
        path(fill="currentColor" d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z")
    when 'backwards'
      svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" title="backward")
        path(fill="currentColor" d="M11.5 280.6l192 160c20.6 17.2 52.5 2.8 52.5-24.6V96c0-27.4-31.9-41.8-52.5-24.6l-192 160c-15.3 12.8-15.3 36.4 0 49.2zm256 0l192 160c20.6 17.2 52.5 2.8 52.5-24.6V96c0-27.4-31.9-41.8-52.5-24.6l-192 160c-15.3 12.8-15.3 36.4 0 49.2z")
    when 'forwards'
      svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="100" title="forward")
        path(fill="currentColor" d="M500.5 231.4l-192-160C287.9 54.3 256 68.6 256 96v320c0 27.4 31.9 41.8 52.5 24.6l192-160c15.3-12.8 15.3-36.4 0-49.2zm-256 0l-192-160C31.9 54.3 0 68.6 0 96v320c0 27.4 31.9 41.8 52.5 24.6l192-160c15.3-12.8 15.3-36.4 0-49.2z")
    when 'pause'
      svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="100" title="pause")
        path(fill="currentColor" d="M144 479H48c-26.5 0-48-21.5-48-48V79c0-26.5 21.5-48 48-48h96c26.5 0 48 21.5 48 48v352c0 26.5-21.5 48-48 48zm304-48V79c0-26.5-21.5-48-48-48h-96c-26.5 0-48 21.5-48 48v352c0 26.5 21.5 48 48 48h96c26.5 0 48-21.5 48-48z")

//- MAIN SCENE ----------------------------

mixin mainScene()
  //.floor.box
    .face__top
  .stripes.box
    .face__back
    .face__bottom
  .tapes
    +box("tape")
  .radio
    +scene("handle")
      +box("handle__left")
      +box("handle__grip")
      +box("handle__right")
    .case
      +box("case__back")
      +box("case__front--left")
      +box("case__front--right")
      +box("case__front--c-back")
      +box("case__front--c-top")
      +box("case__front--c-bottom")
    .speaker
      +box('speaker__left')
      +box('speaker__right')
    +scene('tapedeck')
      +box('tape')
      +box('tapedeck__cover')
    +scene('buttons')
      +box('btn btn-play')
      +box('btn btn-backwards')
      +box('btn btn-forwards')
      +box('btn btn-pause')
      +box('btn btn-record')

//- PAGE ----------------------------

.page 
  .page-wrap
    nav
      button.btn-play(data-state="play")
        +svg('play')
      button.btn-backwards(data-state="backwards")
        +svg('backwards')
      button.btn-forwards(data-state="forwards")
        +svg('forwards')
      button.btn-pause(data-state="pause")
        +svg('pause')
      button.btn-record(data-state="record")
        | rec •

    main
      header
        h1 GLAZE OF <br>NOSTALGY
        p Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.

      section.stage-wrapper
        .stage
          .scene
            +mainScene()

  footer 
    a(href="https://dribbble.com/shots/15821710-Retro-Music-and-Podcasts-Online") dribbble
    a(href="https://codepen.io/toabr/full/oNeGKOr") codepen
    a(href="https://toabr.de") toabr.de
              
            
!

CSS

              
                
// Color Theme:
// https://dribbble.com/shots/15821710-Retro-Music-and-Podcasts-Online

:root
  --factor 5px
  
  --primary #403428
  --primary-light #524538
  --secondary #f1e1ca
  --bg #93c2d2
  --text #ebe0d4
  --accent-1 #f8c43f
  --accent-2 #f2a83a
  --accent-3 #f27d3b
  --accent-4 #f14a42

svg-play = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" title="play"><path fill="currentColor" d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z" /></svg>'

svg-backwards = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" title="backward"><path fill="currentColor" d="M11.5 280.6l192 160c20.6 17.2 52.5 2.8 52.5-24.6V96c0-27.4-31.9-41.8-52.5-24.6l-192 160c-15.3 12.8-15.3 36.4 0 49.2zm256 0l192 160c20.6 17.2 52.5 2.8 52.5-24.6V96c0-27.4-31.9-41.8-52.5-24.6l-192 160c-15.3 12.8-15.3 36.4 0 49.2z" /></svg>'

svg-forwards = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="100" title="forward"><path fill="currentColor" d="M500.5 231.4l-192-160C287.9 54.3 256 68.6 256 96v320c0 27.4 31.9 41.8 52.5 24.6l192-160c15.3-12.8 15.3-36.4 0-49.2zm-256 0l-192-160C31.9 54.3 0 68.6 0 96v320c0 27.4 31.9 41.8 52.5 24.6l192-160c15.3-12.8 15.3-36.4 0-49.2z" /></svg>'

svg-pause = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="100" title="pause"><path fill="currentColor" d="M144 479H48c-26.5 0-48-21.5-48-48V79c0-26.5 21.5-48 48-48h96c26.5 0 48 21.5 48 48v352c0 26.5-21.5 48-48 48zm304-48V79c0-26.5-21.5-48-48-48h-96c-26.5 0-48 21.5-48 48v352c0 26.5 21.5 48 48 48h96c26.5 0 48-21.5 48-48z" /></svg>'

BUTTONS = 'play', 'backwards', 'forwards', 'pause', 'record'

navButtons()
  for icon in BUTTONS
    .btn-{icon} .face__front
      background-image embedurl(svg- + icon)
  
*, *::after, *::before
  margin 0
  padding 0
  box-sizing border-box
  
html
  height 100%
  
body 
  min-height 100%
  background-color var(--bg)


// ===============================================
//   PAGE
// ===============================================

.page
  display flex
  flex-direction column
  justify-content center
  align-items center

.page-wrap
  max-width calc(var(--factor) * 100)
  padding 1rem
  margin 1.6rem 0.5rem 1rem
  background-color var(--secondary)

nav 
  padding 1rem 0 
  display flex
  justify-content center
  gap 0.5rem

  button
    width 3.5rem
    height 2rem
    color: var(--primary);
    background-color unset
    border-radius 0.5rem

    &:not(:last-child)
      border 1px solid var(--primary)

    svg
      height 100%
      width 1rem
      pointer-events none

    &:hover
      cursor pointer
      // background-color rgba(0,0,0,0.1)

  .btn-record
    color white
    background-color var(--accent-4)

main
  position relative
  overflow hidden
  color var(--text)
  border-radius 1.5rem
  background-color var(--primary)
  background-image linear-gradient(0deg, rgba(0,0,0,0.2) 30%, rgba(0,0,0,0) 31%)
  
  &::before
    content "FM"
    position absolute
    font-family 'Archivo Black', sans-serif
    font-size 21rem
    color var(--primary-light)
    width 100%
    top -1rem
    overflow hidden
    display flex
    justify-content center

header
  position relative
  z-index 1
  width 66%
  padding-left 1rem
  
  h1 
    margin-top 3rem
    font-family 'Archivo Black', sans-serif
    font-weight 400
    line-height 1
    
  p
    line-height 1.5
    &::before
      content ""
      width 5rem
      height 0.1rem
      background var(--text)
      position relative
      top -0.5rem
      display block
  
footer 
  display flex
  margin-bottom 1rem

  a
    color var(--primary)
    text-decoration none
    padding 0 0.5rem

  a:not(:first-child)
    border-left 0.1rem solid


// ===============================================
//   SCENE
// ===============================================


section.stage-wrapper
  height calc(var(--factor) * 15)
  margin-top calc(var(--factor) * 60)

.scene
  --width 65

.stripes 
  --width 18
  --height 200
  --depth 200
  --x calc(var(--width) / -2)
  --y -40
  --z calc(var(--height) / 2 - 0.1)
  --color-dark var(--stripes)
  
  left 50%
  
  .face__bottom  
    background-image linear-gradient( 90deg, var(--accent-1), var(--accent-1) 25%, var(--accent-2) 25%, var(--accent-2) 50%, var(--accent-3) 50%, var(--accent-3) 75%, var(--accent-4) 75% )
    
  .face__back  
    background-image linear-gradient( -90deg, var(--accent-1), var(--accent-1) 25%, var(--accent-2) 25%, var(--accent-2) 50%, var(--accent-3) 50%, var(--accent-3) 75%, var(--accent-4) 75% )

.tapes
  .tape:first-child
    --x 8
    --y 21
    --z calc(var(--depth)/2)
    --rotate-x 90
    --rotate-y 27
      
    &:hover
      transition transform 100ms linear
      --z 8
      --rotate-x 0
      --rotate-y 0
      --rotate-z calc(var(--global-z) * -1)
      
.handle 
  --width 65
  --height 28
  --z 29
  --rotate-x 35
  
  //left 0
  
  & > div 
   coloring(#333)
  
  &__grip 
    --width 65
    --height 1
    --depth 2
    --z 14.5
    
    top 50%
    --y -1
  
  &__right, &__left 
    --width 1
    --height 15
    --depth 2
    --z 7.5
    
    top 50%
    --y -1
  
  &__left 
    --x -1
  
  &__right 
    --x 65
  
.case
  .face
    border 1px solid rgba(255,255,255,0.3)
    
  &__back
    --width 65
    --height 35
    --depth 8
    --y -8.3
    --z calc(var(--height) / 2)
  &__front--left, &__front--right
    --width 21.5
    --height 35
    --depth 8
    --z calc(var(--height) / 2)
  &__front--right
    --x 43.5
  &__front--c-back
    --width 21.5
    --height 35
    --depth 4
    --x 21.8
    --z calc(var(--height) / 2)
  &__front--c-top
    --width 21.5
    --height 6
    --depth 4
    --x 21.8
    --y 4
    --z calc(var(--height) / 2 + 24)
  &__front--c-bottom
    --width 21.5
    --height 7.5
    --depth 4
    --x 21.8
    --y 4
    --z calc(var(--height) / 2)
      
.tapedeck.scene
  --width 21.5
  --depth 10
  --y 8
  --z 8
  
  &:hover
    --rotate-x -0
    
  .tape 
    --x 0
    --y 0
    --z 7
  
  .tapedeck__cover
    --width 21.5
    --height 16
    --depth 1
    --y -1
    --z calc(var(--height) / 2)
    top 50%
    
    coloring(rgba(0, 0, 0, 0.5))
    
    .face__front 
      border calc(var(--unit) * 3) solid black
    
.tape
  --width 20
  --height 12
  --depth 2.5
  
  coloring(#333)
  
  .face__front 
    display flex
    justify-content space-around
    align-items center
    background-color #E9EBDB
    border calc(var(--unit)*2.5) solid var(--color-light)
    border-left-width calc(var(--unit)*3)
    border-right-width calc(var(--unit)*3)
    
    &::before, &::after 
      content ""
      position relative
      border-radius 50%
      width calc(var(--unit)*2.5)
      height calc(var(--unit)*2.5)
      background-color #383832
    
.speaker
  
  &__left, &__right
    coloring(#111)
    --width 18
    --height 18
    --depth 2
    --x 2
    --y 7
    --z 20
    
  &__right
    --x 45
    
  .face
    background-size 1.25vmin
    background-image embedurl('data:image/svg+xml,<svg width="12" height="24" viewBox="0 0 12 24" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><g fill="%239C92AC" fill-opacity="0.4"><path d="M2 0h2v12H2V0zm1 20c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM9 8c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zm-1 4h2v12H8V12z"/></g></g></svg>')
    
.buttons.scene
  --width 0
  --depth 0
  left 0
  top 0
  
  --x 21.5
  --y 4.5
  --z 31.5

  navButtons()
  
  .btn
    coloring(#333)
    --width 4
    --height 4.5
    --depth 3
    
    for i in 1..5
      &:nth-child({ i + 1 })
        --x i * 4.5
        
    &:hover 
      --z -.5
      
    .face__front 
      background-repeat no-repeat
      background-size calc(var(--unit)*2)
      background-position 50% 35%
    
    &.btn-record
      coloring(#d92727)
  
      
// =====================================
//   animations
// =====================================

.stage
  transition transform 350ms linear

// button state
for state in BUTTONS
  [radio={state}] .btn-{state}
    --z -1 !important

[radio=pause] .tapedeck
  transition transform 585ms ease-out
  --rotate-x -30

[radio=play]
  .radio
    animation radio 200ms steps(3) 0s infinite alternate
  .handle
    transition transform 100ms linear
    animation handle 200ms steps(3) 300ms infinite alternate
  .speaker
    animation speaker 100ms steps(2) 0s infinite alternate
    
@keyframes radio 
  from 
    transform scaleZ(1)
  to 
    transform scaleZ(0.95)

@keyframes handle
  from 
    --rotate-x 37
  to
    --rotate-x 32

@keyframes speaker
  from 
    transform translateY(0)
  to
    transform translateY(calc(var(--unit)*0.5))

              
            
!

JS

              
                const win = window
const root = document.documentElement

const navi = document.querySelector('nav')
const navBtnList = navi.querySelectorAll('button')

navBtnList.forEach(btn => btn.onclick = clickHandler)

function clickHandler(e) {
  const state = e.target.dataset.state
  document.documentElement.setAttribute(`radio`, state || "")
}


/*
 * throttle events
 */
function throttle(fn, delay) {
  let allowSample = true;

  return function (e) {
    if (allowSample) {
      allowSample = false;
      setTimeout(() => { allowSample = true; }, delay);
      fn(e);
    }
  }
}

/*
 * mouse move
*/
window.onmousemove = throttle(mouseMoveHandler, 100)
function mouseMoveHandler(e) {
  const clientX = Math.round(e.clientX / (root.clientWidth / 100))/100
  const clientY = Math.round(e.clientY / (root.clientHeight / 100))/100
  root.style.setProperty("--client-x", clientX)
  root.style.setProperty("--client-y", clientY)
}

/*
 * Purely for debugging 
 */
const {
  dat: { GUI },
} = window

const CONTROLLER = new GUI()
const CONFIG = {
  'zoom': 1,
  'global-x': 70,
  'global-y': 0,
  'global-z': 30,
  'parallax-x': 30,
  'parallax-z': 30,
  'face-opacity': 1,
  'checker': false,
  'labels': false,
  'wireframe': false,
}

const UPDATE = () => {
  Object.entries(CONFIG).forEach(([key, value]) => {
    document.documentElement.style.setProperty(`--${key}`, value)
  })
  document.documentElement.setAttribute('checker', CONFIG.checker ? true : false)
  document.documentElement.setAttribute('labels', CONFIG.labels ? true : false)
  document.documentElement.setAttribute('wireframe', CONFIG.wireframe ? true : false)
}

const STAGE_FOLDER = CONTROLLER.addFolder('Stage')
STAGE_FOLDER.add(CONFIG, 'zoom', 0, 5, 0.1)
.name('Zoom')
.onChange(UPDATE)
STAGE_FOLDER.add(CONFIG, 'global-x', 0, 180, 1)
.name('Global X (deg)')
.onChange(UPDATE)
STAGE_FOLDER.add(CONFIG, 'global-y', 0, 180, 1)
.name('Global Y (deg)')
.onChange(UPDATE)
STAGE_FOLDER.add(CONFIG, 'global-z', 0, 180, 1)
.name('Global Z (deg)')
.onChange(UPDATE)
STAGE_FOLDER.add(CONFIG, 'parallax-x', 0, 180, 1)
  .name('Parallax X')
  .onChange(UPDATE)
STAGE_FOLDER.add(CONFIG, 'parallax-z', 0, 180, 1)
  .name('Parallax Z')
  .onChange(UPDATE)
STAGE_FOLDER.add(CONFIG, 'face-opacity', 0, 1, 0.1)
  .name('Face Opacity')
  .onChange(UPDATE)
STAGE_FOLDER.add(CONFIG, 'checker')
  .name('Checker Texture')
  .onChange(UPDATE)
STAGE_FOLDER.add(CONFIG, 'labels')
  .name('Labels')
  .onChange(UPDATE)
STAGE_FOLDER.add(CONFIG, 'wireframe')
  .name('Wireframe')
  .onChange(UPDATE)

UPDATE()

STAGE_FOLDER.open()
CONTROLLER.close()
              
            
!
999px

Console