Last active
October 12, 2017 12:52
-
-
Save PanayotCankov/903814d2938de550e0ef42d7eb3fc65a to your computer and use it in GitHub Desktop.
This file contains 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
# Properties | |
The properties are implemented in the [ui/core/properties/properties.ts](https://github.com/NativeScript/NativeScript/blob/master/tns-core-modules/ui/core/properties/properties.ts). | |
A little bit like XAML properties, these objects define properties on the View, ViewBase or Style classes. | |
- Property | |
- InheritedProperty | |
- CssProperty | |
- CssAnimationProperty | |
- ShorthandProperty | |
The property classes unify the way: | |
- object.defineProperty is made | |
- handle change notifications | |
- handle native getter/setter | |
- handle css value convertion | |
- nativeValueChange - get notified by native controlls that a native value had change and we have to update the JavaScript value | |
# CSS | |
## CSS3 Parser | |
The spec: https://www.w3.org/TR/css-syntax-3/ | |
The currently used CSS parser is ["rework"](https://github.com/NativeScript/NativeScript/tree/master/tns-core-modules/css), may be changed in future. | |
The parser is used to convert CSS strings to rules with selectro strings and key-value objects for the CSS declarations. | |
## CSS Selectors Parser | |
The spec: https://www.w3.org/TR/selectors4/ | |
The selectors strings provided by the CSS3 parser are converted to AST: | |
https://github.com/NativeScript/NativeScript/blob/master/tns-core-modules/ui/styling/css-selector-parser.ts | |
The parser is inhouse grown selectors parser close to the spec. | |
May move and be merged with a css parser to consume the input tokens produced by the CSS parser. | |
And the AST to object model that is capable of performing matches on View-like objects: | |
https://github.com/NativeScript/NativeScript/blob/master/tests/app/ui/styling/css-selector.ts | |
## Applying CSS | |
Css on views is applied by some code integrated in the View classes and the style-scope: | |
https://github.com/NativeScript/NativeScript/blob/master/tns-core-modules/ui/styling/style-scope.ts | |
Selectors are split in two groups: | |
- Dynamic: depend on attributes, pseudo-classes etc. listen for events | |
- Static: depend only on the visual tree, id and className attributes | |
The CssState class is responsible to listen for changes that will invalidate the dynamic state | |
and apply CSS properties on the View instances | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment