Rolling label button
Keep project names readable; use a small motion cue for interaction. Touch selects directly and page scrolling remains native.
See the product image move toward the cart as its quantity updates.
Preparing preview
Keep project names readable; use a small motion cue for interaction. Touch selects directly and page scrolling remains native.
<section class="fx pe-rolling" data-effect="rolling-label" lang="en" aria-label="Rolling label buttons"><p class="fx__eyebrow">REAL WEBSITE SCREENS</p><h3>Rolling labels for project links</h3><p class="fx__lede">Focus, hover over or tap a project button to see its label roll and its screen change.</p><div class="pe-roll-layout"><div class="pe-roll-actions"><button type="button" class="pe-project" data-project="0" aria-pressed="true"><span class="pe-name-wrap"><span class="pe-name">SHOKZ</span><span class="pe-marquee" aria-hidden="true"><span class="pe-marquee__inner"><span>SHOKZ</span><span>SHOKZ</span><span>SHOKZ</span><span>SHOKZ</span></span></span><span class="pe-sub">UK website · project screen</span></span></button><button type="button" class="pe-project" data-project="1" aria-pressed="false"><span class="pe-name-wrap"><span class="pe-name">Termino</span><span class="pe-marquee" aria-hidden="true"><span class="pe-marquee__inner"><span>Termino</span><span>Termino</span><span>Termino</span><span>Termino</span></span></span><span class="pe-sub">Aluminium cabinetry website · project screen</span></span></button><button type="button" class="pe-project" data-project="2" aria-pressed="false"><span class="pe-name-wrap"><span class="pe-name">INIU</span><span class="pe-marquee" aria-hidden="true"><span class="pe-marquee__inner"><span>INIU</span><span>INIU</span><span>INIU</span><span>INIU</span></span></span><span class="pe-sub">Charging products website · project screen</span></span></button><button type="button" class="pe-project" data-project="3" aria-pressed="false"><span class="pe-name-wrap"><span class="pe-name">FMS</span><span class="pe-marquee" aria-hidden="true"><span class="pe-marquee__inner"><span>FMS</span><span>FMS</span><span>FMS</span><span>FMS</span></span></span><span class="pe-sub">Project website · screenshot</span></span><span class="pe-marquee" aria-hidden="true"><span class="pe-marquee__inner"><span>FMS</span><span>FMS</span><span>FMS</span><span>FMS</span></span></span></button></div><div class="pe-roll-preview"><img data-preview="0" src="https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/shokz-openfit-preview.webp" width="900" height="450" alt="SHOKZ UK website screenshot" ><img data-preview="1" src="https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/termino-preview.webp" width="900" height="450" alt="Termino cabinetry website screenshot" hidden><img data-preview="2" src="https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/iniu-preview.webp" width="900" height="450" alt="INIU charging products website screenshot" hidden><div class="pe-caption">Real website screenshot · <span data-caption>SHOKZ</span><img data-preview="3" src="https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/fms-preview.webp" width="900" height="450" alt="FMS website screenshot" hidden></div></div></div><span class="fx__status" data-status role="status" aria-live="polite"></span></section>/*
* MIT License
*
* Copyright (c) 2009 - 2021 [Codrops](https://tympanus.net/codrops)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* Source: https://github.com/codrops/ButtonHoverStyles
*/
.fx{box-sizing:border-box;font-family:inherit;color:#172523;background:#f3f5ef;border-radius:18px;padding:clamp(18px,4vw,38px);overflow:hidden}.fx *{box-sizing:border-box}.fx button,.fx input{font:inherit}.fx h3{font-size:clamp(24px,3vw,34px);line-height:1.2;margin:8px 0}.fx p{line-height:1.6}.fx__eyebrow{font-size:10px;letter-spacing:.14em;font-weight:700}.fx__lede{font-size:13px;color:#536159;max-width:620px}.fx__control{border:1px solid #c4cec1;border-radius:999px;background:transparent;padding:9px 14px;cursor:pointer;color:inherit}.fx__control:focus-visible,.fx button:focus-visible,.fx input:focus-visible{outline:3px solid #356940;outline-offset:3px}.fx__controls{display:flex;gap:8px;flex-wrap:wrap;margin-top:16px}.fx__status{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.fx img{max-width:100%;display:block}.fx [hidden]{display:none!important}@media(prefers-reduced-motion:reduce){.fx *{scroll-behavior:auto!important;animation:none!important;transition:none!important}}
.pe-roll-layout,.pe-mag-layout,.pe-menu-panel{display:grid;grid-template-columns:minmax(190px,.75fr) minmax(0,1.25fr);gap:22px;align-items:center}.pe-roll-actions,.pe-mag-list,.pe-menu-items{display:grid;border-top:1px solid #cfd7ca}.pe-project{position:relative;display:flex;align-items:center;justify-content:space-between;gap:12px;text-align:left;width:100%;border:0;border-bottom:1px solid #cfd7ca;background:transparent;padding:15px 10px;color:inherit;cursor:pointer}.pe-project[aria-pressed=true]{background:#e5eadf}.pe-name{font-size:clamp(17px,2vw,24px);font-weight:700}.pe-sub{font-size:10px;color:#536159}.pe-roll-actions .pe-project{overflow:hidden}.pe-roll-actions .pe-name{display:inline-block;transition:transform .24s cubic-bezier(.2,.8,.2,1)}.pe-roll-actions .pe-project:hover .pe-name,.pe-roll-actions .pe-project:focus-visible .pe-name,.pe-roll-actions .pe-project[aria-pressed=true] .pe-name{transform:translateY(-2px)}.pe-roll-preview,.pe-mag-card,.pe-menu-image{min-width:0;border:1px solid #c4cec1;border-radius:12px;background:#fff;overflow:hidden}.pe-roll-preview img,.pe-mag-image img,.pe-menu-image img{width:100%;aspect-ratio:2/1;object-fit:contain}.pe-caption{font-size:10px;color:#536159;padding:10px 14px;margin:0}.pe-caption span{font-weight:700;color:#172523}
.fx.is-paused .pe-roll-actions .pe-name{transition:none!important;transform:none!important}.fx.is-paused .pe-magnet,.fx.is-paused .pe-magnet-label{transition:none!important;transform:none!important}
/* Adapted from ButtonHoverStyles css/base.css .button--atlas marquee (MIT). */
.pe-roll-actions .pe-project{position:relative;overflow:hidden}.pe-roll-actions .pe-name{display:inline-block;position:relative;transition:opacity .15s}.pe-marquee{position:absolute;left:0;top:0;width:100%;height:100%;display:flex;align-items:center;overflow:hidden;pointer-events:none;opacity:0}.pe-marquee span{white-space:nowrap;font-weight:700;font-size:20px;padding:.3rem .8rem}.pe-roll-actions .pe-project:hover .pe-name,.pe-roll-actions .pe-project:focus-visible .pe-name,.pe-roll-actions .pe-project:hover .pe-marquee,.pe-roll-actions .pe-project:focus-visible .pe-marquee,.pe-roll-actions .pe-project:hover .pe-marquee span,.pe-roll-actions .pe-project:focus-visible .pe-marquee span,.pe-roll-actions .pe-project[aria-pressed=true] .pe-marquee span{animation:pe-marquee 1s linear infinite}.pe-marquee span{--move-start:calc(-25% + .25rem);--move-end:calc(-50% + .25rem);transform:translate3d(var(--move-start),0,0)}@keyframes pe-marquee{to{transform:translate3d(var(--move-end),0,0)}}@media(prefers-reduced-motion:reduce){.pe-roll-actions .pe-project:hover .pe-name,.pe-roll-actions .pe-project:focus-visible .pe-name,.pe-roll-actions .pe-project[aria-pressed=true] .pe-name{opacity:1}.pe-marquee{display:none!important}.pe-roll-actions .pe-project:hover .pe-marquee span,.pe-roll-actions .pe-project:focus-visible .pe-marquee span{animation:none!important}}
/* Directly adapts Codrops ButtonHoverStyles css/base.css .button--atlas / .marquee / .marquee__inner. */
.pe-roll-actions .pe-project{position:relative;overflow:hidden}.pe-roll-actions .pe-name{display:inline-block;position:relative;transition:opacity .15s}.pe-marquee{position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;opacity:0}.pe-marquee__inner{width:max-content;display:flex;align-items:center;position:relative;--offset:1rem;--move-initial:calc(-25% + var(--offset));--move-final:calc(-50% + var(--offset));transform:translate3d(var(--move-initial),0,0);animation:pe-marquee 1s linear infinite;animation-play-state:paused;opacity:0}.pe-marquee span{white-space:nowrap;font-weight:700;font-size:20px;padding:.4rem .8rem}.pe-roll-actions .pe-project:hover .pe-name,.pe-roll-actions .pe-project:focus-visible .pe-name,.pe-roll-actions .pe-project:hover .pe-marquee,.pe-roll-actions .pe-project:focus-visible .pe-marquee,.pe-roll-actions .pe-project:hover .pe-marquee__inner,.pe-roll-actions .pe-project:focus-visible .pe-marquee__inner,@keyframes pe-marquee{0%{transform:translate3d(var(--move-initial),0,0)}100%{transform:translate3d(var(--move-final),0,0)}}.fx.is-paused .pe-marquee__inner{animation-play-state:paused!important;transform:translate3d(0,0,0)}@media(prefers-reduced-motion:reduce){.pe-roll-actions .pe-project:hover .pe-name,.pe-roll-actions .pe-project:focus-visible .pe-name,.pe-roll-actions .pe-project[aria-pressed=true] .pe-name{opacity:1}.pe-marquee{display:none!important}.pe-marquee__inner{animation:none!important}}
.fx.is-paused *, .fx.is-reduced-motion *{scroll-behavior:auto;animation-play-state:paused!important}
.pe-roll-preview img,.pe-mag-image img,.pe-menu-image img,.pe-audit-image img{display:block;width:100%;height:auto;max-height:none;aspect-ratio:2/1;object-fit:contain}
@media(max-width:680px){.pe-roll-layout,.pe-mag-layout{grid-template-columns:minmax(0,1fr);gap:16px}.pe-roll-preview,.pe-mag-card,.pe-menu-image,.pe-audit-image{width:100%;min-width:0}.pe-roll-preview img,.pe-mag-image img,.pe-menu-image img,.pe-audit-image img{height:auto;aspect-ratio:2/1;object-fit:contain}.pe-roll-actions,.pe-mag-list{grid-template-columns:minmax(0,1fr)}.pe-roll-actions .pe-project,.pe-mag-list .pe-project{min-height:60px}}
/* Keep the Codrops marquee rail inside the name slot, never across the helper label. */
.pe-roll-actions .pe-project{display:flex;min-width:0;gap:10px}.pe-name-wrap{position:relative;display:block;flex:0 0 clamp(66px,42%,110px);width:clamp(66px,42%,110px);height:1.5em;min-width:0;overflow:hidden;white-space:nowrap}.pe-name-wrap .pe-name{display:block;opacity:1!important;transition:opacity .15s}.pe-name-wrap .pe-marquee{position:absolute;inset:0;width:100%;height:100%;overflow:hidden;opacity:0;pointer-events:none}.pe-marquee__inner{width:max-content;display:flex;align-items:center;gap:0;white-space:nowrap}.pe-marquee__inner span{flex:none;padding:0 .35rem}.pe-sub{flex:1 1 auto;min-width:0;text-align:right;white-space:normal;line-height:1.35;overflow-wrap:anywhere}.pe-roll-actions .pe-project:hover .pe-name-wrap .pe-name,.pe-roll-actions .pe-project:focus-visible .pe-name-wrap .pe-name{opacity:0!important}.pe-roll-actions .pe-project:hover .pe-name-wrap .pe-marquee,.pe-roll-actions .pe-project:focus-visible .pe-name-wrap .pe-marquee{opacity:1}.pe-roll-actions .pe-project:hover .pe-name-wrap .pe-marquee__inner,.pe-roll-actions .pe-project:focus-visible .pe-name-wrap .pe-marquee__inner{animation-play-state:running;opacity:1}.fx.is-paused .pe-name-wrap .pe-name{opacity:1!important}.fx.is-paused .pe-name-wrap .pe-marquee{display:none!important}.fx.is-paused .pe-name-wrap .pe-marquee__inner{animation:none!important;transform:none!important}@media(max-width:680px){.pe-name-wrap{flex-basis:clamp(66px,36%,110px);width:clamp(66px,36%,110px)}.pe-sub{font-size:10px}}
.fx.is-reduced-motion .pe-name-wrap .pe-name{opacity:1!important}.fx.is-reduced-motion .pe-name-wrap .pe-marquee{display:none!important}.fx.is-reduced-motion .pe-magnet,.fx.is-reduced-motion .pe-magnet-label{transform:none!important;transition:none!important}
/* Shared visual primitives are duplicated intentionally so every effect runs alone in its iframe. */
.pe-project{box-sizing:border-box;position:relative;display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;min-width:0;min-height:60px;padding:13px 10px;border:0;border-bottom:1px solid #cfd7ca;background:transparent;color:#172523;text-align:left;font:inherit;cursor:pointer}.pe-project[aria-pressed=true]{background:#e5eadf}.pe-project:focus-visible{outline:3px solid #356940;outline-offset:-3px}.pe-name{display:block;min-width:0;font-size:clamp(16px,2vw,23px);line-height:1.2;font-weight:700;letter-spacing:-.02em}.pe-sub{display:block;min-width:0;font-size:10px;line-height:1.45;color:#536159}.pe-caption{margin:0;padding:11px 14px;font-size:10px;line-height:1.45;color:#536159}.pe-caption span{font-weight:700;color:#172523}.pe-mag-layout{display:grid;grid-template-columns:minmax(190px,.75fr) minmax(0,1.25fr);gap:22px;align-items:center}.pe-mag-list{display:grid;border-top:1px solid #cfd7ca}.pe-mag-card{min-width:0;overflow:hidden;border:1px solid #c4cec1;border-radius:12px;background:#fff}.pe-mag-image{min-width:0;overflow:hidden}.pe-mag-image img{display:block;width:100%;height:auto;aspect-ratio:2/1;object-fit:contain}.pe-menu-panel{min-width:0}.pe-menu-items{min-width:0}.pe-menu-image img,.pe-roll-preview img,.pe-audit-image img{display:block;width:100%;height:auto;aspect-ratio:2/1;object-fit:contain}@media(max-width:680px){.pe-mag-layout{grid-template-columns:minmax(0,1fr);gap:16px}.pe-mag-list{grid-template-columns:minmax(0,1fr)}.pe-mag-card{width:100%;min-width:0}.pe-project{gap:8px;padding:12px 8px}.pe-sub{font-size:10px}}
@media(max-width:680px){.pe-roll-layout{grid-template-columns:minmax(0,1fr)}.pe-roll-actions{grid-template-columns:minmax(0,1fr)}}
/*
* MIT License
*
* Copyright (c) 2009 - 2021 [Codrops](https://tympanus.net/codrops)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* Source: https://github.com/codrops/ButtonHoverStyles
*/
export function mountEffect(root,{reducedMotion=false}={}){
const controller=new AbortController(), signal=controller.signal;
const buttons=[...root.querySelectorAll('[data-project]')], images=[...root.querySelectorAll('[data-preview]')];
const caption=root.querySelector('[data-caption]'), status=root.querySelector('[data-status]'), motion=root.querySelector('[data-motion]');
const toggle=root.querySelector('.pe-menu-toggle'), panel=root.querySelector('.pe-menu-panel');
const controls=[...root.querySelectorAll('button,input')];
const original={className:root.className,style:root.getAttribute('style'),buttons:buttons.map(b=>[b.className,b.getAttribute('aria-pressed')]),images:images.map(i=>[i.className,i.hidden]),caption:caption?.textContent,status:status?.textContent,controls:controls.map(c=>[c,c.value,c.innerHTML,c.getAttribute('aria-expanded'),c.getAttribute('aria-pressed')]),panelHidden:panel?.hidden};
const motionReduced=!!reducedMotion||(typeof window!=='undefined'&&window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches);
let active=0, paused=motionReduced, destroyed=false;
const cleanups=[];
const listen=(node,type,fn,opts={})=>node.addEventListener(type,fn,{...opts,signal});
const announce=s=>{if(status)status.textContent=s};
function select(index,announceChange=false){if(destroyed||!buttons[index]||!images[index])return;active=index;buttons.forEach((b,i)=>{b.setAttribute('aria-pressed',String(i===index));b.classList.toggle('is-active',i===index)});images.forEach((img,i)=>{img.hidden=i!==index;img.classList.toggle('is-active',i===index)});if(caption)caption.textContent=buttons[index].querySelector('.pe-name')?.textContent||'';if(announceChange)announce((root.lang.startsWith('en')?'Showing ':'正在显示 ')+(caption?.textContent||''));}
buttons.forEach((b,i)=>{listen(b,'pointerenter',e=>{if(e.pointerType==='mouse')select(i)});listen(b,'focus',()=>select(i));listen(b,'click',()=>select(i,true));listen(b,'keydown',e=>{let n;if(['ArrowDown','ArrowRight'].includes(e.key))n=(i+1)%buttons.length;else if(['ArrowUp','ArrowLeft'].includes(e.key))n=(i+buttons.length-1)%buttons.length;else if(e.key==='Home')n=0;else if(e.key==='End')n=buttons.length-1;if(n!==undefined){e.preventDefault();buttons[n].focus();select(n,true)}})});
if(motion){motion.setAttribute('aria-pressed',String(paused));motion.textContent=paused?(root.lang.startsWith('en')?'Resume motion':'继续动效'):(root.lang.startsWith('en')?'Pause motion':'暂停动效');listen(motion,'click',()=>{paused=!paused;motion.setAttribute('aria-pressed',String(paused));motion.textContent=paused?(root.lang.startsWith('en')?'Resume motion':'继续动效'):(root.lang.startsWith('en')?'Pause motion':'暂停动效');root.classList.toggle('is-paused',paused);announce(paused?(root.lang.startsWith('en')?'Motion paused':'动效已暂停'):(root.lang.startsWith('en')?'Motion resumed':'动效已继续'))})}
// CSS-only rolling-label treatment adapted from ButtonHoverStyles (MIT);
// transition is interaction-triggered and the control pauses it globally.
select(0);root.classList.toggle('is-reduced-motion',motionReduced);
return {resume(){if(destroyed)return;paused=motionReduced;root.classList.toggle('is-paused',paused);if(motion){motion.setAttribute('aria-pressed','false');motion.textContent=root.lang.startsWith('en')?'Pause motion':'暂停动效'}},pause(){if(destroyed)return;paused=true;root.classList.add('is-paused');const magnet=root.querySelector('[data-magnet]');if(magnet)magnet.style.transform='';if(motion){motion.setAttribute('aria-pressed','true');motion.textContent=root.lang.startsWith('en')?'Resume motion':'继续动效'}},destroy(){if(destroyed)return;destroyed=true;controller.abort();cleanups.forEach(fn=>fn());root.className=original.className;if(original.style===null)root.removeAttribute('style');else root.setAttribute('style',original.style);buttons.forEach((b,i)=>{b.className=original.buttons[i][0];original.buttons[i][1]===null?b.removeAttribute('aria-pressed'):b.setAttribute('aria-pressed',original.buttons[i][1])});images.forEach((img,i)=>{img.className=original.images[i][0];img.hidden=original.images[i][1]});if(caption)caption.textContent=original.caption;if(status)status.textContent=original.status;controls.forEach(([c,value,label,expanded,pressed])=>{if(c.matches('input'))c.value=value;if(c.matches('button'))c.innerHTML=label;expanded===null?c.removeAttribute('aria-expanded'):c.setAttribute('aria-expanded',expanded);pressed===null?c.removeAttribute('aria-pressed'):c.setAttribute('aria-pressed',pressed)});if(panel)panel.hidden=original.panelHidden}};
}Use with existing project screenshots and labels. Obtain permission for imagery before deploying.
The module is scoped to its root, uses native DOM events and makes no network requests.
Reduced-motion mode disables movement; keyboard, touch and normal page scrolling remain available.
Check mobile touch, keyboard focus, pause/resume, and destroy/remount behavior. Confirm screenshot ownership and link destination. FMS labels an existing project website screenshot only; no project metrics are claimed. Four existing website screenshots are labelled SHOKZ, Termino, INIU and FMS. No Codrops demo imagery is used.
Replace sample images with imagery you may use, then test the interaction in the theme editor and on phones.
Work in a duplicate theme. Replace demo copy and artwork with Section settings, scope styles to that Section, and use the lifecycle module for editor reloads, visibility and teardown.
{% comment %} WESWOO example shell. Add ONE effect's HTML inside .fx-slot. {% endcomment %}
{{ 'ww-effects.css' | asset_url | stylesheet_tag }}
<section id="ww-effect-{{ section.id }}" data-ww-effect-section>
<h2>{{ section.settings.heading | escape }}</h2>
<button type="button" data-effect-toggle aria-pressed="false">Play / pause effect</button>
<div class="fx-slot">
{% comment %} Insert the chosen .fx element here; read copy/images from section settings. {% endcomment %}
</div>
</section>
<script type="module" src="{{ 'ww-effect-section.js' | asset_url }}"></script>
{% schema %}
{"name":"WESWOO effect","settings":[{"type":"text","id":"heading","label":"Heading","default":"Our story"}],"presets":[{"name":"WESWOO effect"}]}
{% endschema %}
// Put the chosen example JS in assets/ww-selected-effect.js (rename .mjs to .js).
import {mountEffect} from './ww-selected-effect.js';
const instances=new Map();
function mount(container=document){
const roots=[...(container.matches?.('[data-ww-effect-section]')?[container]:[]),...container.querySelectorAll('[data-ww-effect-section]')];
for(const section of roots){
if(instances.has(section))continue;
const root=section.querySelector('.fx'),button=section.querySelector('[data-effect-toggle]');
if(!root||!button)continue;
const effect=mountEffect(root),events=new AbortController();let playing=false;
const pause=()=>{playing=false;effect.pause();button.setAttribute('aria-pressed','false');};
button.addEventListener('click',()=>{playing=!playing;playing?effect.resume():effect.pause();button.setAttribute('aria-pressed',String(playing));},{signal:events.signal});
const observer=new IntersectionObserver(entries=>{if(!entries[0].isIntersecting)pause();});observer.observe(section);
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:events.signal});
instances.set(section,()=>{observer.disconnect();events.abort();effect.destroy();});
}
}
document.addEventListener('shopify:section:load',event=>mount(event.target));
document.addEventListener('shopify:section:unload',event=>{for(const [section,destroy] of instances)if(section===event.target||event.target.contains(section)){destroy();instances.delete(section);}});
mount();
// Original WESWOO integration. Copy alongside the selected ww-effect-*.js asset.
// The server supplies the asset URL; do not accept a URL from a query parameter.
if (!customElements.get('ww-effect-study')) {
customElements.define('ww-effect-study', class extends HTMLElement {
connectedCallback() {
if (this.events) return;
this.events=new AbortController();this.session={};const session=this.session;
const button=this.querySelector('[data-effect-toggle]');
button.disabled=false;button.setAttribute('aria-pressed','false');this.visible=true;
const preference=matchMedia('(prefers-reduced-motion: reduce)');
const pause=()=>{this.effect?.pause();button.setAttribute('aria-pressed','false');};
this.pause=pause;
button.addEventListener('click',async()=>{
if(this.loading)return;
if(!this.effect){
this.loading=true;button.disabled=true;
try {
const {mountEffect}=await import(this.dataset.moduleUrl);
if(!this.isConnected||this.session!==session)return;
this.effect=mountEffect(this.querySelector('.fx'),{reducedMotion:preference.matches});
} catch {this.querySelector('[data-effect-status]').textContent='The static content is available. Reload to retry motion.';return;}
finally {if(this.session===session){this.loading=false;button.disabled=false;}}
}
if(this.session!==session||document.hidden||!this.visible)return;
const playing=button.getAttribute('aria-pressed')!=='true';
playing?this.effect.resume():this.effect.pause();button.setAttribute('aria-pressed',String(playing));
},{signal:this.events.signal});
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:this.events.signal});
preference.addEventListener('change',()=>{pause();this.effect?.destroy();this.effect=null;},{signal:this.events.signal});
this.observer=new IntersectionObserver(entries=>{this.visible=entries[0].isIntersecting;if(!this.visible)pause();});this.observer.observe(this);
const root=this.querySelector('.fx');
root.querySelectorAll('[data-view]').forEach(trigger=>trigger.addEventListener('click',()=>{const target=root.querySelector('dialog .art'),source=trigger.querySelector('.ww-fx-image');target.querySelector('.ww-fx-image')?.remove();if(source)target.append(source.cloneNode(true));},{signal:this.events.signal}));
// Section unload disconnects this custom element; reconnect mounts one fresh instance.
document.addEventListener('shopify:section:unload',event=>{if(event.target.contains(this))this.teardown();},{signal:this.events.signal});
}
teardown(){this.session=null;this.loading=false;this.observer?.disconnect();this.events?.abort();this.effect?.destroy();this.effect=null;this.events=null;}
disconnectedCallback(){this.teardown();}
});
}
Insert the selected effect into the shell. Each module loads one effect; multiple types need an explicit registry and Section mapping.
Rolling text adapted from Codrops ButtonHoverStyles under MIT.
Shopify: Section architectureShopify: theme editor events and lifecycleShopify: theme performanceMDN: Web Animations APIMDN: reduced-motion preferenceMDN: iframe sandboxingShopify: image rendering and dimensionsShopify: Section settings and schemaMDN: element geometryMDN: image and text clippingMDN: native dialogShopify: theme accessibilityMDN: native range inputExamples are authored by WESWOO and credited open-source contributors; retain their applicable licenses. Project screens and photographs remain with their rights holders. Downloads use placeholders; replace them with imagery you may use.
Shopify/dawn · modal / slider base classesShopify/dawn · product media galleryShopify/dawn · licensePreparing preview
Keep the magnetic response subtle so the CTA remains easy to activate. Replace the demo anchor with a verified project destination.
<section class="fx pe-magnetic" data-effect="magnetic-cta" lang="en" aria-label="Subtle magnetic button demo"><p class="fx__eyebrow">REAL WEBSITE SCREENS</p><h3>Subtle magnetic CTA</h3><p class="fx__lede">Choose a project, then move the pointer over its button. Tap or use the keyboard to select a project.</p><div class="pe-mag-layout"><div class="pe-mag-list"><button type="button" class="pe-project" data-project="0" aria-pressed="true"><span class="pe-name">SHOKZ</span><span class="pe-sub">UK website · project screen</span></button><button type="button" class="pe-project" data-project="1" aria-pressed="false"><span class="pe-name">Termino</span><span class="pe-sub">Aluminium cabinetry website · project screen</span></button><button type="button" class="pe-project" data-project="2" aria-pressed="false"><span class="pe-name">INIU</span><span class="pe-sub">Charging products website · project screen</span></button><button type="button" class="pe-project" data-project="3" aria-pressed="false"><span class="pe-name">FMS</span><span class="pe-sub">Project website · screenshot</span></button></div><div class="pe-mag-card" id="project-preview"><div class="pe-mag-image"><img data-preview="0" src="https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/shokz-openfit-preview.webp" width="900" height="450" alt="SHOKZ UK website screenshot" ><img data-preview="1" src="https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/termino-preview.webp" width="900" height="450" alt="Termino cabinetry website screenshot" hidden><img data-preview="2" src="https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/iniu-preview.webp" width="900" height="450" alt="INIU charging products website screenshot" hidden><img data-preview="3" src="https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/fms-preview.webp" width="900" height="450" alt="FMS website screenshot" hidden></div><p class="pe-caption">Real website screenshot · <span data-caption>SHOKZ</span></p><button type="button" class="pe-magnet" data-magnet><span class="pe-magnet-label">View project screen</span></button></div></div><span class="pe-feedback" data-status role="status" aria-live="polite"></span></section>
.fx{box-sizing:border-box;font-family:inherit;color:#172523;background:#f3f5ef;border-radius:18px;padding:clamp(18px,4vw,38px);overflow:hidden}.fx *{box-sizing:border-box}.fx button,.fx input{font:inherit}.fx h3{font-size:clamp(24px,3vw,34px);line-height:1.2;margin:8px 0}.fx p{line-height:1.6}.fx__eyebrow{font-size:10px;letter-spacing:.14em;font-weight:700}.fx__lede{font-size:13px;color:#536159;max-width:620px}.fx__control{border:1px solid #c4cec1;border-radius:999px;background:transparent;padding:9px 14px;cursor:pointer;color:inherit}.fx__control:focus-visible,.fx button:focus-visible,.fx input:focus-visible{outline:3px solid #356940;outline-offset:3px}.fx__controls{display:flex;gap:8px;flex-wrap:wrap;margin-top:16px}.fx__status{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.fx img{max-width:100%;display:block}.fx [hidden]{display:none!important}@media(prefers-reduced-motion:reduce){.fx *{scroll-behavior:auto!important;animation:none!important;transition:none!important}}
.pe-mag-card{padding:12px}.pe-mag-image img{border-radius:8px}.pe-magnet{position:relative;display:flex;align-items:center;justify-content:space-between;gap:20px;max-width:270px;margin:14px auto 4px;padding:15px 20px;border-radius:999px;background:#172523;color:#fff;text-decoration:none;font-weight:700;will-change:transform;transition:transform .18s ease,background .2s}.pe-magnet:hover{background:#31513f}.pe-magnet:focus-visible{outline:3px solid #356940;outline-offset:4px}.pe-magnet b{font-size:18px}.pe-note{font-size:10px;color:#657369;text-align:center}.pe-magnetic [data-motion][aria-pressed=true]~.pe-status{display:none}
.fx.is-paused .pe-roll-actions .pe-name{transition:none!important;transform:none!important}.fx.is-paused .pe-magnet,.fx.is-paused .pe-magnet-label{transition:none!important;transform:none!important}
.pe-magnet b{font-size:11px;font-weight:500}
/* MagneticButtons src/js/demo1/buttonCtrl.js trigger threshold and counter-motion (MIT), rewritten for scoped pointer events. */
.pe-magnet-label{display:inline-block;transition:transform .16s ease}.pe-magnet{transition:transform .18s cubic-bezier(.2,.8,.2,1),background .2s}.fx.is-paused .pe-magnet,.fx.is-paused .pe-magnet-label{transform:none!important;transition:none!important}
.fx.is-paused *, .fx.is-reduced-motion *{scroll-behavior:auto;animation-play-state:paused!important}
.pe-roll-preview img,.pe-mag-image img,.pe-menu-image img,.pe-audit-image img{display:block;width:100%;height:auto;max-height:none;aspect-ratio:2/1;object-fit:contain}
@media(max-width:680px){.pe-roll-layout,.pe-mag-layout{grid-template-columns:minmax(0,1fr);gap:16px}.pe-roll-preview,.pe-mag-card,.pe-menu-image,.pe-audit-image{width:100%;min-width:0}.pe-roll-preview img,.pe-mag-image img,.pe-menu-image img,.pe-audit-image img{height:auto;aspect-ratio:2/1;object-fit:contain}.pe-roll-actions,.pe-mag-list{grid-template-columns:minmax(0,1fr)}.pe-roll-actions .pe-project,.pe-mag-list .pe-project{min-height:60px}}
.fx.is-reduced-motion .pe-name-wrap .pe-name{opacity:1!important}.fx.is-reduced-motion .pe-name-wrap .pe-marquee{display:none!important}.fx.is-reduced-motion .pe-magnet,.fx.is-reduced-motion .pe-magnet-label{transform:none!important;transition:none!important}
/* Shared visual primitives are duplicated intentionally so every effect runs alone in its iframe. */
.pe-project{box-sizing:border-box;position:relative;display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;min-width:0;min-height:60px;padding:13px 10px;border:0;border-bottom:1px solid #cfd7ca;background:transparent;color:#172523;text-align:left;font:inherit;cursor:pointer}.pe-project[aria-pressed=true]{background:#e5eadf}.pe-project:focus-visible{outline:3px solid #356940;outline-offset:-3px}.pe-name{display:block;min-width:0;font-size:clamp(16px,2vw,23px);line-height:1.2;font-weight:700;letter-spacing:-.02em}.pe-sub{display:block;min-width:0;font-size:10px;line-height:1.45;color:#536159}.pe-caption{margin:0;padding:11px 14px;font-size:10px;line-height:1.45;color:#536159}.pe-caption span{font-weight:700;color:#172523}.pe-mag-layout{display:grid;grid-template-columns:minmax(190px,.75fr) minmax(0,1.25fr);gap:22px;align-items:center}.pe-mag-list{display:grid;border-top:1px solid #cfd7ca}.pe-mag-card{min-width:0;overflow:hidden;border:1px solid #c4cec1;border-radius:12px;background:#fff}.pe-mag-image{min-width:0;overflow:hidden}.pe-mag-image img{display:block;width:100%;height:auto;aspect-ratio:2/1;object-fit:contain}.pe-menu-panel{min-width:0}.pe-menu-items{min-width:0}.pe-menu-image img,.pe-roll-preview img,.pe-audit-image img{display:block;width:100%;height:auto;aspect-ratio:2/1;object-fit:contain}@media(max-width:680px){.pe-mag-layout{grid-template-columns:minmax(0,1fr);gap:16px}.pe-mag-list{grid-template-columns:minmax(0,1fr)}.pe-mag-card{width:100%;min-width:0}.pe-project{gap:8px;padding:12px 8px}.pe-sub{font-size:10px}}
.pe-magnet{appearance:none;border:0;text-align:left;font-family:inherit;cursor:pointer}.pe-feedback{display:block;min-height:1.5em;margin:8px auto 0;max-width:320px;text-align:center;font-size:12px;line-height:1.5;color:#31513f}.pe-feedback:empty{visibility:hidden}
/*
* MIT License
*
* Copyright (c) 2009 - 2020 [Codrops](https://tympanus.net/codrops)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* Source: https://github.com/codrops/MagneticButtons
*/
export function mountEffect(root,{reducedMotion=false}={}){
const controller=new AbortController(), signal=controller.signal;
const buttons=[...root.querySelectorAll('[data-project]')], images=[...root.querySelectorAll('[data-preview]')];
const caption=root.querySelector('[data-caption]'), status=root.querySelector('[data-status]'), motion=root.querySelector('[data-motion]');
const toggle=root.querySelector('.pe-menu-toggle'), panel=root.querySelector('.pe-menu-panel');
const controls=[...root.querySelectorAll('button,input')];
const original={className:root.className,style:root.getAttribute('style'),buttons:buttons.map(b=>[b.className,b.getAttribute('aria-pressed')]),images:images.map(i=>[i.className,i.hidden]),caption:caption?.textContent,status:status?.textContent,controls:controls.map(c=>[c,c.value,c.innerHTML,c.getAttribute('aria-expanded'),c.getAttribute('aria-pressed')]),panelHidden:panel?.hidden};
const motionReduced=!!reducedMotion||(typeof window!=='undefined'&&window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches);
let active=0, paused=motionReduced, destroyed=false;
const cleanups=[];
const listen=(node,type,fn,opts={})=>node.addEventListener(type,fn,{...opts,signal});
const announce=s=>{if(status)status.textContent=s};
function select(index,announceChange=false){if(destroyed||!buttons[index]||!images[index])return;active=index;buttons.forEach((b,i)=>{b.setAttribute('aria-pressed',String(i===index));b.classList.toggle('is-active',i===index)});images.forEach((img,i)=>{img.hidden=i!==index;img.classList.toggle('is-active',i===index)});if(caption)caption.textContent=buttons[index].querySelector('.pe-name')?.textContent||'';if(announceChange)announce((root.lang.startsWith('en')?'Showing ':'正在显示 ')+(caption?.textContent||''));}
buttons.forEach((b,i)=>{listen(b,'pointerenter',e=>{if(e.pointerType==='mouse')select(i)});listen(b,'focus',()=>select(i));listen(b,'click',()=>select(i,true));listen(b,'keydown',e=>{let n;if(['ArrowDown','ArrowRight'].includes(e.key))n=(i+1)%buttons.length;else if(['ArrowUp','ArrowLeft'].includes(e.key))n=(i+buttons.length-1)%buttons.length;else if(e.key==='Home')n=0;else if(e.key==='End')n=buttons.length-1;if(n!==undefined){e.preventDefault();buttons[n].focus();select(n,true)}})});
if(motion){motion.setAttribute('aria-pressed',String(paused));motion.textContent=paused?(root.lang.startsWith('en')?'Resume motion':'继续动效'):(root.lang.startsWith('en')?'Pause motion':'暂停动效');listen(motion,'click',()=>{paused=!paused;motion.setAttribute('aria-pressed',String(paused));motion.textContent=paused?(root.lang.startsWith('en')?'Resume motion':'继续动效'):(root.lang.startsWith('en')?'Pause motion':'暂停动效');root.classList.toggle('is-paused',paused);announce(paused?(root.lang.startsWith('en')?'Motion paused':'动效已暂停'):(root.lang.startsWith('en')?'Motion resumed':'动效已继续'))})}
const magnet=root.querySelector('[data-magnet]'), magnetLabel=root.querySelector('.pe-magnet-label');
if(magnet){const move=e=>{if(paused||e.pointerType!=='mouse')return;const r=magnet.getBoundingClientRect(),cx=r.left+r.width/2,cy=r.top+r.height/2,dx=e.clientX-cx,dy=e.clientY-cy,dist=Math.hypot(dx,dy),trigger=r.width*.7;if(dist<trigger){const x=dx*.3,y=dy*.3;magnet.style.transform='translate3d('+x+'px,'+y+'px,0)';if(magnetLabel)magnetLabel.style.transform='translate3d('+(-x*.6)+'px,'+(-y*.6)+'px,0)'}else leave()};const leave=()=>{magnet.style.transform='';if(magnetLabel)magnetLabel.style.transform=''};listen(magnet,'pointermove',move);listen(magnet,'pointerleave',leave);listen(magnet,'blur',leave);listen(magnet,'click',()=>announce((root.lang.startsWith('en')?'Showing the ':'正在显示 ')+(caption?.textContent||'')+(root.lang.startsWith('en')?' website screen':'官网画面')));cleanups.push(leave)}
select(0);root.classList.toggle('is-reduced-motion',motionReduced);
return {resume(){if(destroyed)return;paused=motionReduced;root.classList.toggle('is-paused',paused);if(motion){motion.setAttribute('aria-pressed','false');motion.textContent=root.lang.startsWith('en')?'Pause motion':'暂停动效'}},pause(){if(destroyed)return;paused=true;root.classList.add('is-paused');const magnet=root.querySelector('[data-magnet]'), magnetLabel=root.querySelector('.pe-magnet-label');if(magnet)magnet.style.transform='';if(magnetLabel)magnetLabel.style.transform='';if(motion){motion.setAttribute('aria-pressed','true');motion.textContent=root.lang.startsWith('en')?'Resume motion':'继续动效'}},destroy(){if(destroyed)return;destroyed=true;controller.abort();cleanups.forEach(fn=>fn());root.className=original.className;if(original.style===null)root.removeAttribute('style');else root.setAttribute('style',original.style);buttons.forEach((b,i)=>{b.className=original.buttons[i][0];original.buttons[i][1]===null?b.removeAttribute('aria-pressed'):b.setAttribute('aria-pressed',original.buttons[i][1])});images.forEach((img,i)=>{img.className=original.images[i][0];img.hidden=original.images[i][1]});if(caption)caption.textContent=original.caption;if(status)status.textContent=original.status;controls.forEach(([c,value,label,expanded,pressed])=>{if(c.matches('input'))c.value=value;if(c.matches('button'))c.innerHTML=label;expanded===null?c.removeAttribute('aria-expanded'):c.setAttribute('aria-expanded',expanded);pressed===null?c.removeAttribute('aria-pressed'):c.setAttribute('aria-pressed',pressed)});if(panel)panel.hidden=original.panelHidden}};
}Use with existing project screenshots and labels. Obtain permission for imagery before deploying.
Mouse movement adds a bounded magnetic response. Clicking announces the selected project screen in place without navigation or scrolling. Keyboard and touch use native button behavior.
Reduced-motion mode disables movement; keyboard, touch and normal page scrolling remain available.
Check mobile touch, keyboard focus, pause/resume, and destroy/remount behavior. Confirm screenshot ownership and link destination. FMS labels an existing project website screenshot only; no project metrics are claimed. Four existing website screenshots are labelled SHOKZ, Termino, INIU and FMS. No Codrops demo imagery is used.
Replace sample images with imagery you may use, then test the interaction in the theme editor and on phones.
Work in a duplicate theme. Replace demo copy and artwork with Section settings, scope styles to that Section, and use the lifecycle module for editor reloads, visibility and teardown.
{% comment %} WESWOO example shell. Add ONE effect's HTML inside .fx-slot. {% endcomment %}
{{ 'ww-effects.css' | asset_url | stylesheet_tag }}
<section id="ww-effect-{{ section.id }}" data-ww-effect-section>
<h2>{{ section.settings.heading | escape }}</h2>
<button type="button" data-effect-toggle aria-pressed="false">Play / pause effect</button>
<div class="fx-slot">
{% comment %} Insert the chosen .fx element here; read copy/images from section settings. {% endcomment %}
</div>
</section>
<script type="module" src="{{ 'ww-effect-section.js' | asset_url }}"></script>
{% schema %}
{"name":"WESWOO effect","settings":[{"type":"text","id":"heading","label":"Heading","default":"Our story"}],"presets":[{"name":"WESWOO effect"}]}
{% endschema %}
// Put the chosen example JS in assets/ww-selected-effect.js (rename .mjs to .js).
import {mountEffect} from './ww-selected-effect.js';
const instances=new Map();
function mount(container=document){
const roots=[...(container.matches?.('[data-ww-effect-section]')?[container]:[]),...container.querySelectorAll('[data-ww-effect-section]')];
for(const section of roots){
if(instances.has(section))continue;
const root=section.querySelector('.fx'),button=section.querySelector('[data-effect-toggle]');
if(!root||!button)continue;
const effect=mountEffect(root),events=new AbortController();let playing=false;
const pause=()=>{playing=false;effect.pause();button.setAttribute('aria-pressed','false');};
button.addEventListener('click',()=>{playing=!playing;playing?effect.resume():effect.pause();button.setAttribute('aria-pressed',String(playing));},{signal:events.signal});
const observer=new IntersectionObserver(entries=>{if(!entries[0].isIntersecting)pause();});observer.observe(section);
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:events.signal});
instances.set(section,()=>{observer.disconnect();events.abort();effect.destroy();});
}
}
document.addEventListener('shopify:section:load',event=>mount(event.target));
document.addEventListener('shopify:section:unload',event=>{for(const [section,destroy] of instances)if(section===event.target||event.target.contains(section)){destroy();instances.delete(section);}});
mount();
// Original WESWOO integration. Copy alongside the selected ww-effect-*.js asset.
// The server supplies the asset URL; do not accept a URL from a query parameter.
if (!customElements.get('ww-effect-study')) {
customElements.define('ww-effect-study', class extends HTMLElement {
connectedCallback() {
if (this.events) return;
this.events=new AbortController();this.session={};const session=this.session;
const button=this.querySelector('[data-effect-toggle]');
button.disabled=false;button.setAttribute('aria-pressed','false');this.visible=true;
const preference=matchMedia('(prefers-reduced-motion: reduce)');
const pause=()=>{this.effect?.pause();button.setAttribute('aria-pressed','false');};
this.pause=pause;
button.addEventListener('click',async()=>{
if(this.loading)return;
if(!this.effect){
this.loading=true;button.disabled=true;
try {
const {mountEffect}=await import(this.dataset.moduleUrl);
if(!this.isConnected||this.session!==session)return;
this.effect=mountEffect(this.querySelector('.fx'),{reducedMotion:preference.matches});
} catch {this.querySelector('[data-effect-status]').textContent='The static content is available. Reload to retry motion.';return;}
finally {if(this.session===session){this.loading=false;button.disabled=false;}}
}
if(this.session!==session||document.hidden||!this.visible)return;
const playing=button.getAttribute('aria-pressed')!=='true';
playing?this.effect.resume():this.effect.pause();button.setAttribute('aria-pressed',String(playing));
},{signal:this.events.signal});
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:this.events.signal});
preference.addEventListener('change',()=>{pause();this.effect?.destroy();this.effect=null;},{signal:this.events.signal});
this.observer=new IntersectionObserver(entries=>{this.visible=entries[0].isIntersecting;if(!this.visible)pause();});this.observer.observe(this);
const root=this.querySelector('.fx');
root.querySelectorAll('[data-view]').forEach(trigger=>trigger.addEventListener('click',()=>{const target=root.querySelector('dialog .art'),source=trigger.querySelector('.ww-fx-image');target.querySelector('.ww-fx-image')?.remove();if(source)target.append(source.cloneNode(true));},{signal:this.events.signal}));
// Section unload disconnects this custom element; reconnect mounts one fresh instance.
document.addEventListener('shopify:section:unload',event=>{if(event.target.contains(this))this.teardown();},{signal:this.events.signal});
}
teardown(){this.session=null;this.loading=false;this.observer?.disconnect();this.events?.abort();this.effect?.destroy();this.effect=null;this.events=null;}
disconnectedCallback(){this.teardown();}
});
}
Insert the selected effect into the shell. Each module loads one effect; multiple types need an explicit registry and Section mapping.
Magnetic interaction adapted from Codrops MagneticButtons under MIT.
Shopify: Section architectureShopify: theme editor events and lifecycleShopify: theme performanceMDN: Web Animations APIMDN: reduced-motion preferenceMDN: iframe sandboxingShopify: image rendering and dimensionsShopify: Section settings and schemaMDN: element geometryMDN: image and text clippingMDN: native dialogShopify: theme accessibilityMDN: native range inputExamples are authored by WESWOO and credited open-source contributors; retain their applicable licenses. Project screens and photographs remain with their rights holders. Downloads use placeholders; replace them with imagery you may use.
Shopify/dawn · modal / slider base classesShopify/dawn · product media galleryShopify/dawn · licensePreparing preview
A project directory might list residential, office and retail work. A preview helps readers recognise the setting before choosing a case. Title, image and destination should come from the same record. The preview supports a decision, while the name and entry remain understandable on their own.
The example shares selection across mouse entry, keyboard focus and clicks. It demonstrates preview selection, not completed project routing. Keep a clear real link for entering the project, including after touch selection. Reserve image dimensions so changes do not shift the list; reduced motion can show the selected image directly.
<section class="fx ww-hover" lang="en" aria-label="Project screen previews">
<div class="ww-hover__intro"><p class="ww-hover__eyebrow">SELECTED PROJECTS</p><h3>Explore the pages behind the projects.</h3><p>Hover, focus or select a project to view its website screen.</p></div>
<div class="ww-hover__layout">
<div class="ww-hover__list" aria-label="Select a project">
<button type="button" class="ww-hover__item is-active" data-project="0" aria-pressed="true"><span class="ww-hover__number">01</span><span><strong>SHOKZ</strong><small>UK website · Project screen</small></span><span class="ww-hover__mark" aria-hidden="true"></span></button>
<button type="button" class="ww-hover__item" data-project="1" aria-pressed="false"><span class="ww-hover__number">02</span><span><strong>Termino</strong><small>Aluminium kitchens · Project screen</small></span><span class="ww-hover__mark" aria-hidden="true"></span></button>
<button type="button" class="ww-hover__item" data-project="2" aria-pressed="false"><span class="ww-hover__number">03</span><span><strong>INIU</strong><small>Charging products · Project screen</small></span><span class="ww-hover__mark" aria-hidden="true"></span></button>
</div>
<div class="ww-hover__preview"><div class="ww-hover__chrome" aria-hidden="true"><i></i><i></i><i></i><span>WESWOO / PROJECT VIEW</span></div><div class="ww-hover__stage"><img class="is-active" data-preview="0" src="https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/shokz-openfit-preview.webp" width="900" height="450" alt="SHOKZ UK website project screen"><img data-preview="1" src="https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/termino-preview.webp" width="900" height="450" alt="Termino aluminium kitchen website project screen" hidden><img data-preview="2" src="https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/iniu-preview.webp" width="900" height="450" alt="INIU charging product website project screen" hidden></div><div class="ww-hover__caption"><span data-caption>SHOKZ</span><span>Website screenshot</span></div></div>
</div><span class="ww-hover__sr" data-status role="status" aria-live="polite"></span>
</section>
.ww-hover{--ink:#172523;--accent:#d7f768;--line:#d3d9d2;padding:clamp(20px,4vw,48px);background:#f3f5ef;color:var(--ink);border-radius:20px;font-family:inherit;overflow:hidden}.ww-hover *{box-sizing:border-box}.ww-hover__intro{max-width:650px;margin-bottom:30px}.ww-hover__eyebrow{font-size:11px;letter-spacing:.16em;font-weight:700}.ww-hover h3{font-size:clamp(24px,3vw,38px);line-height:1.22;margin:12px 0}.ww-hover__intro>p:last-child{font-size:14px;line-height:1.7;color:#55635e}.ww-hover__layout{display:grid;grid-template-columns:minmax(210px,.75fr) minmax(0,1.5fr);gap:36px;align-items:center}.ww-hover__list{border-top:1px solid var(--line)}.ww-hover__item{width:100%;display:flex;align-items:center;gap:18px;text-align:left;background:transparent;border:0;border-bottom:1px solid var(--line);padding:24px 10px;color:inherit;cursor:pointer;font:inherit;transition:background .22s,padding .22s}.ww-hover__item.is-active{background:#e5eadf;padding-left:20px}.ww-hover__number{font-size:11px;color:#657369;align-self:flex-start;padding-top:5px}.ww-hover__item strong{display:block;font-size:clamp(22px,3vw,32px);letter-spacing:-.035em;font-weight:650}.ww-hover__item small{display:block;margin-top:8px;font-size:11px;line-height:1.5;color:#536159}.ww-hover__mark{margin-left:auto;flex:0 0 9px;height:9px;border-radius:50%;border:1px solid #657369}.ww-hover__item.is-active .ww-hover__mark{background:var(--ink);border-color:var(--ink)}.ww-hover__item:focus-visible{outline:3px solid #356940;outline-offset:-3px}.ww-hover__preview{min-width:0;border:1px solid #bcc7bb;border-radius:12px;background:#fff;overflow:hidden;box-shadow:0 16px 35px #162b1a12;transform:translateY(var(--preview-y,0px));transition:transform .3s ease}.ww-hover__chrome{height:34px;background:#e5eadf;display:flex;align-items:center;gap:5px;padding:0 12px}.ww-hover__chrome i{width:5px;height:5px;background:#899889;border-radius:50%}.ww-hover__chrome span{margin-left:auto;font-size:8px;letter-spacing:.08em;color:#52624f}.ww-hover__stage{aspect-ratio:2/1;position:relative;background:#dce2d6}.ww-hover__stage img{width:100%;height:100%;object-fit:contain;display:block;animation:ww-hover-reveal .32s ease both}.ww-hover__stage img[hidden]{display:none}.ww-hover__caption{display:flex;justify-content:space-between;gap:12px;padding:14px 16px;font-size:10px;color:#5c685c}.ww-hover__caption [data-caption]{font-weight:700;color:var(--ink)}.ww-hover__sr{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.ww-hover.is-reduced-motion *{animation:none!important;transition:none!important}.ww-hover.is-paused .ww-hover__preview{transform:none}.ww-hover.is-paused *{animation:none!important;transition:none!important}@keyframes ww-hover-reveal{from{opacity:.55;transform:scale(1.025)}to{opacity:1;transform:scale(1)}}@media(max-width:680px){.ww-hover__layout{grid-template-columns:1fr;gap:22px}.ww-hover__list{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));border:1px solid var(--line);border-radius:8px;overflow:hidden}.ww-hover__item{display:block;padding:14px 10px!important;min-width:0;border-bottom:0;border-right:1px solid var(--line)}.ww-hover__item:last-child{border-right:0}.ww-hover__number{display:block;margin-bottom:8px}.ww-hover__item strong{font-size:clamp(17px,4.7vw,25px)}.ww-hover__item small{font-size:10px}.ww-hover__mark{display:none}.ww-hover__preview{transform:none}.ww-hover__caption{font-size:10px;padding:12px}}@media(prefers-reduced-motion:reduce){.ww-hover *{animation:none!important;transition:none!important}.ww-hover__preview{transform:none}}
// Uses project screenshots hosted on WESWOO; no external runtime.
export function mountEffect(root,{reducedMotion=false}={}){
const buttons=[...root.querySelectorAll('[data-project]')];
const images=[...root.querySelectorAll('[data-preview]')];
const caption=root.querySelector('[data-caption]');
const status=root.querySelector('[data-status]');
const controller=new AbortController();
const originalClass=root.className;
const originalStyle=root.style.cssText;
const original=buttons.map(button=>({className:button.className,pressed:button.getAttribute('aria-pressed')}));
const originalImages=images.map(img=>({className:img.className,hidden:img.hidden}));
const originalCaption=caption.textContent;
let selected=0,paused=false,destroyed=false;
root.classList.toggle('is-reduced-motion',reducedMotion);
function select(index,announce=false){
if(destroyed||!buttons[index]||!images[index])return;
selected=index;
buttons.forEach((button,i)=>{button.classList.toggle('is-active',i===index);button.setAttribute('aria-pressed',String(i===index));});
images.forEach((img,i)=>{img.hidden=i!==index;img.classList.toggle('is-active',i===index);});
const name=buttons[index].querySelector('strong').textContent;
caption.textContent=name;
root.style.setProperty('--preview-y',(!paused&&!reducedMotion?(index-1)*5:0)+'px');
if(announce)status.textContent=root.lang.startsWith('en')?'Showing '+name+' website screen':'正在显示 '+name+' 官网画面';
}
buttons.forEach((button,index)=>{
button.addEventListener('pointerenter',event=>{if(event.pointerType==='mouse')select(index);},{signal:controller.signal});
button.addEventListener('focus',()=>select(index),{signal:controller.signal});
button.addEventListener('click',()=>select(index,true),{signal:controller.signal});
button.addEventListener('keydown',event=>{
let next;
if(event.key==='ArrowDown'||event.key==='ArrowRight')next=(index+1)%buttons.length;
if(event.key==='ArrowUp'||event.key==='ArrowLeft')next=(index+buttons.length-1)%buttons.length;
if(event.key==='Home')next=0;
if(event.key==='End')next=buttons.length-1;
if(next!==undefined){event.preventDefault();buttons[next].focus();select(next,true);}
},{signal:controller.signal});
});
select(0);
// Manual selection stays available while paused; no autonomous playback exists.
return {
pause(){if(destroyed)return;paused=true;root.classList.add('is-paused');root.style.setProperty('--preview-y','0px');},
resume(){if(destroyed)return;paused=false;root.classList.remove('is-paused');select(selected);},
destroy(){if(destroyed)return;destroyed=true;controller.abort();root.className=originalClass;root.style.cssText=originalStyle;buttons.forEach((button,i)=>{button.className=original[i].className;if(original[i].pressed===null)button.removeAttribute('aria-pressed');else button.setAttribute('aria-pressed',original[i].pressed);});images.forEach((img,i)=>{img.className=originalImages[i].className;img.hidden=originalImages[i].hidden;});caption.textContent=originalCaption;status.textContent='';}
};
}
A case list, collection guide or editorial Section. Read title, destination and image from the same block.
Pointer enter, keyboard focus and click share one selection function. Update pressed state and alternative text. Use image_url / image_tag with reserved dimensions for real imagery.
Tap to choose on phones. Reduced motion swaps content without transition. Provide a separate explicit destination link.
Mouse hover, keyboard focus and phone taps select the same project; manual selection remains available while paused. Screenshots belong to their respective owners.
Work in a duplicate theme. Replace demo copy and artwork with Section settings, scope styles to that Section, and use the lifecycle module for editor reloads, visibility and teardown.
{% comment %} WESWOO example shell. Add ONE effect's HTML inside .fx-slot. {% endcomment %}
{{ 'ww-effects.css' | asset_url | stylesheet_tag }}
<section id="ww-effect-{{ section.id }}" data-ww-effect-section>
<h2>{{ section.settings.heading | escape }}</h2>
<button type="button" data-effect-toggle aria-pressed="false">Play / pause effect</button>
<div class="fx-slot">
{% comment %} Insert the chosen .fx element here; read copy/images from section settings. {% endcomment %}
</div>
</section>
<script type="module" src="{{ 'ww-effect-section.js' | asset_url }}"></script>
{% schema %}
{"name":"WESWOO effect","settings":[{"type":"text","id":"heading","label":"Heading","default":"Our story"}],"presets":[{"name":"WESWOO effect"}]}
{% endschema %}
// Put the chosen example JS in assets/ww-selected-effect.js (rename .mjs to .js).
import {mountEffect} from './ww-selected-effect.js';
const instances=new Map();
function mount(container=document){
const roots=[...(container.matches?.('[data-ww-effect-section]')?[container]:[]),...container.querySelectorAll('[data-ww-effect-section]')];
for(const section of roots){
if(instances.has(section))continue;
const root=section.querySelector('.fx'),button=section.querySelector('[data-effect-toggle]');
if(!root||!button)continue;
const effect=mountEffect(root),events=new AbortController();let playing=false;
const pause=()=>{playing=false;effect.pause();button.setAttribute('aria-pressed','false');};
button.addEventListener('click',()=>{playing=!playing;playing?effect.resume():effect.pause();button.setAttribute('aria-pressed',String(playing));},{signal:events.signal});
const observer=new IntersectionObserver(entries=>{if(!entries[0].isIntersecting)pause();});observer.observe(section);
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:events.signal});
instances.set(section,()=>{observer.disconnect();events.abort();effect.destroy();});
}
}
document.addEventListener('shopify:section:load',event=>mount(event.target));
document.addEventListener('shopify:section:unload',event=>{for(const [section,destroy] of instances)if(section===event.target||event.target.contains(section)){destroy();instances.delete(section);}});
mount();
// Original WESWOO integration. Copy alongside the selected ww-effect-*.js asset.
// The server supplies the asset URL; do not accept a URL from a query parameter.
if (!customElements.get('ww-effect-study')) {
customElements.define('ww-effect-study', class extends HTMLElement {
connectedCallback() {
if (this.events) return;
this.events=new AbortController();this.session={};const session=this.session;
const button=this.querySelector('[data-effect-toggle]');
button.disabled=false;button.setAttribute('aria-pressed','false');this.visible=true;
const preference=matchMedia('(prefers-reduced-motion: reduce)');
const pause=()=>{this.effect?.pause();button.setAttribute('aria-pressed','false');};
this.pause=pause;
button.addEventListener('click',async()=>{
if(this.loading)return;
if(!this.effect){
this.loading=true;button.disabled=true;
try {
const {mountEffect}=await import(this.dataset.moduleUrl);
if(!this.isConnected||this.session!==session)return;
this.effect=mountEffect(this.querySelector('.fx'),{reducedMotion:preference.matches});
} catch {this.querySelector('[data-effect-status]').textContent='The static content is available. Reload to retry motion.';return;}
finally {if(this.session===session){this.loading=false;button.disabled=false;}}
}
if(this.session!==session||document.hidden||!this.visible)return;
const playing=button.getAttribute('aria-pressed')!=='true';
playing?this.effect.resume():this.effect.pause();button.setAttribute('aria-pressed',String(playing));
},{signal:this.events.signal});
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:this.events.signal});
preference.addEventListener('change',()=>{pause();this.effect?.destroy();this.effect=null;},{signal:this.events.signal});
this.observer=new IntersectionObserver(entries=>{this.visible=entries[0].isIntersecting;if(!this.visible)pause();});this.observer.observe(this);
const root=this.querySelector('.fx');
root.querySelectorAll('[data-view]').forEach(trigger=>trigger.addEventListener('click',()=>{const target=root.querySelector('dialog .art'),source=trigger.querySelector('.ww-fx-image');target.querySelector('.ww-fx-image')?.remove();if(source)target.append(source.cloneNode(true));},{signal:this.events.signal}));
// Section unload disconnects this custom element; reconnect mounts one fresh instance.
document.addEventListener('shopify:section:unload',event=>{if(event.target.contains(this))this.teardown();},{signal:this.events.signal});
}
teardown(){this.session=null;this.loading=false;this.observer?.disconnect();this.events?.abort();this.effect?.destroy();this.effect=null;this.events=null;}
disconnectedCallback(){this.teardown();}
});
}
Insert the selected effect into the shell. Each module loads one effect; multiple types need an explicit registry and Section mapping.
Interaction inspired by Codrops; implementation is independently authored and uses existing WESWOO project imagery.
Shopify: Section architectureShopify: theme editor events and lifecycleShopify: theme performanceMDN: Web Animations APIMDN: reduced-motion preferenceMDN: iframe sandboxingShopify: image rendering and dimensionsShopify: Section settings and schemaMDN: element geometryMDN: image and text clippingMDN: native dialogShopify: theme accessibilityMDN: native range inputExamples are authored by WESWOO and credited open-source contributors; retain their applicable licenses. Project screens and photographs remain with their rights holders. Downloads use placeholders; replace them with imagery you may use.
Shopify/dawn · modal / slider base classesShopify/dawn · product media galleryShopify/dawn · licensePreparing preview
A project cover can show “View project” near the mouse while its name and link remain fixed. People without a mouse can then understand the action. The badge supplements an image entry; it should not contain the only price, explanation or next step.
The example translates mouse coordinates into the card and clamps the label within its bounds. The label does not receive pointer events and the normal cursor remains; the underlying demo button only updates status. During theme integration, replace it with a real destination link and read the image and destination from one record. Touch retains an ordinary entry, and reduced motion can leave a fixed cue.
<section class="fx" data-effect="cursor-label"><small>20 / CONTEXT AT THE POINTER</small><button type="button" class="cursor-target" aria-label="Explore the INIU website project screen"><span class="art" data-art="3" aria-hidden="true"></span><span class="cursor-caption">INIU / PROJECT SCREEN</span><span class="cursor-badge" aria-hidden="true">VIEW<br>STUDY</span></button><p class="hint" role="status">Hover to move the label; tap or press Enter to select.</p></section>
*{box-sizing:border-box}body{margin:0;background:#111211;color:#f4f0e7;font:14px/1.55 Arial,Helvetica,sans-serif}button,input{font:inherit}button{cursor:pointer;border:1px solid #ffffff50;border-radius:99px;padding:11px 18px;color:inherit;background:transparent;min-height:42px}button:hover{background:#ffffff15}button:focus-visible,a:focus-visible,input:focus-visible,[tabindex]:focus-visible{outline:3px solid #c6fc6b;outline-offset:4px}.fx{position:relative;min-height:500px;padding:34px;overflow:hidden;display:grid;align-content:center;gap:20px;isolation:isolate;background:#111211}.fx h2,.fx h3,.fx p{margin:0}.fx h2{font-size:clamp(36px,7vw,82px);font-weight:750;letter-spacing:-.065em;line-height:.98}.fx small{letter-spacing:.18em;color:#c2c3b9;font-size:10px}.fx>small{position:relative;z-index:2;align-self:start}.fx p{max-width:46ch}.fx:after{content:'WESWOO / INTERACTION STUDY';position:absolute;bottom:12px;right:23px;font-size:8px;letter-spacing:.18em;color:inherit;opacity:.45;pointer-events:none}.art{position:relative;min-height:240px;border-radius:3px;overflow:hidden;background-color:#ea754e;background-size:cover;background-position:center}.art:before,.art:after{content:none!important}.hint{font-size:11px;color:#b5b8ad}.controls{display:flex;gap:8px;flex-wrap:wrap}.scroller{height:385px;overflow-y:auto;scrollbar-width:thin;scrollbar-color:#b7b9a6 #292a26;border-radius:3px;position:relative;outline-offset:2px;overscroll-behavior-y:contain}.spacer{height:120px;display:grid;place-items:center;color:#bfc1b5;font-size:11px;letter-spacing:.04em}.fx [hidden]{display:none!important}.fx[data-playing=false] *{animation-play-state:paused!important}.fx button[aria-pressed=true]{background:#c6fc6b;color:#171a12}.fx a{color:inherit;text-underline-offset:4px}.fx[data-reduced-motion=true] *,.fx[data-reduced-motion=true] *:before,.fx[data-reduced-motion=true] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important}
@media(max-width:500px){.fx{padding:22px;min-height:460px;gap:18px}.fx h2{font-size:43px}.fx>small{font-size:8px}.art{min-height:215px}.scroller{height:355px}.fx:after{font-size:7px;right:16px}}
@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}
.fx{padding:25px;background:#111625}.cursor-target{padding:0;border:0;border-radius:0;position:relative;overflow:hidden;text-align:left;background:transparent!important}.cursor-target .art{display:block;height:360px}.cursor-caption{position:absolute;left:20px;bottom:20px;border-radius:99px;background:#e6e9f0;color:#1b2240;padding:10px 16px;font-size:10px;letter-spacing:.08em}.cursor-badge{display:grid;place-content:center;position:absolute;left:var(--cx,50%);top:var(--cy,50%);transform:translate(-50%,-50%) scale(.6);width:95px;height:95px;border-radius:50%;background:#d8fc75;color:#16202a;font:11px/1.2 Arial,sans-serif;letter-spacing:.1em;text-align:center;opacity:0;pointer-events:none;transition:opacity .2s,transform .25s}.fx[data-label=true] .cursor-badge{opacity:1;transform:translate(-50%,-50%) scale(1)}.fx[data-reduced-motion=true] .cursor-badge{display:none}@media(max-width:500px){.cursor-target .art{height:330px}.cursor-caption{font-size:8px;left:12px;bottom:12px}}
/* Real website project imagery; rights remain with the project owners. */
.art{background-image:url("https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/shokz-openfit-preview.webp");background-size:cover;background-position:center} .art[data-art="1"]{background-image:url("https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/shokz-openfit-preview.webp");background-size:cover;background-position:center} .art[data-art="2"]{background-image:url("https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/termino-preview.webp");background-size:cover;background-position:center} .art[data-art="3"]{background-image:url("https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/iniu-preview.webp");background-size:cover;background-position:center} .art:before,.art:after{content:none!important}// WESWOO original educational example; no third-party runtime required.
export function mountEffect(root, {reducedMotion=false}={}) {
const reduced=reducedMotion||matchMedia('(prefers-reduced-motion: reduce)').matches;
root.dataset.reducedMotion=String(reduced);
const life=new AbortController(), animations=[];
let active=false, started=false;
const on=(node,type,fn,options={})=>node.addEventListener(type,fn,{...options,signal:life.signal});
const animate=(node,frames,options)=>{
if(reduced)return null;
const animation=node.animate(frames,options);animations.push(animation);return animation;
};
let start=()=>{}, stop=()=>{}, cleanup=()=>{};
const target=root.querySelector('.cursor-target');let frame=0,x=0,y=0;
on(target,'pointermove',event=>{if(!active||reduced||event.pointerType!=='mouse')return;const r=target.getBoundingClientRect();x=Math.max(52,Math.min(r.width-52,event.clientX-r.left));y=Math.max(52,Math.min(r.height-52,event.clientY-r.top));root.dataset.label='true';if(!frame)frame=requestAnimationFrame(()=>{frame=0;root.style.setProperty('--cx',x+'px');root.style.setProperty('--cy',y+'px');});});
on(target,'pointerleave',()=>root.dataset.label='false');on(target,'click',()=>{if(active)root.querySelector('[role=status]').textContent='INIU project screen selected. Add your own destination when integrating.';});stop=()=>{cancelAnimationFrame(frame);frame=0;root.dataset.label='false';};cleanup=stop;
root.dataset.playing='false';
return {
resume(){active=true;root.dataset.playing='true';if(!started){started=true;start();}animations.forEach(a=>a.play());root.dispatchEvent(new Event('ww:resume'));},
pause(){active=false;root.dataset.playing='false';animations.forEach(a=>a.pause());stop();},
destroy(){active=false;life.abort();animations.forEach(a=>a.cancel());cleanup();}
};
}
A case or collection Section. image_3 provides the visual and a link setting supplies a real destination. The integration example uses a normal anchor instead of the demo button.
Map pointermove coordinates to the card and clamp the badge by its radius. CSS variables move the non-interactive, pointer-events:none label. Handle mouse pointers only and retain the browser cursor.
Touch, keyboard and reduced motion use the static caption and ordinary link. Hide the duplicate badge from assistive technology; clear it on leave and pause.
Check edge bounds, a named working link, keyboard access without chasing the pointer and canceled frames after teardown. The online preview uses existing project imagery; rights remain with the respective owners.
Files: copy sections/ww-effect-cursor-label.liquid; save this example’s JavaScript unchanged as assets/ww-effect-cursor-label.js, and copy the shared assets/ww-effect-studio.js below. The Section includes CSS scoped to .ww-fx-host.
Data: A case or collection Section. image_3 provides the visual and a link setting supplies a real destination. The integration example uses a normal anchor instead of the demo button.
Initialization: load the selected module on the first play action. Each Section keeps its own instance; offscreen, visibility and preference changes pause it, and unload releases observers and listeners.
Delivery scope: this concrete theme example retains the local canvas scroll model. A page-driven version needs the documented Section interval adaptation. Replace images, localize controls and verify actual theme styles and devices in a duplicate theme.
Work in a duplicate theme. Replace demo copy and artwork with Section settings, scope styles to that Section, and use the lifecycle module for editor reloads, visibility and teardown.
{% comment %}
WESWOO original Section example. Copy assets/ww-effect-cursor-label.js and assets/ww-effect-studio.js.
This preserves the local preview scroll model. A page-driven story needs the documented Section interval adaptation.
Theme Check is static validation, not a completed merchant-theme installation. Localize control strings for multilingual shops.
{% endcomment %}
<ww-effect-study class="ww-fx-host" data-effect-type="cursor-label" id="WWEffect-{{ section.id }}" data-module-url="{{ 'ww-effect-cursor-label.js' | asset_url }}">
<div class="ww-fx-controls"><button type="button" data-effect-toggle aria-pressed="false">Play / pause</button><span data-effect-status role="status"></span></div>
<section class="fx" data-effect="cursor-label"><small>20 / CONTEXT AT THE POINTER</small><a class="cursor-target" href="{{ section.settings.link | default: routes.all_products_collection_url }}" aria-label="{{ section.settings.heading_1 | escape }}"><span class="art" data-art="3" aria-hidden="true">{% if section.settings.image_3 != blank %}{{ section.settings.image_3 | image_url: width: 1600 | image_tag: widths: '360, 720, 1080, 1600', sizes: '(min-width: 990px) 50vw, 100vw', loading: 'lazy', class: 'ww-fx-image' }}{% endif %}</span><span class="cursor-caption">{{ section.settings.heading_1 | escape }}</span><span class="cursor-badge" aria-hidden="true">VIEW<br>STUDY</span></a><p class="hint" role="status">Hover to move the label; tap or press Enter to select.</p></section>
</ww-effect-study>
<script type="module" src="{{ 'ww-effect-studio.js' | asset_url }}"></script>
{% stylesheet %}
.ww-fx-host[data-effect-type="cursor-label"] *{box-sizing:border-box}.ww-fx-host[data-effect-type="cursor-label"]{margin:0;background:#111211;color:#f4f0e7;font:14px/1.55 Arial,Helvetica,sans-serif}.ww-fx-host[data-effect-type="cursor-label"] button,.ww-fx-host[data-effect-type="cursor-label"] input{font:inherit}.ww-fx-host[data-effect-type="cursor-label"] button{cursor:pointer;border:1px solid #ffffff50;border-radius:99px;padding:11px 18px;color:inherit;background:transparent;min-height:42px}.ww-fx-host[data-effect-type="cursor-label"] button:hover{background:#ffffff15}.ww-fx-host[data-effect-type="cursor-label"] button:focus-visible,.ww-fx-host[data-effect-type="cursor-label"] a:focus-visible,.ww-fx-host[data-effect-type="cursor-label"] input:focus-visible,.ww-fx-host[data-effect-type="cursor-label"] [tabindex]:focus-visible{outline:3px solid #c6fc6b;outline-offset:4px}.ww-fx-host[data-effect-type="cursor-label"] .fx{position:relative;min-height:500px;padding:34px;overflow:hidden;display:grid;align-content:center;gap:20px;isolation:isolate;background:#111211}.ww-fx-host[data-effect-type="cursor-label"] .fx h2,.ww-fx-host[data-effect-type="cursor-label"] .fx h3,.ww-fx-host[data-effect-type="cursor-label"] .fx p{margin:0}.ww-fx-host[data-effect-type="cursor-label"] .fx h2{font-size:clamp(36px,7vw,82px);font-weight:750;letter-spacing:-.065em;line-height:.98}.ww-fx-host[data-effect-type="cursor-label"] .fx small{letter-spacing:.18em;color:#c2c3b9;font-size:10px}.ww-fx-host[data-effect-type="cursor-label"] .fx>small{position:relative;z-index:2;align-self:start}.ww-fx-host[data-effect-type="cursor-label"] .fx p{max-width:46ch}.ww-fx-host[data-effect-type="cursor-label"] .fx:after{content:'WESWOO / INTERACTION STUDY';position:absolute;bottom:12px;right:23px;font-size:8px;letter-spacing:.18em;color:inherit;opacity:.45;pointer-events:none}.ww-fx-host[data-effect-type="cursor-label"] .art{position:relative;min-height:240px;border-radius:3px;overflow:hidden;background-color:#ea754e;background-size:cover;background-position:center}.ww-fx-host[data-effect-type="cursor-label"] .art:before,.ww-fx-host[data-effect-type="cursor-label"] .art:after{content:none!important}.ww-fx-host[data-effect-type="cursor-label"] .hint{font-size:11px;color:#b5b8ad}.ww-fx-host[data-effect-type="cursor-label"] .controls{display:flex;gap:8px;flex-wrap:wrap}.ww-fx-host[data-effect-type="cursor-label"] .scroller{height:385px;overflow-y:auto;scrollbar-width:thin;scrollbar-color:#b7b9a6 #292a26;border-radius:3px;position:relative;outline-offset:2px;overscroll-behavior-y:contain}.ww-fx-host[data-effect-type="cursor-label"] .spacer{height:120px;display:grid;place-items:center;color:#bfc1b5;font-size:11px;letter-spacing:.04em}.ww-fx-host[data-effect-type="cursor-label"] .fx [hidden]{display:none!important}.ww-fx-host[data-effect-type="cursor-label"] .fx[data-playing=false] *{animation-play-state:paused!important}.ww-fx-host[data-effect-type="cursor-label"] .fx button[aria-pressed=true]{background:#c6fc6b;color:#171a12}.ww-fx-host[data-effect-type="cursor-label"] .fx a{color:inherit;text-underline-offset:4px}.ww-fx-host[data-effect-type="cursor-label"] .fx[data-reduced-motion=true] *,.ww-fx-host[data-effect-type="cursor-label"] .fx[data-reduced-motion=true] *:before,.ww-fx-host[data-effect-type="cursor-label"] .fx[data-reduced-motion=true] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important}
@media(max-width:500px){.ww-fx-host[data-effect-type="cursor-label"] .fx{padding:22px;min-height:460px;gap:18px}.ww-fx-host[data-effect-type="cursor-label"] .fx h2{font-size:43px}.ww-fx-host[data-effect-type="cursor-label"] .fx>small{font-size:8px}.ww-fx-host[data-effect-type="cursor-label"] .art{min-height:215px}.ww-fx-host[data-effect-type="cursor-label"] .scroller{height:355px}.ww-fx-host[data-effect-type="cursor-label"] .fx:after{font-size:7px;right:16px}}
@media(prefers-reduced-motion:reduce){.ww-fx-host[data-effect-type="cursor-label"] *,.ww-fx-host[data-effect-type="cursor-label"] *:before,.ww-fx-host[data-effect-type="cursor-label"] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}.ww-fx-host[data-effect-type="cursor-label"] .art{background-image:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20900%20700%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%22bg%22%20x2%3D%221%22%20y2%3D%221%22%3E%3Cstop%20stop-color%3D%22%23ff764a%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23b52d29%22%2F%3E%3C%2FlinearGradient%3E%3ClinearGradient%20id%3D%22chrome%22%20x2%3D%22.8%22%20y2%3D%221%22%3E%3Cstop%20stop-color%3D%22%23fff8d7%22%2F%3E%3Cstop%20offset%3D%22.26%22%20stop-color%3D%22%23b3aca6%22%2F%3E%3Cstop%20offset%3D%22.48%22%20stop-color%3D%22%23fef9e8%22%2F%3E%3Cstop%20offset%3D%22.59%22%20stop-color%3D%22%23656773%22%2F%3E%3Cstop%20offset%3D%22.82%22%20stop-color%3D%22%23d5d9d2%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23373c46%22%2F%3E%3C%2FlinearGradient%3E%3CradialGradient%20id%3D%22pad%22%3E%3Cstop%20stop-color%3D%22%2355565c%22%2F%3E%3Cstop%20offset%3D%22.75%22%20stop-color%3D%22%23191b25%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%230e1019%22%2F%3E%3C%2FradialGradient%3E%3Cfilter%20id%3D%22shadow%22%3E%3CfeGaussianBlur%20stdDeviation%3D%2223%22%2F%3E%3C%2Ffilter%3E%3C%2Fdefs%3E%3Cpath%20fill%3D%22url%28%23bg%29%22%20d%3D%22M0%200h900v700H0z%22%2F%3E%3Ccircle%20cx%3D%22770%22%20cy%3D%2280%22%20r%3D%22265%22%20fill%3D%22%23ffa873%22%20opacity%3D%22.35%22%2F%3E%3Cpath%20d%3D%22M0%20560L900%20395V700H0%22%20fill%3D%22%23f88958%22%20opacity%3D%22.24%22%2F%3E%3Cellipse%20cx%3D%22463%22%20cy%3D%22594%22%20rx%3D%22230%22%20ry%3D%2238%22%20fill%3D%22%2353272b%22%20opacity%3D%22.55%22%20filter%3D%22url%28%23shadow%29%22%2F%3E%3Cg%20transform%3D%22rotate%28-17%20450%20350%29%22%3E%3Cpath%20d%3D%22M285%20417V296c0-231%20336-231%20336%200v121%22%20fill%3D%22none%22%20stroke%3D%22%232c3039%22%20stroke-width%3D%2262%22%2F%3E%3Cpath%20d%3D%22M285%20405V296c0-231%20336-231%20336%200v109%22%20fill%3D%22none%22%20stroke%3D%22url%28%23chrome%29%22%20stroke-width%3D%2243%22%2F%3E%3Cpath%20d%3D%22M306%20271c15-135%20269-135%20294%200%22%20fill%3D%22none%22%20stroke%3D%22%23f3e5d6%22%20stroke-width%3D%227%22%20opacity%3D%22.65%22%2F%3E%3Crect%20x%3D%22230%22%20y%3D%22335%22%20width%3D%22115%22%20height%3D%22200%22%20rx%3D%2255%22%20fill%3D%22url%28%23chrome%29%22%2F%3E%3Crect%20x%3D%22258%22%20y%3D%22344%22%20width%3D%2286%22%20height%3D%22181%22%20rx%3D%2242%22%20fill%3D%22url%28%23pad%29%22%2F%3E%3Crect%20x%3D%22559%22%20y%3D%22335%22%20width%3D%22115%22%20height%3D%22200%22%20rx%3D%2255%22%20fill%3D%22url%28%23chrome%29%22%2F%3E%3Crect%20x%3D%22558%22%20y%3D%22345%22%20width%3D%2283%22%20height%3D%22180%22%20rx%3D%2241%22%20fill%3D%22url%28%23pad%29%22%2F%3E%3Cpath%20d%3D%22M652%20374v109%22%20stroke%3D%22%23eee9d4%22%20opacity%3D%22.6%22%20stroke-width%3D%223%22%2F%3E%3Ccircle%20cx%3D%22655%22%20cy%3D%22505%22%20r%3D%225%22%20fill%3D%22%23df7a45%22%2F%3E%3C%2Fg%3E%3Cg%20fill%3D%22%23fff2db%22%20font-family%3D%22Arial%2Csans-serif%22%3E%3Ctext%20x%3D%2248%22%20y%3D%2266%22%20font-size%3D%2215%22%20letter-spacing%3D%225%22%3EARC%20%2F%20SOUND%20STUDY%3C%2Ftext%3E%3Ctext%20x%3D%2248%22%20y%3D%22650%22%20font-size%3D%2217%22%20letter-spacing%3D%222%22%3EFORM%20MEETS%20FEELING.%3C%2Ftext%3E%3Ctext%20x%3D%22804%22%20y%3D%22650%22%20font-size%3D%2217%22%3E01%3C%2Ftext%3E%3C%2Fg%3E%3C%2Fsvg%3E")}.ww-fx-host[data-effect-type="cursor-label"] .art[data-art="2"]{background-image:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20900%20700%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%22room%22%20x2%3D%221%22%20y2%3D%221%22%3E%3Cstop%20stop-color%3D%22%23e7ddcc%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23b8a78d%22%2F%3E%3C%2FlinearGradient%3E%3ClinearGradient%20id%3D%22seat%22%20x2%3D%22.8%22%20y2%3D%221%22%3E%3Cstop%20stop-color%3D%22%23efe9d7%22%2F%3E%3Cstop%20offset%3D%22.38%22%20stop-color%3D%22%23d1c8b3%22%2F%3E%3Cstop%20offset%3D%22.75%22%20stop-color%3D%22%23a99c82%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%238b806d%22%2F%3E%3C%2FlinearGradient%3E%3ClinearGradient%20id%3D%22leg%22%3E%3Cstop%20stop-color%3D%22%23a9a39b%22%2F%3E%3Cstop%20offset%3D%22.32%22%20stop-color%3D%22%23f7f4e6%22%2F%3E%3Cstop%20offset%3D%22.55%22%20stop-color%3D%22%23776f64%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23d5cbb9%22%2F%3E%3C%2FlinearGradient%3E%3Cfilter%20id%3D%22blur%22%3E%3CfeGaussianBlur%20stdDeviation%3D%2215%22%2F%3E%3C%2Ffilter%3E%3C%2Fdefs%3E%3Cpath%20fill%3D%22url%28%23room%29%22%20d%3D%22M0%200h900v700H0z%22%2F%3E%3Cpath%20d%3D%22M675%200h225v700H675z%22%20fill%3D%22%23b19e80%22%20opacity%3D%22.38%22%2F%3E%3Cpath%20d%3D%22M0%20512l675-85%20225%2083v190H0z%22%20fill%3D%22%23cfc0a4%22%2F%3E%3Cpath%20d%3D%22M65%200h144v480L65%20504z%22%20fill%3D%22%23f9f4df%22%20opacity%3D%22.45%22%2F%3E%3Cpath%20d%3D%22M250%200h40v470l-40%204z%22%20fill%3D%22%23f9f4df%22%20opacity%3D%22.3%22%2F%3E%3Cellipse%20cx%3D%22480%22%20cy%3D%22586%22%20rx%3D%22207%22%20ry%3D%2234%22%20fill%3D%22%236c5c47%22%20opacity%3D%22.32%22%20filter%3D%22url%28%23blur%29%22%2F%3E%3Cpath%20d%3D%22M350%20452l-43%20131M564%20435l50%20135M377%20429l140%20159%22%20fill%3D%22none%22%20stroke%3D%22url%28%23leg%29%22%20stroke-width%3D%2214%22%20stroke-linecap%3D%22round%22%2F%3E%3Cpath%20d%3D%22M295%20350c-27-24-40-81-18-145%2024-72%20201-97%20275-47%2058%2040%2070%20150%2065%20216-5%2063-46%2095-159%20104-118%2010-177-42-163-128z%22%20fill%3D%22url%28%23seat%29%22%2F%3E%3Cpath%20d%3D%22M302%20350c19%2038%20235%2035%20289-14%22%20fill%3D%22none%22%20stroke%3D%22%23f6efdb%22%20stroke-width%3D%224%22%20opacity%3D%22.5%22%2F%3E%3Cpath%20d%3D%22M285%20223c40-51%20185-66%20251-29%22%20fill%3D%22none%22%20stroke%3D%22%23fffae9%22%20stroke-width%3D%226%22%20opacity%3D%22.7%22%2F%3E%3Cpath%20d%3D%22M307%20372c38%2026%20178%2024%20255-7%22%20fill%3D%22none%22%20stroke%3D%22%237a705e%22%20stroke-width%3D%222%22%20opacity%3D%22.5%22%2F%3E%3Cg%20fill%3D%22%234c463b%22%20font-family%3D%22Arial%2Csans-serif%22%3E%3Ctext%20x%3D%2248%22%20y%3D%2266%22%20font-size%3D%2215%22%20letter-spacing%3D%225%22%3EOBJECT%20%2F%20COMFORT%20STUDY%3C%2Ftext%3E%3Ctext%20x%3D%2248%22%20y%3D%22650%22%20font-size%3D%2217%22%20letter-spacing%3D%222%22%3EA%20QUIETER%20KIND%20OF%20DESIGN.%3C%2Ftext%3E%3Ctext%20x%3D%22804%22%20y%3D%22650%22%20font-size%3D%2217%22%3E02%3C%2Ftext%3E%3C%2Fg%3E%3C%2Fsvg%3E")}.ww-fx-host[data-effect-type="cursor-label"] .art[data-art="3"]{background-image:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20900%20700%22%3E%3Cdefs%3E%3CradialGradient%20id%3D%22space%22%3E%3Cstop%20stop-color%3D%22%233350bd%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23101526%22%2F%3E%3C%2FradialGradient%3E%3ClinearGradient%20id%3D%22ring%22%20x2%3D%22.5%22%20y2%3D%221%22%3E%3Cstop%20stop-color%3D%22%23d6e6ff%22%2F%3E%3Cstop%20offset%3D%22.22%22%20stop-color%3D%22%236575a5%22%2F%3E%3Cstop%20offset%3D%22.42%22%20stop-color%3D%22%23f3f5ff%22%2F%3E%3Cstop%20offset%3D%22.6%22%20stop-color%3D%22%23263460%22%2F%3E%3Cstop%20offset%3D%22.85%22%20stop-color%3D%22%2394b5f0%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23131b3e%22%2F%3E%3C%2FlinearGradient%3E%3CradialGradient%20id%3D%22ball%22%20cx%3D%22.3%22%20cy%3D%22.2%22%3E%3Cstop%20stop-color%3D%22%23f1f4ff%22%2F%3E%3Cstop%20offset%3D%22.25%22%20stop-color%3D%22%239eb7f8%22%2F%3E%3Cstop%20offset%3D%22.63%22%20stop-color%3D%22%233f5aa0%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%2317244e%22%2F%3E%3C%2FradialGradient%3E%3Cfilter%20id%3D%22glow%22%3E%3CfeGaussianBlur%20stdDeviation%3D%2217%22%2F%3E%3C%2Ffilter%3E%3C%2Fdefs%3E%3Cpath%20fill%3D%22url%28%23space%29%22%20d%3D%22M0%200h900v700H0z%22%2F%3E%3Cg%20stroke%3D%22%23b2c4ff%22%20fill%3D%22none%22%20opacity%3D%22.14%22%3E%3Cellipse%20cx%3D%22450%22%20cy%3D%22370%22%20rx%3D%22374%22%20ry%3D%22210%22%2F%3E%3Cellipse%20cx%3D%22450%22%20cy%3D%22370%22%20rx%3D%22324%22%20ry%3D%22180%22%2F%3E%3Cellipse%20cx%3D%22450%22%20cy%3D%22370%22%20rx%3D%22274%22%20ry%3D%22150%22%2F%3E%3Cpath%20d%3D%22M0%20535h900M0%20600h900M450%20150v550M0%20700l450-550%20450%20550%22%2F%3E%3C%2Fg%3E%3Cellipse%20cx%3D%22466%22%20cy%3D%22568%22%20rx%3D%22193%22%20ry%3D%2224%22%20fill%3D%22%230b1028%22%20filter%3D%22url%28%23glow%29%22%2F%3E%3Cg%20transform%3D%22rotate%28-32%20450%20350%29%22%3E%3Cellipse%20cx%3D%22450%22%20cy%3D%22350%22%20rx%3D%22238%22%20ry%3D%22140%22%20fill%3D%22none%22%20stroke%3D%22url%28%23ring%29%22%20stroke-width%3D%2258%22%2F%3E%3Ccircle%20cx%3D%22450%22%20cy%3D%22350%22%20r%3D%2291%22%20fill%3D%22url%28%23ball%29%22%2F%3E%3Cpath%20d%3D%22M216%20350c0%2078%20104%20141%20234%20141s234-63%20234-141%22%20fill%3D%22none%22%20stroke%3D%22url%28%23ring%29%22%20stroke-width%3D%2258%22%2F%3E%3Cpath%20d%3D%22M218%20363c20%2075%20140%20128%20260%20119%22%20fill%3D%22none%22%20stroke%3D%22%23e5eaff%22%20stroke-width%3D%223%22%20opacity%3D%22.6%22%2F%3E%3C%2Fg%3E%3Cg%20fill%3D%22%23d0dcff%22%20font-family%3D%22Arial%2Csans-serif%22%3E%3Ctext%20x%3D%2248%22%20y%3D%2266%22%20font-size%3D%2215%22%20letter-spacing%3D%225%22%3EORBIT%20%2F%20MOTION%20STUDY%3C%2Ftext%3E%3Ctext%20x%3D%2248%22%20y%3D%22650%22%20font-size%3D%2217%22%20letter-spacing%3D%222%22%3EA%20DIFFERENT%20PERSPECTIVE.%3C%2Ftext%3E%3Ctext%20x%3D%22804%22%20y%3D%22650%22%20font-size%3D%2217%22%3E03%3C%2Ftext%3E%3C%2Fg%3E%3C%2Fsvg%3E")}.ww-fx-host[data-effect-type="cursor-label"] .fx{padding:25px;background:#111625}.ww-fx-host[data-effect-type="cursor-label"] .cursor-target{padding:0;border:0;border-radius:0;position:relative;overflow:hidden;text-align:left;background:transparent!important}.ww-fx-host[data-effect-type="cursor-label"] .cursor-target .art{display:block;height:360px}.ww-fx-host[data-effect-type="cursor-label"] .cursor-caption{position:absolute;left:20px;bottom:20px;border-radius:99px;background:#e6e9f0;color:#1b2240;padding:10px 16px;font-size:10px;letter-spacing:.08em}.ww-fx-host[data-effect-type="cursor-label"] .cursor-badge{display:grid;place-content:center;position:absolute;left:var(--cx,50%);top:var(--cy,50%);transform:translate(-50%,-50%) scale(.6);width:95px;height:95px;border-radius:50%;background:#d8fc75;color:#16202a;font:11px/1.2 Arial,sans-serif;letter-spacing:.1em;text-align:center;opacity:0;pointer-events:none;transition:opacity .2s,transform .25s}.ww-fx-host[data-effect-type="cursor-label"] .fx[data-label=true] .cursor-badge{opacity:1;transform:translate(-50%,-50%) scale(1)}.ww-fx-host[data-effect-type="cursor-label"] .fx[data-reduced-motion=true] .cursor-badge{display:none}@media(max-width:500px){.ww-fx-host[data-effect-type="cursor-label"] .cursor-target .art{height:330px}.ww-fx-host[data-effect-type="cursor-label"] .cursor-caption{font-size:8px;left:12px;bottom:12px}}
.ww-fx-host{display:block;position:relative;isolation:isolate;max-width:100%;background:#111211;color:#f4f0e7}.ww-fx-host>.ww-fx-controls{display:flex;gap:15px;align-items:center;padding:12px 20px;font:12px Arial,sans-serif}.ww-fx-host .ww-fx-controls button{color:inherit;border:1px solid #ffffff55;background:transparent;border-radius:99px;min-height:42px;padding:8px 18px;cursor:pointer}.ww-fx-host .ww-fx-image{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block}.ww-fx-host .cursor-target{display:block;color:inherit;text-decoration:none}.ww-fx-host .fx{min-height:500px}.ww-fx-host .fx .art{position:relative}.ww-fx-host .fx .portal-art,.ww-fx-host .fx .thumb-destination,.ww-fx-host .fx .scene-art{position:absolute}
{% endstylesheet %}
{% schema %}
{
"name": "WW cursor-label",
"settings": [
{
"type": "text",
"id": "heading_1",
"label": "Heading 1",
"default": "ORBIT — EXPLORE THE STUDY"
},
{
"type": "image_picker",
"id": "image_3",
"label": "Image 3"
},
{
"type": "url",
"id": "link",
"label": "Destination"
}
],
"presets": [
{
"name": "WW cursor-label"
}
]
}
{% endschema %}
{% comment %} WESWOO example shell. Add ONE effect's HTML inside .fx-slot. {% endcomment %}
{{ 'ww-effects.css' | asset_url | stylesheet_tag }}
<section id="ww-effect-{{ section.id }}" data-ww-effect-section>
<h2>{{ section.settings.heading | escape }}</h2>
<button type="button" data-effect-toggle aria-pressed="false">Play / pause effect</button>
<div class="fx-slot">
{% comment %} Insert the chosen .fx element here; read copy/images from section settings. {% endcomment %}
</div>
</section>
<script type="module" src="{{ 'ww-effect-section.js' | asset_url }}"></script>
{% schema %}
{"name":"WESWOO effect","settings":[{"type":"text","id":"heading","label":"Heading","default":"Our story"}],"presets":[{"name":"WESWOO effect"}]}
{% endschema %}
// Put the chosen example JS in assets/ww-selected-effect.js (rename .mjs to .js).
import {mountEffect} from './ww-selected-effect.js';
const instances=new Map();
function mount(container=document){
const roots=[...(container.matches?.('[data-ww-effect-section]')?[container]:[]),...container.querySelectorAll('[data-ww-effect-section]')];
for(const section of roots){
if(instances.has(section))continue;
const root=section.querySelector('.fx'),button=section.querySelector('[data-effect-toggle]');
if(!root||!button)continue;
const effect=mountEffect(root),events=new AbortController();let playing=false;
const pause=()=>{playing=false;effect.pause();button.setAttribute('aria-pressed','false');};
button.addEventListener('click',()=>{playing=!playing;playing?effect.resume():effect.pause();button.setAttribute('aria-pressed',String(playing));},{signal:events.signal});
const observer=new IntersectionObserver(entries=>{if(!entries[0].isIntersecting)pause();});observer.observe(section);
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:events.signal});
instances.set(section,()=>{observer.disconnect();events.abort();effect.destroy();});
}
}
document.addEventListener('shopify:section:load',event=>mount(event.target));
document.addEventListener('shopify:section:unload',event=>{for(const [section,destroy] of instances)if(section===event.target||event.target.contains(section)){destroy();instances.delete(section);}});
mount();
// Original WESWOO integration. Copy alongside the selected ww-effect-*.js asset.
// The server supplies the asset URL; do not accept a URL from a query parameter.
if (!customElements.get('ww-effect-study')) {
customElements.define('ww-effect-study', class extends HTMLElement {
connectedCallback() {
if (this.events) return;
this.events=new AbortController();this.session={};const session=this.session;
const button=this.querySelector('[data-effect-toggle]');
button.disabled=false;button.setAttribute('aria-pressed','false');this.visible=true;
const preference=matchMedia('(prefers-reduced-motion: reduce)');
const pause=()=>{this.effect?.pause();button.setAttribute('aria-pressed','false');};
this.pause=pause;
button.addEventListener('click',async()=>{
if(this.loading)return;
if(!this.effect){
this.loading=true;button.disabled=true;
try {
const {mountEffect}=await import(this.dataset.moduleUrl);
if(!this.isConnected||this.session!==session)return;
this.effect=mountEffect(this.querySelector('.fx'),{reducedMotion:preference.matches});
} catch {this.querySelector('[data-effect-status]').textContent='The static content is available. Reload to retry motion.';return;}
finally {if(this.session===session){this.loading=false;button.disabled=false;}}
}
if(this.session!==session||document.hidden||!this.visible)return;
const playing=button.getAttribute('aria-pressed')!=='true';
playing?this.effect.resume():this.effect.pause();button.setAttribute('aria-pressed',String(playing));
},{signal:this.events.signal});
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:this.events.signal});
preference.addEventListener('change',()=>{pause();this.effect?.destroy();this.effect=null;},{signal:this.events.signal});
this.observer=new IntersectionObserver(entries=>{this.visible=entries[0].isIntersecting;if(!this.visible)pause();});this.observer.observe(this);
const root=this.querySelector('.fx');
root.querySelectorAll('[data-view]').forEach(trigger=>trigger.addEventListener('click',()=>{const target=root.querySelector('dialog .art'),source=trigger.querySelector('.ww-fx-image');target.querySelector('.ww-fx-image')?.remove();if(source)target.append(source.cloneNode(true));},{signal:this.events.signal}));
// Section unload disconnects this custom element; reconnect mounts one fresh instance.
document.addEventListener('shopify:section:unload',event=>{if(event.target.contains(this))this.teardown();},{signal:this.events.signal});
}
teardown(){this.session=null;this.loading=false;this.observer?.disconnect();this.events?.abort();this.effect?.destroy();this.effect=null;this.events=null;}
disconnectedCallback(){this.teardown();}
});
}
Insert the selected effect into the shell. Each module loads one effect; multiple types need an explicit registry and Section mapping.
Examples are authored by WESWOO and credited open-source contributors; retain their applicable licenses. Project screens and photographs remain with their rights holders. Downloads use placeholders; replace them with imagery you may use.
Shopify/dawn · modal / slider base classesShopify/dawn · product media galleryShopify/dawn · licensePreparing preview
Material, making and finished-product images can introduce a furniture story. Hover or focus opens the arrangement; clicking pins it for inspection. This suits a brand opening, while separate product purchase entries are better kept outside moving fragments.
The example maps local pointer position to opposing small movements and combines updates into a frame. Theme image and heading settings should describe one subject, with room for longer text. Phones favour a clear composition and reduced motion a still arrangement. Pinning and closing need understandable feedback.
<section class="fx" data-effect="pointer-mosaic"><small>19 / EXPLORE THE BRAND</small><div class="mosaic-scene"><div class="mosaic-column" aria-hidden="true"><div class="art" data-art="1"></div><div class="art" data-art="2"></div></div><button type="button" class="mosaic-trigger" aria-pressed="false">A NEW<br><em>PERSPECTIVE.</em><span>Hover or tap to explore</span></button><div class="mosaic-column" aria-hidden="true"><div class="art" data-art="3"></div><div class="art" data-art="1"></div></div></div><p class="hint" role="status">A local hero composition. The normal pointer stays visible.</p></section>
*{box-sizing:border-box}body{margin:0;background:#111211;color:#f4f0e7;font:14px/1.55 Arial,Helvetica,sans-serif}button,input{font:inherit}button{cursor:pointer;border:1px solid #ffffff50;border-radius:99px;padding:11px 18px;color:inherit;background:transparent;min-height:42px}button:hover{background:#ffffff15}button:focus-visible,a:focus-visible,input:focus-visible,[tabindex]:focus-visible{outline:3px solid #c6fc6b;outline-offset:4px}.fx{position:relative;min-height:500px;padding:34px;overflow:hidden;display:grid;align-content:center;gap:20px;isolation:isolate;background:#111211}.fx h2,.fx h3,.fx p{margin:0}.fx h2{font-size:clamp(36px,7vw,82px);font-weight:750;letter-spacing:-.065em;line-height:.98}.fx small{letter-spacing:.18em;color:#c2c3b9;font-size:10px}.fx>small{position:relative;z-index:2;align-self:start}.fx p{max-width:46ch}.fx:after{content:'WESWOO / INTERACTION STUDY';position:absolute;bottom:12px;right:23px;font-size:8px;letter-spacing:.18em;color:inherit;opacity:.45;pointer-events:none}.art{position:relative;min-height:240px;border-radius:3px;overflow:hidden;background-color:#ea754e;background-size:cover;background-position:center}.art:before,.art:after{content:none!important}.hint{font-size:11px;color:#b5b8ad}.controls{display:flex;gap:8px;flex-wrap:wrap}.scroller{height:385px;overflow-y:auto;scrollbar-width:thin;scrollbar-color:#b7b9a6 #292a26;border-radius:3px;position:relative;outline-offset:2px;overscroll-behavior-y:contain}.spacer{height:120px;display:grid;place-items:center;color:#bfc1b5;font-size:11px;letter-spacing:.04em}.fx [hidden]{display:none!important}.fx[data-playing=false] *{animation-play-state:paused!important}.fx button[aria-pressed=true]{background:#c6fc6b;color:#171a12}.fx a{color:inherit;text-underline-offset:4px}.fx[data-reduced-motion=true] *,.fx[data-reduced-motion=true] *:before,.fx[data-reduced-motion=true] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important}
@media(max-width:500px){.fx{padding:22px;min-height:460px;gap:18px}.fx h2{font-size:43px}.fx>small{font-size:8px}.art{min-height:215px}.scroller{height:355px}.fx:after{font-size:7px;right:16px}}
@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}
.fx{background:#e8e5db;color:#26291f}.fx small,.hint{color:#626950}.mosaic-scene{position:relative;min-height:340px;display:grid;align-items:center;grid-template-columns:1fr 1.6fr 1fr;gap:20px}.mosaic-column{display:grid;gap:17px;transition:transform .45s,opacity .45s;opacity:.55}.mosaic-column:first-child{transform:translate(-30px,30px) rotate(-9deg)}.mosaic-column:last-child{transform:translate(30px,-30px) rotate(9deg)}.mosaic-column .art{min-height:145px;border-radius:4px}.mosaic-column .art:nth-child(2){height:100px;min-height:100px}.mosaic-trigger{position:relative;z-index:1;border:0;padding:25px 0;font-size:clamp(33px,5.5vw,64px);line-height:.95;font-weight:750;letter-spacing:-.065em;background:transparent!important;color:#26291f}.mosaic-trigger em{font:italic 1em Georgia,serif}.mosaic-trigger span{display:block;font:10px Arial,sans-serif;letter-spacing:.03em;margin-top:24px}.fx[data-exploring=true] .mosaic-column{opacity:1;transform:translate(var(--mx,0px),var(--my,0px)) rotate(0)}.fx[data-exploring=true] .mosaic-column:last-child{transform:translate(calc(-1 * var(--mx,0px)),calc(-1 * var(--my,0px))) rotate(0)}@media(max-width:500px){.mosaic-scene{grid-template-columns:1fr 2fr 1fr;gap:0;margin:0 -12px}.mosaic-column .art{min-height:140px}.mosaic-trigger{font-size:32px}}.fx[data-reduced-motion=true] .mosaic-column{opacity:1;transform:none!important}
@media(max-width:500px){.mosaic-trigger em{font-size:25px}}
/* Real website project imagery; rights remain with the project owners. */
.art{background-image:url("https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/shokz-openfit-preview.webp");background-size:cover;background-position:center} .art[data-art="1"]{background-image:url("https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/shokz-openfit-preview.webp");background-size:cover;background-position:center} .art[data-art="2"]{background-image:url("https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/termino-preview.webp");background-size:cover;background-position:center} .art[data-art="3"]{background-image:url("https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/iniu-preview.webp");background-size:cover;background-position:center} .art:before,.art:after{content:none!important}// WESWOO original educational example; no third-party runtime required.
export function mountEffect(root, {reducedMotion=false}={}) {
const reduced=reducedMotion||matchMedia('(prefers-reduced-motion: reduce)').matches;
root.dataset.reducedMotion=String(reduced);
const life=new AbortController(), animations=[];
let active=false, started=false;
const on=(node,type,fn,options={})=>node.addEventListener(type,fn,{...options,signal:life.signal});
const animate=(node,frames,options)=>{
if(reduced)return null;
const animation=node.animate(frames,options);animations.push(animation);return animation;
};
let start=()=>{}, stop=()=>{}, cleanup=()=>{};
const trigger=root.querySelector('.mosaic-trigger');let pinned=false,frame=0,x=0,y=0;
function reflect(value){root.dataset.exploring=String(value);trigger.setAttribute('aria-pressed',String(value));}
on(trigger,'pointerenter',event=>{if(active&&event.pointerType==='mouse')reflect(true);});on(trigger,'focus',()=>{if(active)reflect(true);});
on(trigger,'click',()=>{if(active){pinned=!pinned;reflect(pinned);root.querySelector('[role=status]').textContent=pinned?'Composition expanded. Tap again to settle.':'Composition settled.';}});
on(root,'pointermove',event=>{if(!active||reduced||event.pointerType!=='mouse')return;const r=root.getBoundingClientRect();x=(event.clientX-r.left-r.width/2)/r.width*30;y=(event.clientY-r.top-r.height/2)/r.height*30;if(!frame)frame=requestAnimationFrame(()=>{frame=0;root.style.setProperty('--mx',x+'px');root.style.setProperty('--my',y+'px');});});
on(trigger,'pointerleave',()=>reflect(pinned));on(trigger,'blur',()=>reflect(pinned));stop=()=>{cancelAnimationFrame(frame);frame=0;pinned=false;reflect(false);root.style.removeProperty('--mx');root.style.removeProperty('--my');};cleanup=stop;
root.dataset.playing='false';
return {
resume(){active=true;root.dataset.playing='true';if(!started){started=true;start();}animations.forEach(a=>a.play());root.dispatchEvent(new Event('ww:resume'));},
pause(){active=false;root.dataset.playing='false';animations.forEach(a=>a.pause());stop();},
destroy(){active=false;life.abort();animations.forEach(a=>a.cancel());cleanup();}
};
}
A brand hero Section. image_1 through image_3 supply artwork, and heading_1 / heading_2 provide copy. Decorative imagery does not replace a stable project link list.
Hover or focus expands both columns; clicking pins or closes the composition. Normalize mouse coordinates within the container, cap displacement at 30px, then update --mx and --my in one scheduled frame with opposing signs.
Touch uses the real button; keyboard keeps a stable accessible name. Reduced motion expands statically. Leave, blur and pause reset the scene without replacing the normal pointer.
Check phone text visibility, click-to-close, a stable target and no pending frames or listeners after teardown. The online preview uses existing project imagery; rights remain with the respective owners.
Files: copy sections/ww-effect-pointer-mosaic.liquid; save this example’s JavaScript unchanged as assets/ww-effect-pointer-mosaic.js, and copy the shared assets/ww-effect-studio.js below. The Section includes CSS scoped to .ww-fx-host.
Data: A brand hero Section. image_1 through image_3 supply artwork, and heading_1 / heading_2 provide copy. Decorative imagery does not replace a stable project link list.
Initialization: load the selected module on the first play action. Each Section keeps its own instance; offscreen, visibility and preference changes pause it, and unload releases observers and listeners.
Delivery scope: this concrete theme example retains the local canvas scroll model. A page-driven version needs the documented Section interval adaptation. Replace images, localize controls and verify actual theme styles and devices in a duplicate theme.
Work in a duplicate theme. Replace demo copy and artwork with Section settings, scope styles to that Section, and use the lifecycle module for editor reloads, visibility and teardown.
{% comment %}
WESWOO original Section example. Copy assets/ww-effect-pointer-mosaic.js and assets/ww-effect-studio.js.
This preserves the local preview scroll model. A page-driven story needs the documented Section interval adaptation.
Theme Check is static validation, not a completed merchant-theme installation. Localize control strings for multilingual shops.
{% endcomment %}
<ww-effect-study class="ww-fx-host" data-effect-type="pointer-mosaic" id="WWEffect-{{ section.id }}" data-module-url="{{ 'ww-effect-pointer-mosaic.js' | asset_url }}">
<div class="ww-fx-controls"><button type="button" data-effect-toggle aria-pressed="false">Play / pause</button><span data-effect-status role="status"></span></div>
<section class="fx" data-effect="pointer-mosaic"><small>19 / EXPLORE THE BRAND</small><div class="mosaic-scene"><div class="mosaic-column" aria-hidden="true"><div class="art" data-art="1">{% if section.settings.image_1 != blank %}{{ section.settings.image_1 | image_url: width: 1600 | image_tag: widths: '360, 720, 1080, 1600', sizes: '(min-width: 990px) 50vw, 100vw', loading: 'lazy', class: 'ww-fx-image' }}{% endif %}</div><div class="art" data-art="2">{% if section.settings.image_2 != blank %}{{ section.settings.image_2 | image_url: width: 1600 | image_tag: widths: '360, 720, 1080, 1600', sizes: '(min-width: 990px) 50vw, 100vw', loading: 'lazy', class: 'ww-fx-image' }}{% endif %}</div></div><button type="button" class="mosaic-trigger" aria-pressed="false">{{ section.settings.heading_1 | escape }}<br><em>{{ section.settings.heading_2 | escape }}</em><span>Hover or tap to explore</span></button><div class="mosaic-column" aria-hidden="true"><div class="art" data-art="3">{% if section.settings.image_3 != blank %}{{ section.settings.image_3 | image_url: width: 1600 | image_tag: widths: '360, 720, 1080, 1600', sizes: '(min-width: 990px) 50vw, 100vw', loading: 'lazy', class: 'ww-fx-image' }}{% endif %}</div><div class="art" data-art="1">{% if section.settings.image_1 != blank %}{{ section.settings.image_1 | image_url: width: 1600 | image_tag: widths: '360, 720, 1080, 1600', sizes: '(min-width: 990px) 50vw, 100vw', loading: 'lazy', class: 'ww-fx-image' }}{% endif %}</div></div></div><p class="hint" role="status">A local hero composition. The normal pointer stays visible.</p></section>
</ww-effect-study>
<script type="module" src="{{ 'ww-effect-studio.js' | asset_url }}"></script>
{% stylesheet %}
.ww-fx-host[data-effect-type="pointer-mosaic"] *{box-sizing:border-box}.ww-fx-host[data-effect-type="pointer-mosaic"]{margin:0;background:#111211;color:#f4f0e7;font:14px/1.55 Arial,Helvetica,sans-serif}.ww-fx-host[data-effect-type="pointer-mosaic"] button,.ww-fx-host[data-effect-type="pointer-mosaic"] input{font:inherit}.ww-fx-host[data-effect-type="pointer-mosaic"] button{cursor:pointer;border:1px solid #ffffff50;border-radius:99px;padding:11px 18px;color:inherit;background:transparent;min-height:42px}.ww-fx-host[data-effect-type="pointer-mosaic"] button:hover{background:#ffffff15}.ww-fx-host[data-effect-type="pointer-mosaic"] button:focus-visible,.ww-fx-host[data-effect-type="pointer-mosaic"] a:focus-visible,.ww-fx-host[data-effect-type="pointer-mosaic"] input:focus-visible,.ww-fx-host[data-effect-type="pointer-mosaic"] [tabindex]:focus-visible{outline:3px solid #c6fc6b;outline-offset:4px}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx{position:relative;min-height:500px;padding:34px;overflow:hidden;display:grid;align-content:center;gap:20px;isolation:isolate;background:#111211}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx h2,.ww-fx-host[data-effect-type="pointer-mosaic"] .fx h3,.ww-fx-host[data-effect-type="pointer-mosaic"] .fx p{margin:0}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx h2{font-size:clamp(36px,7vw,82px);font-weight:750;letter-spacing:-.065em;line-height:.98}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx small{letter-spacing:.18em;color:#c2c3b9;font-size:10px}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx>small{position:relative;z-index:2;align-self:start}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx p{max-width:46ch}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx:after{content:'WESWOO / INTERACTION STUDY';position:absolute;bottom:12px;right:23px;font-size:8px;letter-spacing:.18em;color:inherit;opacity:.45;pointer-events:none}.ww-fx-host[data-effect-type="pointer-mosaic"] .art{position:relative;min-height:240px;border-radius:3px;overflow:hidden;background-color:#ea754e;background-size:cover;background-position:center}.ww-fx-host[data-effect-type="pointer-mosaic"] .art:before,.ww-fx-host[data-effect-type="pointer-mosaic"] .art:after{content:none!important}.ww-fx-host[data-effect-type="pointer-mosaic"] .hint{font-size:11px;color:#b5b8ad}.ww-fx-host[data-effect-type="pointer-mosaic"] .controls{display:flex;gap:8px;flex-wrap:wrap}.ww-fx-host[data-effect-type="pointer-mosaic"] .scroller{height:385px;overflow-y:auto;scrollbar-width:thin;scrollbar-color:#b7b9a6 #292a26;border-radius:3px;position:relative;outline-offset:2px;overscroll-behavior-y:contain}.ww-fx-host[data-effect-type="pointer-mosaic"] .spacer{height:120px;display:grid;place-items:center;color:#bfc1b5;font-size:11px;letter-spacing:.04em}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx [hidden]{display:none!important}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx[data-playing=false] *{animation-play-state:paused!important}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx button[aria-pressed=true]{background:#c6fc6b;color:#171a12}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx a{color:inherit;text-underline-offset:4px}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx[data-reduced-motion=true] *,.ww-fx-host[data-effect-type="pointer-mosaic"] .fx[data-reduced-motion=true] *:before,.ww-fx-host[data-effect-type="pointer-mosaic"] .fx[data-reduced-motion=true] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important}
@media(max-width:500px){.ww-fx-host[data-effect-type="pointer-mosaic"] .fx{padding:22px;min-height:460px;gap:18px}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx h2{font-size:43px}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx>small{font-size:8px}.ww-fx-host[data-effect-type="pointer-mosaic"] .art{min-height:215px}.ww-fx-host[data-effect-type="pointer-mosaic"] .scroller{height:355px}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx:after{font-size:7px;right:16px}}
@media(prefers-reduced-motion:reduce){.ww-fx-host[data-effect-type="pointer-mosaic"] *,.ww-fx-host[data-effect-type="pointer-mosaic"] *:before,.ww-fx-host[data-effect-type="pointer-mosaic"] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}.ww-fx-host[data-effect-type="pointer-mosaic"] .art{background-image:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20900%20700%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%22bg%22%20x2%3D%221%22%20y2%3D%221%22%3E%3Cstop%20stop-color%3D%22%23ff764a%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23b52d29%22%2F%3E%3C%2FlinearGradient%3E%3ClinearGradient%20id%3D%22chrome%22%20x2%3D%22.8%22%20y2%3D%221%22%3E%3Cstop%20stop-color%3D%22%23fff8d7%22%2F%3E%3Cstop%20offset%3D%22.26%22%20stop-color%3D%22%23b3aca6%22%2F%3E%3Cstop%20offset%3D%22.48%22%20stop-color%3D%22%23fef9e8%22%2F%3E%3Cstop%20offset%3D%22.59%22%20stop-color%3D%22%23656773%22%2F%3E%3Cstop%20offset%3D%22.82%22%20stop-color%3D%22%23d5d9d2%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23373c46%22%2F%3E%3C%2FlinearGradient%3E%3CradialGradient%20id%3D%22pad%22%3E%3Cstop%20stop-color%3D%22%2355565c%22%2F%3E%3Cstop%20offset%3D%22.75%22%20stop-color%3D%22%23191b25%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%230e1019%22%2F%3E%3C%2FradialGradient%3E%3Cfilter%20id%3D%22shadow%22%3E%3CfeGaussianBlur%20stdDeviation%3D%2223%22%2F%3E%3C%2Ffilter%3E%3C%2Fdefs%3E%3Cpath%20fill%3D%22url%28%23bg%29%22%20d%3D%22M0%200h900v700H0z%22%2F%3E%3Ccircle%20cx%3D%22770%22%20cy%3D%2280%22%20r%3D%22265%22%20fill%3D%22%23ffa873%22%20opacity%3D%22.35%22%2F%3E%3Cpath%20d%3D%22M0%20560L900%20395V700H0%22%20fill%3D%22%23f88958%22%20opacity%3D%22.24%22%2F%3E%3Cellipse%20cx%3D%22463%22%20cy%3D%22594%22%20rx%3D%22230%22%20ry%3D%2238%22%20fill%3D%22%2353272b%22%20opacity%3D%22.55%22%20filter%3D%22url%28%23shadow%29%22%2F%3E%3Cg%20transform%3D%22rotate%28-17%20450%20350%29%22%3E%3Cpath%20d%3D%22M285%20417V296c0-231%20336-231%20336%200v121%22%20fill%3D%22none%22%20stroke%3D%22%232c3039%22%20stroke-width%3D%2262%22%2F%3E%3Cpath%20d%3D%22M285%20405V296c0-231%20336-231%20336%200v109%22%20fill%3D%22none%22%20stroke%3D%22url%28%23chrome%29%22%20stroke-width%3D%2243%22%2F%3E%3Cpath%20d%3D%22M306%20271c15-135%20269-135%20294%200%22%20fill%3D%22none%22%20stroke%3D%22%23f3e5d6%22%20stroke-width%3D%227%22%20opacity%3D%22.65%22%2F%3E%3Crect%20x%3D%22230%22%20y%3D%22335%22%20width%3D%22115%22%20height%3D%22200%22%20rx%3D%2255%22%20fill%3D%22url%28%23chrome%29%22%2F%3E%3Crect%20x%3D%22258%22%20y%3D%22344%22%20width%3D%2286%22%20height%3D%22181%22%20rx%3D%2242%22%20fill%3D%22url%28%23pad%29%22%2F%3E%3Crect%20x%3D%22559%22%20y%3D%22335%22%20width%3D%22115%22%20height%3D%22200%22%20rx%3D%2255%22%20fill%3D%22url%28%23chrome%29%22%2F%3E%3Crect%20x%3D%22558%22%20y%3D%22345%22%20width%3D%2283%22%20height%3D%22180%22%20rx%3D%2241%22%20fill%3D%22url%28%23pad%29%22%2F%3E%3Cpath%20d%3D%22M652%20374v109%22%20stroke%3D%22%23eee9d4%22%20opacity%3D%22.6%22%20stroke-width%3D%223%22%2F%3E%3Ccircle%20cx%3D%22655%22%20cy%3D%22505%22%20r%3D%225%22%20fill%3D%22%23df7a45%22%2F%3E%3C%2Fg%3E%3Cg%20fill%3D%22%23fff2db%22%20font-family%3D%22Arial%2Csans-serif%22%3E%3Ctext%20x%3D%2248%22%20y%3D%2266%22%20font-size%3D%2215%22%20letter-spacing%3D%225%22%3EARC%20%2F%20SOUND%20STUDY%3C%2Ftext%3E%3Ctext%20x%3D%2248%22%20y%3D%22650%22%20font-size%3D%2217%22%20letter-spacing%3D%222%22%3EFORM%20MEETS%20FEELING.%3C%2Ftext%3E%3Ctext%20x%3D%22804%22%20y%3D%22650%22%20font-size%3D%2217%22%3E01%3C%2Ftext%3E%3C%2Fg%3E%3C%2Fsvg%3E")}.ww-fx-host[data-effect-type="pointer-mosaic"] .art[data-art="2"]{background-image:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20900%20700%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%22room%22%20x2%3D%221%22%20y2%3D%221%22%3E%3Cstop%20stop-color%3D%22%23e7ddcc%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23b8a78d%22%2F%3E%3C%2FlinearGradient%3E%3ClinearGradient%20id%3D%22seat%22%20x2%3D%22.8%22%20y2%3D%221%22%3E%3Cstop%20stop-color%3D%22%23efe9d7%22%2F%3E%3Cstop%20offset%3D%22.38%22%20stop-color%3D%22%23d1c8b3%22%2F%3E%3Cstop%20offset%3D%22.75%22%20stop-color%3D%22%23a99c82%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%238b806d%22%2F%3E%3C%2FlinearGradient%3E%3ClinearGradient%20id%3D%22leg%22%3E%3Cstop%20stop-color%3D%22%23a9a39b%22%2F%3E%3Cstop%20offset%3D%22.32%22%20stop-color%3D%22%23f7f4e6%22%2F%3E%3Cstop%20offset%3D%22.55%22%20stop-color%3D%22%23776f64%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23d5cbb9%22%2F%3E%3C%2FlinearGradient%3E%3Cfilter%20id%3D%22blur%22%3E%3CfeGaussianBlur%20stdDeviation%3D%2215%22%2F%3E%3C%2Ffilter%3E%3C%2Fdefs%3E%3Cpath%20fill%3D%22url%28%23room%29%22%20d%3D%22M0%200h900v700H0z%22%2F%3E%3Cpath%20d%3D%22M675%200h225v700H675z%22%20fill%3D%22%23b19e80%22%20opacity%3D%22.38%22%2F%3E%3Cpath%20d%3D%22M0%20512l675-85%20225%2083v190H0z%22%20fill%3D%22%23cfc0a4%22%2F%3E%3Cpath%20d%3D%22M65%200h144v480L65%20504z%22%20fill%3D%22%23f9f4df%22%20opacity%3D%22.45%22%2F%3E%3Cpath%20d%3D%22M250%200h40v470l-40%204z%22%20fill%3D%22%23f9f4df%22%20opacity%3D%22.3%22%2F%3E%3Cellipse%20cx%3D%22480%22%20cy%3D%22586%22%20rx%3D%22207%22%20ry%3D%2234%22%20fill%3D%22%236c5c47%22%20opacity%3D%22.32%22%20filter%3D%22url%28%23blur%29%22%2F%3E%3Cpath%20d%3D%22M350%20452l-43%20131M564%20435l50%20135M377%20429l140%20159%22%20fill%3D%22none%22%20stroke%3D%22url%28%23leg%29%22%20stroke-width%3D%2214%22%20stroke-linecap%3D%22round%22%2F%3E%3Cpath%20d%3D%22M295%20350c-27-24-40-81-18-145%2024-72%20201-97%20275-47%2058%2040%2070%20150%2065%20216-5%2063-46%2095-159%20104-118%2010-177-42-163-128z%22%20fill%3D%22url%28%23seat%29%22%2F%3E%3Cpath%20d%3D%22M302%20350c19%2038%20235%2035%20289-14%22%20fill%3D%22none%22%20stroke%3D%22%23f6efdb%22%20stroke-width%3D%224%22%20opacity%3D%22.5%22%2F%3E%3Cpath%20d%3D%22M285%20223c40-51%20185-66%20251-29%22%20fill%3D%22none%22%20stroke%3D%22%23fffae9%22%20stroke-width%3D%226%22%20opacity%3D%22.7%22%2F%3E%3Cpath%20d%3D%22M307%20372c38%2026%20178%2024%20255-7%22%20fill%3D%22none%22%20stroke%3D%22%237a705e%22%20stroke-width%3D%222%22%20opacity%3D%22.5%22%2F%3E%3Cg%20fill%3D%22%234c463b%22%20font-family%3D%22Arial%2Csans-serif%22%3E%3Ctext%20x%3D%2248%22%20y%3D%2266%22%20font-size%3D%2215%22%20letter-spacing%3D%225%22%3EOBJECT%20%2F%20COMFORT%20STUDY%3C%2Ftext%3E%3Ctext%20x%3D%2248%22%20y%3D%22650%22%20font-size%3D%2217%22%20letter-spacing%3D%222%22%3EA%20QUIETER%20KIND%20OF%20DESIGN.%3C%2Ftext%3E%3Ctext%20x%3D%22804%22%20y%3D%22650%22%20font-size%3D%2217%22%3E02%3C%2Ftext%3E%3C%2Fg%3E%3C%2Fsvg%3E")}.ww-fx-host[data-effect-type="pointer-mosaic"] .art[data-art="3"]{background-image:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20900%20700%22%3E%3Cdefs%3E%3CradialGradient%20id%3D%22space%22%3E%3Cstop%20stop-color%3D%22%233350bd%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23101526%22%2F%3E%3C%2FradialGradient%3E%3ClinearGradient%20id%3D%22ring%22%20x2%3D%22.5%22%20y2%3D%221%22%3E%3Cstop%20stop-color%3D%22%23d6e6ff%22%2F%3E%3Cstop%20offset%3D%22.22%22%20stop-color%3D%22%236575a5%22%2F%3E%3Cstop%20offset%3D%22.42%22%20stop-color%3D%22%23f3f5ff%22%2F%3E%3Cstop%20offset%3D%22.6%22%20stop-color%3D%22%23263460%22%2F%3E%3Cstop%20offset%3D%22.85%22%20stop-color%3D%22%2394b5f0%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23131b3e%22%2F%3E%3C%2FlinearGradient%3E%3CradialGradient%20id%3D%22ball%22%20cx%3D%22.3%22%20cy%3D%22.2%22%3E%3Cstop%20stop-color%3D%22%23f1f4ff%22%2F%3E%3Cstop%20offset%3D%22.25%22%20stop-color%3D%22%239eb7f8%22%2F%3E%3Cstop%20offset%3D%22.63%22%20stop-color%3D%22%233f5aa0%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%2317244e%22%2F%3E%3C%2FradialGradient%3E%3Cfilter%20id%3D%22glow%22%3E%3CfeGaussianBlur%20stdDeviation%3D%2217%22%2F%3E%3C%2Ffilter%3E%3C%2Fdefs%3E%3Cpath%20fill%3D%22url%28%23space%29%22%20d%3D%22M0%200h900v700H0z%22%2F%3E%3Cg%20stroke%3D%22%23b2c4ff%22%20fill%3D%22none%22%20opacity%3D%22.14%22%3E%3Cellipse%20cx%3D%22450%22%20cy%3D%22370%22%20rx%3D%22374%22%20ry%3D%22210%22%2F%3E%3Cellipse%20cx%3D%22450%22%20cy%3D%22370%22%20rx%3D%22324%22%20ry%3D%22180%22%2F%3E%3Cellipse%20cx%3D%22450%22%20cy%3D%22370%22%20rx%3D%22274%22%20ry%3D%22150%22%2F%3E%3Cpath%20d%3D%22M0%20535h900M0%20600h900M450%20150v550M0%20700l450-550%20450%20550%22%2F%3E%3C%2Fg%3E%3Cellipse%20cx%3D%22466%22%20cy%3D%22568%22%20rx%3D%22193%22%20ry%3D%2224%22%20fill%3D%22%230b1028%22%20filter%3D%22url%28%23glow%29%22%2F%3E%3Cg%20transform%3D%22rotate%28-32%20450%20350%29%22%3E%3Cellipse%20cx%3D%22450%22%20cy%3D%22350%22%20rx%3D%22238%22%20ry%3D%22140%22%20fill%3D%22none%22%20stroke%3D%22url%28%23ring%29%22%20stroke-width%3D%2258%22%2F%3E%3Ccircle%20cx%3D%22450%22%20cy%3D%22350%22%20r%3D%2291%22%20fill%3D%22url%28%23ball%29%22%2F%3E%3Cpath%20d%3D%22M216%20350c0%2078%20104%20141%20234%20141s234-63%20234-141%22%20fill%3D%22none%22%20stroke%3D%22url%28%23ring%29%22%20stroke-width%3D%2258%22%2F%3E%3Cpath%20d%3D%22M218%20363c20%2075%20140%20128%20260%20119%22%20fill%3D%22none%22%20stroke%3D%22%23e5eaff%22%20stroke-width%3D%223%22%20opacity%3D%22.6%22%2F%3E%3C%2Fg%3E%3Cg%20fill%3D%22%23d0dcff%22%20font-family%3D%22Arial%2Csans-serif%22%3E%3Ctext%20x%3D%2248%22%20y%3D%2266%22%20font-size%3D%2215%22%20letter-spacing%3D%225%22%3EORBIT%20%2F%20MOTION%20STUDY%3C%2Ftext%3E%3Ctext%20x%3D%2248%22%20y%3D%22650%22%20font-size%3D%2217%22%20letter-spacing%3D%222%22%3EA%20DIFFERENT%20PERSPECTIVE.%3C%2Ftext%3E%3Ctext%20x%3D%22804%22%20y%3D%22650%22%20font-size%3D%2217%22%3E03%3C%2Ftext%3E%3C%2Fg%3E%3C%2Fsvg%3E")}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx{background:#e8e5db;color:#26291f}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx small,.ww-fx-host[data-effect-type="pointer-mosaic"] .hint{color:#626950}.ww-fx-host[data-effect-type="pointer-mosaic"] .mosaic-scene{position:relative;min-height:340px;display:grid;align-items:center;grid-template-columns:1fr 1.6fr 1fr;gap:20px}.ww-fx-host[data-effect-type="pointer-mosaic"] .mosaic-column{display:grid;gap:17px;transition:transform .45s,opacity .45s;opacity:.55}.ww-fx-host[data-effect-type="pointer-mosaic"] .mosaic-column:first-child{transform:translate(-30px,30px) rotate(-9deg)}.ww-fx-host[data-effect-type="pointer-mosaic"] .mosaic-column:last-child{transform:translate(30px,-30px) rotate(9deg)}.ww-fx-host[data-effect-type="pointer-mosaic"] .mosaic-column .art{min-height:145px;border-radius:4px}.ww-fx-host[data-effect-type="pointer-mosaic"] .mosaic-column .art:nth-child(2){height:100px;min-height:100px}.ww-fx-host[data-effect-type="pointer-mosaic"] .mosaic-trigger{position:relative;z-index:1;border:0;padding:25px 0;font-size:clamp(33px,5.5vw,64px);line-height:.95;font-weight:750;letter-spacing:-.065em;background:transparent!important;color:#26291f}.ww-fx-host[data-effect-type="pointer-mosaic"] .mosaic-trigger em{font:italic 1em Georgia,serif}.ww-fx-host[data-effect-type="pointer-mosaic"] .mosaic-trigger span{display:block;font:10px Arial,sans-serif;letter-spacing:.03em;margin-top:24px}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx[data-exploring=true] .mosaic-column{opacity:1;transform:translate(var(--mx,0px),var(--my,0px)) rotate(0)}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx[data-exploring=true] .mosaic-column:last-child{transform:translate(calc(-1 * var(--mx,0px)),calc(-1 * var(--my,0px))) rotate(0)}@media(max-width:500px){.ww-fx-host[data-effect-type="pointer-mosaic"] .mosaic-scene{grid-template-columns:1fr 2fr 1fr;gap:0;margin:0 -12px}.ww-fx-host[data-effect-type="pointer-mosaic"] .mosaic-column .art{min-height:140px}.ww-fx-host[data-effect-type="pointer-mosaic"] .mosaic-trigger{font-size:32px}}.ww-fx-host[data-effect-type="pointer-mosaic"] .fx[data-reduced-motion=true] .mosaic-column{opacity:1;transform:none!important}
@media(max-width:500px){.ww-fx-host[data-effect-type="pointer-mosaic"] .mosaic-trigger em{font-size:25px}}
.ww-fx-host{display:block;position:relative;isolation:isolate;max-width:100%;background:#111211;color:#f4f0e7}.ww-fx-host>.ww-fx-controls{display:flex;gap:15px;align-items:center;padding:12px 20px;font:12px Arial,sans-serif}.ww-fx-host .ww-fx-controls button{color:inherit;border:1px solid #ffffff55;background:transparent;border-radius:99px;min-height:42px;padding:8px 18px;cursor:pointer}.ww-fx-host .ww-fx-image{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block}.ww-fx-host .cursor-target{display:block;color:inherit;text-decoration:none}.ww-fx-host .fx{min-height:500px}.ww-fx-host .fx .art{position:relative}.ww-fx-host .fx .portal-art,.ww-fx-host .fx .thumb-destination,.ww-fx-host .fx .scene-art{position:absolute}
{% endstylesheet %}
{% schema %}
{
"name": "WW pointer-mosaic",
"settings": [
{
"type": "text",
"id": "heading_1",
"label": "Heading 1",
"default": "A NEW"
},
{
"type": "text",
"id": "heading_2",
"label": "Heading 2",
"default": "PERSPECTIVE."
},
{
"type": "image_picker",
"id": "image_1",
"label": "Image 1"
},
{
"type": "image_picker",
"id": "image_2",
"label": "Image 2"
},
{
"type": "image_picker",
"id": "image_3",
"label": "Image 3"
}
],
"presets": [
{
"name": "WW pointer-mosaic"
}
]
}
{% endschema %}
{% comment %} WESWOO example shell. Add ONE effect's HTML inside .fx-slot. {% endcomment %}
{{ 'ww-effects.css' | asset_url | stylesheet_tag }}
<section id="ww-effect-{{ section.id }}" data-ww-effect-section>
<h2>{{ section.settings.heading | escape }}</h2>
<button type="button" data-effect-toggle aria-pressed="false">Play / pause effect</button>
<div class="fx-slot">
{% comment %} Insert the chosen .fx element here; read copy/images from section settings. {% endcomment %}
</div>
</section>
<script type="module" src="{{ 'ww-effect-section.js' | asset_url }}"></script>
{% schema %}
{"name":"WESWOO effect","settings":[{"type":"text","id":"heading","label":"Heading","default":"Our story"}],"presets":[{"name":"WESWOO effect"}]}
{% endschema %}
// Put the chosen example JS in assets/ww-selected-effect.js (rename .mjs to .js).
import {mountEffect} from './ww-selected-effect.js';
const instances=new Map();
function mount(container=document){
const roots=[...(container.matches?.('[data-ww-effect-section]')?[container]:[]),...container.querySelectorAll('[data-ww-effect-section]')];
for(const section of roots){
if(instances.has(section))continue;
const root=section.querySelector('.fx'),button=section.querySelector('[data-effect-toggle]');
if(!root||!button)continue;
const effect=mountEffect(root),events=new AbortController();let playing=false;
const pause=()=>{playing=false;effect.pause();button.setAttribute('aria-pressed','false');};
button.addEventListener('click',()=>{playing=!playing;playing?effect.resume():effect.pause();button.setAttribute('aria-pressed',String(playing));},{signal:events.signal});
const observer=new IntersectionObserver(entries=>{if(!entries[0].isIntersecting)pause();});observer.observe(section);
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:events.signal});
instances.set(section,()=>{observer.disconnect();events.abort();effect.destroy();});
}
}
document.addEventListener('shopify:section:load',event=>mount(event.target));
document.addEventListener('shopify:section:unload',event=>{for(const [section,destroy] of instances)if(section===event.target||event.target.contains(section)){destroy();instances.delete(section);}});
mount();
// Original WESWOO integration. Copy alongside the selected ww-effect-*.js asset.
// The server supplies the asset URL; do not accept a URL from a query parameter.
if (!customElements.get('ww-effect-study')) {
customElements.define('ww-effect-study', class extends HTMLElement {
connectedCallback() {
if (this.events) return;
this.events=new AbortController();this.session={};const session=this.session;
const button=this.querySelector('[data-effect-toggle]');
button.disabled=false;button.setAttribute('aria-pressed','false');this.visible=true;
const preference=matchMedia('(prefers-reduced-motion: reduce)');
const pause=()=>{this.effect?.pause();button.setAttribute('aria-pressed','false');};
this.pause=pause;
button.addEventListener('click',async()=>{
if(this.loading)return;
if(!this.effect){
this.loading=true;button.disabled=true;
try {
const {mountEffect}=await import(this.dataset.moduleUrl);
if(!this.isConnected||this.session!==session)return;
this.effect=mountEffect(this.querySelector('.fx'),{reducedMotion:preference.matches});
} catch {this.querySelector('[data-effect-status]').textContent='The static content is available. Reload to retry motion.';return;}
finally {if(this.session===session){this.loading=false;button.disabled=false;}}
}
if(this.session!==session||document.hidden||!this.visible)return;
const playing=button.getAttribute('aria-pressed')!=='true';
playing?this.effect.resume():this.effect.pause();button.setAttribute('aria-pressed',String(playing));
},{signal:this.events.signal});
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:this.events.signal});
preference.addEventListener('change',()=>{pause();this.effect?.destroy();this.effect=null;},{signal:this.events.signal});
this.observer=new IntersectionObserver(entries=>{this.visible=entries[0].isIntersecting;if(!this.visible)pause();});this.observer.observe(this);
const root=this.querySelector('.fx');
root.querySelectorAll('[data-view]').forEach(trigger=>trigger.addEventListener('click',()=>{const target=root.querySelector('dialog .art'),source=trigger.querySelector('.ww-fx-image');target.querySelector('.ww-fx-image')?.remove();if(source)target.append(source.cloneNode(true));},{signal:this.events.signal}));
// Section unload disconnects this custom element; reconnect mounts one fresh instance.
document.addEventListener('shopify:section:unload',event=>{if(event.target.contains(this))this.teardown();},{signal:this.events.signal});
}
teardown(){this.session=null;this.loading=false;this.observer?.disconnect();this.events?.abort();this.effect?.destroy();this.effect=null;this.events=null;}
disconnectedCallback(){this.teardown();}
});
}
Insert the selected effect into the shell. Each module loads one effect; multiple types need an explicit registry and Section mapping.
Examples are authored by WESWOO and credited open-source contributors; retain their applicable licenses. Project screens and photographs remain with their rights holders. Downloads use placeholders; replace them with imagery you may use.
Shopify/dawn · modal / slider base classesShopify/dawn · product media galleryShopify/dawn · licensePreparing preview
Switch among the SHOKZ, Termino, INIU and FMS website screenshots. Adjust brightness, contrast and zoom to inspect the composition; controls affect only the preview.
<section class="fx pe-audit" data-effect="material-explorer" lang="en" aria-label="Website screenshot hierarchy check"><p class="fx__eyebrow">REAL WEBSITE SCREENS</p><h3>Website screenshot hierarchy check</h3><p class="fx__lede">Switch website screenshots and adjust brightness, contrast and zoom to inspect visual hierarchy. </p><div class="pe-audit-grid"><div class="pe-audit-image"><img data-preview="0" src="https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/shokz-openfit-preview.webp" width="900" height="450" alt="SHOKZ UK website screenshot" ><img data-preview="1" src="https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/termino-preview.webp" width="900" height="450" alt="Termino cabinetry website screenshot" hidden><img data-preview="2" src="https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/iniu-preview.webp" width="900" height="450" alt="INIU charging products website screenshot" hidden><img data-preview="3" src="https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/fms-preview.webp" width="900" height="450" alt="FMS project website screenshot" hidden><div class="pe-crosshair" aria-hidden="true"></div></div><div class="pe-audit-controls"><div class="pe-audit-projects"><button type="button" class="pe-project" data-project="0" aria-pressed="true"><span class="pe-name">SHOKZ</span><span class="pe-sub">UK website · project screen</span></button><button type="button" class="pe-project" data-project="1" aria-pressed="false"><span class="pe-name">Termino</span><span class="pe-sub">Aluminium cabinetry website · project screen</span></button><button type="button" class="pe-project" data-project="2" aria-pressed="false"><span class="pe-name">INIU</span><span class="pe-sub">Charging products website · project screen</span></button><button type="button" class="pe-project" data-project="3" aria-pressed="false"><span class="pe-name">FMS</span><span class="pe-sub">Project website · screenshot</span></button></div><label>Brightness <input type="range" min="70" max="130" value="100" data-filter="brightness" aria-label="Brightness"></label><label>Contrast <input type="range" min="70" max="150" value="100" data-filter="contrast" aria-label="Contrast"></label><label>Zoom <input type="range" min="100" max="160" value="100" data-filter="zoom" aria-label="Zoom"></label><button type="button" class="fx__control" data-reset>Reset display</button></div></div><span class="fx__status" data-status role="status" aria-live="polite"></span></section>
.fx{box-sizing:border-box;font-family:inherit;color:#172523;background:#f3f5ef;border-radius:18px;padding:clamp(18px,4vw,38px);overflow:hidden}.fx *{box-sizing:border-box}.fx button,.fx input{font:inherit}.fx h3{font-size:clamp(24px,3vw,34px);line-height:1.2;margin:8px 0}.fx p{line-height:1.6}.fx__eyebrow{font-size:10px;letter-spacing:.14em;font-weight:700}.fx__lede{font-size:13px;color:#536159;max-width:620px}.fx__control{border:1px solid #c4cec1;border-radius:999px;background:transparent;padding:9px 14px;cursor:pointer;color:inherit}.fx__control:focus-visible,.fx button:focus-visible,.fx input:focus-visible{outline:3px solid #356940;outline-offset:3px}.fx__controls{display:flex;gap:8px;flex-wrap:wrap;margin-top:16px}.fx__status{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.fx img{max-width:100%;display:block}.fx [hidden]{display:none!important}@media(prefers-reduced-motion:reduce){.fx *{scroll-behavior:auto!important;animation:none!important;transition:none!important}}
.pe-audit-grid{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(190px,.8fr);gap:20px;align-items:start}.pe-audit-image{position:relative;overflow:hidden;border:1px solid #c4cec1;border-radius:12px;background:white}.pe-audit-image img{width:100%;aspect-ratio:2/1;object-fit:contain;filter:brightness(var(--audit-brightness,1)) contrast(var(--audit-contrast,1));transform:scale(var(--audit-zoom,1));transition:filter .12s,transform .12s}.pe-crosshair{position:absolute;inset:0;pointer-events:none;background:linear-gradient(90deg,transparent 49.9%,#203c2730 50%,transparent 50.1%),linear-gradient(0deg,transparent 49.9%,#203c2730 50%,transparent 50.1%)}.pe-audit-projects{display:grid}.pe-project{display:grid;gap:4px;text-align:left;background:transparent;border:0;border-bottom:1px solid #cfd7ca;padding:10px;cursor:pointer;color:inherit}.pe-project[aria-pressed=true]{background:#e5eadf}.pe-name{font-weight:700}.pe-sub{font-size:10px;color:#536159}.pe-audit-controls label{display:grid;gap:5px;font-size:12px;margin:12px 0}.pe-audit-controls input{width:100%;min-height:32px;accent-color:#31513f;touch-action:pan-y}.pe-audit-note{font-size:11px;color:#536159}@media(max-width:640px){.pe-audit-grid{grid-template-columns:1fr}.pe-audit-projects{grid-template-columns:repeat(3,1fr)}.pe-project{padding:8px 4px}.pe-name{font-size:14px}.pe-sub{font-size:8px}}
.fx.is-paused .pe-roll-actions .pe-name{transition:none!important;transform:none!important}.fx.is-paused .pe-magnet,.fx.is-paused .pe-magnet-label{transition:none!important;transform:none!important}
.fx.is-paused *, .fx.is-reduced-motion *{scroll-behavior:auto;animation-play-state:paused!important}
.pe-roll-preview img,.pe-mag-image img,.pe-menu-image img,.pe-audit-image img{display:block;width:100%;height:auto;max-height:none;aspect-ratio:2/1;object-fit:contain}
@media(max-width:680px){.pe-roll-layout,.pe-mag-layout{grid-template-columns:minmax(0,1fr);gap:16px}.pe-roll-preview,.pe-mag-card,.pe-menu-image,.pe-audit-image{width:100%;min-width:0}.pe-roll-preview img,.pe-mag-image img,.pe-menu-image img,.pe-audit-image img{height:auto;aspect-ratio:2/1;object-fit:contain}.pe-roll-actions,.pe-mag-list{grid-template-columns:minmax(0,1fr)}.pe-roll-actions .pe-project,.pe-mag-list .pe-project{min-height:60px}}
.fx.is-reduced-motion .pe-name-wrap .pe-name{opacity:1!important}.fx.is-reduced-motion .pe-name-wrap .pe-marquee{display:none!important}.fx.is-reduced-motion .pe-magnet,.fx.is-reduced-motion .pe-magnet-label{transform:none!important;transition:none!important}
/* Shared visual primitives are duplicated intentionally so every effect runs alone in its iframe. */
.pe-project{box-sizing:border-box;position:relative;display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;min-width:0;min-height:60px;padding:13px 10px;border:0;border-bottom:1px solid #cfd7ca;background:transparent;color:#172523;text-align:left;font:inherit;cursor:pointer}.pe-project[aria-pressed=true]{background:#e5eadf}.pe-project:focus-visible{outline:3px solid #356940;outline-offset:-3px}.pe-name{display:block;min-width:0;font-size:clamp(16px,2vw,23px);line-height:1.2;font-weight:700;letter-spacing:-.02em}.pe-sub{display:block;min-width:0;font-size:10px;line-height:1.45;color:#536159}.pe-caption{margin:0;padding:11px 14px;font-size:10px;line-height:1.45;color:#536159}.pe-caption span{font-weight:700;color:#172523}.pe-mag-layout{display:grid;grid-template-columns:minmax(190px,.75fr) minmax(0,1.25fr);gap:22px;align-items:center}.pe-mag-list{display:grid;border-top:1px solid #cfd7ca}.pe-mag-card{min-width:0;overflow:hidden;border:1px solid #c4cec1;border-radius:12px;background:#fff}.pe-mag-image{min-width:0;overflow:hidden}.pe-mag-image img{display:block;width:100%;height:auto;aspect-ratio:2/1;object-fit:contain}.pe-menu-panel{min-width:0}.pe-menu-items{min-width:0}.pe-menu-image img,.pe-roll-preview img,.pe-audit-image img{display:block;width:100%;height:auto;aspect-ratio:2/1;object-fit:contain}@media(max-width:680px){.pe-mag-layout{grid-template-columns:minmax(0,1fr);gap:16px}.pe-mag-list{grid-template-columns:minmax(0,1fr)}.pe-mag-card{width:100%;min-width:0}.pe-project{gap:8px;padding:12px 8px}.pe-sub{font-size:10px}}
/* Phone selectors: two readable rows with names and details kept inside each tile. */
@media(max-width:680px){.pe-audit-grid{grid-template-columns:minmax(0,1fr);gap:14px}.pe-audit-projects{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin:0 0 12px}.pe-audit-projects .pe-project{display:grid;align-content:start;justify-items:start;gap:5px;min-width:0;min-height:68px;padding:10px;border:1px solid #cfd7ca;border-radius:8px;text-align:left}.pe-audit-projects .pe-name{font-size:15px;line-height:1.2;white-space:normal;overflow-wrap:anywhere}.pe-audit-projects .pe-sub{font-size:9px;line-height:1.35;text-align:left;white-space:normal;overflow-wrap:anywhere}.pe-audit-controls label{grid-template-columns:80px minmax(0,1fr);align-items:center;gap:10px}.pe-audit-note{margin:8px 0}}
export function mountEffect(root,{reducedMotion=false}={}){
const controller=new AbortController(), signal=controller.signal;
const buttons=[...root.querySelectorAll('[data-project]')], images=[...root.querySelectorAll('[data-preview]')];
const caption=root.querySelector('[data-caption]'), status=root.querySelector('[data-status]'), motion=root.querySelector('[data-motion]');
const toggle=root.querySelector('.pe-menu-toggle'), panel=root.querySelector('.pe-menu-panel');
const controls=[...root.querySelectorAll('button,input')];
const original={className:root.className,style:root.getAttribute('style'),buttons:buttons.map(b=>[b.className,b.getAttribute('aria-pressed')]),images:images.map(i=>[i.className,i.hidden]),caption:caption?.textContent,status:status?.textContent,auditNote:root.querySelector('[data-audit-note]')?.textContent,controls:controls.map(c=>[c,c.value,c.innerHTML,c.getAttribute('aria-expanded'),c.getAttribute('aria-pressed')]),panelHidden:panel?.hidden};
const motionReduced=!!reducedMotion||(typeof window!=='undefined'&&window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches);
let active=0, paused=motionReduced, destroyed=false;
const cleanups=[];
const listen=(node,type,fn,opts={})=>node.addEventListener(type,fn,{...opts,signal});
const announce=s=>{if(status)status.textContent=s};
function select(index,announceChange=false){if(destroyed||!buttons[index]||!images[index])return;active=index;buttons.forEach((b,i)=>{b.setAttribute('aria-pressed',String(i===index));b.classList.toggle('is-active',i===index)});images.forEach((img,i)=>{img.hidden=i!==index;img.classList.toggle('is-active',i===index)});const projectName=buttons[index].querySelector('.pe-name')?.textContent||'';if(caption)caption.textContent=projectName;const auditNote=root.querySelector('[data-audit-note]');if(auditNote)auditNote.textContent=(root.lang.startsWith('en')?'Current view: ':'当前检查:')+(projectName)+(root.lang.startsWith('en')?' screenshot. Controls affect the preview only.':'截图。控件只改变预览显示。');if(announceChange)announce((root.lang.startsWith('en')?'Showing ':'正在显示 ')+(projectName));}
buttons.forEach((b,i)=>{listen(b,'pointerenter',e=>{if(e.pointerType==='mouse')select(i)});listen(b,'focus',()=>select(i));listen(b,'click',()=>select(i,true));listen(b,'keydown',e=>{let n;if(['ArrowDown','ArrowRight'].includes(e.key))n=(i+1)%buttons.length;else if(['ArrowUp','ArrowLeft'].includes(e.key))n=(i+buttons.length-1)%buttons.length;else if(e.key==='Home')n=0;else if(e.key==='End')n=buttons.length-1;if(n!==undefined){e.preventDefault();buttons[n].focus();select(n,true)}})});
if(motion){motion.setAttribute('aria-pressed',String(paused));motion.textContent=paused?(root.lang.startsWith('en')?'Resume motion':'继续动效'):(root.lang.startsWith('en')?'Pause motion':'暂停动效');listen(motion,'click',()=>{paused=!paused;motion.setAttribute('aria-pressed',String(paused));motion.textContent=paused?(root.lang.startsWith('en')?'Resume motion':'继续动效'):(root.lang.startsWith('en')?'Pause motion':'暂停动效');root.classList.toggle('is-paused',paused);announce(paused?(root.lang.startsWith('en')?'Motion paused':'动效已暂停'):(root.lang.startsWith('en')?'Motion resumed':'动效已继续'))})}
const audit=root.querySelector('.pe-audit-image'), note=root.querySelector('[data-audit-note]');
root.querySelectorAll('[data-filter]').forEach(input=>listen(input,'input',()=>{const key=input.dataset.filter;const value=Number(input.value);if(key==='brightness')root.style.setProperty('--audit-brightness',value/100);if(key==='contrast')root.style.setProperty('--audit-contrast',value/100);if(key==='zoom')root.style.setProperty('--audit-zoom',value/100);if(note)note.textContent=(root.lang.startsWith('en')?'Display adjustment: ':'显示调整:')+key+' '+value+'%'}));
const reset=root.querySelector('[data-reset]');if(reset)listen(reset,'click',()=>{root.querySelectorAll('[data-filter]').forEach(i=>i.value='100');root.style.setProperty('--audit-brightness','1');root.style.setProperty('--audit-contrast','1');root.style.setProperty('--audit-zoom','1');if(note)note.textContent=root.lang.startsWith('en')?'Display restored.':'已恢复初始显示。'});
cleanups.push(()=>{root.style.removeProperty('--audit-brightness');root.style.removeProperty('--audit-contrast');root.style.removeProperty('--audit-zoom')});
select(0);root.classList.toggle('is-reduced-motion',motionReduced);
return {resume(){if(destroyed)return;paused=motionReduced;root.classList.toggle('is-paused',paused);if(motion){motion.setAttribute('aria-pressed','false');motion.textContent=root.lang.startsWith('en')?'Pause motion':'暂停动效'}},pause(){if(destroyed)return;paused=true;root.classList.add('is-paused');const magnet=root.querySelector('[data-magnet]');if(magnet)magnet.style.transform='';if(motion){motion.setAttribute('aria-pressed','true');motion.textContent=root.lang.startsWith('en')?'Resume motion':'继续动效'}},destroy(){if(destroyed)return;destroyed=true;controller.abort();cleanups.forEach(fn=>fn());root.className=original.className;if(original.style===null)root.removeAttribute('style');else root.setAttribute('style',original.style);buttons.forEach((b,i)=>{b.className=original.buttons[i][0];original.buttons[i][1]===null?b.removeAttribute('aria-pressed'):b.setAttribute('aria-pressed',original.buttons[i][1])});images.forEach((img,i)=>{img.className=original.images[i][0];img.hidden=original.images[i][1]});if(caption)caption.textContent=original.caption;if(status)status.textContent=original.status;const note=root.querySelector('[data-audit-note]');if(note)note.textContent=original.auditNote;controls.forEach(([c,value,label,expanded,pressed])=>{if(c.matches('input'))c.value=value;if(c.matches('button'))c.innerHTML=label;expanded===null?c.removeAttribute('aria-expanded'):c.setAttribute('aria-expanded',expanded);pressed===null?c.removeAttribute('aria-pressed'):c.setAttribute('aria-pressed',pressed)});if(panel)panel.hidden=original.panelHidden}};
}Use with existing project screenshots and labels. Obtain permission for imagery before deploying.
The module is scoped to its root, uses native DOM events and makes no network requests.
Reduced-motion mode disables movement; keyboard, touch and normal page scrolling remain available.
Check mobile touch, keyboard focus, pause/resume, and destroy/remount behavior. Confirm screenshot ownership and link destination. Four existing website screenshots are labelled SHOKZ, Termino, INIU and FMS. No Codrops demo imagery is used.
Replace sample images with imagery you may use, then test the interaction in the theme editor and on phones.
Work in a duplicate theme. Replace demo copy and artwork with Section settings, scope styles to that Section, and use the lifecycle module for editor reloads, visibility and teardown.
{% comment %} WESWOO example shell. Add ONE effect's HTML inside .fx-slot. {% endcomment %}
{{ 'ww-effects.css' | asset_url | stylesheet_tag }}
<section id="ww-effect-{{ section.id }}" data-ww-effect-section>
<h2>{{ section.settings.heading | escape }}</h2>
<button type="button" data-effect-toggle aria-pressed="false">Play / pause effect</button>
<div class="fx-slot">
{% comment %} Insert the chosen .fx element here; read copy/images from section settings. {% endcomment %}
</div>
</section>
<script type="module" src="{{ 'ww-effect-section.js' | asset_url }}"></script>
{% schema %}
{"name":"WESWOO effect","settings":[{"type":"text","id":"heading","label":"Heading","default":"Our story"}],"presets":[{"name":"WESWOO effect"}]}
{% endschema %}
// Put the chosen example JS in assets/ww-selected-effect.js (rename .mjs to .js).
import {mountEffect} from './ww-selected-effect.js';
const instances=new Map();
function mount(container=document){
const roots=[...(container.matches?.('[data-ww-effect-section]')?[container]:[]),...container.querySelectorAll('[data-ww-effect-section]')];
for(const section of roots){
if(instances.has(section))continue;
const root=section.querySelector('.fx'),button=section.querySelector('[data-effect-toggle]');
if(!root||!button)continue;
const effect=mountEffect(root),events=new AbortController();let playing=false;
const pause=()=>{playing=false;effect.pause();button.setAttribute('aria-pressed','false');};
button.addEventListener('click',()=>{playing=!playing;playing?effect.resume():effect.pause();button.setAttribute('aria-pressed',String(playing));},{signal:events.signal});
const observer=new IntersectionObserver(entries=>{if(!entries[0].isIntersecting)pause();});observer.observe(section);
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:events.signal});
instances.set(section,()=>{observer.disconnect();events.abort();effect.destroy();});
}
}
document.addEventListener('shopify:section:load',event=>mount(event.target));
document.addEventListener('shopify:section:unload',event=>{for(const [section,destroy] of instances)if(section===event.target||event.target.contains(section)){destroy();instances.delete(section);}});
mount();
// Original WESWOO integration. Copy alongside the selected ww-effect-*.js asset.
// The server supplies the asset URL; do not accept a URL from a query parameter.
if (!customElements.get('ww-effect-study')) {
customElements.define('ww-effect-study', class extends HTMLElement {
connectedCallback() {
if (this.events) return;
this.events=new AbortController();this.session={};const session=this.session;
const button=this.querySelector('[data-effect-toggle]');
button.disabled=false;button.setAttribute('aria-pressed','false');this.visible=true;
const preference=matchMedia('(prefers-reduced-motion: reduce)');
const pause=()=>{this.effect?.pause();button.setAttribute('aria-pressed','false');};
this.pause=pause;
button.addEventListener('click',async()=>{
if(this.loading)return;
if(!this.effect){
this.loading=true;button.disabled=true;
try {
const {mountEffect}=await import(this.dataset.moduleUrl);
if(!this.isConnected||this.session!==session)return;
this.effect=mountEffect(this.querySelector('.fx'),{reducedMotion:preference.matches});
} catch {this.querySelector('[data-effect-status]').textContent='The static content is available. Reload to retry motion.';return;}
finally {if(this.session===session){this.loading=false;button.disabled=false;}}
}
if(this.session!==session||document.hidden||!this.visible)return;
const playing=button.getAttribute('aria-pressed')!=='true';
playing?this.effect.resume():this.effect.pause();button.setAttribute('aria-pressed',String(playing));
},{signal:this.events.signal});
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:this.events.signal});
preference.addEventListener('change',()=>{pause();this.effect?.destroy();this.effect=null;},{signal:this.events.signal});
this.observer=new IntersectionObserver(entries=>{this.visible=entries[0].isIntersecting;if(!this.visible)pause();});this.observer.observe(this);
const root=this.querySelector('.fx');
root.querySelectorAll('[data-view]').forEach(trigger=>trigger.addEventListener('click',()=>{const target=root.querySelector('dialog .art'),source=trigger.querySelector('.ww-fx-image');target.querySelector('.ww-fx-image')?.remove();if(source)target.append(source.cloneNode(true));},{signal:this.events.signal}));
// Section unload disconnects this custom element; reconnect mounts one fresh instance.
document.addEventListener('shopify:section:unload',event=>{if(event.target.contains(this))this.teardown();},{signal:this.events.signal});
}
teardown(){this.session=null;this.loading=false;this.observer?.disconnect();this.events?.abort();this.effect?.destroy();this.effect=null;this.events=null;}
disconnectedCallback(){this.teardown();}
});
}
Insert the selected effect into the shell. Each module loads one effect; multiple types need an explicit registry and Section mapping.
Visual switching inspired by Codrops; implementation independently authored.
Shopify: Section architectureShopify: theme editor events and lifecycleShopify: theme performanceMDN: Web Animations APIMDN: reduced-motion preferenceMDN: iframe sandboxingShopify: image rendering and dimensionsShopify: Section settings and schemaMDN: element geometryMDN: image and text clippingMDN: native dialogShopify: theme accessibilityMDN: native range inputExamples are authored by WESWOO and credited open-source contributors; retain their applicable licenses. Project screens and photographs remain with their rights holders. Downloads use placeholders; replace them with imagery you may use.
Shopify/dawn · modal / slider base classesShopify/dawn · product media galleryShopify/dawn · licensePreparing preview
Add an item in the preview and watch the count. In a live store, wait for confirmation and show stock or network errors next to the button.
<section class="fx cart" lang="en" aria-label="Add to cart feedback demo">
<header class="cart-header"><h2>Add to cart feedback</h2><span class="count">Cart <strong data-count>0</strong></span></header>
<figure class="product"><img src="https://www.weswoo.com/wp-content/themes/weswoo/assets/images/case-brands/project-previews/shokz-openfit-preview.webp" alt="Shokz UK storefront screenshot"></figure>
<div class="cart-actions"><button class="buy" type="button" data-add>Add to demo cart</button>
<button class="reset" type="button" data-reset>Clear cart</button></div>
<p class="cart-status" role="status" data-status>Demo cart is empty.</p>
</section>* { box-sizing: border-box; }
.fx {
color: #f8f7ed; background: #18211e; min-height: 270px;
padding: clamp(16px, 4vw, 40px); font: 16px/1.55 system-ui, sans-serif;
}
h2, h3, p, figure { margin: 0; }
h2 { font-size: clamp(1.4rem, 4vw, 2.4rem); line-height: 1.08; letter-spacing: -.035em; }
p { max-width: 58ch; }
button { font: inherit; cursor: pointer; min-height: 44px; }
button:focus-visible { outline: 2px solid #ffe78f; outline-offset: 3px; }
img { display: block; width: 100%; height: auto; }
[hidden] { display: none !important; }
.cart { position: relative; isolation: isolate; overflow: hidden; }
.cart-header, .cart-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.count { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border: 1px solid #84968a; border-radius: 100px; }
.count strong { display: grid; place-items: center; min-width: 1.7em; aspect-ratio: 1; color: #18211e; background: #e0fa93; border-radius: 50%; }
.product { margin-block: 18px; border-radius: 12px; overflow: hidden; background: #48564d; }
.product img { aspect-ratio: 2 / 1; object-fit: cover; object-position: 50% 25%; }
.cart-actions { justify-content: flex-start; }
.buy, .reset { border-radius: 7px; padding: 8px 14px; border: 1px solid #84968a; }
.buy { color: #18211e; background: #e0fa93; font-weight: 650; }
.reset { color: inherit; background: transparent; }
.cart-status { min-height: 1.6em; margin-top: 10px; color: #d3ded4; }
.cart-trail { position: absolute; z-index: 1; width: 66px; aspect-ratio: 1; object-fit: cover; border-radius: 8px; pointer-events: none; }/*
MIT License
Copyright (c) 2024 Andrea Biason
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// Adapted from Andrea Biason's product-to-cart coordinate transition for Codrops.
export function mountEffect(root, {reducedMotion = matchMedia('(prefers-reduced-motion: reduce)').matches} = {}) {
const lifetime = new AbortController();
const add = root.querySelector('[data-add]');
const reset = root.querySelector('[data-reset]');
const counter = root.querySelector('[data-count]');
const status = root.querySelector('[data-status]');
const image = root.querySelector('.product img');
let quantity = 0;
let motion = false;
let trail;
let animation;
function stopTrail() {
animation?.cancel();
trail?.remove();
animation = trail = undefined;
}
function show(quantity, message) {
counter.textContent = quantity;
status.textContent = message;
}
add.addEventListener('click', () => {
show(++quantity, quantity === 1 ? '1 item added.' : quantity + ' items in the demo cart.');
stopTrail();
if (!motion || !image.naturalWidth || !Element.prototype.animate) return;
const from = image.getBoundingClientRect();
const to = counter.getBoundingClientRect();
const canvas = root.getBoundingClientRect();
const x = from.left + from.width / 2 - 33;
const y = from.top + from.height / 2 - 33;
trail = image.cloneNode();
trail.alt = '';
trail.setAttribute('aria-hidden', 'true');
trail.className = 'cart-trail';
trail.style.left = x - canvas.left + 'px';
trail.style.top = y - canvas.top + 'px';
root.append(trail);
const dx = to.left + to.width / 2 - x - 33;
const dy = to.top + to.height / 2 - y - 33;
animation = trail.animate([
{transform:'translate(0, 0) scale(1)', opacity:1},
{transform:'translate(' + dx + 'px, ' + dy + 'px) scale(.2)', opacity:.2}
], {duration:540, easing:'cubic-bezier(.18,.7,.2,1)'});
animation.onfinish = stopTrail;
}, {signal:lifetime.signal});
reset.addEventListener('click', () => {
quantity = 0;
stopTrail();
show(quantity, 'Demo cart cleared.');
}, {signal:lifetime.signal});
return {
resume() { motion = !reducedMotion; },
pause() { motion = false; stopTrail(); },
destroy() { lifetime.abort(); stopTrail(); }
};
}Product pages and featured product cards.
Update the count after the add succeeds, then animate from the image to the cart.
With reduced motion, show the quantity and success message immediately.
Check repeated adds, API errors and the count after clearing the cart.
Update the count from your theme’s cart response. The animation only needs the positions of the image and cart.
Work in a duplicate theme. Replace demo copy and artwork with Section settings, scope styles to that Section, and use the lifecycle module for editor reloads, visibility and teardown.
{% comment %} WESWOO example shell. Add ONE effect's HTML inside .fx-slot. {% endcomment %}
{{ 'ww-effects.css' | asset_url | stylesheet_tag }}
<section id="ww-effect-{{ section.id }}" data-ww-effect-section>
<h2>{{ section.settings.heading | escape }}</h2>
<button type="button" data-effect-toggle aria-pressed="false">Play / pause effect</button>
<div class="fx-slot">
{% comment %} Insert the chosen .fx element here; read copy/images from section settings. {% endcomment %}
</div>
</section>
<script type="module" src="{{ 'ww-effect-section.js' | asset_url }}"></script>
{% schema %}
{"name":"WESWOO effect","settings":[{"type":"text","id":"heading","label":"Heading","default":"Our story"}],"presets":[{"name":"WESWOO effect"}]}
{% endschema %}
// Put the chosen example JS in assets/ww-selected-effect.js (rename .mjs to .js).
import {mountEffect} from './ww-selected-effect.js';
const instances=new Map();
function mount(container=document){
const roots=[...(container.matches?.('[data-ww-effect-section]')?[container]:[]),...container.querySelectorAll('[data-ww-effect-section]')];
for(const section of roots){
if(instances.has(section))continue;
const root=section.querySelector('.fx'),button=section.querySelector('[data-effect-toggle]');
if(!root||!button)continue;
const effect=mountEffect(root),events=new AbortController();let playing=false;
const pause=()=>{playing=false;effect.pause();button.setAttribute('aria-pressed','false');};
button.addEventListener('click',()=>{playing=!playing;playing?effect.resume():effect.pause();button.setAttribute('aria-pressed',String(playing));},{signal:events.signal});
const observer=new IntersectionObserver(entries=>{if(!entries[0].isIntersecting)pause();});observer.observe(section);
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:events.signal});
instances.set(section,()=>{observer.disconnect();events.abort();effect.destroy();});
}
}
document.addEventListener('shopify:section:load',event=>mount(event.target));
document.addEventListener('shopify:section:unload',event=>{for(const [section,destroy] of instances)if(section===event.target||event.target.contains(section)){destroy();instances.delete(section);}});
mount();
// Original WESWOO integration. Copy alongside the selected ww-effect-*.js asset.
// The server supplies the asset URL; do not accept a URL from a query parameter.
if (!customElements.get('ww-effect-study')) {
customElements.define('ww-effect-study', class extends HTMLElement {
connectedCallback() {
if (this.events) return;
this.events=new AbortController();this.session={};const session=this.session;
const button=this.querySelector('[data-effect-toggle]');
button.disabled=false;button.setAttribute('aria-pressed','false');this.visible=true;
const preference=matchMedia('(prefers-reduced-motion: reduce)');
const pause=()=>{this.effect?.pause();button.setAttribute('aria-pressed','false');};
this.pause=pause;
button.addEventListener('click',async()=>{
if(this.loading)return;
if(!this.effect){
this.loading=true;button.disabled=true;
try {
const {mountEffect}=await import(this.dataset.moduleUrl);
if(!this.isConnected||this.session!==session)return;
this.effect=mountEffect(this.querySelector('.fx'),{reducedMotion:preference.matches});
} catch {this.querySelector('[data-effect-status]').textContent='The static content is available. Reload to retry motion.';return;}
finally {if(this.session===session){this.loading=false;button.disabled=false;}}
}
if(this.session!==session||document.hidden||!this.visible)return;
const playing=button.getAttribute('aria-pressed')!=='true';
playing?this.effect.resume():this.effect.pause();button.setAttribute('aria-pressed',String(playing));
},{signal:this.events.signal});
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:this.events.signal});
preference.addEventListener('change',()=>{pause();this.effect?.destroy();this.effect=null;},{signal:this.events.signal});
this.observer=new IntersectionObserver(entries=>{this.visible=entries[0].isIntersecting;if(!this.visible)pause();});this.observer.observe(this);
const root=this.querySelector('.fx');
root.querySelectorAll('[data-view]').forEach(trigger=>trigger.addEventListener('click',()=>{const target=root.querySelector('dialog .art'),source=trigger.querySelector('.ww-fx-image');target.querySelector('.ww-fx-image')?.remove();if(source)target.append(source.cloneNode(true));},{signal:this.events.signal}));
// Section unload disconnects this custom element; reconnect mounts one fresh instance.
document.addEventListener('shopify:section:unload',event=>{if(event.target.contains(this))this.teardown();},{signal:this.events.signal});
}
teardown(){this.session=null;this.loading=false;this.observer?.disconnect();this.events?.abort();this.effect?.destroy();this.effect=null;this.events=null;}
disconnectedCallback(){this.teardown();}
});
}
Insert the selected effect into the shell. Each module loads one effect; multiple types need an explicit registry and Section mapping.
Motion adapted from Andrea Biason’s MIT-licensed Codrops demo. The preview uses WESWOO’s Shokz UK storefront screenshot.
Shopify: Section architectureShopify: theme editor events and lifecycleShopify: theme performanceMDN: Web Animations APIMDN: reduced-motion preferenceMDN: iframe sandboxingShopify: image rendering and dimensionsShopify: Section settings and schemaMDN: element geometryMDN: image and text clippingMDN: native dialogShopify: theme accessibilityMDN: native range inputExamples are authored by WESWOO and credited open-source contributors; retain their applicable licenses. Project screens and photographs remain with their rights holders. Downloads use placeholders; replace them with imagery you may use.
Shopify/dawn · modal / slider base classesShopify/dawn · product media galleryShopify/dawn · licensePreparing preview
Try shirt, then a word with no matches. The count should match the list, and you can edit the query or close the panel at any time.
<section class="fx search-demo" lang="en" aria-label="Product search preview">
<div class="search-cover">
<img src="__WW_VISUAL_1__" alt="">
<div class="cover-copy">
<h2>Find what fits</h2>
<button type="button" data-search-open aria-expanded="false" aria-controls="search-panel">Search products</button>
</div>
</div>
<section id="search-panel" aria-label="Product search" hidden>
<div class="search-field">
<label for="sample-query">Search the sample catalog</label>
<button type="button" data-search-close>Close</button>
<input type="search" id="sample-query" autocomplete="off" placeholder="Try shirt, bag or shoe" aria-controls="sample-results">
</div>
<p class="search-count" role="status">4 results</p>
<ul id="sample-results">
<li>Oxford shirt <span>Clothing</span></li>
<li>Linen shirt <span>Clothing</span></li>
<li>Canvas tote bag <span>Accessories</span></li>
<li>Trail shoes <span>Footwear</span></li>
</ul>
<p class="no-results" hidden>Try a shorter search term.</p>
</section>
</section>* { box-sizing: border-box; }
.fx {
--ink: #1d2825; --paper: #f2f1eb; --edge: #c3cac0;
min-height: 270px; padding: clamp(16px,4vw,40px); color: var(--ink);
background: var(--paper); font: 16px/1.45 system-ui, sans-serif;
}
h2,h3,p,figure { margin: 0; }
h2 { font-size: clamp(1.45rem,4vw,2.75rem); line-height: 1.1; letter-spacing: -.035em; }
img { display: block; max-width: 100%; }
button,input { font: inherit; }
button { min-height: 44px; cursor: pointer; border-radius: 8px; padding: 7px 13px; }
button:focus-visible,input:focus-visible { outline: 2px solid #006d62; outline-offset: 2px; }
[hidden] { display: none !important; }
.search-demo { --paper: #f1efeb; }
.search-cover { position: relative; display: grid; align-items: end; min-height: clamp(235px,42vw,420px); overflow: hidden;
isolation: isolate; border-radius: 12px; background: #304543; color: #fff; }
.search-cover img,.search-cover::after { position: absolute; inset: 0; width: 100%; height: 100%; }
.search-cover img { object-fit: cover; object-position: 50% 45%; z-index: -2; }
.search-cover::after { content: ""; z-index: -1; background: linear-gradient(0deg, #121d1dee, #121d1d33 80%); }
.cover-copy { padding: clamp(18px,5vw,44px); }
.cover-copy h2 { margin-bottom: 16px; }
[data-search-open] { background: #fbf7ea; border: 1px solid transparent; color: #233b36; font-weight: 650; }
#search-panel { color: #233b36; border: 1px solid var(--edge); padding: clamp(10px,3vw,24px); border-radius: 12px; background: #fffdf5; }
.search-field { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: center; }
.search-field label { font-weight: 650; }
.search-field button { background: transparent; color: inherit; border: 1px solid var(--edge); }
.search-field input { grid-column: 1 / -1; width: 100%; min-width: 0; min-height: 44px; background: #ecf0e8;
color: #233b36; border: 1px solid #81968d; border-radius: 8px; padding: 9px 12px; }
.search-count { margin-block: 12px 6px; color: #52685d; }
#sample-results { list-style: none; padding: 0; margin: 0; }
#sample-results li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--edge); }
#sample-results span { color: #52685d; font-size: .85rem; }// Adapted from Codrops' MorphingSearch focus, explicit close and Escape pattern.
// Source: https://github.com/codrops/MorphingSearch (Codrops, 2014).
export function mountEffect(root, {reducedMotion = matchMedia('(prefers-reduced-motion: reduce)').matches} = {}) {
const lifetime = new AbortController();
const options = {signal:lifetime.signal};
const cover = root.querySelector('.search-cover');
const trigger = root.querySelector('[data-search-open]');
const panel = root.querySelector('#search-panel');
const query = root.querySelector('#sample-query');
const rows = [...root.querySelectorAll('#sample-results li')];
const count = root.querySelector('.search-count');
const empty = root.querySelector('.no-results');
let motion = false;
let animation;
function updateResults() {
const words = query.value.trim().toLowerCase().split(/\s+/).filter(Boolean);
let matches = 0;
for (const row of rows) {
const text = row.textContent.toLowerCase();
row.hidden = !words.every(word => text.includes(word));
if (!row.hidden) matches++;
}
count.textContent = matches === 1 ? '1 result' : matches + ' results';
empty.hidden = matches > 0;
}
function setOpen(open) {
animation?.cancel();
const oldWidth = trigger.getBoundingClientRect().width;
trigger.setAttribute('aria-expanded', String(open));
panel.hidden = !open;
cover.hidden = open;
if (open) {
query.focus({preventScroll:true});
if (motion && Element.prototype.animate) {
const newWidth = panel.getBoundingClientRect().width;
animation = panel.animate([
{clipPath:'inset(0 ' + Math.max(0, newWidth - oldWidth) + 'px 0 0 round 8px)', opacity:.65},
{clipPath:'inset(0 0 0 0 round 8px)', opacity:1}
], {duration:240,easing:'ease-out'});
}
} else {
trigger.focus({preventScroll:true});
}
}
trigger.addEventListener('click', () => setOpen(true), options);
root.querySelector('[data-search-close]').addEventListener('click', () => setOpen(false), options);
query.addEventListener('input', updateResults, options);
root.addEventListener('keydown', event => {
if (event.key === 'Escape' && !panel.hidden) {
event.preventDefault();
setOpen(false);
}
}, options);
return {
resume() { motion = !reducedMotion; },
pause() { motion = false; animation?.cancel(); },
destroy() { lifetime.abort(); animation?.cancel(); }
};
}Store headers and collection search.
Focus the search field on open, update matches as the query changes, and restore focus on close.
Tap Close or press Escape. Reduced motion opens the panel immediately.
Check blank queries, no results, fast typing and focus after closing.
When connecting Shopify predictive search, show only the latest query response and handle loading, empty and error states.
Work in a duplicate theme. Replace demo copy and artwork with Section settings, scope styles to that Section, and use the lifecycle module for editor reloads, visibility and teardown.
{% comment %} WESWOO example shell. Add ONE effect's HTML inside .fx-slot. {% endcomment %}
{{ 'ww-effects.css' | asset_url | stylesheet_tag }}
<section id="ww-effect-{{ section.id }}" data-ww-effect-section>
<h2>{{ section.settings.heading | escape }}</h2>
<button type="button" data-effect-toggle aria-pressed="false">Play / pause effect</button>
<div class="fx-slot">
{% comment %} Insert the chosen .fx element here; read copy/images from section settings. {% endcomment %}
</div>
</section>
<script type="module" src="{{ 'ww-effect-section.js' | asset_url }}"></script>
{% schema %}
{"name":"WESWOO effect","settings":[{"type":"text","id":"heading","label":"Heading","default":"Our story"}],"presets":[{"name":"WESWOO effect"}]}
{% endschema %}
// Put the chosen example JS in assets/ww-selected-effect.js (rename .mjs to .js).
import {mountEffect} from './ww-selected-effect.js';
const instances=new Map();
function mount(container=document){
const roots=[...(container.matches?.('[data-ww-effect-section]')?[container]:[]),...container.querySelectorAll('[data-ww-effect-section]')];
for(const section of roots){
if(instances.has(section))continue;
const root=section.querySelector('.fx'),button=section.querySelector('[data-effect-toggle]');
if(!root||!button)continue;
const effect=mountEffect(root),events=new AbortController();let playing=false;
const pause=()=>{playing=false;effect.pause();button.setAttribute('aria-pressed','false');};
button.addEventListener('click',()=>{playing=!playing;playing?effect.resume():effect.pause();button.setAttribute('aria-pressed',String(playing));},{signal:events.signal});
const observer=new IntersectionObserver(entries=>{if(!entries[0].isIntersecting)pause();});observer.observe(section);
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:events.signal});
instances.set(section,()=>{observer.disconnect();events.abort();effect.destroy();});
}
}
document.addEventListener('shopify:section:load',event=>mount(event.target));
document.addEventListener('shopify:section:unload',event=>{for(const [section,destroy] of instances)if(section===event.target||event.target.contains(section)){destroy();instances.delete(section);}});
mount();
// Original WESWOO integration. Copy alongside the selected ww-effect-*.js asset.
// The server supplies the asset URL; do not accept a URL from a query parameter.
if (!customElements.get('ww-effect-study')) {
customElements.define('ww-effect-study', class extends HTMLElement {
connectedCallback() {
if (this.events) return;
this.events=new AbortController();this.session={};const session=this.session;
const button=this.querySelector('[data-effect-toggle]');
button.disabled=false;button.setAttribute('aria-pressed','false');this.visible=true;
const preference=matchMedia('(prefers-reduced-motion: reduce)');
const pause=()=>{this.effect?.pause();button.setAttribute('aria-pressed','false');};
this.pause=pause;
button.addEventListener('click',async()=>{
if(this.loading)return;
if(!this.effect){
this.loading=true;button.disabled=true;
try {
const {mountEffect}=await import(this.dataset.moduleUrl);
if(!this.isConnected||this.session!==session)return;
this.effect=mountEffect(this.querySelector('.fx'),{reducedMotion:preference.matches});
} catch {this.querySelector('[data-effect-status]').textContent='The static content is available. Reload to retry motion.';return;}
finally {if(this.session===session){this.loading=false;button.disabled=false;}}
}
if(this.session!==session||document.hidden||!this.visible)return;
const playing=button.getAttribute('aria-pressed')!=='true';
playing?this.effect.resume():this.effect.pause();button.setAttribute('aria-pressed',String(playing));
},{signal:this.events.signal});
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:this.events.signal});
preference.addEventListener('change',()=>{pause();this.effect?.destroy();this.effect=null;},{signal:this.events.signal});
this.observer=new IntersectionObserver(entries=>{this.visible=entries[0].isIntersecting;if(!this.visible)pause();});this.observer.observe(this);
const root=this.querySelector('.fx');
root.querySelectorAll('[data-view]').forEach(trigger=>trigger.addEventListener('click',()=>{const target=root.querySelector('dialog .art'),source=trigger.querySelector('.ww-fx-image');target.querySelector('.ww-fx-image')?.remove();if(source)target.append(source.cloneNode(true));},{signal:this.events.signal}));
// Section unload disconnects this custom element; reconnect mounts one fresh instance.
document.addEventListener('shopify:section:unload',event=>{if(event.target.contains(this))this.teardown();},{signal:this.events.signal});
}
teardown(){this.session=null;this.loading=false;this.observer?.disconnect();this.events?.abort();this.effect?.destroy();this.effect=null;this.events=null;}
disconnectedCallback(){this.teardown();}
});
}
Insert the selected effect into the shell. Each module loads one effect; multiple types need an explicit registry and Section mapping.
The expansion is adapted from Codrops MorphingSearch and uses the Unsplash photograph credited in the original demo.
Shopify: Section architectureShopify: theme editor events and lifecycleShopify: theme performanceMDN: Web Animations APIMDN: reduced-motion preferenceMDN: iframe sandboxingShopify: image rendering and dimensionsShopify: Section settings and schemaMDN: element geometryMDN: image and text clippingMDN: native dialogShopify: theme accessibilityMDN: native range inputExamples are authored by WESWOO and credited open-source contributors; retain their applicable licenses. Project screens and photographs remain with their rights holders. Downloads use placeholders; replace them with imagery you may use.
Shopify/dawn · modal / slider base classesShopify/dawn · product media galleryShopify/dawn · licensePreparing preview
Open Clothing, then Shirts. Returning restores the department so the shopper can continue browsing.
<section class="fx drill" lang="en" aria-label="Collection drilldown demo">
<div class="cols">
<div>
<h2>Browse the store</h2>
<p class="intro">Choose a department to see its collections.</p>
<div class="panel">
<div class="row drill-head"><h3 tabindex="-1">Departments</h3><button type="button" data-back hidden>Back</button></div>
<div class="drill-options">
<button type="button" data-branch="Clothing">Clothing</button>
<button type="button" data-branch="Accessories">Accessories</button>
</div>
<p class="status" role="status" data-choice></p>
</div>
</div>
<figure><img src="__WW_VISUAL_1__" alt="Blue tailored outfit from the Codrops ColumnScroll demo"></figure>
</div>
</section>* { box-sizing: border-box; }
.fx {
--paper:#f2f3eb; --ink:#20332b; --accent:#205a4c; --edge:#c6cec0; --card:#fffdf8; --mute:#466056;
padding:clamp(14px,3.3vw,34px); min-height:268px; color:var(--ink); background:var(--paper);
font:16px/1.48 system-ui,sans-serif;
}
h2,h3,p,figure,ul,ol,dl,dd,fieldset { margin:0; }
h2 { font-size:clamp(1.38rem,3.8vw,2.55rem); letter-spacing:-.035em; line-height:1.1; }
h3 { font-size:1.12em; }
p { max-width:62ch; }
img { display:block; max-width:100%; }
button,input,select { font:inherit; }
button {
min-height:44px; padding:8px 12px; border:1px solid var(--edge); border-radius:8px;
background:var(--card); color:var(--ink); cursor:pointer; line-height:1.25;
}
button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible,[tabindex="0"]:focus-visible {
outline:2px solid var(--accent); outline-offset:2px;
}
button:disabled { opacity:.55; cursor:default; }
button[aria-pressed="true"],button.primary { color:white; background:var(--accent); border-color:var(--accent); font-weight:650; }
button:hover:not(:disabled) { border-color:var(--accent); }
[hidden] { display:none !important; }
.intro { margin:8px 0 15px; color:var(--mute); }
.panel { padding:clamp(10px,2.2vw,22px); border:1px solid var(--edge); border-radius:12px; background:var(--card); }
.row { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.cols { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:clamp(12px,3vw,28px); align-items:start; }
.product-photo { width:100%; height:clamp(94px,21vw,204px); object-fit:contain; padding:10px; border-radius:10px; background:#e6e9e1; }
.status { color:var(--mute); margin-top:10px; min-height:1.45em; }
@media(max-width:600px){ .cols { grid-template-columns:minmax(0,1fr); } }
.drill { --paper:#e6ecee; --accent:#1b5270; }
.drill-head { justify-content:space-between; }
.drill-options { display:grid; gap:7px; margin-top:10px; }
.drill-options button { text-align:left; }
.drill figure img { width:100%; height:clamp(138px,28vw,345px); object-fit:cover; object-position:50% 30%; border-radius:12px; }
@media(max-width:600px){ .drill figure img { height:116px; } }/*
* Adapted from Multi-Level Menu; Copyright (c) 2015 Codrops.
* https://github.com/codrops/MultiLevelMenu/blob/master/js/main.js
* The original JavaScript is licensed under the MIT License.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
export function mountEffect(root, {reducedMotion = matchMedia('(prefers-reduced-motion: reduce)').matches} = {}) {
const lifetime = new AbortController();
const $ = selector => root.querySelector(selector);
const all = selector => [...root.querySelectorAll(selector)];
const listen = (element, type, handler) => element.addEventListener(type, handler, {signal:lifetime.signal});
const animations = new Map();
let motion = false;
function cancelMotion() {
for (const animation of animations.values()) animation.cancel();
animations.clear();
}
function reveal(element, position = 'translateY(6px)') {
animations.get(element)?.cancel();
if (!motion || !element.animate) return;
const animation = element.animate(
[{transform:position, opacity:.52},{transform:'none', opacity:1}],
{duration:225, easing:'ease-out'}
);
animations.set(element,animation);
animation.onfinish = () => animations.delete(element);
}
const menu = $('.drill-options');
const heading = $('.drill-head h3');
const back = $('[data-back]');
const status = $('[data-choice]');
const departments = ['Clothing','Accessories'];
const tree = {Clothing:['Shirts','Outerwear'],Accessories:['Bags','Caps']};
function show(department) {
const previous = heading.textContent;
heading.textContent = department || 'Departments';
back.hidden = !department;
status.textContent = '';
const entries = department ? tree[department] : departments;
menu.replaceChildren(...entries.map(label => {
const button = document.createElement('button');
button.type = 'button';
button.textContent = label;
button.dataset[department ? 'leaf' : 'branch'] = label;
return button;
}));
reveal(menu, department ? 'translateX(9px)' : 'translateX(-9px)');
const returnControl = all('[data-branch]').find(button => button.dataset.branch === previous);
(returnControl || heading).focus({preventScroll:true});
}
listen(menu,'click',event => {
const control = event.target.closest('button');
if (!control) return;
if (control.dataset.branch) {
show(control.dataset.branch);
return;
}
status.textContent = 'Collection selected: ' + control.dataset.leaf;
reveal(status);
});
listen(back,'click',() => show(null));
return {
resume() { motion = !reducedMotion; },
pause() { motion = false; cancelMotion(); },
destroy() { lifetime.abort(); cancelMotion(); }
};
}Mobile collection and store navigation.
Show one level at a time and name the current department.
Tap to enter. Back restores focus to the previous department.
Check entry, back navigation and the final destination.
Build the hierarchy from your navigation data and link terminal entries to real collections.
Work in a duplicate theme. Replace demo copy and artwork with Section settings, scope styles to that Section, and use the lifecycle module for editor reloads, visibility and teardown.
{% comment %} WESWOO example shell. Add ONE effect's HTML inside .fx-slot. {% endcomment %}
{{ 'ww-effects.css' | asset_url | stylesheet_tag }}
<section id="ww-effect-{{ section.id }}" data-ww-effect-section>
<h2>{{ section.settings.heading | escape }}</h2>
<button type="button" data-effect-toggle aria-pressed="false">Play / pause effect</button>
<div class="fx-slot">
{% comment %} Insert the chosen .fx element here; read copy/images from section settings. {% endcomment %}
</div>
</section>
<script type="module" src="{{ 'ww-effect-section.js' | asset_url }}"></script>
{% schema %}
{"name":"WESWOO effect","settings":[{"type":"text","id":"heading","label":"Heading","default":"Our story"}],"presets":[{"name":"WESWOO effect"}]}
{% endschema %}
// Put the chosen example JS in assets/ww-selected-effect.js (rename .mjs to .js).
import {mountEffect} from './ww-selected-effect.js';
const instances=new Map();
function mount(container=document){
const roots=[...(container.matches?.('[data-ww-effect-section]')?[container]:[]),...container.querySelectorAll('[data-ww-effect-section]')];
for(const section of roots){
if(instances.has(section))continue;
const root=section.querySelector('.fx'),button=section.querySelector('[data-effect-toggle]');
if(!root||!button)continue;
const effect=mountEffect(root),events=new AbortController();let playing=false;
const pause=()=>{playing=false;effect.pause();button.setAttribute('aria-pressed','false');};
button.addEventListener('click',()=>{playing=!playing;playing?effect.resume():effect.pause();button.setAttribute('aria-pressed',String(playing));},{signal:events.signal});
const observer=new IntersectionObserver(entries=>{if(!entries[0].isIntersecting)pause();});observer.observe(section);
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:events.signal});
instances.set(section,()=>{observer.disconnect();events.abort();effect.destroy();});
}
}
document.addEventListener('shopify:section:load',event=>mount(event.target));
document.addEventListener('shopify:section:unload',event=>{for(const [section,destroy] of instances)if(section===event.target||event.target.contains(section)){destroy();instances.delete(section);}});
mount();
// Original WESWOO integration. Copy alongside the selected ww-effect-*.js asset.
// The server supplies the asset URL; do not accept a URL from a query parameter.
if (!customElements.get('ww-effect-study')) {
customElements.define('ww-effect-study', class extends HTMLElement {
connectedCallback() {
if (this.events) return;
this.events=new AbortController();this.session={};const session=this.session;
const button=this.querySelector('[data-effect-toggle]');
button.disabled=false;button.setAttribute('aria-pressed','false');this.visible=true;
const preference=matchMedia('(prefers-reduced-motion: reduce)');
const pause=()=>{this.effect?.pause();button.setAttribute('aria-pressed','false');};
this.pause=pause;
button.addEventListener('click',async()=>{
if(this.loading)return;
if(!this.effect){
this.loading=true;button.disabled=true;
try {
const {mountEffect}=await import(this.dataset.moduleUrl);
if(!this.isConnected||this.session!==session)return;
this.effect=mountEffect(this.querySelector('.fx'),{reducedMotion:preference.matches});
} catch {this.querySelector('[data-effect-status]').textContent='The static content is available. Reload to retry motion.';return;}
finally {if(this.session===session){this.loading=false;button.disabled=false;}}
}
if(this.session!==session||document.hidden||!this.visible)return;
const playing=button.getAttribute('aria-pressed')!=='true';
playing?this.effect.resume():this.effect.pause();button.setAttribute('aria-pressed',String(playing));
},{signal:this.events.signal});
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:this.events.signal});
preference.addEventListener('change',()=>{pause();this.effect?.destroy();this.effect=null;},{signal:this.events.signal});
this.observer=new IntersectionObserver(entries=>{this.visible=entries[0].isIntersecting;if(!this.visible)pause();});this.observer.observe(this);
const root=this.querySelector('.fx');
root.querySelectorAll('[data-view]').forEach(trigger=>trigger.addEventListener('click',()=>{const target=root.querySelector('dialog .art'),source=trigger.querySelector('.ww-fx-image');target.querySelector('.ww-fx-image')?.remove();if(source)target.append(source.cloneNode(true));},{signal:this.events.signal}));
// Section unload disconnects this custom element; reconnect mounts one fresh instance.
document.addEventListener('shopify:section:unload',event=>{if(event.target.contains(this))this.teardown();},{signal:this.events.signal});
}
teardown(){this.session=null;this.loading=false;this.observer?.disconnect();this.events?.abort();this.effect?.destroy();this.effect=null;this.events=null;}
disconnectedCallback(){this.teardown();}
});
}
Insert the selected effect into the shell. Each module loads one effect; multiple types need an explicit registry and Section mapping.
Level transitions adapt Codrops Multi-Level Menu (MIT). The photograph is from the Unsplash imagery in Codrops ColumnScroll.
Shopify: Section architectureShopify: theme editor events and lifecycleShopify: theme performanceMDN: Web Animations APIMDN: reduced-motion preferenceMDN: iframe sandboxingShopify: image rendering and dimensionsShopify: Section settings and schemaMDN: element geometryMDN: image and text clippingMDN: native dialogShopify: theme accessibilityMDN: native range inputExamples are authored by WESWOO and credited open-source contributors; retain their applicable licenses. Project screens and photographs remain with their rights holders. Downloads use placeholders; replace them with imagery you may use.
Shopify/dawn · modal / slider base classesShopify/dawn · product media galleryShopify/dawn · licensePreparing preview
Switch to inches and back to centimeters. The original values stay intact. Label garment and body measurements clearly.
<section class="fx size-guide" lang="en" aria-label="Size guide demo">
<div class="cols">
<div>
<h2>Find your size</h2>
<p class="intro">Compare the sample garment measurements before choosing.</p>
<button type="button" class="primary" data-size-open>Open size guide</button>
</div>
<img class="product-photo" src="__WW_VISUAL_1__" alt="Sage graphic T-shirt">
</div>
<dialog aria-labelledby="size-title">
<div class="row guide-head"><h3 id="size-title">Garment measurements</h3><button type="button" data-close>Close</button></div>
<div class="row" role="group" aria-label="Measurement units">
<button type="button" data-unit="cm" aria-pressed="true">cm</button>
<button type="button" data-unit="in" aria-pressed="false">in</button>
</div>
<table><caption>Sample chart <span data-unit-label>(cm)</span></caption>
<thead><tr><th scope="col">Size</th><th scope="col">Width</th><th scope="col">Length</th></tr></thead>
<tbody><tr><th scope="row">S</th><td data-cm="48">48</td><td data-cm="66">66</td></tr>
<tr><th scope="row">M</th><td data-cm="51">51</td><td data-cm="69">69</td></tr>
<tr><th scope="row">L</th><td data-cm="54">54</td><td data-cm="72">72</td></tr></tbody>
</table>
<p class="status" role="status" data-units-status>Showing centimeters.</p>
</dialog>
</section>* { box-sizing: border-box; }
.fx {
--paper:#f2f3eb; --ink:#20332b; --accent:#205a4c; --edge:#c6cec0; --card:#fffdf8; --mute:#466056;
padding:clamp(14px,3.3vw,34px); min-height:268px; color:var(--ink); background:var(--paper);
font:16px/1.48 system-ui,sans-serif;
}
h2,h3,p,figure,ul,ol,dl,dd,fieldset { margin:0; }
h2 { font-size:clamp(1.38rem,3.8vw,2.55rem); letter-spacing:-.035em; line-height:1.1; }
h3 { font-size:1.12em; }
p { max-width:62ch; }
img { display:block; max-width:100%; }
button,input,select { font:inherit; }
button {
min-height:44px; padding:8px 12px; border:1px solid var(--edge); border-radius:8px;
background:var(--card); color:var(--ink); cursor:pointer; line-height:1.25;
}
button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible,[tabindex="0"]:focus-visible {
outline:2px solid var(--accent); outline-offset:2px;
}
button:disabled { opacity:.55; cursor:default; }
button[aria-pressed="true"],button.primary { color:white; background:var(--accent); border-color:var(--accent); font-weight:650; }
button:hover:not(:disabled) { border-color:var(--accent); }
[hidden] { display:none !important; }
.intro { margin:8px 0 15px; color:var(--mute); }
.panel { padding:clamp(10px,2.2vw,22px); border:1px solid var(--edge); border-radius:12px; background:var(--card); }
.row { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.cols { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:clamp(12px,3vw,28px); align-items:start; }
.product-photo { width:100%; height:clamp(94px,21vw,204px); object-fit:contain; padding:10px; border-radius:10px; background:#e6e9e1; }
.status { color:var(--mute); margin-top:10px; min-height:1.45em; }
@media(max-width:600px){ .cols { grid-template-columns:minmax(0,1fr); } }
.size-guide { --paper:#e9eee1; min-height:360px; }
.size-guide dialog { max-width:min(480px,calc(100% - 24px)); max-height:calc(100% - 24px);
width:100%; color:var(--ink); border:1px solid var(--edge); border-radius:12px; padding:12px; background:var(--card); }
.size-guide dialog::backdrop { background:#18352788; }
.guide-head { justify-content:space-between; margin-bottom:10px; }
.size-guide table { border-collapse:collapse; table-layout:fixed; width:100%; margin-top:9px; }
.size-guide caption { text-align:left; color:var(--mute); }
.size-guide th,.size-guide td { padding:5px 4px; border-bottom:1px solid var(--edge); text-align:left; }export function mountEffect(root, {reducedMotion = matchMedia('(prefers-reduced-motion: reduce)').matches} = {}) {
const lifetime = new AbortController();
const $ = selector => root.querySelector(selector);
const all = selector => [...root.querySelectorAll(selector)];
const listen = (element, type, handler) => element.addEventListener(type, handler, {signal:lifetime.signal});
const animations = new Map();
let motion = false;
function cancelMotion() {
for (const animation of animations.values()) animation.cancel();
animations.clear();
}
function reveal(element, position = 'translateY(6px)') {
animations.get(element)?.cancel();
if (!motion || !element.animate) return;
const animation = element.animate(
[{transform:position, opacity:.52},{transform:'none', opacity:1}],
{duration:225, easing:'ease-out'}
);
animations.set(element,animation);
animation.onfinish = () => animations.delete(element);
}
const trigger = $('[data-size-open]');
const dialog = $('dialog');
const units = all('[data-unit]');
listen(trigger,'click',() => {
dialog.showModal();
reveal(dialog);
});
listen($('[data-close]'),'click',() => dialog.close());
listen(dialog,'close',() => trigger.focus({preventScroll:true}));
for (const button of units) listen(button,'click',() => {
const inches = button.dataset.unit === 'in';
for (const cell of all('[data-cm]')) {
cell.textContent = inches ? (Number(cell.dataset.cm)/2.54).toFixed(1) : cell.dataset.cm;
}
for (const unit of units) unit.setAttribute('aria-pressed',String(unit===button));
$('[data-unit-label]').textContent = inches ? '(in)' : '(cm)';
$('[data-units-status]').textContent = inches ? 'Showing inches.' : 'Showing centimeters.';
reveal($('tbody'));
});
return {
resume() { motion = !reducedMotion; },
pause() { motion = false; cancelMotion(); },
destroy() { lifetime.abort(); cancelMotion(); if (dialog.open) dialog.close(); }
};
}Apparel, footwear and products with size choices.
Keep one source measurement and convert it on demand.
Escape closes the dialog and focus returns to its opener.
Check unit labels, rounding and restored focus.
Store measurements per size in product metafields and convert at display time.
Work in a duplicate theme. Replace demo copy and artwork with Section settings, scope styles to that Section, and use the lifecycle module for editor reloads, visibility and teardown.
{% comment %} WESWOO example shell. Add ONE effect's HTML inside .fx-slot. {% endcomment %}
{{ 'ww-effects.css' | asset_url | stylesheet_tag }}
<section id="ww-effect-{{ section.id }}" data-ww-effect-section>
<h2>{{ section.settings.heading | escape }}</h2>
<button type="button" data-effect-toggle aria-pressed="false">Play / pause effect</button>
<div class="fx-slot">
{% comment %} Insert the chosen .fx element here; read copy/images from section settings. {% endcomment %}
</div>
</section>
<script type="module" src="{{ 'ww-effect-section.js' | asset_url }}"></script>
{% schema %}
{"name":"WESWOO effect","settings":[{"type":"text","id":"heading","label":"Heading","default":"Our story"}],"presets":[{"name":"WESWOO effect"}]}
{% endschema %}
// Put the chosen example JS in assets/ww-selected-effect.js (rename .mjs to .js).
import {mountEffect} from './ww-selected-effect.js';
const instances=new Map();
function mount(container=document){
const roots=[...(container.matches?.('[data-ww-effect-section]')?[container]:[]),...container.querySelectorAll('[data-ww-effect-section]')];
for(const section of roots){
if(instances.has(section))continue;
const root=section.querySelector('.fx'),button=section.querySelector('[data-effect-toggle]');
if(!root||!button)continue;
const effect=mountEffect(root),events=new AbortController();let playing=false;
const pause=()=>{playing=false;effect.pause();button.setAttribute('aria-pressed','false');};
button.addEventListener('click',()=>{playing=!playing;playing?effect.resume():effect.pause();button.setAttribute('aria-pressed',String(playing));},{signal:events.signal});
const observer=new IntersectionObserver(entries=>{if(!entries[0].isIntersecting)pause();});observer.observe(section);
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:events.signal});
instances.set(section,()=>{observer.disconnect();events.abort();effect.destroy();});
}
}
document.addEventListener('shopify:section:load',event=>mount(event.target));
document.addEventListener('shopify:section:unload',event=>{for(const [section,destroy] of instances)if(section===event.target||event.target.contains(section)){destroy();instances.delete(section);}});
mount();
// Original WESWOO integration. Copy alongside the selected ww-effect-*.js asset.
// The server supplies the asset URL; do not accept a URL from a query parameter.
if (!customElements.get('ww-effect-study')) {
customElements.define('ww-effect-study', class extends HTMLElement {
connectedCallback() {
if (this.events) return;
this.events=new AbortController();this.session={};const session=this.session;
const button=this.querySelector('[data-effect-toggle]');
button.disabled=false;button.setAttribute('aria-pressed','false');this.visible=true;
const preference=matchMedia('(prefers-reduced-motion: reduce)');
const pause=()=>{this.effect?.pause();button.setAttribute('aria-pressed','false');};
this.pause=pause;
button.addEventListener('click',async()=>{
if(this.loading)return;
if(!this.effect){
this.loading=true;button.disabled=true;
try {
const {mountEffect}=await import(this.dataset.moduleUrl);
if(!this.isConnected||this.session!==session)return;
this.effect=mountEffect(this.querySelector('.fx'),{reducedMotion:preference.matches});
} catch {this.querySelector('[data-effect-status]').textContent='The static content is available. Reload to retry motion.';return;}
finally {if(this.session===session){this.loading=false;button.disabled=false;}}
}
if(this.session!==session||document.hidden||!this.visible)return;
const playing=button.getAttribute('aria-pressed')!=='true';
playing?this.effect.resume():this.effect.pause();button.setAttribute('aria-pressed',String(playing));
},{signal:this.events.signal});
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:this.events.signal});
preference.addEventListener('change',()=>{pause();this.effect?.destroy();this.effect=null;},{signal:this.events.signal});
this.observer=new IntersectionObserver(entries=>{this.visible=entries[0].isIntersecting;if(!this.visible)pause();});this.observer.observe(this);
const root=this.querySelector('.fx');
root.querySelectorAll('[data-view]').forEach(trigger=>trigger.addEventListener('click',()=>{const target=root.querySelector('dialog .art'),source=trigger.querySelector('.ww-fx-image');target.querySelector('.ww-fx-image')?.remove();if(source)target.append(source.cloneNode(true));},{signal:this.events.signal}));
// Section unload disconnects this custom element; reconnect mounts one fresh instance.
document.addEventListener('shopify:section:unload',event=>{if(event.target.contains(this))this.teardown();},{signal:this.events.signal});
}
teardown(){this.session=null;this.loading=false;this.observer?.disconnect();this.events?.abort();this.effect?.destroy();this.effect=null;this.events=null;}
disconnectedCallback(){this.teardown();}
});
}
Insert the selected effect into the shell. Each module loads one effect; multiple types need an explicit registry and Section mapping.
Product imagery is from the original Codrops Product Grid Layout.
Shopify: Section architectureShopify: theme editor events and lifecycleShopify: theme performanceMDN: Web Animations APIMDN: reduced-motion preferenceMDN: iframe sandboxingShopify: image rendering and dimensionsShopify: Section settings and schemaMDN: element geometryMDN: image and text clippingMDN: native dialogShopify: theme accessibilityMDN: native range inputExamples are authored by WESWOO and credited open-source contributors; retain their applicable licenses. Project screens and photographs remain with their rights holders. Downloads use placeholders; replace them with imagery you may use.
Shopify/dawn · modal / slider base classesShopify/dawn · product media galleryShopify/dawn · licensePreparing preview
Increase to three and try again. The demo reports the limit and the subtotal still matches the current quantity.
<section class="fx quantity-demo" lang="en" aria-label="Cart quantity demo">
<div class="cols">
<img class="product-photo" src="__WW_VISUAL_1__" alt="Rose graphic T-shirt">
<div>
<h2>Adjust quantity</h2>
<p class="intro">Rose tee · sample price $26 each</p>
<div class="panel">
<div class="row quantity-stepper" role="group" aria-label="Quantity">
<button type="button" data-step="-1" aria-label="Decrease quantity" aria-disabled="true">−</button>
<output data-qty>1</output>
<button type="button" data-step="1" aria-label="Increase quantity" aria-disabled="false">+</button>
</div>
<p class="qty-total">Subtotal <strong data-total>$26.00</strong></p>
<p class="status" role="status" data-cap>1 of 3 available</p>
</div>
</div>
</div>
</section>* { box-sizing: border-box; }
.fx {
--paper:#f2f3eb; --ink:#20332b; --accent:#205a4c; --edge:#c6cec0; --card:#fffdf8; --mute:#466056;
padding:clamp(14px,3.3vw,34px); min-height:268px; color:var(--ink); background:var(--paper);
font:16px/1.48 system-ui,sans-serif;
}
h2,h3,p,figure,ul,ol,dl,dd,fieldset { margin:0; }
h2 { font-size:clamp(1.38rem,3.8vw,2.55rem); letter-spacing:-.035em; line-height:1.1; }
h3 { font-size:1.12em; }
p { max-width:62ch; }
img { display:block; max-width:100%; }
button,input,select { font:inherit; }
button {
min-height:44px; padding:8px 12px; border:1px solid var(--edge); border-radius:8px;
background:var(--card); color:var(--ink); cursor:pointer; line-height:1.25;
}
button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible,[tabindex="0"]:focus-visible {
outline:2px solid var(--accent); outline-offset:2px;
}
button:disabled { opacity:.55; cursor:default; }
button[aria-pressed="true"],button.primary { color:white; background:var(--accent); border-color:var(--accent); font-weight:650; }
button:hover:not(:disabled) { border-color:var(--accent); }
[hidden] { display:none !important; }
.intro { margin:8px 0 15px; color:var(--mute); }
.panel { padding:clamp(10px,2.2vw,22px); border:1px solid var(--edge); border-radius:12px; background:var(--card); }
.row { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.cols { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:clamp(12px,3vw,28px); align-items:start; }
.product-photo { width:100%; height:clamp(94px,21vw,204px); object-fit:contain; padding:10px; border-radius:10px; background:#e6e9e1; }
.status { color:var(--mute); margin-top:10px; min-height:1.45em; }
@media(max-width:600px){ .cols { grid-template-columns:minmax(0,1fr); } }
.quantity-demo { --paper:#f5ebe9; --accent:#713e4f; }
.quantity-demo .product-photo { background:#ecdbdd; }
.quantity-stepper output { min-width:24px; text-align:center; font-variant-numeric:tabular-nums; }
.quantity-stepper button { min-width:44px; font-size:1.2rem; }
.quantity-stepper [aria-disabled="true"] { opacity:.55; cursor:default; }
.qty-total { display:flex; flex-wrap:wrap; justify-content:space-between; gap:8px; margin-top:12px; font-variant-numeric:tabular-nums; }export function mountEffect(root, {reducedMotion = matchMedia('(prefers-reduced-motion: reduce)').matches} = {}) {
const lifetime = new AbortController();
const $ = selector => root.querySelector(selector);
const all = selector => [...root.querySelectorAll(selector)];
const listen = (element, type, handler) => element.addEventListener(type, handler, {signal:lifetime.signal});
const animations = new Map();
let motion = false;
function cancelMotion() {
for (const animation of animations.values()) animation.cancel();
animations.clear();
}
function reveal(element, position = 'translateY(6px)') {
animations.get(element)?.cancel();
if (!motion || !element.animate) return;
const animation = element.animate(
[{transform:position, opacity:.52},{transform:'none', opacity:1}],
{duration:225, easing:'ease-out'}
);
animations.set(element,animation);
animation.onfinish = () => animations.delete(element);
}
const controls = all('[data-step]');
const format = new Intl.NumberFormat('en-US',{style:'currency',currency:'USD'});
let quantity = 1;
const max = 3;
for (const button of controls) listen(button,'click',() => {
const next = quantity + Number(button.dataset.step);
if (next < 1 || next > max) return;
quantity = next;
$('[data-qty]').value = quantity;
$('[data-total]').textContent = format.format(quantity * 26);
$('[data-cap]').textContent = quantity === max ? 'Maximum available quantity: 3.' : quantity + ' of 3 available';
for (const control of controls) {
control.setAttribute('aria-disabled',String(control.dataset.step === '1' ? quantity===max : quantity===1));
}
reveal($('[data-total]'));
});
return {
resume() { motion = !reducedMotion; },
pause() { motion = false; cancelMotion(); },
destroy() { lifetime.abort(); cancelMotion(); }
};
}Carts, quick buys and product forms.
Bound the quantity and compute the subtotal from the same value.
Large buttons work on phones and retain focus at a boundary.
Check repeated changes, stock limits and currency formatting.
Use cart responses to confirm stock and subtotal. Handle server errors and stock changes.
Work in a duplicate theme. Replace demo copy and artwork with Section settings, scope styles to that Section, and use the lifecycle module for editor reloads, visibility and teardown.
{% comment %} WESWOO example shell. Add ONE effect's HTML inside .fx-slot. {% endcomment %}
{{ 'ww-effects.css' | asset_url | stylesheet_tag }}
<section id="ww-effect-{{ section.id }}" data-ww-effect-section>
<h2>{{ section.settings.heading | escape }}</h2>
<button type="button" data-effect-toggle aria-pressed="false">Play / pause effect</button>
<div class="fx-slot">
{% comment %} Insert the chosen .fx element here; read copy/images from section settings. {% endcomment %}
</div>
</section>
<script type="module" src="{{ 'ww-effect-section.js' | asset_url }}"></script>
{% schema %}
{"name":"WESWOO effect","settings":[{"type":"text","id":"heading","label":"Heading","default":"Our story"}],"presets":[{"name":"WESWOO effect"}]}
{% endschema %}
// Put the chosen example JS in assets/ww-selected-effect.js (rename .mjs to .js).
import {mountEffect} from './ww-selected-effect.js';
const instances=new Map();
function mount(container=document){
const roots=[...(container.matches?.('[data-ww-effect-section]')?[container]:[]),...container.querySelectorAll('[data-ww-effect-section]')];
for(const section of roots){
if(instances.has(section))continue;
const root=section.querySelector('.fx'),button=section.querySelector('[data-effect-toggle]');
if(!root||!button)continue;
const effect=mountEffect(root),events=new AbortController();let playing=false;
const pause=()=>{playing=false;effect.pause();button.setAttribute('aria-pressed','false');};
button.addEventListener('click',()=>{playing=!playing;playing?effect.resume():effect.pause();button.setAttribute('aria-pressed',String(playing));},{signal:events.signal});
const observer=new IntersectionObserver(entries=>{if(!entries[0].isIntersecting)pause();});observer.observe(section);
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:events.signal});
instances.set(section,()=>{observer.disconnect();events.abort();effect.destroy();});
}
}
document.addEventListener('shopify:section:load',event=>mount(event.target));
document.addEventListener('shopify:section:unload',event=>{for(const [section,destroy] of instances)if(section===event.target||event.target.contains(section)){destroy();instances.delete(section);}});
mount();
// Original WESWOO integration. Copy alongside the selected ww-effect-*.js asset.
// The server supplies the asset URL; do not accept a URL from a query parameter.
if (!customElements.get('ww-effect-study')) {
customElements.define('ww-effect-study', class extends HTMLElement {
connectedCallback() {
if (this.events) return;
this.events=new AbortController();this.session={};const session=this.session;
const button=this.querySelector('[data-effect-toggle]');
button.disabled=false;button.setAttribute('aria-pressed','false');this.visible=true;
const preference=matchMedia('(prefers-reduced-motion: reduce)');
const pause=()=>{this.effect?.pause();button.setAttribute('aria-pressed','false');};
this.pause=pause;
button.addEventListener('click',async()=>{
if(this.loading)return;
if(!this.effect){
this.loading=true;button.disabled=true;
try {
const {mountEffect}=await import(this.dataset.moduleUrl);
if(!this.isConnected||this.session!==session)return;
this.effect=mountEffect(this.querySelector('.fx'),{reducedMotion:preference.matches});
} catch {this.querySelector('[data-effect-status]').textContent='The static content is available. Reload to retry motion.';return;}
finally {if(this.session===session){this.loading=false;button.disabled=false;}}
}
if(this.session!==session||document.hidden||!this.visible)return;
const playing=button.getAttribute('aria-pressed')!=='true';
playing?this.effect.resume():this.effect.pause();button.setAttribute('aria-pressed',String(playing));
},{signal:this.events.signal});
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:this.events.signal});
preference.addEventListener('change',()=>{pause();this.effect?.destroy();this.effect=null;},{signal:this.events.signal});
this.observer=new IntersectionObserver(entries=>{this.visible=entries[0].isIntersecting;if(!this.visible)pause();});this.observer.observe(this);
const root=this.querySelector('.fx');
root.querySelectorAll('[data-view]').forEach(trigger=>trigger.addEventListener('click',()=>{const target=root.querySelector('dialog .art'),source=trigger.querySelector('.ww-fx-image');target.querySelector('.ww-fx-image')?.remove();if(source)target.append(source.cloneNode(true));},{signal:this.events.signal}));
// Section unload disconnects this custom element; reconnect mounts one fresh instance.
document.addEventListener('shopify:section:unload',event=>{if(event.target.contains(this))this.teardown();},{signal:this.events.signal});
}
teardown(){this.session=null;this.loading=false;this.observer?.disconnect();this.events?.abort();this.effect?.destroy();this.effect=null;this.events=null;}
disconnectedCallback(){this.teardown();}
});
}
Insert the selected effect into the shell. Each module loads one effect; multiple types need an explicit registry and Section mapping.
Quantity and total feedback refer to the open Codrops cart demo. The product image is from Codrops Product Grid Layout.
Shopify: Section architectureShopify: theme editor events and lifecycleShopify: theme performanceMDN: Web Animations APIMDN: reduced-motion preferenceMDN: iframe sandboxingShopify: image rendering and dimensionsShopify: Section settings and schemaMDN: element geometryMDN: image and text clippingMDN: native dialogShopify: theme accessibilityMDN: native range inputExamples are authored by WESWOO and credited open-source contributors; retain their applicable licenses. Project screens and photographs remain with their rights holders. Downloads use placeholders; replace them with imagery you may use.
Shopify/dawn · modal / slider base classesShopify/dawn · product media galleryShopify/dawn · licensePreparing preview
Choose Remove item, then Undo removal. The item and its subtotal return together.
<section class="fx undo-demo" lang="en" aria-label="Cart removal and undo demo">
<h2>Your demo cart</h2>
<div class="panel cart-line">
<img class="product-photo" src="__WW_VISUAL_1__" alt="Sky blue graphic T-shirt">
<div><h3>Sky tee</h3><p>$24.00</p><button type="button" data-remove>Remove item</button></div>
</div>
<div class="panel empty-cart" hidden><h3>Your cart is empty</h3><p>Restore the last item if you removed it by mistake.</p></div>
<div class="row undo-row"><p class="status" role="status" data-state>1 item · $24.00</p><button type="button" data-undo hidden>Undo removal</button></div>
</section>* { box-sizing: border-box; }
.fx {
--paper:#f2f3eb; --ink:#20332b; --accent:#205a4c; --edge:#c6cec0; --card:#fffdf8; --mute:#466056;
padding:clamp(14px,3.3vw,34px); min-height:268px; color:var(--ink); background:var(--paper);
font:16px/1.48 system-ui,sans-serif;
}
h2,h3,p,figure,ul,ol,dl,dd,fieldset { margin:0; }
h2 { font-size:clamp(1.38rem,3.8vw,2.55rem); letter-spacing:-.035em; line-height:1.1; }
h3 { font-size:1.12em; }
p { max-width:62ch; }
img { display:block; max-width:100%; }
button,input,select { font:inherit; }
button {
min-height:44px; padding:8px 12px; border:1px solid var(--edge); border-radius:8px;
background:var(--card); color:var(--ink); cursor:pointer; line-height:1.25;
}
button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible,[tabindex="0"]:focus-visible {
outline:2px solid var(--accent); outline-offset:2px;
}
button:disabled { opacity:.55; cursor:default; }
button[aria-pressed="true"],button.primary { color:white; background:var(--accent); border-color:var(--accent); font-weight:650; }
button:hover:not(:disabled) { border-color:var(--accent); }
[hidden] { display:none !important; }
.intro { margin:8px 0 15px; color:var(--mute); }
.panel { padding:clamp(10px,2.2vw,22px); border:1px solid var(--edge); border-radius:12px; background:var(--card); }
.row { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.cols { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:clamp(12px,3vw,28px); align-items:start; }
.product-photo { width:100%; height:clamp(94px,21vw,204px); object-fit:contain; padding:10px; border-radius:10px; background:#e6e9e1; }
.status { color:var(--mute); margin-top:10px; min-height:1.45em; }
@media(max-width:600px){ .cols { grid-template-columns:minmax(0,1fr); } }
.undo-demo { --paper:#e8eff4; --accent:#28556f; }
.cart-line { display:grid; grid-template-columns:minmax(74px,.7fr) minmax(0,1fr); align-items:center; gap:12px; margin-top:14px; }
.cart-line p { margin:3px 0 7px; }
.cart-line img { background:#deebef; height:clamp(80px,17vw,145px); }
.empty-cart { margin-top:14px; }
.undo-row { margin-top:9px; align-items:center; justify-content:space-between; }
.undo-row .status { margin-top:0; }export function mountEffect(root, {reducedMotion = matchMedia('(prefers-reduced-motion: reduce)').matches} = {}) {
const lifetime = new AbortController();
const $ = selector => root.querySelector(selector);
const all = selector => [...root.querySelectorAll(selector)];
const listen = (element, type, handler) => element.addEventListener(type, handler, {signal:lifetime.signal});
const animations = new Map();
let motion = false;
function cancelMotion() {
for (const animation of animations.values()) animation.cancel();
animations.clear();
}
function reveal(element, position = 'translateY(6px)') {
animations.get(element)?.cancel();
if (!motion || !element.animate) return;
const animation = element.animate(
[{transform:position, opacity:.52},{transform:'none', opacity:1}],
{duration:225, easing:'ease-out'}
);
animations.set(element,animation);
animation.onfinish = () => animations.delete(element);
}
const line = $('.cart-line');
const empty = $('.empty-cart');
const remove = $('[data-remove]');
const undo = $('[data-undo]');
const status = $('[data-state]');
function setRemoved(removed) {
line.hidden = removed;
empty.hidden = undo.hidden = !removed;
status.textContent = removed ? 'Sky tee removed · $0.00' : 'Sky tee restored · $24.00';
(removed ? undo : remove).focus({preventScroll:true});
reveal(removed ? empty : line);
}
listen(remove,'click',() => setRemoved(true));
listen(undo,'click',() => setRemoved(false));
return {
resume() { motion = !reducedMotion; },
pause() { motion = false; cancelMotion(); },
destroy() { lifetime.abort(); cancelMotion(); }
};
}Cart drawers and cart pages.
Update the list and leave a clear way to restore the same line.
Focus moves to Undo, then back to the restored item.
Check restored variant, quantity, total and failed requests.
Keep the removed variant and quantity for undo and reconcile the result with the cart response.
Work in a duplicate theme. Replace demo copy and artwork with Section settings, scope styles to that Section, and use the lifecycle module for editor reloads, visibility and teardown.
{% comment %} WESWOO example shell. Add ONE effect's HTML inside .fx-slot. {% endcomment %}
{{ 'ww-effects.css' | asset_url | stylesheet_tag }}
<section id="ww-effect-{{ section.id }}" data-ww-effect-section>
<h2>{{ section.settings.heading | escape }}</h2>
<button type="button" data-effect-toggle aria-pressed="false">Play / pause effect</button>
<div class="fx-slot">
{% comment %} Insert the chosen .fx element here; read copy/images from section settings. {% endcomment %}
</div>
</section>
<script type="module" src="{{ 'ww-effect-section.js' | asset_url }}"></script>
{% schema %}
{"name":"WESWOO effect","settings":[{"type":"text","id":"heading","label":"Heading","default":"Our story"}],"presets":[{"name":"WESWOO effect"}]}
{% endschema %}
// Put the chosen example JS in assets/ww-selected-effect.js (rename .mjs to .js).
import {mountEffect} from './ww-selected-effect.js';
const instances=new Map();
function mount(container=document){
const roots=[...(container.matches?.('[data-ww-effect-section]')?[container]:[]),...container.querySelectorAll('[data-ww-effect-section]')];
for(const section of roots){
if(instances.has(section))continue;
const root=section.querySelector('.fx'),button=section.querySelector('[data-effect-toggle]');
if(!root||!button)continue;
const effect=mountEffect(root),events=new AbortController();let playing=false;
const pause=()=>{playing=false;effect.pause();button.setAttribute('aria-pressed','false');};
button.addEventListener('click',()=>{playing=!playing;playing?effect.resume():effect.pause();button.setAttribute('aria-pressed',String(playing));},{signal:events.signal});
const observer=new IntersectionObserver(entries=>{if(!entries[0].isIntersecting)pause();});observer.observe(section);
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:events.signal});
instances.set(section,()=>{observer.disconnect();events.abort();effect.destroy();});
}
}
document.addEventListener('shopify:section:load',event=>mount(event.target));
document.addEventListener('shopify:section:unload',event=>{for(const [section,destroy] of instances)if(section===event.target||event.target.contains(section)){destroy();instances.delete(section);}});
mount();
// Original WESWOO integration. Copy alongside the selected ww-effect-*.js asset.
// The server supplies the asset URL; do not accept a URL from a query parameter.
if (!customElements.get('ww-effect-study')) {
customElements.define('ww-effect-study', class extends HTMLElement {
connectedCallback() {
if (this.events) return;
this.events=new AbortController();this.session={};const session=this.session;
const button=this.querySelector('[data-effect-toggle]');
button.disabled=false;button.setAttribute('aria-pressed','false');this.visible=true;
const preference=matchMedia('(prefers-reduced-motion: reduce)');
const pause=()=>{this.effect?.pause();button.setAttribute('aria-pressed','false');};
this.pause=pause;
button.addEventListener('click',async()=>{
if(this.loading)return;
if(!this.effect){
this.loading=true;button.disabled=true;
try {
const {mountEffect}=await import(this.dataset.moduleUrl);
if(!this.isConnected||this.session!==session)return;
this.effect=mountEffect(this.querySelector('.fx'),{reducedMotion:preference.matches});
} catch {this.querySelector('[data-effect-status]').textContent='The static content is available. Reload to retry motion.';return;}
finally {if(this.session===session){this.loading=false;button.disabled=false;}}
}
if(this.session!==session||document.hidden||!this.visible)return;
const playing=button.getAttribute('aria-pressed')!=='true';
playing?this.effect.resume():this.effect.pause();button.setAttribute('aria-pressed',String(playing));
},{signal:this.events.signal});
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:this.events.signal});
preference.addEventListener('change',()=>{pause();this.effect?.destroy();this.effect=null;},{signal:this.events.signal});
this.observer=new IntersectionObserver(entries=>{this.visible=entries[0].isIntersecting;if(!this.visible)pause();});this.observer.observe(this);
const root=this.querySelector('.fx');
root.querySelectorAll('[data-view]').forEach(trigger=>trigger.addEventListener('click',()=>{const target=root.querySelector('dialog .art'),source=trigger.querySelector('.ww-fx-image');target.querySelector('.ww-fx-image')?.remove();if(source)target.append(source.cloneNode(true));},{signal:this.events.signal}));
// Section unload disconnects this custom element; reconnect mounts one fresh instance.
document.addEventListener('shopify:section:unload',event=>{if(event.target.contains(this))this.teardown();},{signal:this.events.signal});
}
teardown(){this.session=null;this.loading=false;this.observer?.disconnect();this.events?.abort();this.effect?.destroy();this.effect=null;this.events=null;}
disconnectedCallback(){this.teardown();}
});
}
Insert the selected effect into the shell. Each module loads one effect; multiple types need an explicit registry and Section mapping.
The status feedback follows Codrops Notification Styles. Product imagery is from Codrops Product Grid Layout.
Shopify: Section architectureShopify: theme editor events and lifecycleShopify: theme performanceMDN: Web Animations APIMDN: reduced-motion preferenceMDN: iframe sandboxingShopify: image rendering and dimensionsShopify: Section settings and schemaMDN: element geometryMDN: image and text clippingMDN: native dialogShopify: theme accessibilityMDN: native range inputExamples are authored by WESWOO and credited open-source contributors; retain their applicable licenses. Project screens and photographs remain with their rights holders. Downloads use placeholders; replace them with imagery you may use.
Shopify/dawn · modal / slider base classesShopify/dawn · product media galleryShopify/dawn · licensePreparing preview
Choose Express or Store pickup. The fee and estimate should both change so the shopper can compare the options.
<section class="fx delivery-demo" lang="en" aria-label="Delivery options demo">
<h2>Choose delivery</h2>
<p class="intro">Sample rates and estimates</p>
<div class="cols">
<fieldset class="panel delivery-options"><legend>Delivery method</legend>
<label><input type="radio" name="delivery" value="standard" checked><span>Standard</span></label>
<label><input type="radio" name="delivery" value="express"><span>Express</span></label>
<label><input type="radio" name="delivery" value="pickup"><span>Store pickup</span></label>
</fieldset>
<div class="panel delivery-summary" role="status" aria-atomic="true">
<h3 data-method>Standard</h3>
<p data-fee>$6.00</p>
<p data-estimate>3–5 business days</p>
</div>
</div>
</section>* { box-sizing: border-box; }
.fx {
--paper:#f2f3eb; --ink:#20332b; --accent:#205a4c; --edge:#c6cec0; --card:#fffdf8; --mute:#466056;
padding:clamp(14px,3.3vw,34px); min-height:268px; color:var(--ink); background:var(--paper);
font:16px/1.48 system-ui,sans-serif;
}
h2,h3,p,figure,ul,ol,dl,dd,fieldset { margin:0; }
h2 { font-size:clamp(1.38rem,3.8vw,2.55rem); letter-spacing:-.035em; line-height:1.1; }
h3 { font-size:1.12em; }
p { max-width:62ch; }
img { display:block; max-width:100%; }
button,input,select { font:inherit; }
button {
min-height:44px; padding:8px 12px; border:1px solid var(--edge); border-radius:8px;
background:var(--card); color:var(--ink); cursor:pointer; line-height:1.25;
}
button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible,[tabindex="0"]:focus-visible {
outline:2px solid var(--accent); outline-offset:2px;
}
button:disabled { opacity:.55; cursor:default; }
button[aria-pressed="true"],button.primary { color:white; background:var(--accent); border-color:var(--accent); font-weight:650; }
button:hover:not(:disabled) { border-color:var(--accent); }
[hidden] { display:none !important; }
.intro { margin:8px 0 15px; color:var(--mute); }
.panel { padding:clamp(10px,2.2vw,22px); border:1px solid var(--edge); border-radius:12px; background:var(--card); }
.row { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.cols { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:clamp(12px,3vw,28px); align-items:start; }
.product-photo { width:100%; height:clamp(94px,21vw,204px); object-fit:contain; padding:10px; border-radius:10px; background:#e6e9e1; }
.status { color:var(--mute); margin-top:10px; min-height:1.45em; }
@media(max-width:600px){ .cols { grid-template-columns:minmax(0,1fr); } }
.delivery-demo { --paper:#ecf0e7; --accent:#3e5c38; }
.delivery-options { min-width:0; }
.delivery-options legend { font-weight:650; padding-inline:5px; }
.delivery-options label { display:flex; gap:9px; align-items:center; cursor:pointer; min-height:44px; padding:6px; }
.delivery-options input { accent-color:var(--accent); width:17px; height:17px; }
.delivery-summary { background:#dce7d5; }
.delivery-summary [data-fee] { font-size:1.45rem; font-weight:650; margin:6px 0; font-variant-numeric:tabular-nums; }
.delivery-summary [data-estimate] { color:var(--mute); }export function mountEffect(root, {reducedMotion = matchMedia('(prefers-reduced-motion: reduce)').matches} = {}) {
const lifetime = new AbortController();
const $ = selector => root.querySelector(selector);
const all = selector => [...root.querySelectorAll(selector)];
const listen = (element, type, handler) => element.addEventListener(type, handler, {signal:lifetime.signal});
const animations = new Map();
let motion = false;
function cancelMotion() {
for (const animation of animations.values()) animation.cancel();
animations.clear();
}
function reveal(element, position = 'translateY(6px)') {
animations.get(element)?.cancel();
if (!motion || !element.animate) return;
const animation = element.animate(
[{transform:position, opacity:.52},{transform:'none', opacity:1}],
{duration:225, easing:'ease-out'}
);
animations.set(element,animation);
animation.onfinish = () => animations.delete(element);
}
const rates = {
standard:['Standard','$6.00','3–5 business days'],
express:['Express','$14.00','1–2 business days'],
pickup:['Store pickup','Free','Ready next business day']
};
for (const input of all('input[name=delivery]')) listen(input,'change',() => {
if (!input.checked) return;
const [method,fee,estimate] = rates[input.value];
$('[data-method]').textContent = method;
$('[data-fee]').textContent = fee;
$('[data-estimate]').textContent = estimate;
reveal($('.delivery-summary'));
});
return {
resume() { motion = !reducedMotion; },
pause() { motion = false; cancelMotion(); },
destroy() { lifetime.abort(); cancelMotion(); }
};
}Cart shipping estimates and delivery options.
Update the fee and timing from one selected service.
Native radios work with touch and keyboard and announce the updated summary.
Check free pickup, express delivery and unavailable methods.
Fill the summary from current rates and commitments for the shopper’s address.
Work in a duplicate theme. Replace demo copy and artwork with Section settings, scope styles to that Section, and use the lifecycle module for editor reloads, visibility and teardown.
{% comment %} WESWOO example shell. Add ONE effect's HTML inside .fx-slot. {% endcomment %}
{{ 'ww-effects.css' | asset_url | stylesheet_tag }}
<section id="ww-effect-{{ section.id }}" data-ww-effect-section>
<h2>{{ section.settings.heading | escape }}</h2>
<button type="button" data-effect-toggle aria-pressed="false">Play / pause effect</button>
<div class="fx-slot">
{% comment %} Insert the chosen .fx element here; read copy/images from section settings. {% endcomment %}
</div>
</section>
<script type="module" src="{{ 'ww-effect-section.js' | asset_url }}"></script>
{% schema %}
{"name":"WESWOO effect","settings":[{"type":"text","id":"heading","label":"Heading","default":"Our story"}],"presets":[{"name":"WESWOO effect"}]}
{% endschema %}
// Put the chosen example JS in assets/ww-selected-effect.js (rename .mjs to .js).
import {mountEffect} from './ww-selected-effect.js';
const instances=new Map();
function mount(container=document){
const roots=[...(container.matches?.('[data-ww-effect-section]')?[container]:[]),...container.querySelectorAll('[data-ww-effect-section]')];
for(const section of roots){
if(instances.has(section))continue;
const root=section.querySelector('.fx'),button=section.querySelector('[data-effect-toggle]');
if(!root||!button)continue;
const effect=mountEffect(root),events=new AbortController();let playing=false;
const pause=()=>{playing=false;effect.pause();button.setAttribute('aria-pressed','false');};
button.addEventListener('click',()=>{playing=!playing;playing?effect.resume():effect.pause();button.setAttribute('aria-pressed',String(playing));},{signal:events.signal});
const observer=new IntersectionObserver(entries=>{if(!entries[0].isIntersecting)pause();});observer.observe(section);
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:events.signal});
instances.set(section,()=>{observer.disconnect();events.abort();effect.destroy();});
}
}
document.addEventListener('shopify:section:load',event=>mount(event.target));
document.addEventListener('shopify:section:unload',event=>{for(const [section,destroy] of instances)if(section===event.target||event.target.contains(section)){destroy();instances.delete(section);}});
mount();
// Original WESWOO integration. Copy alongside the selected ww-effect-*.js asset.
// The server supplies the asset URL; do not accept a URL from a query parameter.
if (!customElements.get('ww-effect-study')) {
customElements.define('ww-effect-study', class extends HTMLElement {
connectedCallback() {
if (this.events) return;
this.events=new AbortController();this.session={};const session=this.session;
const button=this.querySelector('[data-effect-toggle]');
button.disabled=false;button.setAttribute('aria-pressed','false');this.visible=true;
const preference=matchMedia('(prefers-reduced-motion: reduce)');
const pause=()=>{this.effect?.pause();button.setAttribute('aria-pressed','false');};
this.pause=pause;
button.addEventListener('click',async()=>{
if(this.loading)return;
if(!this.effect){
this.loading=true;button.disabled=true;
try {
const {mountEffect}=await import(this.dataset.moduleUrl);
if(!this.isConnected||this.session!==session)return;
this.effect=mountEffect(this.querySelector('.fx'),{reducedMotion:preference.matches});
} catch {this.querySelector('[data-effect-status]').textContent='The static content is available. Reload to retry motion.';return;}
finally {if(this.session===session){this.loading=false;button.disabled=false;}}
}
if(this.session!==session||document.hidden||!this.visible)return;
const playing=button.getAttribute('aria-pressed')!=='true';
playing?this.effect.resume():this.effect.pause();button.setAttribute('aria-pressed',String(playing));
},{signal:this.events.signal});
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:this.events.signal});
preference.addEventListener('change',()=>{pause();this.effect?.destroy();this.effect=null;},{signal:this.events.signal});
this.observer=new IntersectionObserver(entries=>{this.visible=entries[0].isIntersecting;if(!this.visible)pause();});this.observer.observe(this);
const root=this.querySelector('.fx');
root.querySelectorAll('[data-view]').forEach(trigger=>trigger.addEventListener('click',()=>{const target=root.querySelector('dialog .art'),source=trigger.querySelector('.ww-fx-image');target.querySelector('.ww-fx-image')?.remove();if(source)target.append(source.cloneNode(true));},{signal:this.events.signal}));
// Section unload disconnects this custom element; reconnect mounts one fresh instance.
document.addEventListener('shopify:section:unload',event=>{if(event.target.contains(this))this.teardown();},{signal:this.events.signal});
}
teardown(){this.session=null;this.loading=false;this.observer?.disconnect();this.events?.abort();this.effect?.destroy();this.effect=null;this.events=null;}
disconnectedCallback(){this.teardown();}
});
}
Insert the selected effect into the shell. Each module loads one effect; multiple types need an explicit registry and Section mapping.
Selection feedback refers to Codrops. All rates and estimates are sample values.
Shopify: Section architectureShopify: theme editor events and lifecycleShopify: theme performanceMDN: Web Animations APIMDN: reduced-motion preferenceMDN: iframe sandboxingShopify: image rendering and dimensionsShopify: Section settings and schemaMDN: element geometryMDN: image and text clippingMDN: native dialogShopify: theme accessibilityMDN: native range inputExamples are authored by WESWOO and credited open-source contributors; retain their applicable licenses. Project screens and photographs remain with their rights holders. Downloads use placeholders; replace them with imagery you may use.
Shopify/dawn · modal / slider base classesShopify/dawn · product media galleryShopify/dawn · licensePreparing preview
Enter a sample email and postal code. Go back from review and edit one field without retyping the other.
<section class="fx checkout-demo" lang="en" aria-label="Checkout step demo">
<h2>Checkout walkthrough</h2>
<p class="intro">Use sample details to try the steps.</p>
<ol class="checkout-steps" aria-label="Checkout steps">
<li aria-current="step">Contact</li><li>Destination</li><li>Review</li>
</ol>
<form class="panel" novalidate autocomplete="off">
<div data-step-panel>
<h3 tabindex="-1">Contact</h3><label for="sample-email">Email</label>
<input id="sample-email" type="email" placeholder="demo@example.com" required>
</div>
<div data-step-panel hidden>
<h3 tabindex="-1">Destination</h3><label for="sample-postal">Postal code</label>
<input id="sample-postal" type="text" placeholder="12345" required>
</div>
<div data-step-panel hidden>
<h3 tabindex="-1">Review sample details</h3>
<dl><dt>Email</dt><dd data-email></dd><dt>Postal code</dt><dd data-postal></dd></dl>
</div>
<div class="row step-actions"><button type="button" data-previous hidden>Back</button><button type="button" class="primary" data-next>Continue</button></div>
</form>
<p class="panel checkout-complete" tabindex="-1" role="status" hidden>Walkthrough complete.</p>
</section>* { box-sizing: border-box; }
.fx {
--paper:#f2f3eb; --ink:#20332b; --accent:#205a4c; --edge:#c6cec0; --card:#fffdf8; --mute:#466056;
padding:clamp(14px,3.3vw,34px); min-height:268px; color:var(--ink); background:var(--paper);
font:16px/1.48 system-ui,sans-serif;
}
h2,h3,p,figure,ul,ol,dl,dd,fieldset { margin:0; }
h2 { font-size:clamp(1.38rem,3.8vw,2.55rem); letter-spacing:-.035em; line-height:1.1; }
h3 { font-size:1.12em; }
p { max-width:62ch; }
img { display:block; max-width:100%; }
button,input,select { font:inherit; }
button {
min-height:44px; padding:8px 12px; border:1px solid var(--edge); border-radius:8px;
background:var(--card); color:var(--ink); cursor:pointer; line-height:1.25;
}
button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible,[tabindex="0"]:focus-visible {
outline:2px solid var(--accent); outline-offset:2px;
}
button:disabled { opacity:.55; cursor:default; }
button[aria-pressed="true"],button.primary { color:white; background:var(--accent); border-color:var(--accent); font-weight:650; }
button:hover:not(:disabled) { border-color:var(--accent); }
[hidden] { display:none !important; }
.intro { margin:8px 0 15px; color:var(--mute); }
.panel { padding:clamp(10px,2.2vw,22px); border:1px solid var(--edge); border-radius:12px; background:var(--card); }
.row { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.cols { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:clamp(12px,3vw,28px); align-items:start; }
.product-photo { width:100%; height:clamp(94px,21vw,204px); object-fit:contain; padding:10px; border-radius:10px; background:#e6e9e1; }
.status { color:var(--mute); margin-top:10px; min-height:1.45em; }
@media(max-width:600px){ .cols { grid-template-columns:minmax(0,1fr); } }
.checkout-demo { --paper:#ebeaf2; --accent:#4e4977; }
.checkout-steps { display:flex; flex-wrap:wrap; gap:7px; padding:0; list-style:none; margin-bottom:10px; }
.checkout-steps li { flex:1 1 auto; padding:6px 7px; border:1px solid var(--edge); border-radius:6px; color:var(--mute); }
.checkout-steps [aria-current=step] { color:white; background:var(--accent); border-color:var(--accent); font-weight:650; }
.checkout-demo form label { display:block; margin:8px 0 4px; }
.checkout-demo form input { width:100%; max-width:29rem; min-height:44px; padding:7px;
border:1px solid #7e7994; background:#fff; border-radius:7px; }
.checkout-demo dt { margin-top:6px; font-weight:650; }
.checkout-demo dd { overflow-wrap:anywhere; }
.step-actions { margin-top:11px; }export function mountEffect(root, {reducedMotion = matchMedia('(prefers-reduced-motion: reduce)').matches} = {}) {
const lifetime = new AbortController();
const $ = selector => root.querySelector(selector);
const all = selector => [...root.querySelectorAll(selector)];
const listen = (element, type, handler) => element.addEventListener(type, handler, {signal:lifetime.signal});
const animations = new Map();
let motion = false;
function cancelMotion() {
for (const animation of animations.values()) animation.cancel();
animations.clear();
}
function reveal(element, position = 'translateY(6px)') {
animations.get(element)?.cancel();
if (!motion || !element.animate) return;
const animation = element.animate(
[{transform:position, opacity:.52},{transform:'none', opacity:1}],
{duration:225, easing:'ease-out'}
);
animations.set(element,animation);
animation.onfinish = () => animations.delete(element);
}
const form = $('form');
const panels = all('[data-step-panel]');
const markers = all('.checkout-steps li');
const back = $('[data-previous]');
const next = $('[data-next]');
let step = 0;
function go(index) {
step = index;
panels.forEach((panel,i) => { panel.hidden = i !== step; });
markers.forEach((marker,i) => {
if (i === step) marker.setAttribute('aria-current','step');
else marker.removeAttribute('aria-current');
});
back.hidden = step === 0;
next.textContent = step === 2 ? 'Finish walkthrough' : 'Continue';
if (step === 2) {
$('[data-email]').textContent = $('#sample-email').value;
$('[data-postal]').textContent = $('#sample-postal').value.trim();
}
panels[step].querySelector('h3').focus({preventScroll:true});
reveal(panels[step]);
}
function advance() {
const field = panels[step].querySelector('input');
if (field && !field.reportValidity()) return;
if (step < 2) {
go(step + 1);
return;
}
form.hidden = true;
$('.checkout-complete').hidden = false;
$('.checkout-complete').focus({preventScroll:true});
reveal($('.checkout-complete'));
}
listen(back,'click',() => go(step - 1));
listen(next,'click',advance);
listen(form,'keydown',event => {
if (event.key !== 'Enter' || event.isComposing || event.target.tagName !== 'INPUT') return;
event.preventDefault();
advance();
});
listen(form,'submit',event => event.preventDefault());
return {
resume() { motion = !reducedMotion; },
pause() { motion = false; cancelMotion(); },
destroy() { lifetime.abort(); cancelMotion(); }
};
}Address forms, quote wizards and checkout prototypes.
Validate the current step before advancing and keep values when going back.
Keyboard submission works and focus moves to the new step heading.
Check missing values, editing, review and completion.
Keep Shopify checkout on the platform. Use this sample for a theme-side quote or pre-checkout flow.
Work in a duplicate theme. Replace demo copy and artwork with Section settings, scope styles to that Section, and use the lifecycle module for editor reloads, visibility and teardown.
{% comment %} WESWOO example shell. Add ONE effect's HTML inside .fx-slot. {% endcomment %}
{{ 'ww-effects.css' | asset_url | stylesheet_tag }}
<section id="ww-effect-{{ section.id }}" data-ww-effect-section>
<h2>{{ section.settings.heading | escape }}</h2>
<button type="button" data-effect-toggle aria-pressed="false">Play / pause effect</button>
<div class="fx-slot">
{% comment %} Insert the chosen .fx element here; read copy/images from section settings. {% endcomment %}
</div>
</section>
<script type="module" src="{{ 'ww-effect-section.js' | asset_url }}"></script>
{% schema %}
{"name":"WESWOO effect","settings":[{"type":"text","id":"heading","label":"Heading","default":"Our story"}],"presets":[{"name":"WESWOO effect"}]}
{% endschema %}
// Put the chosen example JS in assets/ww-selected-effect.js (rename .mjs to .js).
import {mountEffect} from './ww-selected-effect.js';
const instances=new Map();
function mount(container=document){
const roots=[...(container.matches?.('[data-ww-effect-section]')?[container]:[]),...container.querySelectorAll('[data-ww-effect-section]')];
for(const section of roots){
if(instances.has(section))continue;
const root=section.querySelector('.fx'),button=section.querySelector('[data-effect-toggle]');
if(!root||!button)continue;
const effect=mountEffect(root),events=new AbortController();let playing=false;
const pause=()=>{playing=false;effect.pause();button.setAttribute('aria-pressed','false');};
button.addEventListener('click',()=>{playing=!playing;playing?effect.resume():effect.pause();button.setAttribute('aria-pressed',String(playing));},{signal:events.signal});
const observer=new IntersectionObserver(entries=>{if(!entries[0].isIntersecting)pause();});observer.observe(section);
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:events.signal});
instances.set(section,()=>{observer.disconnect();events.abort();effect.destroy();});
}
}
document.addEventListener('shopify:section:load',event=>mount(event.target));
document.addEventListener('shopify:section:unload',event=>{for(const [section,destroy] of instances)if(section===event.target||event.target.contains(section)){destroy();instances.delete(section);}});
mount();
// Original WESWOO integration. Copy alongside the selected ww-effect-*.js asset.
// The server supplies the asset URL; do not accept a URL from a query parameter.
if (!customElements.get('ww-effect-study')) {
customElements.define('ww-effect-study', class extends HTMLElement {
connectedCallback() {
if (this.events) return;
this.events=new AbortController();this.session={};const session=this.session;
const button=this.querySelector('[data-effect-toggle]');
button.disabled=false;button.setAttribute('aria-pressed','false');this.visible=true;
const preference=matchMedia('(prefers-reduced-motion: reduce)');
const pause=()=>{this.effect?.pause();button.setAttribute('aria-pressed','false');};
this.pause=pause;
button.addEventListener('click',async()=>{
if(this.loading)return;
if(!this.effect){
this.loading=true;button.disabled=true;
try {
const {mountEffect}=await import(this.dataset.moduleUrl);
if(!this.isConnected||this.session!==session)return;
this.effect=mountEffect(this.querySelector('.fx'),{reducedMotion:preference.matches});
} catch {this.querySelector('[data-effect-status]').textContent='The static content is available. Reload to retry motion.';return;}
finally {if(this.session===session){this.loading=false;button.disabled=false;}}
}
if(this.session!==session||document.hidden||!this.visible)return;
const playing=button.getAttribute('aria-pressed')!=='true';
playing?this.effect.resume():this.effect.pause();button.setAttribute('aria-pressed',String(playing));
},{signal:this.events.signal});
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:this.events.signal});
preference.addEventListener('change',()=>{pause();this.effect?.destroy();this.effect=null;},{signal:this.events.signal});
this.observer=new IntersectionObserver(entries=>{this.visible=entries[0].isIntersecting;if(!this.visible)pause();});this.observer.observe(this);
const root=this.querySelector('.fx');
root.querySelectorAll('[data-view]').forEach(trigger=>trigger.addEventListener('click',()=>{const target=root.querySelector('dialog .art'),source=trigger.querySelector('.ww-fx-image');target.querySelector('.ww-fx-image')?.remove();if(source)target.append(source.cloneNode(true));},{signal:this.events.signal}));
// Section unload disconnects this custom element; reconnect mounts one fresh instance.
document.addEventListener('shopify:section:unload',event=>{if(event.target.contains(this))this.teardown();},{signal:this.events.signal});
}
teardown(){this.session=null;this.loading=false;this.observer?.disconnect();this.events?.abort();this.effect?.destroy();this.effect=null;this.events=null;}
disconnectedCallback(){this.teardown();}
});
}
Insert the selected effect into the shell. Each module loads one effect; multiple types need an explicit registry and Section mapping.
Step transitions follow Codrops Fullscreen Form Interface. Sample entries are used only in the current preview.
Shopify: Section architectureShopify: theme editor events and lifecycleShopify: theme performanceMDN: Web Animations APIMDN: reduced-motion preferenceMDN: iframe sandboxingShopify: image rendering and dimensionsShopify: Section settings and schemaMDN: element geometryMDN: image and text clippingMDN: native dialogShopify: theme accessibilityMDN: native range inputExamples are authored by WESWOO and credited open-source contributors; retain their applicable licenses. Project screens and photographs remain with their rights holders. Downloads use placeholders; replace them with imagery you may use.
Shopify/dawn · modal / slider base classesShopify/dawn · product media galleryShopify/dawn · licensePreparing preview
Before making a trip, a buyer needs the exact size at a particular location. Keep each store and its preparation time together.
<section class="fx pickup" lang="en" aria-label="Pickup by size">
<div class="tee" data-stage><img src="__WW_VISUAL_1__" alt="Pale blue everyday tee"></div>
<div><p class="eyebrow">STUDIO BASICS</p><h2>Everyday tee</h2>
<fieldset><legend>Choose a size</legend><div class="row"><button aria-pressed="true" data-size="S">S</button><button aria-pressed="false" data-size="M">M</button><button aria-pressed="false" data-size="L">L</button></div></fieldset>
<h3>Store pickup</h3><div data-stores role="status"></div></div>
</section>* { box-sizing: border-box; }
.fx {
--paper:#f2f3eb; --ink:#20332b; --accent:#205a4c; --edge:#c6cec0; --card:#fffdf8; --mute:#466056;
padding:clamp(14px,3.3vw,34px); min-height:268px; color:var(--ink); background:var(--paper);
font:16px/1.48 system-ui,sans-serif;
}
h2,h3,p,figure,ul,ol,dl,dd,fieldset { margin:0; }
h2 { font-size:clamp(1.38rem,3.8vw,2.55rem); letter-spacing:-.035em; line-height:1.1; }
h3 { font-size:1.12em; }
p { max-width:62ch; }
img { display:block; max-width:100%; }
button,input,select { font:inherit; }
button {
min-height:44px; padding:8px 12px; border:1px solid var(--edge); border-radius:8px;
background:var(--card); color:var(--ink); cursor:pointer; line-height:1.25;
}
button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible,[tabindex="0"]:focus-visible {
outline:2px solid var(--accent); outline-offset:2px;
}
button:disabled { opacity:.55; cursor:default; }
button[aria-pressed="true"],button.primary { color:white; background:var(--accent); border-color:var(--accent); font-weight:650; }
button:hover:not(:disabled) { border-color:var(--accent); }
[hidden] { display:none !important; }
.intro { margin:8px 0 15px; color:var(--mute); }
.panel { padding:clamp(10px,2.2vw,22px); border:1px solid var(--edge); border-radius:12px; background:var(--card); }
.row { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.cols { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:clamp(12px,3vw,28px); align-items:start; }
.product-photo { width:100%; height:clamp(94px,21vw,204px); object-fit:contain; padding:10px; border-radius:10px; background:#e6e9e1; }
.status { color:var(--mute); margin-top:10px; min-height:1.45em; }
@media(max-width:600px){ .cols { grid-template-columns:minmax(0,1fr); } }
.pickup{display:grid;grid-template-columns:minmax(0,.8fr) minmax(0,1.2fr);gap:clamp(16px,3vw,34px);align-items:center;background:#eef1f3;color:#192e3e}
.tee{background:#fff;border-radius:8px}.tee img{width:100%;height:clamp(130px,24vw,235px);object-fit:contain}
.pickup fieldset{padding:0;margin:12px 0;border:0}.pickup legend{margin-bottom:6px}.pickup button{min-width:44px}.pickup h3{margin:12px 0 5px}
.pickup [data-stores] p{display:flex;justify-content:space-between;gap:5px;flex-wrap:wrap;border-top:1px solid #c2cdd0;padding:6px 0;font-size:14px}
@media(max-width:520px){.pickup{grid-template-columns:1fr;gap:14px}.tee img{height:115px}}export function mountEffect(root, {reducedMotion = matchMedia('(prefers-reduced-motion: reduce)').matches} = {}) {
const lifetime = new AbortController();
const $ = selector => root.querySelector(selector);
const all = selector => [...root.querySelectorAll(selector)];
const listen = (element, type, handler) => element.addEventListener(type, handler, {signal:lifetime.signal});
const animations = new Map();
let motion = false;
function cancelMotion() {
for (const animation of animations.values()) animation.cancel();
animations.clear();
}
function reveal(element, position = 'translateY(6px)') {
animations.get(element)?.cancel();
if (!motion || !element.animate) return;
const animation = element.animate(
[{transform:position, opacity:.52},{transform:'none', opacity:1}],
{duration:225, easing:'ease-out'}
);
animations.set(element,animation);
animation.onfinish = () => animations.delete(element);
}
const inventory = {S:['Ready in 2 hours','Unavailable'],M:['Unavailable','Ready tomorrow'],L:['Unavailable','Unavailable']};
function show(size) {
all('[data-size]').forEach(button=>button.setAttribute('aria-pressed',String(button.dataset.size===size)));
const panel=$('[data-stores]');
const rows=inventory[size].map((value,i)=>{
const row=document.createElement('p'), name=document.createElement('b'), status=document.createElement('span');
name.textContent=['North Studio','Market Street'][i]; status.textContent=value;
row.append(name,status); return row;
});
panel.replaceChildren(...rows); reveal(panel);
}
all('[data-size]').forEach(button=>listen(button,'click',()=>show(button.dataset.size)));
show('S');
return {
resume() { motion = !reducedMotion; const stage = root.querySelector('[data-stage]'); if (stage) reveal(stage); },
pause() { motion = false; cancelMotion(); },
destroy() { lifetime.abort(); cancelMotion(); }
};
}Next to the size picker.
Both location rows refresh for the selected variant.
Size buttons work with touch and keyboard. Store names stay visible.
Switch from an available size to one unavailable at both stores.
Read store_availabilities on the selected variant. Show preparation times only for eligible, available pickup locations.
Work in a duplicate theme. Replace demo copy and artwork with Section settings, scope styles to that Section, and use the lifecycle module for editor reloads, visibility and teardown.
{% comment %} WESWOO example shell. Add ONE effect's HTML inside .fx-slot. {% endcomment %}
{{ 'ww-effects.css' | asset_url | stylesheet_tag }}
<section id="ww-effect-{{ section.id }}" data-ww-effect-section>
<h2>{{ section.settings.heading | escape }}</h2>
<button type="button" data-effect-toggle aria-pressed="false">Play / pause effect</button>
<div class="fx-slot">
{% comment %} Insert the chosen .fx element here; read copy/images from section settings. {% endcomment %}
</div>
</section>
<script type="module" src="{{ 'ww-effect-section.js' | asset_url }}"></script>
{% schema %}
{"name":"WESWOO effect","settings":[{"type":"text","id":"heading","label":"Heading","default":"Our story"}],"presets":[{"name":"WESWOO effect"}]}
{% endschema %}
// Put the chosen example JS in assets/ww-selected-effect.js (rename .mjs to .js).
import {mountEffect} from './ww-selected-effect.js';
const instances=new Map();
function mount(container=document){
const roots=[...(container.matches?.('[data-ww-effect-section]')?[container]:[]),...container.querySelectorAll('[data-ww-effect-section]')];
for(const section of roots){
if(instances.has(section))continue;
const root=section.querySelector('.fx'),button=section.querySelector('[data-effect-toggle]');
if(!root||!button)continue;
const effect=mountEffect(root),events=new AbortController();let playing=false;
const pause=()=>{playing=false;effect.pause();button.setAttribute('aria-pressed','false');};
button.addEventListener('click',()=>{playing=!playing;playing?effect.resume():effect.pause();button.setAttribute('aria-pressed',String(playing));},{signal:events.signal});
const observer=new IntersectionObserver(entries=>{if(!entries[0].isIntersecting)pause();});observer.observe(section);
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:events.signal});
instances.set(section,()=>{observer.disconnect();events.abort();effect.destroy();});
}
}
document.addEventListener('shopify:section:load',event=>mount(event.target));
document.addEventListener('shopify:section:unload',event=>{for(const [section,destroy] of instances)if(section===event.target||event.target.contains(section)){destroy();instances.delete(section);}});
mount();
// Original WESWOO integration. Copy alongside the selected ww-effect-*.js asset.
// The server supplies the asset URL; do not accept a URL from a query parameter.
if (!customElements.get('ww-effect-study')) {
customElements.define('ww-effect-study', class extends HTMLElement {
connectedCallback() {
if (this.events) return;
this.events=new AbortController();this.session={};const session=this.session;
const button=this.querySelector('[data-effect-toggle]');
button.disabled=false;button.setAttribute('aria-pressed','false');this.visible=true;
const preference=matchMedia('(prefers-reduced-motion: reduce)');
const pause=()=>{this.effect?.pause();button.setAttribute('aria-pressed','false');};
this.pause=pause;
button.addEventListener('click',async()=>{
if(this.loading)return;
if(!this.effect){
this.loading=true;button.disabled=true;
try {
const {mountEffect}=await import(this.dataset.moduleUrl);
if(!this.isConnected||this.session!==session)return;
this.effect=mountEffect(this.querySelector('.fx'),{reducedMotion:preference.matches});
} catch {this.querySelector('[data-effect-status]').textContent='The static content is available. Reload to retry motion.';return;}
finally {if(this.session===session){this.loading=false;button.disabled=false;}}
}
if(this.session!==session||document.hidden||!this.visible)return;
const playing=button.getAttribute('aria-pressed')!=='true';
playing?this.effect.resume():this.effect.pause();button.setAttribute('aria-pressed',String(playing));
},{signal:this.events.signal});
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:this.events.signal});
preference.addEventListener('change',()=>{pause();this.effect?.destroy();this.effect=null;},{signal:this.events.signal});
this.observer=new IntersectionObserver(entries=>{this.visible=entries[0].isIntersecting;if(!this.visible)pause();});this.observer.observe(this);
const root=this.querySelector('.fx');
root.querySelectorAll('[data-view]').forEach(trigger=>trigger.addEventListener('click',()=>{const target=root.querySelector('dialog .art'),source=trigger.querySelector('.ww-fx-image');target.querySelector('.ww-fx-image')?.remove();if(source)target.append(source.cloneNode(true));},{signal:this.events.signal}));
// Section unload disconnects this custom element; reconnect mounts one fresh instance.
document.addEventListener('shopify:section:unload',event=>{if(event.target.contains(this))this.teardown();},{signal:this.events.signal});
}
teardown(){this.session=null;this.loading=false;this.observer?.disconnect();this.events?.abort();this.effect?.destroy();this.effect=null;this.events=null;}
disconnectedCallback(){this.teardown();}
});
}
Insert the selected effect into the shell. Each module loads one effect; multiple types need an explicit registry and Section mapping.
The location rows follow Shopify’s variant pickup model. Product photography comes from the original Codrops Product Grid Layout demo.
Shopify: Section architectureShopify: theme editor events and lifecycleShopify: theme performanceMDN: Web Animations APIMDN: reduced-motion preferenceMDN: iframe sandboxingShopify: image rendering and dimensionsShopify: Section settings and schemaMDN: element geometryMDN: image and text clippingMDN: native dialogShopify: theme accessibilityMDN: native range inputExamples are authored by WESWOO and credited open-source contributors; retain their applicable licenses. Project screens and photographs remain with their rights holders. Downloads use placeholders; replace them with imagery you may use.
Shopify/dawn · modal / slider base classesShopify/dawn · product media galleryShopify/dawn · licensePreparing preview
The buyer should see which offer applies and what removing it costs. An invalid replacement needs to explain the fate of the existing offer.
<section class="fx receipt" lang="en" aria-label="Discount code trial"><div data-stage><h2>Order summary</h2><dl><div><dt>Merchandise</dt><dd>$80.00</dd></div><div data-saving hidden><dt>STUDIO10</dt><dd>−$8.00</dd></div><div class="total"><dt>Item total</dt><dd data-total>$80.00</dd></div></dl></div>
<div class="coupon"><label for="code">Discount code</label><input id="code" autocapitalize="characters" aria-describedby="hint"><small id="hint">Try STUDIO10 for 10% off the items.</small><div class="row"><button class="primary" data-apply>Apply code</button><button data-remove hidden>Remove</button></div><p data-result role="status"></p></div>
</section>* { box-sizing: border-box; }
.fx {
--paper:#f2f3eb; --ink:#20332b; --accent:#205a4c; --edge:#c6cec0; --card:#fffdf8; --mute:#466056;
padding:clamp(14px,3.3vw,34px); min-height:268px; color:var(--ink); background:var(--paper);
font:16px/1.48 system-ui,sans-serif;
}
h2,h3,p,figure,ul,ol,dl,dd,fieldset { margin:0; }
h2 { font-size:clamp(1.38rem,3.8vw,2.55rem); letter-spacing:-.035em; line-height:1.1; }
h3 { font-size:1.12em; }
p { max-width:62ch; }
img { display:block; max-width:100%; }
button,input,select { font:inherit; }
button {
min-height:44px; padding:8px 12px; border:1px solid var(--edge); border-radius:8px;
background:var(--card); color:var(--ink); cursor:pointer; line-height:1.25;
}
button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible,[tabindex="0"]:focus-visible {
outline:2px solid var(--accent); outline-offset:2px;
}
button:disabled { opacity:.55; cursor:default; }
button[aria-pressed="true"],button.primary { color:white; background:var(--accent); border-color:var(--accent); font-weight:650; }
button:hover:not(:disabled) { border-color:var(--accent); }
[hidden] { display:none !important; }
.intro { margin:8px 0 15px; color:var(--mute); }
.panel { padding:clamp(10px,2.2vw,22px); border:1px solid var(--edge); border-radius:12px; background:var(--card); }
.row { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.cols { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:clamp(12px,3vw,28px); align-items:start; }
.product-photo { width:100%; height:clamp(94px,21vw,204px); object-fit:contain; padding:10px; border-radius:10px; background:#e6e9e1; }
.status { color:var(--mute); margin-top:10px; min-height:1.45em; }
@media(max-width:600px){ .cols { grid-template-columns:minmax(0,1fr); } }
.receipt{background:#d8dfd5;color:#233729;display:grid;grid-template-columns:1fr 1fr;padding:0;min-height:225px}
.receipt>div{padding:clamp(16px,3vw,34px)}.receipt dl{margin:18px 0 0}.receipt dl div{display:flex;justify-content:space-between;border-top:1px solid #9fb09d;padding:8px 0}.receipt .total{font-weight:700}.coupon{background:#f8faf5}
.coupon label,.coupon small{display:block}.coupon label{font-weight:650}.coupon input{margin:5px 0;padding:10px;width:100%;border:1px solid #80917e;border-radius:4px;color:#253826;background:#fff}.coupon .row{margin:12px 0 8px}.coupon [data-result]{min-height:1.5em;font-size:14px}.coupon [aria-invalid=true]{border-color:#963d2d}
@media(max-width:520px){.receipt{grid-template-columns:1fr}}export function mountEffect(root, {reducedMotion = matchMedia('(prefers-reduced-motion: reduce)').matches} = {}) {
const lifetime = new AbortController();
const $ = selector => root.querySelector(selector);
const all = selector => [...root.querySelectorAll(selector)];
const listen = (element, type, handler) => element.addEventListener(type, handler, {signal:lifetime.signal});
const animations = new Map();
let motion = false;
function cancelMotion() {
for (const animation of animations.values()) animation.cancel();
animations.clear();
}
function reveal(element, position = 'translateY(6px)') {
animations.get(element)?.cancel();
if (!motion || !element.animate) return;
const animation = element.animate(
[{transform:position, opacity:.52},{transform:'none', opacity:1}],
{duration:225, easing:'ease-out'}
);
animations.set(element,animation);
animation.onfinish = () => animations.delete(element);
}
const input=$('#code'), output=$('[data-result]'), remove=$('[data-remove]');
let applied=false;
function apply() {
if(input.value.trim().toUpperCase()!=='STUDIO10') {
input.setAttribute('aria-invalid','true');
output.textContent=applied ? 'Code not recognized. STUDIO10 is still applied.' : 'Code not recognized. Check the spelling.';
} else {
input.removeAttribute('aria-invalid');
output.textContent=applied ? 'STUDIO10 is already applied.' : 'STUDIO10 applied. You saved $8.00.';
applied=true; $('[data-saving]').hidden=false; remove.hidden=false; $('[data-total]').textContent='$72.00';
}
reveal(output);
}
listen($('[data-apply]'),'click',apply);
listen(input,'keydown',event=>{if(event.key==='Enter'&&!event.isComposing){event.preventDefault();apply();}});
listen(remove,'click',()=>{
applied=false;remove.hidden=true;$('[data-saving]').hidden=true;$('[data-total]').textContent='$80.00';
input.value='';input.removeAttribute('aria-invalid');output.textContent='Discount removed.';input.focus({preventScroll:true});reveal(output);
});
return {
resume() { motion = !reducedMotion; const stage = root.querySelector('[data-stage]'); if (stage) reveal(stage); },
pause() { motion = false; cancelMotion(); },
destroy() { lifetime.abort(); cancelMotion(); }
};
}In the cart summary.
A valid code adds a discount line. Applying it twice keeps the same total.
Enter and tap both work. Feedback stays beside the input.
Try an invalid code after a successful one and inspect the original discount.
Use allocations and amounts returned by cart or checkout in a live integration. Prevent duplicate submissions while a request is pending.
Work in a duplicate theme. Replace demo copy and artwork with Section settings, scope styles to that Section, and use the lifecycle module for editor reloads, visibility and teardown.
{% comment %} WESWOO example shell. Add ONE effect's HTML inside .fx-slot. {% endcomment %}
{{ 'ww-effects.css' | asset_url | stylesheet_tag }}
<section id="ww-effect-{{ section.id }}" data-ww-effect-section>
<h2>{{ section.settings.heading | escape }}</h2>
<button type="button" data-effect-toggle aria-pressed="false">Play / pause effect</button>
<div class="fx-slot">
{% comment %} Insert the chosen .fx element here; read copy/images from section settings. {% endcomment %}
</div>
</section>
<script type="module" src="{{ 'ww-effect-section.js' | asset_url }}"></script>
{% schema %}
{"name":"WESWOO effect","settings":[{"type":"text","id":"heading","label":"Heading","default":"Our story"}],"presets":[{"name":"WESWOO effect"}]}
{% endschema %}
// Put the chosen example JS in assets/ww-selected-effect.js (rename .mjs to .js).
import {mountEffect} from './ww-selected-effect.js';
const instances=new Map();
function mount(container=document){
const roots=[...(container.matches?.('[data-ww-effect-section]')?[container]:[]),...container.querySelectorAll('[data-ww-effect-section]')];
for(const section of roots){
if(instances.has(section))continue;
const root=section.querySelector('.fx'),button=section.querySelector('[data-effect-toggle]');
if(!root||!button)continue;
const effect=mountEffect(root),events=new AbortController();let playing=false;
const pause=()=>{playing=false;effect.pause();button.setAttribute('aria-pressed','false');};
button.addEventListener('click',()=>{playing=!playing;playing?effect.resume():effect.pause();button.setAttribute('aria-pressed',String(playing));},{signal:events.signal});
const observer=new IntersectionObserver(entries=>{if(!entries[0].isIntersecting)pause();});observer.observe(section);
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:events.signal});
instances.set(section,()=>{observer.disconnect();events.abort();effect.destroy();});
}
}
document.addEventListener('shopify:section:load',event=>mount(event.target));
document.addEventListener('shopify:section:unload',event=>{for(const [section,destroy] of instances)if(section===event.target||event.target.contains(section)){destroy();instances.delete(section);}});
mount();
// Original WESWOO integration. Copy alongside the selected ww-effect-*.js asset.
// The server supplies the asset URL; do not accept a URL from a query parameter.
if (!customElements.get('ww-effect-study')) {
customElements.define('ww-effect-study', class extends HTMLElement {
connectedCallback() {
if (this.events) return;
this.events=new AbortController();this.session={};const session=this.session;
const button=this.querySelector('[data-effect-toggle]');
button.disabled=false;button.setAttribute('aria-pressed','false');this.visible=true;
const preference=matchMedia('(prefers-reduced-motion: reduce)');
const pause=()=>{this.effect?.pause();button.setAttribute('aria-pressed','false');};
this.pause=pause;
button.addEventListener('click',async()=>{
if(this.loading)return;
if(!this.effect){
this.loading=true;button.disabled=true;
try {
const {mountEffect}=await import(this.dataset.moduleUrl);
if(!this.isConnected||this.session!==session)return;
this.effect=mountEffect(this.querySelector('.fx'),{reducedMotion:preference.matches});
} catch {this.querySelector('[data-effect-status]').textContent='The static content is available. Reload to retry motion.';return;}
finally {if(this.session===session){this.loading=false;button.disabled=false;}}
}
if(this.session!==session||document.hidden||!this.visible)return;
const playing=button.getAttribute('aria-pressed')!=='true';
playing?this.effect.resume():this.effect.pause();button.setAttribute('aria-pressed',String(playing));
},{signal:this.events.signal});
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();},{signal:this.events.signal});
preference.addEventListener('change',()=>{pause();this.effect?.destroy();this.effect=null;},{signal:this.events.signal});
this.observer=new IntersectionObserver(entries=>{this.visible=entries[0].isIntersecting;if(!this.visible)pause();});this.observer.observe(this);
const root=this.querySelector('.fx');
root.querySelectorAll('[data-view]').forEach(trigger=>trigger.addEventListener('click',()=>{const target=root.querySelector('dialog .art'),source=trigger.querySelector('.ww-fx-image');target.querySelector('.ww-fx-image')?.remove();if(source)target.append(source.cloneNode(true));},{signal:this.events.signal}));
// Section unload disconnects this custom element; reconnect mounts one fresh instance.
document.addEventListener('shopify:section:unload',event=>{if(event.target.contains(this))this.teardown();},{signal:this.events.signal});
}
teardown(){this.session=null;this.loading=false;this.observer?.disconnect();this.events?.abort();this.effect?.destroy();this.effect=null;this.events=null;}
disconnectedCallback(){this.teardown();}
});
}
Insert the selected effect into the shell. Each module loads one effect; multiple types need an explicit registry and Section mapping.
Feedback motion inspired by Codrops Notification Styles. Amounts are local demo data.
Shopify: Section architectureShopify: theme editor events and lifecycleShopify: theme performanceMDN: Web Animations APIMDN: reduced-motion preferenceMDN: iframe sandboxingShopify: image rendering and dimensionsShopify: Section settings and schemaMDN: element geometryMDN: image and text clippingMDN: native dialogShopify: theme accessibilityMDN: native range inputExamples are authored by WESWOO and credited open-source contributors; retain their applicable licenses. Project screens and photographs remain with their rights holders. Downloads use placeholders; replace them with imagery you may use.
Shopify/dawn · modal / slider base classesShopify/dawn · product media galleryShopify/dawn · license