Dot-grid crafts
Two dot-grid stages: a hold-to-confirm button that fills while pressed and springs back, and a magnetic dock whose icons swell near the pointer.
Part of the style
Dot Grid Workbench
7 parts that belong together, with their tokens, type and rules.
https://kitbash.me/components/dot-grid-workbench/crafts/figma.html?palette=bcfbd17fceb87e6e
Use the Figma MCP server (https://mcp.figma.com/mcp). Download https://kitbash.me/components/dot-grid-workbench/crafts/figma.html?palette=bcfbd17fceb87e6e and pass that whole HTML document to the html_to_figma tool, so the part "Dot-grid crafts" lands as editable layers in my open Figma file. Fonts come from Google Fonts: if a face is missing in Figma, pick the closest one.
Code
<style>
/* Goes after the pack's base.css */
:root {
--paper: #f0f0f0;
--surface: #fafafa;
--glass: rgba(240, 240, 240, 0.72);
--ink: #000000;
--ink-soft: #000000;
--ink-faint: #292929;
--rule: #afafaf;
--rule-solid: #d2d2d2;
--dot: #a5a5a5;
--stage: #e6e6e6;
--night: #989898;
--on-night: #d6d6d6;
--icon-gloss: rgba(250, 250, 250, 0.28);
--accent: #913066;
--accent-halo: rgba(145, 48, 102, 0.18);
--icon-2b: #854666;
--icon-3a: #a85f83;
--icon-3b: #812d5b;
--icon-1a: #947786;
--icon-1b: #715062;
--danger: #725163;
--icon-6a: #9e808f;
--icon-6b: #795d6c;
--glow: rgba(148, 119, 134, 0.35);
--icon-2a: #8a6378;
--icon-4a: #913066;
--icon-4b: #580939;
--icon-5a: #947786;
--icon-5b: #684c5a;
}
</style>
<section class="crafts">
<div class="crafts__col">
<div class="crafts__head">
<h2 class="crafts__title">Crafts</h2>
<a class="crafts__more" href="#">See all <span class="crafts__arrow" aria-hidden="true">→</span></a>
</div>
<div class="crafts__grid">
<figure class="crafts__item">
<div class="crafts__stage">
<button class="crafts__hold" type="button" data-done="Take deleted">
<span class="crafts__fill" aria-hidden="true"></span>
<span class="crafts__label">Hold to delete take</span>
</button>
</div>
<figcaption class="crafts__caption">
<strong class="crafts__name">Hold to Confirm</strong>
<span class="crafts__note">A destructive action that asks for a steady press instead of a dialog. Let go early and it drains back.</span>
</figcaption>
</figure>
<figure class="crafts__item">
<div class="crafts__stage crafts__stage--dock">
<div class="crafts__dock" role="toolbar" aria-label="Tools">
<button class="crafts__tool" type="button" aria-label="Record" style="--from: var(--icon-1a); --to: var(--icon-1b)"><svg viewBox="0 0 20 20" width="18" height="18" aria-hidden="true"><circle cx="10" cy="10" r="5" fill="currentColor"/></svg></button>
<button class="crafts__tool" type="button" aria-label="Loop" style="--from: var(--icon-2a); --to: var(--icon-2b)"><svg viewBox="0 0 20 20" width="18" height="18" aria-hidden="true"><path d="M5 8a4 4 0 0 1 4-3h4M15 12a4 4 0 0 1-4 3H7M11 3l2 2-2 2M9 17l-2-2 2-2" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
<button class="crafts__tool" type="button" aria-label="Mix" style="--from: var(--icon-3a); --to: var(--icon-3b)"><svg viewBox="0 0 20 20" width="18" height="18" aria-hidden="true"><path d="M5 4v12M10 4v12M15 4v12" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><rect x="3" y="11" width="4" height="2.4" rx="1" fill="currentColor"/><rect x="8" y="6" width="4" height="2.4" rx="1" fill="currentColor"/><rect x="13" y="9" width="4" height="2.4" rx="1" fill="currentColor"/></svg></button>
<button class="crafts__tool" type="button" aria-label="Notes" style="--from: var(--icon-4a); --to: var(--icon-4b)"><svg viewBox="0 0 20 20" width="18" height="18" aria-hidden="true"><path d="M8 14V5l7-2v9" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/><circle cx="6" cy="14" r="2.2" fill="currentColor"/><circle cx="13" cy="12" r="2.2" fill="currentColor"/></svg></button>
<button class="crafts__tool" type="button" aria-label="Effects" style="--from: var(--icon-5a); --to: var(--icon-5b)"><svg viewBox="0 0 20 20" width="18" height="18" aria-hidden="true"><path d="M10 3l1.8 4.6L16.5 9l-4.7 1.6L10 15l-1.8-4.4L3.5 9l4.7-1.4Z" fill="currentColor"/></svg></button>
<button class="crafts__tool" type="button" aria-label="Export" style="--from: var(--icon-6a); --to: var(--icon-6b)"><svg viewBox="0 0 20 20" width="18" height="18" aria-hidden="true"><path d="M10 13V4M6.5 7.5 10 4l3.5 3.5M4 13v3h12v-3" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
</div>
</div>
<figcaption class="crafts__caption">
<strong class="crafts__name">Magnetic Dock</strong>
<span class="crafts__note">Icons swell and lift by their distance to the pointer, so the one you aim at is already waiting.</span>
</figcaption>
</figure>
</div>
</div>
</section>
<style>
.crafts__col {
max-width: calc(var(--column) + 2 * var(--edge) + 2 * var(--line));
margin: 0 auto;
padding: var(--space-xl) var(--edge) var(--section);
border-inline: var(--line) dashed var(--rule);
}
.crafts__head {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: var(--gap);
margin-bottom: var(--space-s);
}
.crafts__title {
margin: 0;
color: var(--ink);
font-family: var(--font-display);
font-size: var(--text-l);
font-weight: 600;
line-height: var(--leading-tight);
letter-spacing: var(--tracking-head);
}
.crafts__more {
display: inline-flex;
align-items: center;
justify-content: flex-end;
min-width: var(--tap);
gap: 4px;
min-height: var(--tap);
color: var(--ink-soft);
font-size: var(--text-s);
text-decoration: none;
transition: color var(--quick) var(--ease);
}
.crafts__more:hover { color: var(--ink); }
.crafts__more:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.crafts__arrow { display: inline-block; transition: transform var(--spring-time) var(--ease-out); }
.crafts__more:hover .crafts__arrow { transform: translateX(3px); }
.crafts__grid { display: grid; gap: var(--space-l); }
.crafts__item { margin: 0; }
.crafts__stage {
display: grid;
place-items: center;
height: 190px;
border: var(--line) solid var(--rule-solid);
border-radius: var(--radius-l);
background-color: var(--stage);
background-image: radial-gradient(circle, var(--dot) 1px, transparent 1.3px);
background-size: var(--dot-gap) var(--dot-gap);
background-position: calc(var(--dot-gap) / 2) calc(var(--dot-gap) / 2);
overflow: hidden;
}
.crafts__caption { display: grid; gap: 2px; margin-top: var(--space-m); }
.crafts__name { color: var(--ink); font-size: var(--text-base); font-weight: 500; }
.crafts__note { font-size: var(--text-m); line-height: 1.6; }
/* Hold to confirm */
.crafts__hold {
position: relative;
min-width: 190px;
min-height: var(--tap);
padding: 0 var(--space-l);
overflow: hidden;
border: var(--line) solid var(--rule-solid);
border-radius: var(--radius-s);
background: var(--surface);
box-shadow: var(--shadow);
color: var(--ink);
font: 500 var(--text-m) / 1 var(--font-body);
letter-spacing: var(--tracking);
cursor: pointer;
user-select: none;
-webkit-user-select: none;
touch-action: none;
transition: transform var(--spring-time) var(--ease-out);
}
.crafts__hold:active { transform: scale(0.97); }
.crafts__hold:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.crafts__fill {
position: absolute;
inset: 0;
background: var(--danger);
transform: scaleX(0);
transform-origin: left;
transition: transform 400ms var(--ease-out);
}
.crafts__label { position: relative; display: inline-block; transition: color var(--quick) var(--ease); }
.crafts__hold.is-holding .crafts__fill { transform: scaleX(1); transition: transform var(--hold-time) linear; }
.crafts__hold.is-holding .crafts__label,
.crafts__hold.is-done .crafts__label { color: var(--surface); }
.crafts__hold.is-done .crafts__fill { transform: scaleX(1); transition: none; }
.crafts__hold.is-done .crafts__label { animation: crafts-pop 320ms var(--ease-out); }
@keyframes crafts-pop {
0% { transform: scale(0.8); opacity: 0; }
60% { transform: scale(1.06); opacity: 1; }
100% { transform: none; }
}
/* Magnetic dock */
.crafts__stage--dock { place-items: end center; padding-bottom: 28px; }
.crafts__dock {
display: flex;
align-items: flex-end;
gap: 8px;
padding: 8px;
border: var(--line) solid var(--rule-solid);
border-radius: var(--radius-m);
background: var(--surface);
box-shadow: var(--shadow);
}
.crafts__tool {
position: relative;
display: grid;
place-items: center;
width: var(--tap);
height: var(--tap);
padding: 0;
overflow: hidden;
border: 0;
border-radius: var(--radius-s);
background: linear-gradient(180deg, var(--from), var(--to));
box-shadow: var(--shadow-icon);
color: var(--surface);
cursor: pointer;
transform: translateY(calc(var(--lift, 0) * -10px)) scale(calc(1 + var(--lift, 0) * 0.6));
transform-origin: 50% 100%;
transition: transform var(--spring-time) var(--ease-out);
}
.crafts__tool::after {
content: "";
position: absolute;
inset: 0 0 50%;
background: linear-gradient(180deg, var(--icon-gloss), transparent);
}
.crafts__tool svg { position: relative; z-index: 1; }
.crafts__tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; --lift: 0.5; }
@media (max-width: 720px) {
.crafts__col { border-inline: 0; padding: var(--space-xl) var(--edge-phone); }
}
@media (max-width: 400px) {
.crafts__dock { gap: 4px; padding: 6px; }
}
@media (prefers-reduced-motion: reduce) {
.crafts__tool { transform: none; }
.crafts__hold.is-done .crafts__label { animation: none; }
}
</style>
<script>
(() => {
const calm = matchMedia('(prefers-reduced-motion: reduce)');
for (const root of document.querySelectorAll('.crafts')) {
for (const hold of root.querySelectorAll('.crafts__hold')) {
const label = hold.querySelector('.crafts__label');
const idle = label.textContent;
let timer = 0;
const start = () => {
if (hold.classList.contains('is-done')) return;
hold.classList.add('is-holding');
const time = parseFloat(getComputedStyle(hold).getPropertyValue('--hold-time')) || 1200;
clearTimeout(timer);
timer = setTimeout(finish, calm.matches ? 0 : time);
};
const stop = () => {
clearTimeout(timer);
hold.classList.remove('is-holding');
};
const finish = () => {
hold.classList.remove('is-holding');
hold.classList.add('is-done');
label.textContent = hold.dataset.done;
setTimeout(() => {
hold.classList.remove('is-done');
label.textContent = idle;
}, 1600);
};
hold.addEventListener('pointerdown', start);
hold.addEventListener('pointerup', stop);
hold.addEventListener('pointerleave', stop);
hold.addEventListener('pointercancel', stop);
hold.addEventListener('keydown', (event) => {
if ((event.key === ' ' || event.key === 'Enter') && !event.repeat) { event.preventDefault(); start(); }
});
hold.addEventListener('keyup', (event) => {
if (event.key === ' ' || event.key === 'Enter') stop();
});
}
for (const stage of root.querySelectorAll('.crafts__stage--dock')) {
const tools = [...stage.querySelectorAll('.crafts__tool')];
const reach = 120;
stage.addEventListener('pointermove', (event) => {
if (calm.matches || event.pointerType === 'touch') return;
for (const tool of tools) {
const box = tool.getBoundingClientRect();
const distance = Math.abs(event.clientX - (box.left + box.width / 2));
tool.style.setProperty('--lift', Math.max(0, 1 - distance / reach).toFixed(3));
}
});
stage.addEventListener('pointerleave', () => {
for (const tool of tools) tool.style.setProperty('--lift', 0);
});
}
}
})();
</script>