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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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 WORD = "Jhey Tompkins"
.text-grid
  .avatar-ring
    img(src="https://assets.codepen.io/605876/me--noticing.png")
    img(src="https://assets.codepen.io/605876/me--standing.png")
  - let t = 0
  while t < 51
    if (t === 25)
      h1.text-grid__main(data-splitting="")= WORD
    else
      h1(aria-hidden="true")= WORD
    - t++
button
  svg(viewBox="0 0 512 512" title="restart")
    path(d="M500.33 0h-47.41a12 12 0 0 0-12 12.57l4 82.76A247.42 247.42 0 0 0 256 8C119.34 8 7.9 119.53 8 256.19 8.1 393.07 119.1 504 256 504a247.1 247.1 0 0 0 166.18-63.91 12 12 0 0 0 .48-17.43l-34-34a12 12 0 0 0-16.38-.55A176 176 0 1 1 402.1 157.8l-101.53-4.87a12 12 0 0 0-12.57 12v47.41a12 12 0 0 0 12 12h200.33a12 12 0 0 0 12-12V12a12 12 0 0 0-12-12z")
              
            
!

CSS

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

*
  box-sizing border-box

:root
  --stroke hsl(0, 0%, 50%)
  --shadow-5 'hsl(%s, 70%, 52%, 0.5)' % var(--hue, 10)
  --shadow-75 'hsl(%s, 70%, 52%, 0.75)' % var(--hue, 10)

body
  font-family 'Nunito', sans-serif
  min-height 100vh
  text-transform uppercase
  overflow hidden
  background hsl(0, 10%, 10%)

h1
  margin 0
  white-space nowrap
  font-size clamp(2rem, 10vmin, 5rem)
  line-height 0.8
  color transparent
  z-index -1

[aria-hidden]
  user-select none
  -webkit-text-stroke 2px var(--stroke)
  opacity 0


.char
  -webkit-text-stroke 2px var(--stroke)
  display inline-block

.text-grid
  display grid
  grid-gap 0 4vmin
  grid-template-columns repeat(3, auto)
  position fixed
  top 50%
  left 50%
  transform translate(-50%, -45%)

  &__main
    z-index 2

    .char
      --drop 0
      will-change filter

      &--on
        filter drop-shadow(0 calc(var(--drop, 0) * -2.5px) calc(var(--drop, 0) * 2.5px) hsl(0, 10%, 0%)) drop-shadow(0 0 calc(var(--drop, 0) * 5px) var(--shadow-5)) drop-shadow(0 0 calc(var(--drop, 0) * 10px) var(--shadow-5)) drop-shadow(0 0 calc(var(--drop, 0) * 0.5px) var(--shadow-75)) brightness(calc(1 + (var(--drop) * 0.2)))

.avatar-ring
  position absolute
  top 50%
  left 50%
  width 50vmin
  height 50vmin
  max-width 280px
  max-height 280px
  border 10px solid var(--stroke)
  border-radius 50%
  background 'hsl(%s, 30%, 20%)' % var(--hue)
  transform translate(-50%, -80%) scale(0)
  overflow hidden

  &:after
    content ''
    height 100%
    width 100%
    // background hsla(0, 0%, 0%, 0.45)
    position absolute
    top 65%
    left 50%
    transform translate(-50%, 0%)

  img
    position absolute
    top 50%
    left 50%
    width 150%
    transform translate(-50%, -50%)
    filter grayscale(0)

  &:hover img:nth-of-type(2)
    display none

button
  height 48px
  width 48px
  position fixed
  right 1rem
  bottom 1rem
  appearance none
  border none
  background transparent
  transition transform 0.2s
  outline transparent

  &:active
    transform scale(0.75)

  svg
    height 2rem
    width 2rem
    fill white

.char--on
  animation flicker 1s infinite

@keyframes flicker
  50%
    --drop 0 !important
    --stroke black !important
              
            
!

JS

              
                import Splitting from 'https://cdn.skypack.dev/splitting'
import gsap from 'https://cdn.skypack.dev/gsap'
import { RoughEase } from 'https://cdn.skypack.dev/gsap/EasePack'

gsap.registerPlugin(RoughEase)

Splitting()

let COLOR
let FLICKER
let MAIN

const setColor = () => {
  const hue = Math.random() * 360
  gsap.set(document.documentElement, {
    '--hue': hue,
  })
  COLOR = `hsl(${hue}, 65%, 80%)`
}
const CHARS = gsap.utils.toArray('.text-grid__main .char')
const STAGGER = 0.025
const SPEED = 0.2
const RESET = () => {
  if (MAIN) MAIN.kill()
  window.FLICKER = FLICKER =
    CHARS[Math.floor(Math.random() * 'Jhey Tompkins'.split('').length)]
  setColor()
  gsap.set(['[aria-hidden]', '.char'], {
    opacity: 0,
  })
  gsap.set('.avatar-ring', {
    clearProps: 'all',
  })
  gsap.set('.avatar-ring', {
    scale: 0,
    transformOrigin: '50% 65%',
  })
  gsap.set('.char', {
    color: 'transparent',
    stroke: 'hsl(0, 0%, 50%)',
    scale: 1,
  })
  gsap.set('img', {
    yPercent: 100,
  })
  gsap.set(CHARS, {
    attr: {
      class: 'char',
    },
  })
}
const REVEAL = () =>
  gsap
    .timeline()
    .set('.char', {
      '--drop': 0,
      '--stroke': 'hsl(0, 0%, 50%)',
    })
    .to('.char', {
      stagger: STAGGER,
      opacity: 1,
      duration: SPEED,
    })
    .to(
      '.char',
      {
        stagger: STAGGER,
        color: COLOR,
        duration: SPEED,
        '--stroke': COLOR,
      },
      '<+0.4'
    )
    .to('[aria-hidden]', {
      opacity: 1,
      duration: STAGGER,
      delay: gsap.utils.distribute({
        base: 0,
        amount: SPEED,
        grid: 'auto',
        from: 'center',
      }),
      repeat: 1,
      yoyo: true,
    })
    .to(
      '.avatar-ring',
      {
        scale: 1,
        duration: SPEED,
      },
      '<'
    )
    .to(
      'img',
      {
        yPercent: -50,
        duration: SPEED,
      },
      `>-${SPEED * 0.5}`
    )
    .set('.text-grid__main .char', {
      attr: {
        class: 'char char--on',
      },
    })
    .to('.text-grid__main .char', {
      '--drop': 1,
      duration: SPEED,
    })
    .add(
      gsap
        .timeline({
          repeat: -1,
          delay: gsap.utils.random(1, 3),
          repeatDelay: gsap.utils.random(5, 10),
        })
        .to(FLICKER, {
          opacity: 0.3,
          yoyo: true,
          duration: 0.5,
          repeatDelay: 0.1,
          ease: `rough({ template: power1.out, strength: 2, points: 50, taper: 'none', randomize: true, clamp: true})`,
          repeat: 1,
        })
    )

RESET()
MAIN = REVEAL()

document.querySelector('button').addEventListener('click', () => {
  RESET()
  MAIN = REVEAL()
})

              
            
!
999px

Console