Community widgets

A creation from the community

Gratitude Constellation

Made by ArkheOS

Tap the night sky to add a gratitude star. Undo a star or reset the constellation, then follow its remix lineage back to the original.

Make your version

What would you change about Gratitude Constellation?

Copy your request, open Widget Canvas, then choose “Try in chat” and paste it.

View your request

You are exploring the published defaults. Changes here stay in this browser and do not change the creator’s work.

Follow the remix chain

  1. Save Rehearsal
    Made by ArkheOS
  2. Kindness Counter
    Made by Sample Maker
  3. Gratitude Constellation
    Made by ArkheOS
View published code

HTML

<main><header><p class="eyebrow">A little light for every thank-you</p><h1>Gratitude Constellation</h1><p>Tap the night sky to add one star.</p></header><button id="increase" type="button" aria-label="Add star"><svg id="sky" viewBox="0 0 400 260" aria-hidden="true"></svg><span class="hint">Tap to add a star ✦</span></button><div class="bar"><div><output id="count" aria-live="polite">0</output><span> gratitude stars</span></div><div class="actions"><button id="undo" type="button" disabled>Undo</button><button id="reset" type="button">Reset</button></div></div><p id="status" role="status" aria-live="polite">Ready</p><footer>Remixed from <a href="https://widgets.arkheos.ai/community/widgets/dfdafdb1-20f3-4cc1-acdd-6c17059a4cf7" target="_blank" rel="noopener noreferrer">Kindness Counter by Sample Maker</a>.<br>Earlier original: <a href="https://widgets.arkheos.ai/community/widgets/db630603-2001-485c-b4c3-61bf35468f46" target="_blank" rel="noopener noreferrer">Save Rehearsal by ArkheOS</a>.</footer></main>

CSS

*{box-sizing:border-box}body{margin:0;background:#0b1023;color:#e8eafa;font:15px system-ui}main{max-width:480px;margin:auto;padding:24px 20px}h1{font:500 29px Georgia,serif;margin:8px 0}header p{color:#aeb7d3;font-size:13px}.eyebrow{letter-spacing:.13em;text-transform:uppercase;font-size:10px!important}button{font:600 13px system-ui;cursor:pointer;border:1px solid #596080;border-radius:10px;color:inherit;background:#1a2341;padding:10px 15px}#increase{position:relative;display:block;width:100%;padding:0;overflow:hidden;background:radial-gradient(ellipse at 50% 100%,#24375b,#0b1129 75%);border-color:#354260;border-radius:18px;margin:22px 0}svg{display:block;width:100%;height:auto}.hint{position:absolute;bottom:13px;left:0;width:100%;font-size:11px;color:#aab6d3;font-weight:400}.bar{display:flex;justify-content:space-between;gap:12px;align-items:center;flex-wrap:wrap}.bar span{font-size:12px;color:#aeb7d3}output{font-size:32px;font-variant-numeric:tabular-nums}.actions{display:flex;gap:8px}button:disabled{opacity:.4;cursor:default}button:focus-visible,a:focus-visible{outline:3px solid #f7d38a;outline-offset:4px}#status{font-size:11px;color:#aeb7d3;min-height:16px}footer{border-top:1px solid #354260;margin-top:20px;padding-top:14px;font-size:11px;line-height:1.8;color:#939fbe}a{color:#c6cfee}

JavaScript

const MAX=999999,LIMIT=20;
// Visual cap only: the numeric count and version:1 saved state retain the full count.
const MAX_DRAWN_STARS=120;
let state={version:1,count:0,history:[]},edited=false,epoch=0;const output=document.getElementById("count"),up=document.getElementById("increase"),undo=document.getElementById("undo"),status=document.getElementById("status"),sky=document.getElementById("sky");function valid(s){return s&&s.version===1&&Number.isInteger(s.count)&&s.count>=0&&s.count<=MAX&&Array.isArray(s.history)&&s.history.length<=LIMIT&&s.history.every(n=>Number.isInteger(n)&&n>=0&&n<=MAX)}function paint(){output.textContent=String(state.count);undo.disabled=!state.history.length;up.disabled=state.count>=MAX;let stars="";const drawnStars=Math.min(state.count,MAX_DRAWN_STARS);for(let i=0;i<drawnStars;i++){const x=18+((i*137.508)%364),y=18+((i*83.317)%208);stars+='<circle cx="'+x.toFixed(2)+'" cy="'+y.toFixed(2)+'" r="'+(i%5===0?2.5:1.6)+'" fill="#ffe5ac"/>';if(i%5===0)stars+='<path d="M '+(x-5)+' '+y+' H '+(x+5)+' M '+x+' '+(y-5)+' V '+(y+5)+'" stroke="#ffe5ac" stroke-width=".7"/>'}sky.innerHTML=stars}let pending=null,saving=false;async function drain(){if(saving)return;saving=true;while(pending){const snap=pending;pending=null;try{await WidgetCanvas.setState(snap);status.textContent=pending?"Saving…":"Saved"}catch(e){status.textContent="Save failed; changes remain here"}}saving=false}function update(){edited=true;paint();pending={version:1,count:state.count,history:state.history.slice()};status.textContent="Saving…";void drain();void WidgetCanvas.setContext({title:"Gratitude Constellation",count:state.count}).catch(()=>{})}up.addEventListener("click",()=>{if(state.count>=MAX)return;state.history.push(state.count);state.history=state.history.slice(-LIMIT);state.count++;update()});undo.addEventListener("click",()=>{if(!state.history.length)return;state.count=state.history.pop();update()});document.getElementById("reset").addEventListener("click",()=>{state={version:1,count:0,history:[]};update()});function restore(s){if(!edited&&valid(s)){state={version:1,count:s.count,history:s.history.slice()};paint();status.textContent="Restored"}}WidgetCanvas.setSharingEnabled(false);WidgetCanvas.setResetEnabled(false);WidgetCanvas.setControlsPosition("top-right");window.addEventListener("widgetcanvas:restore",e=>{epoch++;restore(e.detail)});paint();(async()=>{const start=epoch;try{const s=await WidgetCanvas.getState();if(epoch===start)restore(s)}catch(e){status.textContent="State unavailable"}})();