Skip to content

An AI skill that turns books into animated, narrated, interactive web experiences

style(player): reveal volume slider on hover

yzrb58c601915a9
diff --git a/.claude/skills/papermorph/assets/engine/engine.css b/.claude/skills/papermorph/assets/engine/engine.css
index 97169ad..ed244f1 100644
--- a/.claude/skills/papermorph/assets/engine/engine.css
+++ b/.claude/skills/papermorph/assets/engine/engine.css
@@ -106,12 +106,15 @@ button[hidden] { display: none; }
.seg.ask { background: #2d4a57; }
.seg.ask i { background: var(--quiz); }
.step { width: 300px; flex: none; color: var(--dim); font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
-.volume { display: flex; align-items: center; gap: 10px; flex: none; height: 44px; padding: 0 12px;
- border: 1px solid var(--edge); border-radius: 999px; background: var(--panel); color: var(--chalk); }
+.volume { display: flex; align-items: center; flex: none; width: 44px; height: 44px; overflow: hidden;
+ border: 1px solid var(--edge); border-radius: 999px; background: var(--panel); color: var(--chalk); transition: width .18s ease; }
+.volume .icon { width: 42px; height: 42px; border: 0; background: transparent; }
+.volume:hover, .volume:focus-within { width: 166px; gap: 10px; padding-right: 12px; }
.volume:hover { background: #2b3f36; border-color: var(--faint); }
-.volume:has(input:focus-visible) { outline: 2px solid var(--task); outline-offset: 3px; }
-.volume svg { width: 20px; height: 20px; flex: none; }
-.volume input { appearance: none; width: 100px; height: 42px; margin: 0; background: transparent; cursor: pointer; }
+.volume:has(:focus-visible) { outline: 2px solid var(--task); outline-offset: 3px; }
+.volume .icon:focus-visible { outline: none; }
+.volume input { appearance: none; flex: none; width: 0; height: 42px; margin: 0; opacity: 0; background: transparent; cursor: pointer; }
+.volume:hover input, .volume:focus-within input { width: 100px; opacity: 1; }
.volume input:focus-visible { outline: none; }
.volume input::-webkit-slider-runnable-track { height: 4px; border-radius: 999px;
background: linear-gradient(to right, var(--chalk) var(--volume, 100%), var(--faint) var(--volume, 100%)); }
@@ -126,7 +129,11 @@ button[hidden] { display: none; }
transform: scale(calc(1 / var(--k))); transform-origin: left top; border-radius: 0 0 12px 12px; }
#bar .icon { width: 36px; height: 40px; }
.step { display: none; }
- .segs, .volume { order: 1; }
+ .volume { width: 36px; height: 40px; }
+ #bar .volume .icon { width: 34px; height: 38px; }
+ .volume:hover, .volume:focus-within { width: 158px; }
+ .volume input { height: 38px; }
+ .segs { order: 1; }
.segs { min-width: 80px; margin: 0; }
}
.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: rgba(15, 22, 19, .85); color: var(--dim); font-size: 19px; }
@@ -217,7 +224,7 @@ svg.m { display: inline-block; overflow: visible; }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes hop { 40% { transform: translateY(-12px) rotate(4deg); } }
@keyframes wobble { 25% { transform: rotate(-8deg); } 75% { transform: rotate(6deg); } }
-@media (prefers-reduced-motion: reduce) { .card, .fb, .opt, .grid .mark, .mascot * { animation: none !important; } }
+@media (prefers-reduced-motion: reduce) { .volume { transition: none; } .card, .fb, .opt, .grid .mark, .mascot * { animation: none !important; } }
a.icon { text-decoration: none; }
a.btn { text-decoration: none; display: inline-block; }
diff --git a/.claude/skills/papermorph/assets/engine/engine.js b/.claude/skills/papermorph/assets/engine/engine.js
index 7916378..c75969d 100644
--- a/.claude/skills/papermorph/assets/engine/engine.js
+++ b/.claude/skills/papermorph/assets/engine/engine.js
@@ -72,13 +72,15 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
</button>
<div class="segs" id="segs"></div>
<div class="step" id="stepName"></div>
- <label class="volume" for="volume" title="Volume (0 = muted)">
- <svg viewBox="0 0 24 24" aria-hidden="true">
- <path d="M3 9v6h4l5 4V5L7 9z" fill="currentColor"/>
- <path d="M16 8a6 6 0 0 1 0 8m3-11a10 10 0 0 1 0 14" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>
- </svg>
+ <div class="volume">
+ <button class="icon" id="bVolume" aria-label="Adjust volume" aria-controls="volume" title="Volume (0 = muted)">
+ <svg viewBox="0 0 24 24" aria-hidden="true">
+ <path d="M3 9v6h4l5 4V5L7 9z" fill="currentColor"/>
+ <path d="M16 8a6 6 0 0 1 0 8m3-11a10 10 0 0 1 0 14" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>
+ </svg>
+ </button>
<input id="volume" type="range" min="0" max="1" step="0.05" value="1" aria-label="Volume">
- </label>
+ </div>
<button class="icon txt" id="bHelp" aria-label="Keyboard shortcuts (?)" title="Keyboard shortcuts (?)">?</button>
<button class="icon cc" id="bCC" aria-pressed="false" aria-label="Captions (C)" title="Captions (C)">CC</button>
<button class="icon" id="bFull" aria-label="Full screen">
@@ -1572,6 +1574,7 @@ $('stage').addEventListener('click', e => {
if (!b.ask && !e.target.closest('.qlayer')) togglePlay();
});
$('bPlay').onclick = togglePlay;
+$('bVolume').onclick = () => $('volume').focus();
$('volume').oninput = () => {
$('volume').style.setProperty('--volume', +$('volume').value * 100 + '%');
if (P.audio) P.audio.volume = +$('volume').value;
diff --git a/.claude/skills/papermorph/scripts/check_volume.py b/.claude/skills/papermorph/scripts/check_volume.py
index 4384d53..b4cf5a2 100644
--- a/.claude/skills/papermorph/scripts/check_volume.py
+++ b/.claude/skills/papermorph/scripts/check_volume.py
@@ -33,7 +33,7 @@ async def template(route):
async def check(browser, path):
- page = await browser.new_page(viewport={"width": 1440, "height": 900})
+ page = await browser.new_page(viewport={"width": 1440, "height": 900}, has_touch=True)
errors = []
page.on("pageerror", lambda error: errors.append(str(error)))
page.on("console", lambda message: message.type == "error" and errors.append(message.text))
@@ -44,15 +44,31 @@ async def check(browser, path):
await page.goto(f"{BASE}/{path}")
await page.wait_for_function("typeof P !== 'undefined' && P.audio && P.audio.readyState >= 2")
slider = page.get_by_role("slider", name="Volume", exact=True)
+ button = page.get_by_role("button", name="Adjust volume", exact=True)
assert await slider.count() == 1
assert await page.evaluate("P.audio.volume") == 1
- await slider.fill("0.4")
+ assert await page.evaluate("""Math.abs(document.querySelector('.volume').getBoundingClientRect().width -
+ document.querySelector('#bHelp').getBoundingClientRect().width) < .1"""), "collapsed volume matches the other circular controls"
+ assert await slider.evaluate("e => e.getBoundingClientRect().width === 0")
+ await button.hover()
+ await page.wait_for_function("document.querySelector('#volume').getBoundingClientRect().width > 80")
+ await page.mouse.move(0, 0)
+ await page.wait_for_function("document.querySelector('#volume').getBoundingClientRect().width === 0")
+ await button.focus()
+ await button.press("Tab")
+ assert await slider.evaluate("e => e === document.activeElement && e.getBoundingClientRect().width > 80")
+
+ async def volume(value):
+ await button.hover()
+ await slider.fill(value)
+
+ await volume("0.4")
assert await page.evaluate("P.audio.volume") == .4
await page.locator("#cover").click()
await page.wait_for_function("P.audio.currentTime > .2 && P.t > .1")
for value in ("0", "0.5", "1"):
- await slider.fill(value)
+ await volume(value)
assert await page.evaluate("P.audio.volume") == float(value)
before = await page.evaluate("P.audio.currentTime")
await page.wait_for_function("P.audio.currentTime > " + str(before + .1))
@@ -61,10 +77,10 @@ async def check(browser, path):
await page.wait_for_timeout(200)
assert await page.evaluate("P.audio.paused && !P.playing")
assert abs(await page.evaluate("P.audio.currentTime") - paused) < .05
- await slider.fill(f"{1 - float(value):g}")
+ await volume(f"{1 - float(value):g}")
assert await page.evaluate("P.audio.volume") == 1 - float(value)
assert await page.evaluate("P.audio.paused && !P.playing")
- await slider.fill(value)
+ await volume(value)
await page.locator("#bPlay").click()
await page.wait_for_function("P.audio.currentTime > " + str(paused + .1))
await page.locator("#segs button").nth(1).click()
@@ -94,7 +110,8 @@ async def check(browser, path):
for width, height in ((390, 844), (320, 568), (700, 390), (1440, 900)):
await page.set_viewport_size({"width": width, "height": height})
- await page.wait_for_timeout(100)
+ await button.hover()
+ await page.wait_for_timeout(250)
assert await page.evaluate("""[...document.querySelectorAll('#bar > *, #volume')].every(e => {
if (getComputedStyle(e).display === 'none') return true;
const r = e.getBoundingClientRect();
@@ -102,11 +119,19 @@ async def check(browser, path):
})"""), f"controls clipped at {width}x{height}"
if width <= 700:
bounds = await slider.bounding_box()
- assert bounds["width"] >= 100 and bounds["height"] >= 40
+ assert bounds["width"] >= 99 and bounds["height"] >= 38
await slider.click(position={"x": bounds["width"] / 2, "y": bounds["height"] / 2})
assert .3 < await page.evaluate("P.audio.volume") < .7
+ await page.set_viewport_size({"width": 390, "height": 844})
+ await page.mouse.move(0, 0)
+ await slider.evaluate("e => e.blur()")
+ await button.tap()
+ assert await slider.evaluate("e => e === document.activeElement && e.getBoundingClientRect().width > 80"), "touch opens the slider"
+ await slider.press("Escape")
+ await page.mouse.move(0, 0)
+ await page.wait_for_function("document.querySelector('#volume').getBoundingClientRect().width === 0")
assert not errors, errors
- print(f"PASS {path}: real audio, mute/mid/full, pause/resume, steps/restart, keyboard, narrow layout")
+ print(f"PASS {path}: hover/focus/touch, real audio, mute/mid/full, pause/resume, steps/restart, keyboard, narrow layout")
await page.close()
diff --git a/site/elementary-algebra/lib/engine.css b/site/elementary-algebra/lib/engine.css
index 97169ad..ed244f1 100644
--- a/site/elementary-algebra/lib/engine.css
+++ b/site/elementary-algebra/lib/engine.css
@@ -106,12 +106,15 @@ button[hidden] { display: none; }
.seg.ask { background: #2d4a57; }
.seg.ask i { background: var(--quiz); }
.step { width: 300px; flex: none; color: var(--dim); font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
-.volume { display: flex; align-items: center; gap: 10px; flex: none; height: 44px; padding: 0 12px;
- border: 1px solid var(--edge); border-radius: 999px; background: var(--panel); color: var(--chalk); }
+.volume { display: flex; align-items: center; flex: none; width: 44px; height: 44px; overflow: hidden;
+ border: 1px solid var(--edge); border-radius: 999px; background: var(--panel); color: var(--chalk); transition: width .18s ease; }
+.volume .icon { width: 42px; height: 42px; border: 0; background: transparent; }
+.volume:hover, .volume:focus-within { width: 166px; gap: 10px; padding-right: 12px; }
.volume:hover { background: #2b3f36; border-color: var(--faint); }
-.volume:has(input:focus-visible) { outline: 2px solid var(--task); outline-offset: 3px; }
-.volume svg { width: 20px; height: 20px; flex: none; }
-.volume input { appearance: none; width: 100px; height: 42px; margin: 0; background: transparent; cursor: pointer; }
+.volume:has(:focus-visible) { outline: 2px solid var(--task); outline-offset: 3px; }
+.volume .icon:focus-visible { outline: none; }
+.volume input { appearance: none; flex: none; width: 0; height: 42px; margin: 0; opacity: 0; background: transparent; cursor: pointer; }
+.volume:hover input, .volume:focus-within input { width: 100px; opacity: 1; }
.volume input:focus-visible { outline: none; }
.volume input::-webkit-slider-runnable-track { height: 4px; border-radius: 999px;
background: linear-gradient(to right, var(--chalk) var(--volume, 100%), var(--faint) var(--volume, 100%)); }
@@ -126,7 +129,11 @@ button[hidden] { display: none; }
transform: scale(calc(1 / var(--k))); transform-origin: left top; border-radius: 0 0 12px 12px; }
#bar .icon { width: 36px; height: 40px; }
.step { display: none; }
- .segs, .volume { order: 1; }
+ .volume { width: 36px; height: 40px; }
+ #bar .volume .icon { width: 34px; height: 38px; }
+ .volume:hover, .volume:focus-within { width: 158px; }
+ .volume input { height: 38px; }
+ .segs { order: 1; }
.segs { min-width: 80px; margin: 0; }
}
.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: rgba(15, 22, 19, .85); color: var(--dim); font-size: 19px; }
@@ -217,7 +224,7 @@ svg.m { display: inline-block; overflow: visible; }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes hop { 40% { transform: translateY(-12px) rotate(4deg); } }
@keyframes wobble { 25% { transform: rotate(-8deg); } 75% { transform: rotate(6deg); } }
-@media (prefers-reduced-motion: reduce) { .card, .fb, .opt, .grid .mark, .mascot * { animation: none !important; } }
+@media (prefers-reduced-motion: reduce) { .volume { transition: none; } .card, .fb, .opt, .grid .mark, .mascot * { animation: none !important; } }
a.icon { text-decoration: none; }
a.btn { text-decoration: none; display: inline-block; }
diff --git a/site/elementary-algebra/lib/engine.js b/site/elementary-algebra/lib/engine.js
index f6dcb2e..e6ae7e8 100644
--- a/site/elementary-algebra/lib/engine.js
+++ b/site/elementary-algebra/lib/engine.js
@@ -72,13 +72,15 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
</button>
<div class="segs" id="segs"></div>
<div class="step" id="stepName"></div>
- <label class="volume" for="volume" title="Volume (0 = muted)">
- <svg viewBox="0 0 24 24" aria-hidden="true">
- <path d="M3 9v6h4l5 4V5L7 9z" fill="currentColor"/>
- <path d="M16 8a6 6 0 0 1 0 8m3-11a10 10 0 0 1 0 14" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>
- </svg>
+ <div class="volume">
+ <button class="icon" id="bVolume" aria-label="Adjust volume" aria-controls="volume" title="Volume (0 = muted)">
+ <svg viewBox="0 0 24 24" aria-hidden="true">
+ <path d="M3 9v6h4l5 4V5L7 9z" fill="currentColor"/>
+ <path d="M16 8a6 6 0 0 1 0 8m3-11a10 10 0 0 1 0 14" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>
+ </svg>
+ </button>
<input id="volume" type="range" min="0" max="1" step="0.05" value="1" aria-label="Volume">
- </label>
+ </div>
<button class="icon txt" id="bHelp" aria-label="Keyboard shortcuts (?)" title="Keyboard shortcuts (?)">?</button>
<button class="icon cc" id="bCC" aria-pressed="false" aria-label="Captions (C)" title="Captions (C)">CC</button>
<button class="icon" id="bFull" aria-label="Full screen">
@@ -1572,6 +1574,7 @@ $('stage').addEventListener('click', e => {
if (!b.ask && !e.target.closest('.qlayer')) togglePlay();
});
$('bPlay').onclick = togglePlay;
+$('bVolume').onclick = () => $('volume').focus();
$('volume').oninput = () => {
$('volume').style.setProperty('--volume', +$('volume').value * 100 + '%');
if (P.audio) P.audio.volume = +$('volume').value;
diff --git a/site/math-notebook/lib/engine.css b/site/math-notebook/lib/engine.css
index 97169ad..ed244f1 100644
--- a/site/math-notebook/lib/engine.css
+++ b/site/math-notebook/lib/engine.css
@@ -106,12 +106,15 @@ button[hidden] { display: none; }
.seg.ask { background: #2d4a57; }
.seg.ask i { background: var(--quiz); }
.step { width: 300px; flex: none; color: var(--dim); font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
-.volume { display: flex; align-items: center; gap: 10px; flex: none; height: 44px; padding: 0 12px;
- border: 1px solid var(--edge); border-radius: 999px; background: var(--panel); color: var(--chalk); }
+.volume { display: flex; align-items: center; flex: none; width: 44px; height: 44px; overflow: hidden;
+ border: 1px solid var(--edge); border-radius: 999px; background: var(--panel); color: var(--chalk); transition: width .18s ease; }
+.volume .icon { width: 42px; height: 42px; border: 0; background: transparent; }
+.volume:hover, .volume:focus-within { width: 166px; gap: 10px; padding-right: 12px; }
.volume:hover { background: #2b3f36; border-color: var(--faint); }
-.volume:has(input:focus-visible) { outline: 2px solid var(--task); outline-offset: 3px; }
-.volume svg { width: 20px; height: 20px; flex: none; }
-.volume input { appearance: none; width: 100px; height: 42px; margin: 0; background: transparent; cursor: pointer; }
+.volume:has(:focus-visible) { outline: 2px solid var(--task); outline-offset: 3px; }
+.volume .icon:focus-visible { outline: none; }
+.volume input { appearance: none; flex: none; width: 0; height: 42px; margin: 0; opacity: 0; background: transparent; cursor: pointer; }
+.volume:hover input, .volume:focus-within input { width: 100px; opacity: 1; }
.volume input:focus-visible { outline: none; }
.volume input::-webkit-slider-runnable-track { height: 4px; border-radius: 999px;
background: linear-gradient(to right, var(--chalk) var(--volume, 100%), var(--faint) var(--volume, 100%)); }
@@ -126,7 +129,11 @@ button[hidden] { display: none; }
transform: scale(calc(1 / var(--k))); transform-origin: left top; border-radius: 0 0 12px 12px; }
#bar .icon { width: 36px; height: 40px; }
.step { display: none; }
- .segs, .volume { order: 1; }
+ .volume { width: 36px; height: 40px; }
+ #bar .volume .icon { width: 34px; height: 38px; }
+ .volume:hover, .volume:focus-within { width: 158px; }
+ .volume input { height: 38px; }
+ .segs { order: 1; }
.segs { min-width: 80px; margin: 0; }
}
.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: rgba(15, 22, 19, .85); color: var(--dim); font-size: 19px; }
@@ -217,7 +224,7 @@ svg.m { display: inline-block; overflow: visible; }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes hop { 40% { transform: translateY(-12px) rotate(4deg); } }
@keyframes wobble { 25% { transform: rotate(-8deg); } 75% { transform: rotate(6deg); } }
-@media (prefers-reduced-motion: reduce) { .card, .fb, .opt, .grid .mark, .mascot * { animation: none !important; } }
+@media (prefers-reduced-motion: reduce) { .volume { transition: none; } .card, .fb, .opt, .grid .mark, .mascot * { animation: none !important; } }
a.icon { text-decoration: none; }
a.btn { text-decoration: none; display: inline-block; }
diff --git a/site/math-notebook/lib/engine.js b/site/math-notebook/lib/engine.js
index 9328b1a..8ecac77 100644
--- a/site/math-notebook/lib/engine.js
+++ b/site/math-notebook/lib/engine.js
@@ -72,13 +72,15 @@ document.body.insertAdjacentHTML('afterbegin', `<div id="frame">
</button>
<div class="segs" id="segs"></div>
<div class="step" id="stepName"></div>
- <label class="volume" for="volume" title="Volume (0 = muted)">
- <svg viewBox="0 0 24 24" aria-hidden="true">
- <path d="M3 9v6h4l5 4V5L7 9z" fill="currentColor"/>
- <path d="M16 8a6 6 0 0 1 0 8m3-11a10 10 0 0 1 0 14" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>
- </svg>
+ <div class="volume">
+ <button class="icon" id="bVolume" aria-label="Adjust volume" aria-controls="volume" title="Volume (0 = muted)">
+ <svg viewBox="0 0 24 24" aria-hidden="true">
+ <path d="M3 9v6h4l5 4V5L7 9z" fill="currentColor"/>
+ <path d="M16 8a6 6 0 0 1 0 8m3-11a10 10 0 0 1 0 14" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>
+ </svg>
+ </button>
<input id="volume" type="range" min="0" max="1" step="0.05" value="1" aria-label="Volume">
- </label>
+ </div>
<button class="icon txt" id="bHelp" aria-label="Keyboard shortcuts (?)" title="Keyboard shortcuts (?)">?</button>
<button class="icon cc" id="bCC" aria-pressed="false" aria-label="Captions (C)" title="Captions (C)">CC</button>
<button class="icon" id="bFull" aria-label="Full screen">
@@ -1577,6 +1579,7 @@ $('stage').addEventListener('click', e => {
if (!b.ask && !e.target.closest('.qlayer')) togglePlay();
});
$('bPlay').onclick = togglePlay;
+$('bVolume').onclick = () => $('volume').focus();
$('volume').oninput = () => {
$('volume').style.setProperty('--volume', +$('volume').value * 100 + '%');
if (P.audio) P.audio.volume = +$('volume').value;