Created
April 6, 2020 17:05
-
-
Save karol-majewski/d566b204805806d2d4aba82648c87160 to your computer and use it in GitHub Desktop.
Managing CSS Custom Properties
This file contains hidden or 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
declare class CSSPropertyManager<T> { | |
has<K extends keyof T>(property: K): asserts this is CSSPropertyManager<T & Required<T, K>; | |
get<K extends keyof T>(property: K): boolean; | |
set(property: keyof T, value: string): this; | |
} | |
const schema = { | |
'--width-1': string; | |
} | |
const css = new CSSPropertyManager(schema, document); | |
css.get('--width-1'); | |
css.set('--width-1', new CSSUnit({ unit: 'em', value: 22 })); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment