Files
odysseus/static/js/shared/ui/confetti.js
T
Alexandre TeixeiraandLéo f1a47f3812 refactor(notes): decompose Notes into feature-owned modules (#6713)
* refactor(notes): decompose Notes into feature-owned modules

* fix(notes): avoid HTML interpolation in reminder picker

* docs(notes): drop checkpoint archives, session logs and publication drafts

The N0-N6 tarballs and raw pytest/node logs are not read by any script or
test, and the logs carry absolute home-directory paths. Once squashed into
dev they would stay in history for good. notes-pr.md and notes-issue.md
were the drafts used to open #6712 and #6713, not documentation.

notes-validation.md keeps the counts, the checkpoint hashes and
implementation.sha256 as the record; local interpreter paths and the local
Docker image name are replaced with portable placeholders.

* fix(notes): keep the state store raw and stop masonry re-observing after close

- state: writes built from views (filter, spread, splice) stored nested
  read-only views in the store, so structuredClone on a stored note threw
  DataCloneError. Store writes now unwrap nested views.
- layout: a save that resolves after closePanel re-renders the leaving pane
  and re-created the masonry ResizeObserver that teardown had disposed.
  Skip creating it once Notes is closed.
- index.js: drop 30 imported or declared names that were never used and
  group the imports at the top. Import order is unchanged.
- Revert unrelated punctuation edits in .gitattributes and keep the header
  comment and docstring first in compare/vote.js and
  test_notes_dom_xss_helpers.py.

Both fixes have a node test that fails on the previous head.

* test(notes): make script rejection assertion case-insensitive

Address CodeQL js/bad-tag-filter alert #1150 in test-only assertion and refresh Notes evidence manifest checksum.

---------

Co-authored-by: Léo <leograndcontact@gmail.com>
2026-10-15 09:29:41 +01:00

29 lines
1.3 KiB
JavaScript

/** Stateless celebration renderer shared by Notes and Compare. */
export function spawnConfetti(cx, cy, count) {
const colors = ['#ffd700', '#ff6b6b', '#5b8def', '#51cf66', '#ff922b', '#cc5de8', '#22b8cf', '#fff'];
for (let i = 0; i < count; i++) {
const el = document.createElement('div');
el.className = 'confetti-piece';
const color = colors[Math.floor(Math.random() * colors.length)];
const size = 5 + Math.random() * 8;
const isCircle = Math.random() > 0.5;
el.style.width = size + 'px';
el.style.height = (isCircle ? size : size * 0.6) + 'px';
el.style.background = color;
el.style.borderRadius = isCircle ? '50%' : '2px';
el.style.left = cx + 'px';
el.style.top = cy + 'px';
const angle = Math.random() * Math.PI * 2;
const speed = 60 + Math.random() * 160;
const dx = Math.cos(angle) * speed;
const dy = Math.sin(angle) * speed - 100;
const duration = 1.0 + Math.random() * 1.0;
el.animate([
{ transform: 'translate(0, 0) rotate(0deg) scale(1)', opacity: 1 },
{ transform: `translate(${dx}px, ${dy + 200}px) rotate(${400 + Math.random() * 400}deg) scale(0)`, opacity: 0 }
], { duration: duration * 1000, easing: 'cubic-bezier(0.15, 0.6, 0.35, 1)', fill: 'forwards' });
document.body.appendChild(el);
setTimeout(() => el.remove(), duration * 1000 + 50);
}
}