From c4ff73a883ce1ecf989d4d23e67955077d00423f Mon Sep 17 00:00:00 2001 From: David Aerne Date: Fri, 10 May 2024 21:38:15 +0200 Subject: [PATCH] better demo --- demo/index.html | 12 ++++++------ src/demo.css | 17 +++++++++++++++-- src/demo.ts | 6 ++++-- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/demo/index.html b/demo/index.html index dbd612a..c8f7399 100644 --- a/demo/index.html +++ b/demo/index.html @@ -8,19 +8,19 @@ href="https://fonts.cdnfonts.com/css/apple-garamond" rel="stylesheet" /> - - diff --git a/src/demo.css b/src/demo.css index cbaae41..fc68993 100644 --- a/src/demo.css +++ b/src/demo.css @@ -473,9 +473,7 @@ h2 { position: relative; transform: rotate(calc(var(--rnd) * 5deg)) translateX(calc(var(--rnd) * 0.5em)); - height: calc(0.5rem + var(--rnd2) * 1.5rem); - transition: 400ms height cubic-bezier(0.3, 0.7, 0, 1) 100ms; } @@ -515,6 +513,7 @@ h2 { } } +.ramp__step--active, .ramp__step:hover { height: 7rem; .ramp__label { @@ -528,6 +527,20 @@ h2 { } } +.ramp:has(:hover) .ramp__step--active:not(:hover) { + height: calc(0.5rem + var(--rnd2) * 1.5rem); + + .ramp__label { + transform: translateY(0); + span { + opacity: 0; + } + } + .ramp__inner { + transform: rotate(0) scale(0.8); + } +} + .ramp-list h2 { text-align: center; margin-bottom: 0.5em; diff --git a/src/demo.ts b/src/demo.ts index 834ce97..92f6a2a 100644 --- a/src/demo.ts +++ b/src/demo.ts @@ -140,11 +140,13 @@ const createRamps = async (amount = 18, stepsPerRamp = 9) => { const $wrapper = document.querySelector("[data-ramps]") as HTMLElement; $wrapper.innerHTML = ramps .map((ramp, i) => { + const activeIndex = 1 + Math.floor(Math.random() * (ramp.length - 2)); return `

${romanNumerals[i + 1]}

${ramp - .map((hex) => { - return `
+ .map((hex, j) => { + const activeClass = j === activeIndex ? "ramp__step--active" : ""; + return `
${namesForHexes[hex]}