Conversation
When an attribute value contains a double quote, libxml < 2.14 switches the whole attribute to single quotes, while >= 2.14 keeps double quotes and escapes the inner ones as ". The rendering snapshots therefore depend on the libxml the suite happens to run against. Normalize on the escaped form, next to the entity normalization already there for the same 2.14 boundary. This fixes the `calendar` recipe, whose JSON-valued Stimulus attributes hit the case on every example, and the `post-link` snapshot, which until now only matched on libxml < 2.14. Claude-Session: https://claude.ai/code/session_01UnZ3JkQ2pyVz2fYvA83p3D
A bare `ar` locale resolves to Arabic-Indic or Latin digits depending on the ICU version, so the rendered day numbers -- and the snapshot -- differ between the runtime the suite is developed on and the one CI runs. The browser's ICU is not necessarily the server's either, so the digits could also flip on navigation. Pin it with the `-u-nu-` Unicode extension, which both IntlDateFormatter and Intl.DateTimeFormat honour, and document the reason in the RTL section. Claude-Session: https://claude.ai/code/session_01UnZ3JkQ2pyVz2fYvA83p3D
The Windows job passes setup-php an explicit extension list, which replaces the defaults rather than adding to it, so `intl` was absent. Now that the Toolkit test suite renders localized dates through twig/intl-extra, its absence fails the whole suite on Windows with `Class "IntlDateFormatter" not found`. Add `intl` to that list, and declare `ext-intl` in the Toolkit's require-dev so the requirement fails at install time rather than at runtime. Claude-Session: https://claude.ai/code/session_01UnZ3JkQ2pyVz2fYvA83p3D
Member
Ah you had the issue as well :D |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
calendarrecipe to the Shadcn kit, ported fromregistry/bases/radix/ui/calendar.tsx.Upstream is a thin wrapper around react-day-picker, which has no Twig equivalent, so the month grid is reimplemented rather than wrapped:
<twig:Calendar>renders it server-side and one Stimulus controller progressively enhances it.Supports
single/multiple/rangeselection, month navigation, label or dropdown caption, outside days, ISO week numbers, fixed weeks, disabled dates, min/max and navigation bounds, arbitrarymodifiers, and form submission through hidden inputs (name,name[],name[from]/name[to]).Every day state is a
data-*attributeThe grid is always a fixed six-by-seven table, and each day's state is a literal
data-*attribute with an explicit value, with the matching styles expressed as Tailwind data-variants inside the static base class string:So the controller never touches a class name — navigating a month only flips attributes and rewrites day labels. No Tailwind string is duplicated into JavaScript, the no-JS render is complete, and the snapshots are meaningful.
RTL uses the logical-property forms from upstream's own RTL changelog (
rounded-s-/rounded-e-,after:start-0/after:end-0) rather thanltr:/rtl:pairs, since upstream dropped itsui-rtl/directory in favour of exactly that.Localization
Month, weekday and day labels go through
twig/intl-extra(|format_date(pattern: …, locale: …)), mirrored client-side byIntl.DateTimeFormatso server and client agree after navigation. This is the first kit recipe to render dates, so it is also the first to needtwig/intl-extra.Two changes outside the recipe follow from that:
twig/intl-extraadded tosrc/Toolkit/composer.jsonrequire-dev, otherwise|format_dateis undefined when the snapshot test renders the README examples.format_dateadded toComposerSymbolChecker's curated symbol map, so the linter can tell a recipe using it to declaretwig/extra-bundle+twig/intl-extra. Purely additive: no other kit usesformat_date.Deliberate deviations from upstream
react-day-pickerfor its/persianbuild; a faithful port needs a non-Gregorian calendar engine in both PHP and JavaScript, and the grid arithmetic is not Gregorian.--cell-size, which is ported in full; custom per-day content cannot survive the controller re-rendering cells on month change.Every other upstream example is present as a live preview in the recipe
README.md.Deterministic snapshots
A calendar that renders "today" produces snapshots that break on an unrelated day when the month rolls over. Every README example therefore pins
todayandmonthexplicitly —todayis a real prop, as it is in react-day-picker.Testing
bin/ux-toolkit-kit-lint --fail-on-warningclean on all four kits;php-cs-fixer,twig-cs-fixer,oxfmt,oxlintclean.fixedWeeksrow hiding,showOutsideDays, navigation bounds, hidden-input serialization, and presets driving the calendar from outside the grid.ux.symfony.comagainst this branch, in light and dark, with no console or request errors.No companion PR on
symfony/ux.symfony.comis needed: sincesymfony/ux.symfony.com@c8f4c8ekit controllers are auto-registered by globbing the vendored kits, the Tailwind build already@sources the kit directory (and its output is not committed), andtwig/intl-extrais already required there.Three portability fixes it turned out to need
Rendering dates in a snapshot test exposed three latent environment dependencies. Each is a separate commit.
[Toolkit] Make HTML snapshots stable across libxml versions— when an attribute value contains a double quote, libxml < 2.14 switches the whole attribute to single quotes while >= 2.14 keeps double quotes and escapes the inner ones as". The calendar's JSON-valued Stimulus attributes hit this on 9 of 11 examples. Normalized on the escaped form, right next to the entity normalization already inComponentsRenderingTestfor the same 2.14 boundary. This also fixes thecommon/post-linksnapshot, which until now only matched on libxml < 2.14 — it fails on any newer machine, and its snapshot is regenerated here.[Toolkit][Shadcn] Pin the calendar RTL example numbering system— a barearlocale resolves to Arabic-Indic or Latin digits depending on the ICU version, so day numbers differed between my runtime and CI's. Pinned with the-u-nu-Unicode extension, which bothIntlDateFormatterandIntl.DateTimeFormathonour. Not just a snapshot concern: the browser's ICU is not necessarily the server's, so without pinning the digits could flip when navigating a month.[Toolkit] Enable the intl extension on the Windows test job— the Windows job passes setup-php an explicit extension list, which replaces the defaults rather than adding to them, sointlwas absent. Withtwig/intl-extranow in the Toolkit's dev dependencies that failed the whole suite (779 errors, not only the calendar) withClass "IntlDateFormatter" not found. Addedintlto that list and declaredext-intlinrequire-devso the requirement surfaces at install time instead of at runtime.