source: frontend/node_modules/tailwindcss/lib/util/parseAnimationValue.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.8 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", {
3 value: true
4});
5Object.defineProperty(exports, "default", {
6 enumerable: true,
7 get: function() {
8 return parseAnimationValue;
9 }
10});
11const DIRECTIONS = new Set([
12 "normal",
13 "reverse",
14 "alternate",
15 "alternate-reverse"
16]);
17const PLAY_STATES = new Set([
18 "running",
19 "paused"
20]);
21const FILL_MODES = new Set([
22 "none",
23 "forwards",
24 "backwards",
25 "both"
26]);
27const ITERATION_COUNTS = new Set([
28 "infinite"
29]);
30const TIMINGS = new Set([
31 "linear",
32 "ease",
33 "ease-in",
34 "ease-out",
35 "ease-in-out",
36 "step-start",
37 "step-end"
38]);
39const TIMING_FNS = [
40 "cubic-bezier",
41 "steps"
42];
43const COMMA = /\,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubic-bezier(a, b, c)` these don't count.
44;
45const SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
46;
47const TIME = /^(-?[\d.]+m?s)$/;
48const DIGIT = /^(\d+)$/;
49function parseAnimationValue(input) {
50 let animations = input.split(COMMA);
51 return animations.map((animation)=>{
52 let value = animation.trim();
53 let result = {
54 value
55 };
56 let parts = value.split(SPACE);
57 let seen = new Set();
58 for (let part of parts){
59 if (!seen.has("DIRECTIONS") && DIRECTIONS.has(part)) {
60 result.direction = part;
61 seen.add("DIRECTIONS");
62 } else if (!seen.has("PLAY_STATES") && PLAY_STATES.has(part)) {
63 result.playState = part;
64 seen.add("PLAY_STATES");
65 } else if (!seen.has("FILL_MODES") && FILL_MODES.has(part)) {
66 result.fillMode = part;
67 seen.add("FILL_MODES");
68 } else if (!seen.has("ITERATION_COUNTS") && (ITERATION_COUNTS.has(part) || DIGIT.test(part))) {
69 result.iterationCount = part;
70 seen.add("ITERATION_COUNTS");
71 } else if (!seen.has("TIMING_FUNCTION") && TIMINGS.has(part)) {
72 result.timingFunction = part;
73 seen.add("TIMING_FUNCTION");
74 } else if (!seen.has("TIMING_FUNCTION") && TIMING_FNS.some((f)=>part.startsWith(`${f}(`))) {
75 result.timingFunction = part;
76 seen.add("TIMING_FUNCTION");
77 } else if (!seen.has("DURATION") && TIME.test(part)) {
78 result.duration = part;
79 seen.add("DURATION");
80 } else if (!seen.has("DELAY") && TIME.test(part)) {
81 result.delay = part;
82 seen.add("DELAY");
83 } else if (!seen.has("NAME")) {
84 result.name = part;
85 seen.add("NAME");
86 } else {
87 if (!result.unknown) result.unknown = [];
88 result.unknown.push(part);
89 }
90 }
91 return result;
92 });
93}
Note: See TracBrowser for help on using the repository browser.