main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Rev | Line | |
---|
[d565449] | 1 | import {CSSOMAddon} from './cssom';
|
---|
| 2 | import {Css} from './vcssom/cssToTree';
|
---|
| 3 | import {NanoRenderer} from '../types/nano';
|
---|
| 4 | import {CSSOMRule} from './cssom';
|
---|
| 5 | import {CssProps} from '../types/common';
|
---|
| 6 |
|
---|
| 7 | export interface VRule {
|
---|
| 8 | /**
|
---|
| 9 | * CSS declarations, like `{color: 'red'}`
|
---|
| 10 | */
|
---|
| 11 | decl: CssProps;
|
---|
| 12 | rule: CSSOMRule;
|
---|
| 13 |
|
---|
| 14 | /**
|
---|
| 15 | * Re-render css rule according to new CSS declarations.
|
---|
| 16 | * @param decl CSS declarations, like `{color: 'red'}`
|
---|
| 17 | */
|
---|
| 18 | diff(decl: CssProps);
|
---|
| 19 |
|
---|
| 20 | /**
|
---|
| 21 | * Removes this `VRule` from CSSOM. After calling this method, you
|
---|
| 22 | * cannot call `diff` anymore as this rule will be removed from style sheet.
|
---|
| 23 | */
|
---|
| 24 | del();
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | export interface VSheet {
|
---|
| 28 | /**
|
---|
| 29 | * Re-renders style sheet according to specified CSS-like object. The `css`
|
---|
| 30 | * object is a 3-level tree structure:
|
---|
| 31 | *
|
---|
| 32 | * ```
|
---|
| 33 | * {
|
---|
| 34 | * media-query-prelude: {
|
---|
| 35 | * selector: {
|
---|
| 36 | * declarations
|
---|
| 37 | * }
|
---|
| 38 | * }
|
---|
| 39 | * }
|
---|
| 40 | * ```
|
---|
| 41 | *
|
---|
| 42 | * Example:
|
---|
| 43 | *
|
---|
| 44 | * ```js
|
---|
| 45 | * sheet.diff({
|
---|
| 46 | * '': {
|
---|
| 47 | * '.my-class': {
|
---|
| 48 | * color: 'red',
|
---|
| 49 | * },
|
---|
| 50 | * '.my-class:hover': {
|
---|
| 51 | * color: 'blue',
|
---|
| 52 | * },
|
---|
| 53 | * },
|
---|
| 54 | * '@media only screen and (max-width: 600px)': {
|
---|
| 55 | * '.my-class': {
|
---|
| 56 | * color: 'green',
|
---|
| 57 | * },
|
---|
| 58 | * },
|
---|
| 59 | * });
|
---|
| 60 | * ```
|
---|
| 61 | *
|
---|
| 62 | * @param css CSS-like object with media queries as top level.
|
---|
| 63 | */
|
---|
| 64 | diff(css: Css);
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | export interface VCSSOMAddon {
|
---|
| 68 | VRule: new (selector: string, mediaQuery?: string) => VRule;
|
---|
| 69 | VSheet: new () => VSheet;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | export function addon(nano: NanoRenderer);
|
---|
Note:
See
TracBrowser
for help on using the repository browser.