Title: Support multiple pseudo states simultaneously · Issue #9789 · NativeScript/NativeScript · GitHub
Open Graph Title: Support multiple pseudo states simultaneously · Issue #9789 · NativeScript/NativeScript
X Title: Support multiple pseudo states simultaneously · Issue #9789 · NativeScript/NativeScript
Description: Is your feature request related to a problem? Please describe. Update: Looks like there are methods to manipulate pseudoStates already: addPseudoClass deletePseudoClass These might be enough to cover the use-case, though a helper API to ...
Open Graph Description: Is your feature request related to a problem? Please describe. Update: Looks like there are methods to manipulate pseudoStates already: addPseudoClass deletePseudoClass These might be enough to cov...
X Description: Is your feature request related to a problem? Please describe. Update: Looks like there are methods to manipulate pseudoStates already: addPseudoClass deletePseudoClass These might be enough to cov...
Opengraph URL: https://github.com/NativeScript/NativeScript/issues/9789
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support multiple pseudo states simultaneously","articleBody":"### Is your feature request related to a problem? Please describe.\r\n\r\n---\r\n\r\n**Update**: Looks like there are methods to manipulate pseudoStates already:\r\n\r\n- `addPseudoClass`\r\n- `deletePseudoClass`\r\n\r\nThese might be enough to cover the use-case, though a helper API to make it easier to switch would be welcome.\r\n\r\n---\r\n\r\nNativeScript supports pseudo selectors to style views based on their state. For example\r\n\r\n```css\r\nButton:disabled {\r\n background-color: #333;\r\n}\r\n```\r\n\r\nHowever it does not support multiple pseudo states simultaneously. A good example where this would be useful is a Switch/Checkbox view:\r\n\r\n```html\r\n\u003cSwitch checked=\"true\" isEnabled=\"false\" /\u003e\r\n```\r\n\r\n```css\r\nSwitch:checked:disabled {\r\n background-color: #333;\r\n}\r\n```\r\n\r\nThe above css should set the background color of the switch when it is both checked and disabled.\r\n\r\n### Describe the solution you'd like\r\n\r\nA new API to handle multiple pseudo states simultaneously.\r\n\r\nRight now we have the `View._goToVisualState(state: string);` method.\r\n\r\nWe could handle visual states in an array, or for performance reasons a flag system would work too.\r\n\r\n```ts\r\n// clear previous state and set it to :checked:disabled (or :disabled:checked)\r\nthis.setPseudoState(PseudoState.CHECKED | PseudoState.DISABLED);\r\n\r\n// keep previous state and add :disabled\r\nthis.addPseudoState(PseudoState.DISABLED);\r\n\r\n// keep previous state and remove :disabled\r\nthis.removePseudoState(PseudoState.DISABLED);\r\n\r\n// keep previous state, but replace :disabled with :enabled\r\nthis.replacePseudoState(PseudoState.DISABLED, PseudoState.ENABLED);\r\n```\r\n\r\nThe api is open for debate.\r\n\r\nA key missing piece is support for custom PseudoState values - the API would need to consider those to be complete.\r\n\r\n### Describe alternatives you've considered\r\n\r\nWe can handle the different states with simple classes, however a pseudo based solution would be ideal.\r\n\r\n### Anything else?\r\n\r\nThis would be a killer feature for using TailwindCSS where different states can be targeted inline:\r\n\r\n```html\r\n\u003cSwitch \r\n class=\"bg-gray-200 disabled:bg-gray-50 checked:bg-blue-300 text-blue-300 disabled:text-gray-300 checked:text-green-300\" \r\n checked=\"isChecked\" \r\n isEnabled=\"isEnabled\"\r\n/\u003e\r\n```\r\n\r\n### Please accept these terms\r\n\r\n- [X] I have searched the [existing issues](https://github.com/NativeScript/NativeScript/issues) as well as [StackOverflow](https://stackoverflow.com/questions/tagged/nativescript) and this has not been posted before\r\n- [X] I agree to follow this project's [Code of Conduct](https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#coc)","author":{"url":"https://github.com/rigor789","@type":"Person","name":"rigor789"},"datePublished":"2022-02-20T15:11:07.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/9789/NativeScript/issues/9789"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c90ee6a4-e81e-cb9f-2553-8877db4fa7d2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D22:258B52:B59596:F15B90:6A5BACFD |
| html-safe-nonce | e0cb79f416c1a251c3042486a347b38f143caf1d0f99c4803793d521a05922ae |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDIyOjI1OEI1MjpCNTk1OTY6RjE1QjkwOjZBNUJBQ0ZEIiwidmlzaXRvcl9pZCI6IjUzODUzMzI2MjUxOTk4MzY0MTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8fa90da73941661e8df6f847dd085cadde11ac3b93e98a7f81b009b8e4972071 |
| hovercard-subject-tag | issue:1145047058 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NativeScript/NativeScript/9789/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f56ca9a0ca09e34bceba2751a2096a6d6e6c41e2f5b9c1e8536b903fa59f86e4/NativeScript/NativeScript/issues/9789 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f56ca9a0ca09e34bceba2751a2096a6d6e6c41e2f5b9c1e8536b903fa59f86e4/NativeScript/NativeScript/issues/9789 |
| og:image:alt | Is your feature request related to a problem? Please describe. Update: Looks like there are methods to manipulate pseudoStates already: addPseudoClass deletePseudoClass These might be enough to cov... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rigor789 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/NativeScript git https://github.com/NativeScript/NativeScript.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 31492490 |
| octolytics-dimension-repository_nwo | NativeScript/NativeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31492490 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/NativeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width