A stylesheet language written in TypeScript that compiles to CSS
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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. }