Repository navigation
Conversation
A button's variant can now be the name of any colour token in the theme, as well as one of the built-in ones. The button fills like primary in that token and draws its label in the matching on- token, or in on-primary when the theme has none. PHP resolves both colours from the theme and sends them as tint and on_tint, with dark_ shades when they differ, the way the pager's tab colours work. Both renderers draw them in place of primary. The built-in variants send nothing new, and a name the theme doesn't have still draws as primary. This lets an app pick a button's colour at runtime, say a colour each user chooses, while every colour still comes from the theme. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The label's colour went as on_tint, and the bridge sends every prop that starts with on_ as a callback. It reached the renderers as 0, so the label was transparent wherever on_tint was used, which was light mode. Keys ending in _color travel as colours, and both of these are already in the interned key table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
A button's
variantcan now name any colour token in the theme, as well as the built-in ones. The button fills like primary in that token, with its label in the token'son-pair, or inon-primarywhen the theme has none.Why
The devnull app draws its main buttons in the colour each person picks for their lane, so the colour is only known at runtime. Button deliberately takes no per-instance colour. This keeps that rule: the colours still live in the theme and the button only says which pair to use, so
:variant="'lane-'.$lane"works.How
PHP resolves the token's light and dark shades and sends them as
tint_colorandlabel_color, plusdark_tint_coloranddark_label_colorwhen they differ. That's how the pager'stab-*colours travel in #136. Both renderers draw them where they drew primary, and iOS's glass styles pick them up too. Disabled is still surface-variant on both.The built-in variants send nothing new. A name the theme doesn't have still draws as primary, as an unknown variant always has.
The second commit renames the label's key. It was
on_tintat first, and the PHP extension sends any prop starting withon_as a callback id, so the label arrived as 0 and was transparent in light mode (dark useddark_on_tint, which worked). There's a test that no colour goes out under anon_key. That rule is easy to trip over for any element, so it might be worth a line in the element docs.Worth a look
accenthas no case inButtonRenderer.ktand falls through to primary. That's the same on main and I've left it alone, but it means an accent button is primary-coloured on Android.tokenColor()and two arguments swapped), and CI doesn't compile Kotlin either.Verified
tests/ButtonTokenVariantTest.php: the props for a token variant from Blade and the fluent API, theon-primaryfallback, built-ins and unknown names sending nothing, noon_keys, and source checks on both renderers. 282 tests pass, Pint clean,swiftc -parseclean.combined/dev-null-app, in light and dark, with green, rose, teal and ochre lanes.The Account screen: green in light, then rose in light and dark, with the built-in secondary and destructive buttons beside them.
Labels per lane: teal and ochre in dark and light.
The light-mode label before and after the key rename.
Screenshots live on the orphan branch
button-theme-token-variant-screenshots. Delete it after merging.Used by NativePHP/dev-null-app#8, and merged into
combined/dev-null-appfor it.🤖 Generated with Claude Code