A stylesheet language written in TypeScript that compiles to CSS
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

keyframes.ts 876B

12345678910111213141516171819202122232425262728
  1. import * as AST from '../ast';
  2. import Env, { EnvError } from '../env';
  3. export class Keyframes {
  4. public name: AST.Literal;
  5. public children: AST.Node[];
  6. public constructor(name: AST.Literal, children: AST.Node[]) {
  7. this.name = name;
  8. this.children = children;
  9. }
  10. public compile(env: Env, opts: AST.Opts): string | EnvError {
  11. const lineSpacer = opts.prettyPrint ? '\n' : '';
  12. const wordSpacer = opts.prettyPrint ? ' ' : '';
  13. const name = this.name.compile(env, opts);
  14. const children = this.children.map((child) =>
  15. child.compile(env, { ...opts, depth: opts.depth + 2 })
  16. );
  17. const childrenError = children.find((node) => node instanceof EnvError);
  18. if (childrenError instanceof EnvError) return childrenError;
  19. return `@keyframes ${name}${wordSpacer}{${lineSpacer}${children.join(
  20. lineSpacer
  21. )}${lineSpacer}}`;
  22. }
  23. }