Repository navigation
Add the Kanban example (Blaze 3.1 and web platform APIs) - #55
dupontbertrand wants to merge 8 commits into
Conversation
A real-time board on Blaze 3.1 without jQuery and without a UI library: native drag and drop, View Transitions around the Method stub, a <dialog> editor, popovers anchored with CSS Anchor Positioning, clipboard paste into cards, Web Share, a custom element fed from an autorun, and an async helper on the landing page. Mocha and Playwright tests, CI workflow, README entry and examples.json.
With lint turned off, a job that needs it is skipped, and so is the e2e job behind it.
- Scope the menu anchor to its column header: all menus share one anchor name, and a popover in the top layer resolves it to the last button of the page, so every menu opened under the last column, or off screen. A menu now flips at the left edge of the viewport and takes the text colour of the theme. - Put Save before Cancel in the editor: Cancel was the form's default button, so Enter in the Title field threw the edit away. - Take the drop position from the pointer's height among the column's cards: a card released in the gap between two cards, or above the first one, went to the end of the column. A card dropped where it already is no longer calls the Method. - Carry the card id under a type of its own and accept only that type: a column lit up for a link, a file or a text selection, sent their text to cards.move, and kept a text from being dropped in its field. - Handle the ready and finished promises of the view transition: they reject when the stub throws or a newer transition starts, which left uncaught errors next to the toast. - Report a missing Clipboard API (plain HTTP from another host) instead of throwing, and copy or share the board's address without a #card= fragment left behind. - Start a board page without the notice an earlier page left: the next board page showed the last toast again. The notice also loses a timestamp that nothing read.
- Renumber a column one update at a time: with Promise.all the stub
moved several cards of a sorted cursor at once, which Minimongo
cannot do. The tab threw "object missing from query" and kept an
order nobody else had until it was reloaded.
- Break rank ties with the card id, in the column's cursor and in
cards.move: two cards can get the same rank, and each tab, its stub
and the server then ordered them their own way.
- Draw column ids from the Method's seeded stream instead of
Random.id(): the stub and the server created a column under two
different ids, so a card added to a new column before the server
answered was refused. A Method sent again after a reconnect draws
the same id, so the column is only added to a board that has no
column with that id: the resent message keeps the first title, and
$addToSet would add a column renamed meanwhile a second time.
Nothing imports the random package any more, so .meteor/packages
drops it.
- Store columns as { _id, title }: without an _id, #each keys them by
index, and deleting a column handed its typed text, its rename form
and its open menu to the next one. The data-column-id attribute,
which nothing read, goes as well.
The e2e suite pressed Escape before the editor had opened, so it failed at random and proved nothing when it passed. It moved a card with dispatched events that never fire dragover, and checked what the stub drew rather than what the server kept. Mocha left the column guard of cards.move, the 100-card cap and cards.remove unchecked. The suites now guard: - a card dragged with the mouse to another column and inside a column, above the first card too, and what the server kept of a drag and of a paste after a reload; - the editor: Escape closes it and clears #card=, Enter in the Title field saves, a card link opens it; Back and Forward switch pages; - each column menu under its own button, in the page's text colour, and on screen at the left edge of a narrow screen; Rename from it; - Copy link without the #card= fragment, and its notice where there is no Clipboard API; - what review found broken: a link dropped on a column, a card deleted in another tab while it is dragged, a column renumbered after 21 moves, a notice shown again on the next board page, a draft taken by another column when one is deleted, a card added to a new column before the server answers; - in Mocha: boards.removeColumn keeping the cards of other columns, cards.remove, a move to a column of another board refused, more than 100 cards refused, the stats counts, the ranks of appended cards, both gaps after a renumbering, and one id per column.
- Say that Blaze is a beta (3.1.0-beta.0) in the README, the root entry and examples.json, and date the entry from its last change. - Credit async helpers to Blaze 2.7, where #let with @pending, @Rejected and @Resolved arrived: nothing async is new in 3.1. - Describe the menus as the stylesheet now anchors them, and the e2e suite as it now is. Say which browsers have every API and what the others miss, and add the Deployment and Links sections of the other examples. Copy link is there in every browser, not only where Web Share is missing. - Show "Could not load the stats." when the server answers with an error: an unreachable server leaves the helper pending, so "The server is not answering." never showed for it. The counts no longer read "1 boards". - Say why boards.stats runs on the server only. Meteor.callAsync resolves with the server's answer, stub or not; a client holds one board at most, so a stub would have nothing to count. - Count eight apps in the root README.
Dragging was the only way to move a card, so a keyboard could open, edit and delete one but never take it to Doing. The editor gets a Column field that starts on the card's own column: Save moves the card to the end of the column picked, and focus goes back to the card where it landed. Reordering inside a column still needs a pointer, as the README now says. An e2e test moves a card this way and reloads.
| with: | ||
| name: kanban-test-results | ||
| path: kanban/test-results/ | ||
| retention-days: 7 |
There was a problem hiding this comment.
We don't have the CI checks enabled on this repo, we instead run them locally in this momento. Please, disable this job.
|
This is a great example of the recent work on Blaze 3.1! It's also a good opportunity to showcase Blaze-specific conventions and establish testing expectations around them (E2E, integration and unit testing). Examples aren't just useful for showcasing features. We also use them to validate every release, running and verifying all of them for each version, including patches. So they play an important role in ensuring everything continues to work as expected! I'd definitely love to see this example included in Meteor 3.7! I'm also thinking we could showcase our examples more visually, with screenshots in the Meteor docs and a dedicated section explaining how to quickly try them out with a few commands. We already have a good collection, and it's only going to grow! Thanks so much for contributing and helping make Blaze better! |
|
Thanks Nacho! Glad it can ship with 3.7. Screenshots in the docs and a short "try it in a few commands" section sound great, and I'm happy to help with them. |
A new Blaze example: a real-time kanban board that leans on web platform APIs rather than a UI library, on Blaze 3.1 (beta) without jQuery.
What it shows
{{#each}}, withevent.dataTransferstraight on the event (nooriginalEvent)startViewTransition, thenTracker.flush(), so the browser animates the move<dialog>editor withmethod="dialog",event.submitter,closedby="any"; the non-bubblingcloseevent still reaches the event map. Save comes before Cancel, so Enter in the Title field saves, and a Column field moves the card without a drag, from the keyboard too (reordering inside a column still needs a pointer)anchor-scopeon the column header keeps it inside the column, andposition-try-fallbacks: flip-inlineflips a menu that has no room on the left of its button; centered whereanchor-scopeis missing)navigator.shareexists<board-chart>, fed through a property fromonRendered+autorun, the pattern that docs: event properties without jQuery, Template.instance() after await, flush timing, Web Components blaze#541 adds to the Blaze guide#letand@pending/@rejected/@resolvedhistory+popstatebehind a reactive path: two pages, no router packageNo accounts on purpose: anyone with a board link can edit it. Simple Blog already covers roles, permissions and email with Blaze; the README points to it.
Checks
npm run test:headless: 22 Mocha tests (pure helpers and Methods)npm run e2e:headless: 19 Playwright tests, cards dragged with the mouse:#card=fragment, and its notice where there is no Clipboard APInpm run lint: cleankanban.yml: same asparties.yml. Like the other examples, its jobs stay paused while lint is disabled, and the checks run locally.examples.jsonregenerated withscripts/update-examples-json.mjsanchor-scope, centers them. None of these has Web Share, so the Share button was only exercised with a stubbednavigator.share. Not run in Safari: per MDN compatibility data every API used is in Safari 26, exceptclosedby, listed only for Safari 27.3, still in beta, without which a click outside the editor does not close it.Blaze is pinned to
3.1.0-beta.0; I will bump it when 3.1.0 ships.