with-style 5.0.203 → 5.0.206

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ import { Query } from "occam-query";
4
+
5
+ import Keyframe from "./keyframe";
6
+
7
+ import { EMPTY_STRING, TWO_SPACES } from "../constants";
8
+ import { contentFromQueryNodeAndTokens } from "../utilities/content";
9
+
10
+ const keyframeQuery = Query.fromExpression("/keyframes/keyframe"),
11
+ identifierQuery = Query.fromExpression("/keyframes/@identifier");
12
+
13
+ export default class Keyframes {
14
+ constructor(array, identifier) {
15
+ this.array = array;
16
+ this.identifier = identifier;
17
+ }
18
+
19
+ getIdentifier() {
20
+ return this.identifier;
21
+ }
22
+
23
+ asCSS(indent) {
24
+ indent = indent + TWO_SPACES;
25
+
26
+ const keyframesCSS = this.array.reduce((keyframesCSS, keyframe) => {
27
+ const keyframeCSS = keyframe.asCSS(indent);
28
+
29
+ keyframesCSS += keyframeCSS;
30
+
31
+ return keyframesCSS;
32
+ }, EMPTY_STRING),
33
+ css = `@keyframes ${this.identifier} {
34
+ ${keyframesCSS}}
35
+
36
+ `;
37
+
38
+ return css;
39
+ }
40
+
41
+ static fromNodeAndTokens(node, tokens) {
42
+ const keyframeNodes = keyframeQuery.execute(node),
43
+ array = keyframeNodes.map((keyframeNode) => {
44
+ const node = keyframeNode, ///
45
+ keyframe = Keyframe.fromNodeAndTokens(node, tokens);
46
+
47
+ return keyframe;
48
+ }),
49
+ identifierContent = contentFromQueryNodeAndTokens(identifierQuery, node, tokens),
50
+ identifier = identifierContent, ///
51
+ keyframes = new Keyframes(array, identifier);
52
+
53
+ return keyframes;
54
+ }
55
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ import { Query } from "occam-query";
4
+
5
+ import Keyframes from "./keyframes";
6
+
7
+ import { EMPTY_STRING } from "../constants";
8
+
9
+ const keyframesQuery = Query.fromExpression("/stylesheet/keyframes");
10
+
11
+ export default class Keyframess {
12
+ constructor(array) {
13
+ this.array = array;
14
+ }
15
+
16
+ unshift(keyframess) {
17
+ ///
18
+ }
19
+
20
+ forEach(callback) {
21
+ this.array.forEach(callback);
22
+ }
23
+
24
+ asCSS(className, indent) {
25
+ const css = this.array.reduce((css, keyframes) => {
26
+ const keyframesCSS = keyframes.asCSS(indent);
27
+
28
+ css += keyframesCSS;
29
+
30
+ return css;
31
+ }, EMPTY_STRING);
32
+
33
+ return css;
34
+ }
35
+
36
+ static fromNodeAndTokens(node, tokens) {
37
+ const keyframesNodes = keyframesQuery.execute(node),
38
+ array = keyframesNodes.map((keyframesNode) => {
39
+ const node = keyframesNode, ///
40
+ keyframes = Keyframes.fromNodeAndTokens(node, tokens);
41
+
42
+ return keyframes;
43
+ }),
44
+ keyframess = new Keyframess(array);
45
+
46
+ return keyframess;
47
+ }
48
+ }
package/src/style.js CHANGED
@@ -2,13 +2,15 @@
2
2
 
3
3
  import Medias from "./style/medias";
4
4
  import RuleSets from "./style/ruleSets";
5
+ import Keyframess from "./style/keyframess";
5
6
  import Declarations from "./style/declarations";
6
7
 
7
8
  import { EMPTY_STRING } from "./constants";
8
9
 
9
10
  export default class Style {
10
- constructor(declarations, ruleSets, medias) {
11
+ constructor(declarations, keyframess, ruleSets, medias) {
11
12
  this.declarations = declarations;
13
+ this.keyframess = keyframess;
12
14
  this.ruleSets = ruleSets;
13
15
  this.medias = medias;
14
16
  }
@@ -17,6 +19,10 @@ export default class Style {
17
19
  return this.declarations;
18
20
  }
19
21
 
22
+ getKeyframess() {
23
+ return this.keyframess;
24
+ }
25
+
20
26
  getRuleSets() {
21
27
  return this.ruleSets;
22
28
  }
@@ -27,14 +33,16 @@ export default class Style {
27
33
 
28
34
  extends(superStyle) {
29
35
  const declarations = superStyle.getDeclarations(),
36
+ keyframess = superStyle.getKeyframess(),
30
37
  ruleSets = superStyle.getRuleSets(),
31
38
  medias = superStyle.getMedias();
32
39
 
33
- this.unshift(declarations, ruleSets, medias);
40
+ this.unshift(declarations, keyframess, ruleSets, medias);
34
41
  }
35
42
 
36
- unshift(declarations, ruleSets, medias) {
43
+ unshift(declarations, keyframess, ruleSets, medias) {
37
44
  this.declarations.unshift(declarations);
45
+ this.keyframess.unshift(keyframess);
38
46
  this.ruleSets.unshift(ruleSets);
39
47
  this.medias.unshift(medias);
40
48
  }
@@ -42,18 +50,20 @@ export default class Style {
42
50
  asCSS(className) {
43
51
  const indent = EMPTY_STRING,
44
52
  declarationsCSS = this.declarations.asCSS(className, indent),
53
+ keyframessCSS = this.keyframess.asCSS(className, indent),
45
54
  ruleSetsCSS = this.ruleSets.asCSS(className, indent),
46
55
  mediasCSS = this.medias.asCSS(className, indent),
47
- css = `${declarationsCSS}${ruleSetsCSS}${mediasCSS}`;
56
+ css = `${declarationsCSS}${keyframessCSS}${ruleSetsCSS}${mediasCSS}`;
48
57
 
49
58
  return css;
50
59
  }
51
60
 
52
61
  static fromNodeAndTokens(node, tokens) {
53
62
  const declarations = Declarations.fromNodeAndTokens(node, tokens),
63
+ keyframess = Keyframess.fromNodeAndTokens(node, tokens),
54
64
  ruleSets = RuleSets.fromNodeAndTokens(node, tokens),
55
65
  medias = Medias.fromNodeAndTokens(node, tokens),
56
- style = new Style(declarations, ruleSets, medias);
66
+ style = new Style(declarations, keyframess, ruleSets, medias);
57
67
 
58
68
  return style;
59
69
  }