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

v2 style2state syntax proposal #134

Open
tenphi opened this issue Feb 5, 2021 · 4 comments
Open

v2 style2state syntax proposal #134

tenphi opened this issue Feb 5, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request
Projects
Milestone

Comments

@tenphi
Copy link
Collaborator

tenphi commented Feb 5, 2021

The current syntax is very simple and works well in most cases but limits the power of CSS selectors. There is no way to bind style value to the custom selector-like attribute with a specific value.

For example, we want our block to have the color #text by default and the color #special when it's focused or hovered.

Old syntax:

<nu-block color="#text :hover.focus[#special]"></nu-block>

New syntax:

<nu-block color="#text &:hover,:focus{#special}"></nu-block>

It's easier to read the second selector 'cause there is more CSS-like syntax. Also [, ] brackets are replaced with more intuitive {, }.

It's also possible to specify custom selectors with attributes and their values:

<nu-block color="#text &[type='primary'],[type='clear']{#special}"></nu-block>

There is still room for improvements 'cause we don't have the ability to specify CSS pseudo selector and Numl use its syntax to declare modifiers. The declaration color="#text &:hover,:focus{#special}" will be transformed into color="#text &[is-hover],[is-focus]{#special}". If we need to use native :hover syntax then there is no option for that.

Any ideas?

@tenphi tenphi added the enhancement New feature or request label Feb 5, 2021
@tenphi tenphi added this to the v2.0 milestone Feb 5, 2021
@tenphi tenphi self-assigned this Feb 5, 2021
@tenphi tenphi added this to To do in Numl v2 via automation Feb 5, 2021
@tenphi
Copy link
Collaborator Author

tenphi commented Feb 5, 2021

We can also introduce more advanced logic syntax like:

<nu-block color="#text &[type='primary'],(:hover,:focus,:pressed){#special}"></nu-block>

...that is the shorthand for:

<nu-block color="#text &[type='primary']:hover,[type='primary']:focus,[type='primary']:pressed{#special}"></nu-block>

We can support any level of logic nesting here.

@timeshift92
Copy link

in principle, the project is still young, before version 1 you can think about a better implementation

@tenphi
Copy link
Collaborator Author

tenphi commented Feb 5, 2021

We won't change v1 syntax. v1 is almost ready. We already postponed its release by a lot. A new syntax will require a big refactoring to its core. In that case, we will never see the v1 'cause there is always room for enhancements.

@shubham-kaushal
Copy link
Member

Updates: https://github.com/numldesign/tasty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Numl v2
To do
Development

No branches or pull requests

3 participants