Content-Length: 231401 | pFad | https://github.com/NativeScript/NativeScript/issues/9789

32 Support multiple pseudo states simultaneously · Issue #9789 · NativeScript/NativeScript · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple pseudo states simultaneously #9789

Open
2 tasks done
rigor789 opened this issue Feb 20, 2022 · 1 comment
Open
2 tasks done

Support multiple pseudo states simultaneously #9789

rigor789 opened this issue Feb 20, 2022 · 1 comment
Labels

Comments

@rigor789
Copy link
Member

rigor789 commented Feb 20, 2022

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 make it easier to switch would be welcome.


NativeScript supports pseudo selectors to style views based on their state. For example

Button:disabled {
 background-color: #333;
}

However it does not support multiple pseudo states simultaneously. A good example where this would be useful is a Switch/Checkbox view:

<Switch checked="true" isEnabled="false" />
Switch:checked:disabled {
 background-color: #333;
}

The above css should set the background color of the switch when it is both checked and disabled.

Describe the solution you'd like

A new API to handle multiple pseudo states simultaneously.

Right now we have the View._goToVisualState(state: string); method.

We could handle visual states in an array, or for performance reasons a flag system would work too.

// clear previous state and set it to :checked:disabled (or :disabled:checked)
this.setPseudoState(PseudoState.CHECKED | PseudoState.DISABLED);

// keep previous state and add :disabled
this.addPseudoState(PseudoState.DISABLED);

// keep previous state and remove :disabled
this.removePseudoState(PseudoState.DISABLED);

// keep previous state, but replace :disabled with :enabled
this.replacePseudoState(PseudoState.DISABLED, PseudoState.ENABLED);

The api is open for debate.

A key missing piece is support for custom PseudoState values - the API would need to consider those to be complete.

Describe alternatives you've considered

We can handle the different states with simple classes, however a pseudo based solution would be ideal.

Anything else?

This would be a killer feature for using TailwindCSS where different states can be targeted inline:

<Switch 
  class="bg-gray-200 disabled:bg-gray-50 checked:bg-blue-300 text-blue-300 disabled:text-gray-300 checked:text-green-300" 
  checked="isChecked" 
  isEnabled="isEnabled"
/>

Please accept these terms

@CatchABus
Copy link
Contributor

I have already come across a few cases when a new pseudo-state replaces the current one. We should consider including this among future updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/NativeScript/NativeScript/issues/9789

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy