-
Notifications
You must be signed in to change notification settings - Fork 62
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
pseudo classes with params #209
Conversation
new and improved syntax: /*
* types and validators can be one and the same
* types/validarots are imported (optional)
* types/validators can have default values, e.g: min vs min() useful for js validators
* values can have default values, e.g. -st-state(number, min(0), max(31)) 1;
* support multiple named params
* nesting validators - chain them one after the other, e.g. number(x()) === -st-state(number, x)
*/
/* native types will not need to be imported, and would instead be available globally
:import {
-st-from: "stylable-validations";
-st-named: multiplyOf, min, max, number;
}
*/
:import {
-st-from: "./my-validators.ts";
-st-named: custom;
}
date:-st-states("[data-date='$day-$month-$year']") {
day: number(min(0), max(31)) 1;
month: custom(multiplyOf 3, min 0, max 30) 1;
year: number(multiplyOf(3), min(0), max(30)) 1980;
}
.root {
-st-states: date
}
.a {
-st-states: date
}
.a:date(day 1, month 10, year 2001){
}
.root {
-st-states: x(string(contains('x')))
} |
.token:fieldName(email){ | ||
color:lightBlue; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make string glob syntax identical to CSS.
fieldname($_id) does not look like it means 'ends with _id'
Make it fieldname($=_id) like CSS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that looks better, and more consistent with CSS.
|
||
``` | ||
|
||
#### Boolean example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this first example, make clear it is the default.
If it is possible to give an explicit Boolean parameter, give an example.
.cell{ | ||
-st-states: column(number); | ||
-st-states: done(number<0,100>); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two -st-states in one class. Is this correct syntax? Better if it were
-st-states: column(number), done(number<0,100>);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just two examples side by side, no intend to support multiple directives (you can add multiple states for a single directive, and that should be good enough)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but in an example it looks like it's supposed to be correct syntax, which it isn't.
I'd either have two states in the same line, or (better?) two classes side-by-side.
You want this to be copy-paste-able, IMO.
Some notes while trying to get my head around this stuff after xmas break/ sickness: rename -st-state as -custom-state instead; 'cause any example that has an -st- prefix looks like it's part of Stylable core/ reserved word |
i don't know the functionality implied by this example - but "multiplyOf" sounds alien to me. Is it "multiplyBy" so returns number*3, or "multipleOf" so returns true or false of number is perfectly divisible by 3? |
…support for states with string params
…ng links to future intent features)
…nto nadav/pseudo-state-params
…nto nadav/pseudo-state-params
…nto nadav/pseudo-state-params
…nto nadav/pseudo-state-params
const singleSelectorAst = sRule.selectorAst.nodes[0]; | ||
const selectorChunk = singleSelectorAst.nodes; | ||
|
||
if (selectorChunk.length === 1 && selectorChunk[0].type === 'class') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refine with ido what about Elements
Add support for pseudo classes with params (string, number, enum, tag) including validations
Feature request: implement pseudo states with params.
Reason: Customization of data aware components ( AutoViews )
spec is found in pseudo classes readme.