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

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

              
                -
  const IMAGES = ["https://images.unsplash.com/photo-1485163819542-13adeb5e0068?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=300&ixid=MnwxfDB8MXxyYW5kb218MHx8Y3liZXJwdW5rfHx8fHx8MTYzNzUxNTg3NA&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=300","https://images.unsplash.com/photo-1602429438534-f437d3836992?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=300&ixid=MnwxfDB8MXxyYW5kb218MHx8Y3liZXJwdW5rfHx8fHx8MTYzNzUxNTg3NQ&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=300","https://images.unsplash.com/photo-1533972751724-9135a8410a4c?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=300&ixid=MnwxfDB8MXxyYW5kb218MHx8Y3liZXJwdW5rfHx8fHx8MTYzNzUxNTg3Nw&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=300","https://images.unsplash.com/photo-1557040135-9dc2a6b60411?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=300&ixid=MnwxfDB8MXxyYW5kb218MHx8Y3liZXJwdW5rfHx8fHx8MTYzNzUxNTg3OQ&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=300","https://images.unsplash.com/photo-1608501078713-8e445a709b39?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=300&ixid=MnwxfDB8MXxyYW5kb218MHx8Y3liZXJwdW5rfHx8fHx8MTYzNzUxNTg4MA&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=300","https://images.unsplash.com/photo-1604769321486-25cdedb935fa?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=300&ixid=MnwxfDB8MXxyYW5kb218MHx8Y3liZXJwdW5rfHx8fHx8MTYzNzUxNTg4NA&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=300","https://images.unsplash.com/photo-1608501078713-8e445a709b39?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=300&ixid=MnwxfDB8MXxyYW5kb218MHx8Y3liZXJwdW5rfHx8fHx8MTYzNzUxNTg4NQ&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=300","https://images.unsplash.com/photo-1600382224527-3ab1474fbb2a?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=300&ixid=MnwxfDB8MXxyYW5kb218MHx8Y3liZXJwdW5rfHx8fHx8MTYzNzUxNTg4Nw&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=300","https://images.unsplash.com/photo-1611419010196-a360856fc42f?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=300&ixid=MnwxfDB8MXxyYW5kb218MHx8Y3liZXJwdW5rfHx8fHx8MTYzNzUxNTg4OQ&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=300","https://images.unsplash.com/photo-1622125124161-07695cf9df9b?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=300&ixid=MnwxfDB8MXxyYW5kb218MHx8Y3liZXJwdW5rfHx8fHx8MTYzNzUxNTg5Mg&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=300"]
.cybr-sldr
  ul
    - for (let l = 0; l < IMAGES.length; l++)
      li(style=`--clip: url(#${l + 1})`)
        img(src=IMAGES[l])
  svg(height="0" width="0")
    defs
      - let i = 0
      while i < IMAGES.length
        clipPath(id=i + 1)
          text(class=i + 1 dominant-baseline="middle" text-anchor="middle" x="50%" y="50%" font-size="10vmin" font-family="Cyber")= i + 1
        - i++
  span.cybr-sldr__tag.cybr-btn__tag(aria-hidden) IMG.
  button.direction-button.direction-button--next.cybr-btn(data-direction='1')
    | >
    span(aria-hidden) _
    span.cybr-btn__glitch(aria-hidden) >_
    span.cybr-btn__tag(aria-hidden) N3XT
  button.direction-button.direction-button--prev.cybr-btn(data-direction='-1')
    | <
    span(aria-hidden) _
    span.cybr-btn__glitch(aria-hidden) <_
    span.cybr-btn__tag(aria-hidden) PR3V
              
            
!

CSS

              
                @font-face
  font-family Cyber
  src url("https://assets.codepen.io/605876/Blender-Pro-Bold.otf")
  font-display swap

*
  box-sizing border-box

:root
  --size 300px

body
  min-height 100vh
  display grid
  place-items center
  --primary 'hsl(58, 100%, %s)' % calc((48 - var(--lightness, 0)) * 1%)
  --secondary 'hsl(58, 100%, %s)' % calc((45 - var(--lightness, 0)) * 1%)
  background linear-gradient(90deg, var(--primary) 70%, var(--secondary) 70%), var(--primary)
  overflow hidden

ul
  height var(--size)
  aspect-ratio 1 / 1
  list-style-type none
  padding 0
  margin 0
  position relative
  $clip = polygon(0 0, 100% 0, 100% 100%, 90% 100%, 90% 95%, 70% 95%, 70% 100%, 10% 100%, 0 90%)
  -webkit-clip-path $clip
  clip-path $clip
  border-right 6px solid hsl(180, 90%, 60%)
li
  position relative

li
img
  height 100%
  width 100%
  position absolute

img
  position absolute
  left 0
  top 0
  background-size cover
  clip-path var(--clip)
  -webkit-clip-path var(--clip)

svg
  height var(--size)
  width var(--size)
  position absolute

.direction-button
  position absolute
  top 50%
  transform translate(calc(var(--offset) * 50%), -50%)

  &--next
    --offset 1
    left 100%

  &--prev
    --offset -1
    right 100%

.cybr-sldr
  display none
  position relative
  height var(--size)
  aspect-ratio 1 / 1
  background linear-gradient(90deg, transparent 0 15%, hsl(180, 90%, 60%) 15% 72%, transparent 72%)
  font-family 'Cyber', sans-serif

  & > .cybr-btn__tag
    bottom 0
    left 72%
    transform translate(0, 15%)

.cybr-btn
  --primary 'hsl(%s, 85%, %s)' % (var(--primary-hue) calc(var(--primary-lightness, 50) * 1%))
  --shadow-primary 'hsl(%s, 90%, 50%)' % var(--shadow-primary-hue)
  --primary-hue 0
  --primary-lightness 50
  --color hsl(0, 0%, 100%)
  --font-size 26px
  --shadow-primary-hue 180
  --label-size 9px
  --shadow-secondary-hue 60
  --shadow-secondary 'hsl(%s, 90%, 60%)' % var(--shadow-secondary-hue)
  --clip polygon(0 0, 100% 0, 100% 100%, 95% 100%, 95% 90%, 55% 90%, 55% 100%, 18% 100%, 0 82%)
  --border 4px
  --shimmy-distance 5
  --clip-one polygon(0 2%, 100% 2%, 100% 95%, 95% 95%, 95% 90%, 55% 90%, 55% 95%, 18% 95%, 0 82%)
  --clip-two polygon(0 78%, 100% 78%, 100% 100%, 95% 100%, 95% 90%, 55% 90%, 55% 100%, 16% 100%, 0 78%)
  --clip-three polygon(0 44%, 100% 44%, 100% 54%, 95% 54%, 95% 54%, 55% 54%, 55% 54%, 18% 54%, 0 54%)
  --clip-four polygon(0 0, 100% 0, 100% 0, 95% 0, 95% 0, 55% 0, 55% 0, 18% 0, 0 0)
  --clip-five polygon(0 0, 100% 0, 100% 0, 95% 0, 95% 0, 55% 0, 55% 0, 18% 0, 0 0)
  --clip-six polygon(0 40%, 100% 40%, 100% 85%, 95% 85%, 95% 85%, 55% 85%, 55% 85%, 18% 85%, 0 82%)
  --clip-seven polygon(0 63%, 100% 63%, 100% 80%, 95% 80%, 95% 80%, 55% 80%, 55% 80%, 18% 80%, 0 82%)
  font-family 'Cyber', sans-serif
  color var(--color)
  cursor pointer
  background transparent
  text-transform uppercase
  font-size var(--font-size)
  outline transparent
  letter-spacing 2px
  position absolute
  font-weight 700
  border 0
  // min-width 100px
  width 75px
  height 75px
  line-height 75px
  transition background 0.2s

.cybr-btn:hover
  --primary 'hsl(%s, 85%, %s)' % (var(--primary-hue) calc(var(--primary-lightness, 50) * 0.8%))

.cybr-btn:active
  --primary 'hsl(%s, 85%, %s)' % (var(--primary-hue) calc(var(--primary-lightness, 50) * 0.6%))

.cybr-btn:after
.cybr-btn:before
  content ''
  position absolute
  top 0
  left 0
  right 0
  bottom 0
  clip-path var(--clip)
  z-index -1

.cybr-btn:before
  background var(--shadow-primary)
  transform translate(var(--border), 0)

.cybr-btn:after
  background var(--primary)

.cybr-btn__tag
  position absolute
  padding 1px 4px
  letter-spacing 1px
  line-height 1
  bottom -5%
  right 5%
  font-weight normal
  color hsl(0, 0%, 0%)
  font-size var(--label-size)

.cybr-btn__glitch
  position absolute
  top calc(var(--border) * -1)
  left calc(var(--border) * -1)
  right calc(var(--border) * -1)
  bottom calc(var(--border) * -1)
  background var(--shadow-primary)
  text-shadow 2px 2px var(--shadow-primary), -2px -2px var(--shadow-secondary)
  clip-path var(--clip)
  animation glitch 2s infinite
  display none

.cybr-btn:hover .cybr-btn__glitch
  display block

.cybr-btn__glitch:before
  content ''
  position absolute
  top calc(var(--border) * 1)
  right calc(var(--border) * 1)
  bottom calc(var(--border) * 1)
  left calc(var(--border) * 1)
  clip-path var(--clip)
  background var(--primary)
  z-index -1

@keyframes glitch
  0%
    clip-path var(--clip-one)
  2%, 8%
    clip-path var(--clip-two)
    transform translate(calc(var(--shimmy-distance) * -1%), 0)
  6%
    clip-path var(--clip-two)
    transform translate(calc(var(--shimmy-distance) * 1%), 0)
  9%
    clip-path var(--clip-two)
    transform translate(0, 0)
  10%
    clip-path var(--clip-three)
    transform translate(calc(var(--shimmy-distance) * 1%), 0)
  13%
    clip-path var(--clip-three)
    transform translate(0, 0)
  14%, 21%
    clip-path var(--clip-four)
    transform translate(calc(var(--shimmy-distance) * 1%), 0)
  25%
    clip-path var(--clip-five)
    transform translate(calc(var(--shimmy-distance) * 1%), 0)
  30%
    clip-path var(--clip-five)
    transform translate(calc(var(--shimmy-distance) * -1%), 0)
  35%, 45%
    clip-path var(--clip-six)
    transform translate(calc(var(--shimmy-distance) * -1%))
  40%
    clip-path var(--clip-six)
    transform translate(calc(var(--shimmy-distance) * 1%))
  50%
    clip-path var(--clip-six)
    transform translate(0, 0)
  55%
    clip-path var(--clip-seven)
    transform translate(calc(var(--shimmy-distance) * 1%), 0)
  60%
    clip-path var(--clip-seven)
    transform translate(0, 0)
  31%, 61%, 100%
    clip-path var(--clip-four)

.cybr-btn:nth-of-type(2)
  --primary-hue 260
              
            
!

JS

              
                import gsap from 'https://cdn.skypack.dev/gsap'

const ORIGINS = [
  '51% 50%',
  '53% 55%',
  '55% 55%',
  '55% 55%',
  '51% 55%',
  '51% 56%',
  '52% 56%',
  '55% 57%',
  '56% 55%',
  '52% 55%',
]

let CURRENT = 2
const TARGET_BRIGHTNESS = 10
const SPEED = 1.2
const SCALES = [250, 600, 350, 250, 250, 350, 350, 350, 300, 300]

// Weird how you can't access these by class or descendant?
const CLIPS = gsap.utils.toArray('text')
const ITEMS = gsap.utils.toArray('li')
const TAG = document.querySelector('.cybr-sldr__tag')

const RESET = () => {
  // Total nuke first.
  gsap.set(CLIPS, {
    clearProps: true,
  })
  // Then set everything up
  gsap.set(CLIPS, {
    scale: index => (index === CURRENT ? SCALES[index] ?? 300 : 0),
    transformOrigin: index => ORIGINS[index] ?? '55% 55%',
  })
  gsap.set(ITEMS, {
    filter: index => `brightness(${index === CURRENT ? 1 : TARGET_BRIGHTNESS})`,
  })
  TAG.innerText = `IMG.${(CURRENT + 1).toString().padStart(2, 0)}`
}

RESET()

window.addEventListener('resize', RESET)

const UPDATE = e => {
  const DIRECTION = e.currentTarget.getAttribute('data-direction')
  const NEW_INDEX = gsap.utils.wrap(
    0,
    ITEMS.length,
    CURRENT + parseInt(DIRECTION, 10)
  )
  // Run our animation to set the new picture reveals
  gsap
    .timeline({
      onComplete: () => {
        // Set the index
        CURRENT = NEW_INDEX
        TAG.innerText = `IMG.${(CURRENT + 1).toString().padStart(2, 0)}`
      },
    })
    .set(ITEMS[NEW_INDEX], {
      zIndex: 2,
    })
    .set(ITEMS[CURRENT], {
      zIndex: 1,
    })
    .set(ITEMS[NEW_INDEX], {
      filter: 'brightness(0)',
    })
    .to(ITEMS[NEW_INDEX], {
      // delay: SPEED * 0.0625,
      ease: 'power4.in',
      filter: 'brightness(1)',
    })
    .to(
      ITEMS[CURRENT],
      {
        // duration: 0.25,
        filter: `brightness(${TARGET_BRIGHTNESS})`,
      },
      0
    )
    .to(
      CLIPS[NEW_INDEX],
      {
        ease: 'power4.in',
        duration: SPEED,
        scale: SCALES[NEW_INDEX] ?? 300,
      },
      0
    )
    .to(
      document.documentElement,
      {
        '--lightness': 25,
        yoyo: true,
        repeat: 1,
        duration: SPEED * 0.5,
      },
      0
    )
    .set(CLIPS[CURRENT], {
      scale: 0,
    })
}

const NEXT = document.querySelector('[data-direction="1"]')
const PREV = document.querySelector('[data-direction="-1"]')
NEXT.addEventListener('click', UPDATE)
PREV.addEventListener('click', UPDATE)

gsap.set('.cybr-sldr', { display: 'block' })
              
            
!
999px

Console