Repository navigation
ui: when blocks inside elements - #3549
Merged
Merged
Conversation
|
Deployment failed for project salam with the following error: |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 4 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
Deployment failed for project salam with the following error: |
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
when cond:blocks inside an element (section 1 of docs/design/UI_STATES_THEMES.md). A block holds style attributes only, including state prefixes such ashover background.Persian:
وقتی cond:...پایان.How it works (deviation from the design)
The design asks for a generated data attribute plus a CSS rule on the web and a patch layer on native. This PR does not do that. The parser lowers every
whenblock into per-attribute conditional values:x = vinsidewhen cbecomesx = c ? v : <earlier value of x>, and the else branch is an empty text (no declaration) when the element has no earlier value. A laterwhenwraps the result of the earlier ones, so source order wins; state prefixes keep their own slot, so base, thenwhenin order, then states holds.Trade-offs:
salamWsStyle, nativeSetText), so behaviour is identical and only the scope that reads the condition re-runs.dark,screen width < n) need real@mediaand will come in a later PR with their own mapping._,-and spaces ignored). Mixing two aliases of one property (backgroundandbackground color) gives the duplicate attribute error instead of merging.whenis recognised only at the start of a layout line followed by a condition, sowhen = ...as an attribute orwhen:as an element keep working. It is not a global keyword.salamWsStyleandui.Builder.SetText.whenholds style attributes only) is reported for pages; awhenwith elements inside a component body is not checked yet. E173 (condition must be bool) is not added: the ternary type check reports it.Tests
tests/{en,fa}/page/components/when_style(web output lines),tests/en/page/errors/when_holds_elements(E175).page/componentsandpage/errorswith a compiler built from this branch: 1964 passed, 19 failed, all 19 are in tools/ui-gate-known-failures.txt.ui/*test with a dynamic style value is on the known-failures list on main until ui: native page lowering, comma lists, entry errors #3527 lands (the existingui/en/scope_listfails the same way with this branch's compiler). The native twin test will follow once ui: native page lowering, comma lists, entry errors #3527 is merged.