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

              
                //- Configuration
- const SIZE = 40
- const DEPTH = 6

mixin cuboid()
  .cuboid(class!=attributes.class)
    if block
      block
    - let s = 0
    while s < 6
      .cuboid__side
      - s++
mixin cylinder(radius = 10, sides = 10, cut = [5, 10], top = true, bottom = true)
  - const innerAngle = (((sides - 2) * 180) / sides) * 0.5
  - const cosAngle = Math.cos(innerAngle * (Math.PI / 180))
  - const side =  2 * radius * Math.cos(innerAngle * (Math.PI / 180))
  - const projection = Math.sqrt(Math.pow(radius, 2) - Math.pow(side / 2, 2))
  //- Use the cut to determine how many sides get rendered and from what point

  .cylinder(style=`--side: ${side}; --sides: ${sides}; --radius: ${radius}; --projection: ${projection};`, class!=attributes.class)
    if top
      .cylinder__end.cylinder__segment.cylinder__end--top
    if bottom
      .cylinder__end.cylinder__segment.cylinder__end--bottom
    - const [start, end] = cut
    - let i = start
    while i < end
      .cylinder__side.cylinder__segment(style=`--index: ${i};`)
      - i++

- const CORNER_SIDES = 45
- const CORE_RADIUS = SIZE * 0.195
.scene(style=`--size: ${SIZE}; --depth: ${DEPTH};`)
  - const MSG = 'What are you waiting for?   •   '
  - const CHARS = MSG.split('')
  .word-ring(style=`--char-count: ${CHARS.length};`)
    - for(let c = 0; c < CHARS.length; c++)
      - const char = CHARS[c]
      span.word-ring__char(data-char=char === ' ' ? 'space' : char style=`--index: ${c}`)= char


  a.hashnode-portal(href="https://hashnode.com" target="_blank" rel="noreferrer noopener")
    .cuboid__wrapper
      +cylinder(CORE_RADIUS, 24, [0, 24], false, false).hashnode__core
      +cylinder(SIZE * 0.28, CORNER_SIDES, [0, CORNER_SIDES * 0.25], false, false).hashnode__corner.hashnode__corner--one
      +cylinder(SIZE * 0.28, CORNER_SIDES, [CORNER_SIDES * 0.25, CORNER_SIDES * 0.5 + 1], false, false).hashnode__corner.hashnode__corner--two
      +cylinder(SIZE * 0.28, CORNER_SIDES, [CORNER_SIDES * 0.5, CORNER_SIDES * 0.75 + 1], false, false).hashnode__corner.hashnode__corner--three
      +cylinder(SIZE * 0.28, CORNER_SIDES, [CORNER_SIDES * 0.75, CORNER_SIDES], false, false).hashnode__corner.hashnode__corner--four
      .cuboid.hashnode-portal__placeholder
        .cuboid__side
          .hashnode
        .cuboid__side
        .cuboid__side
          .hashnode
        .cuboid__side
        .cuboid__side
        .cuboid__side
button
  span Replay
  svg(viewBox="0 0 24 24")
    path(fill="currentColor" d="M12,5V1L7,6L12,11V7A6,6 0 0,1 18,13A6,6 0 0,1 12,19A6,6 0 0,1 6,13H4A8,8 0 0,0 12,21A8,8 0 0,0 20,13A8,8 0 0,0 12,5Z")
  
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Inter:wght@600&display=swap')

*
*:after
*:before
  box-sizing border-box
  transform-style preserve-3d

// CONFIG
:root
  --bg hsl(0, 0%, 98%)
  --size 40
  --depth 6
  --primary rgb(41, 98, 255)
  --text hsl(0, 0%, 40%)
  // Speeds
  --rotate 10
  --grow 1
  --scale 1
  --scale-delay 1
  --show 1
  --show-delay 1
  --press 0.1
  --rotate-x -26
  --rotate-y 45

// START BOILERPLATE
body
  background var(--bg)
  min-height 100vh
  display grid
  place-items center
  font-family 'Inter', sans-serif
  overflow hidden

.cylinder
  --bg var(--primary)
  height calc(var(--height, 40) * 1vmin)
  position absolute
  width calc(var(--radius, 40) * 2vmin)

  &__segment
    filter brightness(var(--b, 1))
    background var(--bg)
    position absolute

  // Top
  &__end
    --b 1.2
    top var(--t, 0)
    height calc(var(--radius, 40) * 2vmin)
    width calc(var(--radius, 40) * 2vmin)
    border-radius 50%
    transform translate(0, -50%) rotateX(90deg)

  &__end--bottom
    --b 0.8
    --t 100%

  &__side
    --b 0.89
    height calc(var(--height, 30) * 1vmin)
    width calc(var(--side) * 1vmin)
    top 0
    left 50%
    transform translate(-50%, 0) rotateY(calc((var(--index, 0) * 360 / var(--sides)) * 1deg)) translate3d(0, 0, calc(var(--projection) * 1vmin))

.word-ring
  position absolute
  z-index 2
  border-radius 50%
  height calc(var(--size) * 1.45vmin)
  width calc(var(--size) * 1.45vmin)
  top 50%
  left 50%
  transform translate(-50%, -50%) rotate(0deg)
  animation rotate calc(var(--rotate) * 1s) infinite linear, show calc(var(--show) * 1s) calc((var(--grow) + var(--scale) + var(--show-delay)) * 1s) both
  color var(--text)

  &__char
    position absolute
    top 50%
    left 50%
    font-weight bold
    font-size calc(var(--size) * 0.2vmin)
    transform translate(-50%, -50%) rotate(calc(((360 / var(--char-count) * var(--index))) * 1deg)) translate(0, calc(var(--size) * -0.75vmin))

.cuboid
  width 100%
  height 100%
  position relative
  // 1 is the top and go t, r, bottom, l, f, back

  &__side
    filter brightness(var(--b, 1))
    position absolute

  &__side:nth-of-type(1)
    --b 1.1
    height calc(var(--depth, 20) * 1vmin)
    width 100%
    top 0
    transform translate(0, -50%) rotateX(90deg)

  &__side:nth-of-type(2)
    --b 0.9
    height 100%
    width calc(var(--depth, 20) * 1vmin)
    top 50%
    right 0
    transform translate(50%, -50%) rotateY(90deg)

  &__side:nth-of-type(3)
    --b 0.5
    width 100%
    height calc(var(--depth, 20) * 1vmin)
    bottom 0
    transform translate(0%, 50%) rotateX(90deg)

  &__side:nth-of-type(4)
    --b 1
    height 100%
    width calc(var(--depth, 20) * 1vmin)
    left 0
    top 50%
    transform translate(-50%, -50%) rotateY(90deg)

  &__side:nth-of-type(5)
    --b 0.8
    height 100%
    width 100%
    transform translate3d(0, 0, calc(var(--depth, 20) * 0.5vmin))
    top 0
    left 0

  &__side:nth-of-type(6)
    --b 1.2
    height 100%
    width 100%
    transform translate3d(0, 0, calc(var(--depth, 20) * -0.5vmin)) rotateY(180deg)
    top 0
    left 0

// END BOILERPLATE


.scene
  transform translate3d(0, 0, 100vmin) rotateX(calc(var(--rotate-x) * 1deg)) rotateY(calc(var(--rotate-y) * 1deg)) rotateX(90deg)
  // transform translate3d(0, 0, 100vmin) rotateX(0deg) rotateY(0deg) rotateX(0deg)

.hashnode
  height calc(var(--size) * 1vmin)
  width calc(var(--size) * 1vmin)
  border-radius 28%
  $mask = radial-gradient(transparent 0 27%, #000 27%)
  -webkit-mask $mask
  mask $mask
  overflow hidden

  &:after
    content ''
    position absolute
    inset 0
    height 100%
    width 100%
    background var(--primary)
    animation scale calc(var(--scale) * 1s) calc(var(--scale-delay, 1) * 1s) both
    border-radius 28%

  &__corner
  &__core
    --height var(--depth)

  &__core
  &__corner
    animation show calc(var(--scale) * 1s) calc(var(--scale-delay, 1) * 1s) backwards
    top 50%
    opacity 1
    transform translate3d(var(--x, -50%), var(--y, -50%), var(--z, 0))

  &__core
    left 50%
    .cylinder__side
      --b 0.75

  &__corner
    &--one
      right 0
      --x 0%
      --z calc(var(--size) * 0.22vmin)
    &--two
      right 0
      --x 0%
      --z calc(var(--size) * -0.22vmin)
    &--three
      left 0
      --x 0%
      --z calc(var(--size) * -0.22vmin)
    &--four
      left 0
      --x 0%
      --z calc(var(--size) * 0.22vmin)

.hashnode-portal
  height calc(var(--depth) * 1vmin)
  width calc(var(--size) * 1vmin)
  display block
  position absolute
  bottom 50%
  transform-origin 50% 100%
  transform translate(-50%, 0) rotateX(-90deg) scaleY(1)
  animation grow calc(var(--grow) * 1s) calc((var(--scale) + var(--scale-delay)) * 1s) both

  &:hover
    --scale 1.2
  
  &:active
    --scale 0.1

  &__placeholder
    --depth calc(var(--size) * 1)

    .cuboid__side
      background var(--primary)

      &:nth-of-type(1)
      &:nth-of-type(3)
        --b 1.1
        background none

      &:nth-of-type(2)
      &:nth-of-type(4)
      &:nth-of-type(5)
      &:nth-of-type(6)
        --b 0.9
        $clip = inset(0 27% 0 27%)
        -webkit-clip-path $clip
        clip-path $clip

.cuboid__wrapper
  height calc(var(--depth) * 1vmin)
  width calc(var(--size) * 1vmin)
  transform scaleY(var(--scale, 1))
  transform-origin 50% 100%
  transition transform calc(var(--press) * 1s)


@keyframes grow
  from
    transform translate(-50%, 0) rotateX(-90deg) scaleY(0.0000001)

@keyframes scale
  from
    transform scale(0)

@keyframes show
  from
    opacity 0

@keyframes rotate
  to
    transform translate(-50%, -50%) rotate(-360deg)

button
  margin 0
  background none
  padding 0
  position fixed
  bottom 1rem
  right 1rem
  border none
  transition transform 0.1s
  transform scale(var(--scale, 1))
  color var(--text)
  
  
  &:hover
    --scale 1.1
  &:active
    --scale 0.9
  
  svg
    height 44px
  
  span
    position absolute
    width 1px
    height 1px
    padding 0
    margin -1px
    overflow hidden
    clip rect(0, 0, 0, 0)
    white-space nowrap
    border-width 0
              
            
!

JS

              
                // For replaying the animation
const BTN = document.querySelector('button')
const REPLAY = () => {
  const SCENE = document.querySelector('.scene')
  const CURRENT_SCENE = SCENE.cloneNode(true)
  SCENE.innerHTML = ''
  requestAnimationFrame(() => {
    SCENE.replaceWith(CURRENT_SCENE)
  })
}
BTN.addEventListener('click', REPLAY)
              
            
!
999px

Console