Skip to content

Instantly share code, notes, and snippets.

@karol-majewski
Created April 6, 2020 17:05
Show Gist options
  • Save karol-majewski/d566b204805806d2d4aba82648c87160 to your computer and use it in GitHub Desktop.
Save karol-majewski/d566b204805806d2d4aba82648c87160 to your computer and use it in GitHub Desktop.
Managing CSS Custom Properties
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