A stylesheet language written in TypeScript that compiles to CSS
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

rule.ts 777B

12345678910111213141516171819202122232425
  1. import * as AST from '../ast';
  2. import Env, { EnvError } from '../env';
  3. export class Rule {
  4. public property: AST.Property;
  5. public value: AST.Value;
  6. public constructor(
  7. property: AST.Property,
  8. value: AST.Value
  9. ) {
  10. this.property = property;
  11. this.value = value;
  12. }
  13. public compile(env: Env, opts: AST.Opts): string | EnvError {
  14. const wordSpacer = opts.prettyPrint ? ' ' : '';
  15. const indentSpacer = opts.prettyPrint ? ' ' + Array(opts.depth).fill(' ').join('') : '';
  16. const property = this.property.compile(env, opts);
  17. if (property instanceof EnvError) return property;
  18. const value = this.value.compile(env, opts);
  19. if (value instanceof EnvError) return value;
  20. return `${indentSpacer}${property}:${wordSpacer}${value};`;
  21. }
  22. }