Skip to content

kit/ui: rows, share buttons, posters and ad slots, plus kit/testing - #31

Merged
jgb-solutions merged 8 commits into
mainfrom
feat/ui-patterns
Dec 6, 2026
Merged

jgb-solutions merged 8 commits into
mainfrom
feat/ui-patterns

Conversation

@jgb-solutions

@jgb-solutions jgb-solutions commented Dec 6, 2026 •

Copy link
Copy Markdown
Owner

What

Patterns for content sites, in kit/ui (plain HTML with data-slot, no behaviour library), with their own stylesheet ui/patterns.css.

  • Rail and its parts: a row that scrolls sideways, no scrollbar, two arrows at the top right on every screen size (compact on touch screens, 44 px touch area), each disabled at its end, both hidden while the whole row fits. layout="inline" for a row of chips. Right-to-left aware; instant scrolling for people who ask for less motion. Before it is measured a row counts as fitting, so no arrow flashes in.
  • ShareButtons (shareLinks, shareEmailHref): the one order (WhatsApp, Facebook, X, Telegram, Pinterest, LinkedIn, email, copy link) plus the phone's share sheet (first on a phone, last on a wide screen). On a phone the buttons wrap into even rows (4 + 4, 5 + 4), never one alone on a line. Plain links, no third-party script, icons from one cached file (ui/share-icons.svg; brand marks from Simple Icons, CC0). The email link is written between Cloudflare's <!--email_off--> comments. Copy link tries the clipboard API, then a selected field, then the browser's own box, and never throws.
  • Poster: keeps its shape and shows initials on a colour made from the title when there is no picture.
  • AdSlot (pickHouseAd): reserved height, a label, and a house ad (a wash of the brand colour, the product's name, one line, an optional button, and its icon or initials large in a tall slot's corner) that shows until the network marks its element as filled, by CSS alone (:has([data-ad-status='filled'])). enabled={false} renders nothing.
  • kit/testing (new entry): checkTouchTargets and adsAfterContent, self-contained functions for page.evaluate.
  • The showcase gets a Patterns page; its tests and screenshots pick it up from the page list.

Choices to review

  • A separate stylesheet. patterns.css is 3.29 kB gzipped; core.css stays at 6.57 kB. A page without rows, share buttons or ads (an admin) doesn't carry these rules, and an app that imports both into its own CSS still ships one file.
  • One share style. Only the quiet outline ships. Brand colours are raw colours, and several fail contrast as an icon colour on a light or dark surface, so an app that wants them sets --share-tone per network itself.
  • UiText gains five strings (shareOn, shareByEmail, copyLink, linkCopied, shareMore): breaking for an app that builds its own text object. The Haitian Creole strings need a native reader.

Sizes (gzipped)

size budget
ui/core.css 6.57 kB (was 6.26: Poster) 8
ui/patterns.css (new) 3.29 kB 4
Rail and its parts 1.34 kB 2
ShareButtons alone 1.72 kB 2
AdSlot alone 0.86 kB 1.5
every core component 7.78 kB (was 5.17) 9 (was 6)
Button alone 0.67 kB (was 0.59) 1.5

Checks

Types, 275 unit tests (19 new), build, check:package, check:size, check:install, format, audit. Browser tests: e2e/patterns.spec.ts in Chromium, Firefox and WebKit at desktop size and at phone sizes, with the showcase's own suite (axe, the Content-Security-Policy, the page list) covering the new Patterns page.

The new 44 px check found one fault in the showcase itself: its name link was 28 px tall on a phone. Fixed.

Walkthrough

Done on this pull request's preview build, at a phone size with a touch profile and at desktop width. One real fault, fixed: where a browser refuses the clipboard API and has no prompt box, "Copy link" threw and said nothing. Everything else passed: the menu drawer and focus back, row arrows and swiping, no scrollbar, even share rows with correct links, posters, both ad slots, no control under 44 px, no page wider than the phone, no console or CSP error, the 404 page, the keyboard order.

Not verified

  • That Cloudflare honours the email_off comments around a link React did not write (documented by Cloudflare; to be checked on a Cloudflare host when the first app adopts this).
  • :has() hiding the house ad in real ad traffic (the test sets the attribute by hand).
  • The nine-button share layout (5 + 4, share sheet first) on a real phone: the test browsers have no share sheet, so the screenshots show eight buttons.
  • Screen readers on the row; real phones.

Docs and skills

Read: Cloudflare's "Email Address Obfuscation" page (the email_off comments, what is and isn't rewritten); the vendored Modern Web Guidance guides for scroll snap and carousels; WCAG 2.5.8 and 2.5.5 (target size); the repo's own rules for kit/ui (data-slot, :where(), tokens only).

Security review

  • ShareButtons writes one list item with dangerouslySetInnerHTML (the email link, so the comments can exist). Every value in it is attribute-escaped (& " ' < >), the title and address are also URL-encoded, and a unit test feeds it hostile values and checks that no tag but a, svg and use comes out.
  • Share links open with rel="noopener noreferrer". No third-party script, no new request from the kit.
  • share-icons.svg holds symbols only (a test fails on script, href or url( in it).
  • kit/testing imports nothing and runs only in tests.
  • bun audit: no vulnerabilities.

🤖 Generated with Claude Code

jgb-solutions and others added 2 commits December 6, 2026 00:49
…rogress)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…gelog

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
kit-showcase 0eb23f1 Commit Preview URL

Branch Preview URL
Dec 06 2026, 07:10 AM

jgb-solutions and others added 6 commits December 6, 2026 00:57
…o touch

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… optional button; row header centred

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tall house ads get a corner mark

- Phones: 7 or 8 buttons wrap as rows of 4, 9 or 10 as rows of 5; none is left alone on a line.
  The share sheet's button comes first there, and its place is kept while the page comes alive.
- Tall house ads show the product's icon, or its initials, large in the lower corner.
- Changelog: the five new UiText strings are marked as breaking.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…fused, and never throw

Found in the walkthrough: in a browser that refuses the clipboard API and has no prompt(),
the button threw and said nothing. It now tries the clipboard API, then a selected
off-screen field, then the browser's own box, and stays quiet if all three fail. The browser
test now expects "Link copied" in Firefox and WebKit too.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@jgb-solutions
jgb-solutions marked this pull request as ready for review December 6, 2026 07:10
@jgb-solutions
jgb-solutions merged commit d29bf2c into main Dec 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant