rw-elements-tools 1.2.0

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.
Files changed (185) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +1333 -0
  3. package/bin/cli.js +213 -0
  4. package/build-properties.js +654 -0
  5. package/build-shared-hooks.js +253 -0
  6. package/config.js +148 -0
  7. package/controls/Animations/AnimationEffects.js +111 -0
  8. package/controls/Animations/AnimationSettings.js +437 -0
  9. package/controls/Animations/Reveals.js +168 -0
  10. package/controls/Animations/ScrollAnimation_Opacity.js +15 -0
  11. package/controls/Animations/ScrollAnimation_Rotate.js +17 -0
  12. package/controls/Animations/ScrollAnimation_Scale.js +18 -0
  13. package/controls/Animations/ScrollAnimation_Translate.js +31 -0
  14. package/controls/Background/Background.js +66 -0
  15. package/controls/Background/BackgroundButton.js +69 -0
  16. package/controls/Background/BackgroundColor.js +28 -0
  17. package/controls/Background/BackgroundContainer.js +73 -0
  18. package/controls/Background/BackgroundGradient.js +149 -0
  19. package/controls/Background/BackgroundImage.js +108 -0
  20. package/controls/Background/BackgroundOnlyColor.js +53 -0
  21. package/controls/Background/BackgroundTransparent.js +66 -0
  22. package/controls/Background/BackgroundVideo.js +9 -0
  23. package/controls/Background/Color.js +52 -0
  24. package/controls/Background/Gradient.js +263 -0
  25. package/controls/Background/GradientContainer.js +263 -0
  26. package/controls/Background/Image.js +269 -0
  27. package/controls/Background/Image_CMS.js +305 -0
  28. package/controls/Background/SVG.js +235 -0
  29. package/controls/Background/Video.js +29 -0
  30. package/controls/Borders/Border.js +114 -0
  31. package/controls/Borders/BorderColor.js +25 -0
  32. package/controls/Borders/BorderRadius.js +19 -0
  33. package/controls/Borders/BorderStyle.js +26 -0
  34. package/controls/Borders/BorderWidth.js +20 -0
  35. package/controls/Borders/Borders.js +69 -0
  36. package/controls/Borders/BordersContainer.js +90 -0
  37. package/controls/Borders/BordersInput.js +107 -0
  38. package/controls/Borders/Outline.js +100 -0
  39. package/controls/Borders/OutlineColor.js +25 -0
  40. package/controls/Borders/OutlineOffset.js +13 -0
  41. package/controls/Borders/OutlineStyle.js +26 -0
  42. package/controls/Borders/OutlineWidth.js +13 -0
  43. package/controls/Effects/BackdropBlur.js +11 -0
  44. package/controls/Effects/Blur.js +11 -0
  45. package/controls/Effects/BoxShadow.js +15 -0
  46. package/controls/Effects/Brightness.js +11 -0
  47. package/controls/Effects/DropShadow.js +14 -0
  48. package/controls/Effects/Effects.js +71 -0
  49. package/controls/Effects/Filters.js +114 -0
  50. package/controls/Effects/Opacity.js +14 -0
  51. package/controls/Effects/Saturate.js +11 -0
  52. package/controls/Layout/AspectRatio.js +53 -0
  53. package/controls/Layout/Container.js +24 -0
  54. package/controls/Layout/Hidden.js +9 -0
  55. package/controls/Layout/Inset.js +15 -0
  56. package/controls/Layout/Isolation.js +25 -0
  57. package/controls/Layout/Layout.js +38 -0
  58. package/controls/Layout/Overflow.js +33 -0
  59. package/controls/Layout/Position.js +37 -0
  60. package/controls/Layout/TopRightBottomLeft.js +90 -0
  61. package/controls/Layout/Visibility.js +25 -0
  62. package/controls/Layout/ZIndex.js +36 -0
  63. package/controls/Overlay/Color.js +52 -0
  64. package/controls/Overlay/Gradient.js +298 -0
  65. package/controls/Overlay/Image.js +226 -0
  66. package/controls/Overlay/Overlay.js +66 -0
  67. package/controls/Sizing/Height.js +18 -0
  68. package/controls/Sizing/MaxHeight.js +17 -0
  69. package/controls/Sizing/MaxWidth.js +17 -0
  70. package/controls/Sizing/MinHeight.js +18 -0
  71. package/controls/Sizing/MinWidth.js +18 -0
  72. package/controls/Sizing/Sizing.js +66 -0
  73. package/controls/Sizing/SizingContainer.js +122 -0
  74. package/controls/Sizing/SizingImage.js +75 -0
  75. package/controls/Sizing/SizingInput.js +71 -0
  76. package/controls/Sizing/SizingSVG.js +74 -0
  77. package/controls/Sizing/Width.js +18 -0
  78. package/controls/Spacing/Margin.js +17 -0
  79. package/controls/Spacing/Padding.js +17 -0
  80. package/controls/Spacing/Spacing.js +23 -0
  81. package/controls/Spacing/SpacingButton.js +42 -0
  82. package/controls/Spacing/SpacingContainer.js +32 -0
  83. package/controls/Spacing/SpacingInput.js +42 -0
  84. package/controls/Transforms/Rotate.js +13 -0
  85. package/controls/Transforms/Scale.js +13 -0
  86. package/controls/Transforms/Skew.js +25 -0
  87. package/controls/Transforms/TransformOrigin.js +12 -0
  88. package/controls/Transforms/Transforms.js +98 -0
  89. package/controls/Transforms/Translate.js +26 -0
  90. package/controls/Transitions/Delay.js +13 -0
  91. package/controls/Transitions/Duration.js +13 -0
  92. package/controls/Transitions/Property.js +42 -0
  93. package/controls/Transitions/TimingFunction.js +44 -0
  94. package/controls/Transitions/Transitions.js +20 -0
  95. package/controls/alignment/AlignContent.js +48 -0
  96. package/controls/alignment/AlignItems.js +64 -0
  97. package/controls/alignment/AlignSelf.js +34 -0
  98. package/controls/alignment/JustifyContent.js +44 -0
  99. package/controls/alignment/JustifyItems.js +32 -0
  100. package/controls/alignment/JustifySelf.js +34 -0
  101. package/controls/core/CSSClasses.js +11 -0
  102. package/controls/core/ControlType.js +25 -0
  103. package/controls/core/HTMLTag.js +80 -0
  104. package/controls/core/HoverGroup.js +38 -0
  105. package/controls/core/ID.js +12 -0
  106. package/controls/core/Image.js +95 -0
  107. package/controls/core/MenuItem.js +187 -0
  108. package/controls/core/ObjectFit.js +32 -0
  109. package/controls/core/ObjectPosition.js +65 -0
  110. package/controls/grid-flex/ActAsGridOrFlexItem.js +54 -0
  111. package/controls/grid-flex/ColEnd.js +28 -0
  112. package/controls/grid-flex/ColStart.js +27 -0
  113. package/controls/grid-flex/Columns.js +38 -0
  114. package/controls/grid-flex/FlexDirection.js +27 -0
  115. package/controls/grid-flex/FlexItem.js +106 -0
  116. package/controls/grid-flex/GridItem.js +41 -0
  117. package/controls/grid-flex/Order.js +45 -0
  118. package/controls/grid-flex/RowEnd.js +28 -0
  119. package/controls/grid-flex/RowStart.js +27 -0
  120. package/controls/grid-flex/Rows.js +38 -0
  121. package/controls/index.js +187 -0
  122. package/controls/interactive/ButtonFontAndTextStyles.js +208 -0
  123. package/controls/interactive/Filter.js +54 -0
  124. package/controls/interactive/InputFontAndTextStyles.js +156 -0
  125. package/controls/interactive/Link.js +13 -0
  126. package/controls/typography/HeadingColor.js +112 -0
  127. package/controls/typography/TextColor.js +51 -0
  128. package/controls/typography/TextDecoration.js +99 -0
  129. package/controls/typography/TextFontsAndTextStyles.js +243 -0
  130. package/controls/typography/TextSimple.js +55 -0
  131. package/controls/typography/TextStyles.js +55 -0
  132. package/controls/typography/Typography.js +13 -0
  133. package/index.js +19 -0
  134. package/package.json +55 -0
  135. package/properties/BackgroundType.js +18 -0
  136. package/properties/ButtonSize.js +19 -0
  137. package/properties/ContainerHeights.js +23 -0
  138. package/properties/ContainerWidths.js +27 -0
  139. package/properties/FontWeight.js +16 -0
  140. package/properties/GradientDirection.js +39 -0
  141. package/properties/LetterSpacing.js +13 -0
  142. package/properties/LineHeight.js +13 -0
  143. package/properties/RevealAnimations.js +12 -0
  144. package/properties/Slider.js +10 -0
  145. package/properties/TextAlign.js +23 -0
  146. package/properties/TransformOrigins.js +43 -0
  147. package/properties/TransitionNames.js +20 -0
  148. package/properties/index.js +13 -0
  149. package/shared-hooks/animations/globalAnimations.js +141 -0
  150. package/shared-hooks/animations/globalReveal.js +48 -0
  151. package/shared-hooks/background/globalBackground.js +306 -0
  152. package/shared-hooks/background/globalBgImageFetchPriority.js +34 -0
  153. package/shared-hooks/borders/globalBorders.js +85 -0
  154. package/shared-hooks/borders/globalOutline.js +39 -0
  155. package/shared-hooks/core/addPrefixToTailwindClasses.js +24 -0
  156. package/shared-hooks/core/advancedClasses.js +5 -0
  157. package/shared-hooks/core/classnames.js +92 -0
  158. package/shared-hooks/core/getHoverPrefix.js +21 -0
  159. package/shared-hooks/core/globalHTMLTag.js +17 -0
  160. package/shared-hooks/core/injectPrefixOnDarkModeColors.js +6 -0
  161. package/shared-hooks/effects/globalEffects.js +45 -0
  162. package/shared-hooks/effects/globalFilters.js +80 -0
  163. package/shared-hooks/effects/globalOverlay.js +166 -0
  164. package/shared-hooks/interactive/globalFilter.js +24 -0
  165. package/shared-hooks/interactive/globalLink.js +23 -0
  166. package/shared-hooks/layout/globalActAsGridOrFlexItem.js +66 -0
  167. package/shared-hooks/layout/globalLayout.js +50 -0
  168. package/shared-hooks/navigation/globalMenuItem.js +35 -0
  169. package/shared-hooks/navigation/globalNavItems.js +60 -0
  170. package/shared-hooks/navigation/globalNavTitle.js +23 -0
  171. package/shared-hooks/sizing/aspectRatioClasses.js +20 -0
  172. package/shared-hooks/sizing/globalSizing.js +19 -0
  173. package/shared-hooks/sizing/globalSizingContainer.js +40 -0
  174. package/shared-hooks/sizing/objectClasses.js +9 -0
  175. package/shared-hooks/spacing/globalSpacing.js +13 -0
  176. package/shared-hooks/spacing/globalSpacingMargin.js +11 -0
  177. package/shared-hooks/spacing/globalSpacingPadding.js +11 -0
  178. package/shared-hooks/transforms/globalTransforms.js +78 -0
  179. package/shared-hooks/transitions/getAlpineTransitionAttributesDesktop.js +111 -0
  180. package/shared-hooks/transitions/getAlpineTransitionAttributesMobile.js +110 -0
  181. package/shared-hooks/transitions/globalTransitions.js +48 -0
  182. package/shared-hooks/typography/globalButtonFontAndTextStyles.js +65 -0
  183. package/shared-hooks/typography/globalHeadingColor.js +69 -0
  184. package/shared-hooks/typography/globalInputFontAndTextStyles.js +40 -0
  185. package/shared-hooks/typography/globalTextFontsAndTextStyles.js +47 -0
@@ -0,0 +1,18 @@
1
+ const BackgroundType = {
2
+ items: [
3
+ {
4
+ icon: "paintbrush",
5
+ value: "color",
6
+ },
7
+ {
8
+ icon: "photo",
9
+ value: "image",
10
+ },
11
+ {
12
+ icon: "swatchpalette",
13
+ value: "gradient",
14
+ },
15
+ ],
16
+ };
17
+
18
+ export default BackgroundType;
@@ -0,0 +1,19 @@
1
+ const ButtonSize = {
2
+ default: "md",
3
+ items: [
4
+ {
5
+ value: "sm",
6
+ title: "Small",
7
+ },
8
+ {
9
+ value: "md",
10
+ title: "Medium",
11
+ },
12
+ {
13
+ value: "lg",
14
+ title: "Large",
15
+ },
16
+ ],
17
+ };
18
+
19
+ export default ButtonSize;
@@ -0,0 +1,23 @@
1
+ const ContainerHeights = {
2
+ default: "full",
3
+ items: [
4
+ {
5
+ title: "Auto",
6
+ value: "auto"
7
+ },
8
+ {
9
+ title: "Full",
10
+ value: "full"
11
+ },
12
+ {
13
+ title: "Screen",
14
+ value: "screen"
15
+ },
16
+ {
17
+ title: "Custom",
18
+ value: "custom"
19
+ }
20
+ ]
21
+ };
22
+
23
+ export default ContainerHeights;
@@ -0,0 +1,27 @@
1
+ const ContainerWidths = {
2
+ default: "full",
3
+ items: [
4
+ {
5
+ title: "Auto",
6
+ value: "auto"
7
+ },
8
+ {
9
+ title: "Breakpoint",
10
+ value: "breakpoint"
11
+ },
12
+ {
13
+ title: "Full",
14
+ value: "full"
15
+ },
16
+ {
17
+ title: "Screen",
18
+ value: "screen"
19
+ },
20
+ {
21
+ title: "Custom",
22
+ value: "custom"
23
+ }
24
+ ]
25
+ };
26
+
27
+ export default ContainerWidths;
@@ -0,0 +1,16 @@
1
+ export const FontWeight = {
2
+ default: "400",
3
+ items: [
4
+ { value: "100", title: "Thin" },
5
+ { value: "200", title: "Extra Light" },
6
+ { value: "300", title: "Light" },
7
+ { value: "400", title: "Normal" },
8
+ { value: "500", title: "Medium" },
9
+ { value: "600", title: "Semi Bold" },
10
+ { value: "700", title: "Bold" },
11
+ { value: "800", title: "Extra Bold" },
12
+ { value: "900", title: "Black" },
13
+ ],
14
+ };
15
+
16
+ export default FontWeight;
@@ -0,0 +1,39 @@
1
+ const GradientDirection = {
2
+ default: "bg-gradient-to-b",
3
+ items: [
4
+ {
5
+ value: "bg-gradient-to-t",
6
+ title: "To Top",
7
+ },
8
+ {
9
+ value: "bg-gradient-to-tr",
10
+ title: "To Top Right",
11
+ },
12
+ {
13
+ value: "bg-gradient-to-r",
14
+ title: "To Right",
15
+ },
16
+ {
17
+ value: "bg-gradient-to-br",
18
+ title: "To Bottom Right",
19
+ },
20
+ {
21
+ value: "bg-gradient-to-b",
22
+ title: "To Bottom",
23
+ },
24
+ {
25
+ value: "bg-gradient-to-bl",
26
+ title: "To Bottom Left",
27
+ },
28
+ {
29
+ value: "bg-gradient-to-l",
30
+ title: "To Left",
31
+ },
32
+ {
33
+ value: "bg-gradient-to-tl",
34
+ title: "To Top Left",
35
+ },
36
+ ],
37
+ };
38
+
39
+ export default GradientDirection;
@@ -0,0 +1,13 @@
1
+ export const LetterSpacing = {
2
+ default: "normal",
3
+ items: [
4
+ { value: "tighter", title: "Tighter" },
5
+ { value: "tight", title: "Tight" },
6
+ { value: "normal", title: "Normal" },
7
+ { value: "wide", title: "Wide" },
8
+ { value: "wider", title: "Wider" },
9
+ { value: "widest", title: "Widest" },
10
+ ],
11
+ };
12
+
13
+ export default LetterSpacing;
@@ -0,0 +1,13 @@
1
+ export const LineHeight = {
2
+ default: "normal",
3
+ items: [
4
+ { value: "none", title: "None" },
5
+ { value: "tight", title: "Tight" },
6
+ { value: "snug", title: "Snug" },
7
+ { value: "normal", title: "Normal" },
8
+ { value: "relaxed", title: "Relaxed" },
9
+ { value: "loose", title: "Loose" },
10
+ ],
11
+ };
12
+
13
+ export default LineHeight;
@@ -0,0 +1,12 @@
1
+ export const RevealAnimations = {
2
+ default: "fade",
3
+ items: [
4
+ { value: "fade", title: "Fade" },
5
+ { value: "slide", title: "Slide" },
6
+ { value: "zoom", title: "Zoom" },
7
+ { value: "lightSpeed", title: "Light Speed" },
8
+ { value: "rotate", title: "Rotate" },
9
+ ],
10
+ };
11
+
12
+ export default RevealAnimations;
@@ -0,0 +1,10 @@
1
+ const Slider = {
2
+ default: 0,
3
+ min: 0,
4
+ max: 100,
5
+ round: true,
6
+ snap: true,
7
+ units: "px",
8
+ };
9
+
10
+ export default Slider;
@@ -0,0 +1,23 @@
1
+ export const TextAlign = {
2
+ default: "text-left",
3
+ items: [
4
+ {
5
+ value: "text-left",
6
+ icon: "text.alignleft",
7
+ },
8
+ {
9
+ value: "text-center",
10
+ icon: "text.aligncenter",
11
+ },
12
+ {
13
+ value: "text-right",
14
+ icon: "text.alignright",
15
+ },
16
+ {
17
+ value: "text-justify",
18
+ icon: "text.justify",
19
+ },
20
+ ],
21
+ };
22
+
23
+ export default TextAlign;
@@ -0,0 +1,43 @@
1
+ export const TransformOrigins = {
2
+ default: "center",
3
+ items: [
4
+ {
5
+ value: "center",
6
+ title: "Center",
7
+ },
8
+ {
9
+ value: "top",
10
+ title: "Top",
11
+ },
12
+ {
13
+ value: "top-right",
14
+ title: "Top Right",
15
+ },
16
+ {
17
+ value: "right",
18
+ title: "Right",
19
+ },
20
+ {
21
+ value: "bottom-right",
22
+ title: "Bottom Right",
23
+ },
24
+ {
25
+ value: "bottom",
26
+ title: "Bottom",
27
+ },
28
+ {
29
+ value: "bottom-left",
30
+ title: "Bottom Left",
31
+ },
32
+ {
33
+ value: "left",
34
+ title: "Left",
35
+ },
36
+ {
37
+ value: "top-left",
38
+ title: "Top Left",
39
+ },
40
+ ],
41
+ };
42
+
43
+ export default TransformOrigins;
@@ -0,0 +1,20 @@
1
+ export const TransitionNames = {
2
+ default: "dim",
3
+ items: [
4
+ {
5
+ value: "dim",
6
+ title: "Dim",
7
+ },
8
+ {
9
+ value: "zoomOut",
10
+ title: "Zoom Out",
11
+ },
12
+ {
13
+ value: "slide",
14
+ title: "Slide",
15
+ }
16
+ ],
17
+ };
18
+
19
+ export default TransitionNames;
20
+
@@ -0,0 +1,13 @@
1
+ export { default as BackgroundType } from "./BackgroundType.js";
2
+ export { default as ButtonSize } from "./ButtonSize.js";
3
+ export { default as ContainerWidths } from "./ContainerWidths.js";
4
+ export { default as ContainerHeights } from "./ContainerHeights.js";
5
+ export { default as FontWeight } from "./FontWeight.js";
6
+ export { default as GradientDirection } from "./GradientDirection.js";
7
+ export { default as LetterSpacing } from "./LetterSpacing.js";
8
+ export { default as LineHeight } from "./LineHeight.js";
9
+ export { default as RevealAnimations } from "./RevealAnimations.js";
10
+ export { default as Slider } from "./Slider.js";
11
+ export { default as TextAlign } from "./TextAlign.js";
12
+ export { default as TransformOrigins } from "./TransformOrigins.js";
13
+ export { default as TransitionNames } from "./TransitionNames.js";
@@ -0,0 +1,141 @@
1
+ const globalAnimations = (app) => {
2
+ const {
3
+ globalScrollAnimationPreviewInEditor: previewInEditor,
4
+
5
+ globalScrollAnimationTrigger: triggerType, // none, instant, inView, scroll
6
+
7
+ globalScrollAnimationEase: ease,
8
+ globalScrollAnimationEaseCustom: easeCustom,
9
+ globalScrollAnimationEaseSteps: easeSteps,
10
+ globalScrollAnimationOrigin: origin,
11
+ globalScrollAnimationDuration: duration,
12
+ globalScrollAnimationDelay: delay,
13
+
14
+ // inView
15
+ globalScrollAnimationAmount: amount,
16
+
17
+ // spring
18
+ globalScrollAnimationIsSpring: isSpring,
19
+ globalScrollAnimationSpringStrength: springStrength,
20
+ globalScrollAnimationSpringAmplitude: springAmplitude,
21
+
22
+ // trigger positions
23
+ globalScrollAnimationTriggerElementPositionEnter: triggerElementPositionEnter,
24
+ globalScrollAnimationTriggerViewportPositionEnter: triggerViewportPositionEnter,
25
+ globalScrollAnimationTriggerElementPositionExit: triggerElementPositionExit,
26
+ globalScrollAnimationTriggerViewportPositionExit: triggerViewportPositionExit,
27
+
28
+
29
+ // margin
30
+ globalScrollAnimationMarginTop: marginTop,
31
+ globalScrollAnimationMarginBottom: marginBottom,
32
+
33
+ // repeat
34
+ globalScrollAnimationRepeat: repeat,
35
+ globalScrollAnimationRepeatTimes: repeatTimes,
36
+ globalScrollAnimationRepeatYoyo: repeatYoyo,
37
+ globalScrollAnimationRepeatDelay: repeatDelay,
38
+
39
+ // Effects
40
+ // - start
41
+ globalScrollAnimationEnterState: enterState,
42
+ globalScrollAnimationOpacityEnterStart: opacityEnterStart,
43
+ globalScrollAnimationRotateEnterStart: rotateEnterStart,
44
+ globalScrollAnimationScaleEnterStart: scaleEnterStart,
45
+ globalScrollAnimationTranslateXEnterStart: translateXEnterStart,
46
+ globalScrollAnimationTranslateYEnterStart: translateYEnterStart,
47
+ // - end
48
+ globalScrollAnimationOpacityEnterEnd: opacityEnterEnd,
49
+ globalScrollAnimationRotateEnterEnd: rotateEnterEnd,
50
+ globalScrollAnimationScaleEnterEnd: scaleEnterEnd,
51
+ globalScrollAnimationTranslateXEnterEnd: translateXEnterEnd,
52
+ globalScrollAnimationTranslateYEnterEnd: translateYEnterEnd,
53
+
54
+ // exit
55
+ globalScrollAnimationExitEnabled: exitEnabled,
56
+ globalScrollAnimationOpacityExitEnd: opacityExitEnd,
57
+ globalScrollAnimationRotateExitEnd: rotateExitEnd,
58
+ globalScrollAnimationScaleExitEnd: scaleExitEnd,
59
+ globalScrollAnimationTranslateXExitEnd: translateXExitEnd,
60
+ globalScrollAnimationTranslateYExitEnd: translateYExitEnd,
61
+ } = app.props;
62
+
63
+ const { mode } = app.project;
64
+ const gsapEase = isSpring ? `elastic.out(${springAmplitude}, ${springStrength})` : ease;
65
+ const gsapMargin = (value) => value < 0 ? `-=${Math.abs(value)}` : `+=${value}`;
66
+ const scrollTriggerStart = `${triggerElementPositionEnter}${gsapMargin(marginTop)} ${triggerViewportPositionEnter}${gsapMargin(marginBottom)}`;
67
+ const scrollTriggerEnd = `${triggerElementPositionExit}${gsapMargin(marginTop)} ${triggerViewportPositionExit}${gsapMargin(marginBottom)}`;
68
+
69
+ const wantsRepeat = triggerType == 'instant' && repeat != 'false';
70
+ const gsapRepeat = !wantsRepeat
71
+ ? false
72
+ : {
73
+ repeat: repeat == 'infinite' ? -1 : repeatTimes,
74
+ yoyo: repeatYoyo ? true : false,
75
+ repeatDelay: repeatDelay/1000,
76
+ }
77
+
78
+ const onEnterFrom = {
79
+ opacity: opacityEnterStart/100,
80
+ rotation: rotateEnterStart,
81
+ scale: scaleEnterStart/100,
82
+ x: `${translateXEnterStart}%`,
83
+ y: `${translateYEnterStart}%`,
84
+ autoAlpha: 0,
85
+ duration: duration/1000,
86
+ ease: gsapEase,
87
+ transformOrigin: origin.replace("-", " "),
88
+ }
89
+
90
+ const onEnterTo = {
91
+ opacity: opacityEnterEnd/100,
92
+ rotation: rotateEnterEnd,
93
+ scale: scaleEnterEnd/100,
94
+ x: `${translateXEnterEnd}%`,
95
+ y: `${translateYEnterEnd}%`,
96
+ autoAlpha: 1,
97
+ duration: duration/1000,
98
+ ease: gsapEase,
99
+ transformOrigin: origin.replace("-", " "),
100
+ }
101
+
102
+ const onLeaveTo = {
103
+ opacity: opacityExitEnd/100,
104
+ rotation: rotateExitEnd,
105
+ scale: scaleExitEnd/100,
106
+ x: `${translateXExitEnd}%`,
107
+ y: `${translateYExitEnd}%`,
108
+ autoAlpha: 0,
109
+ duration: duration/1000,
110
+ ease: gsapEase,
111
+ transformOrigin: origin.replace("-", " "),
112
+ }
113
+
114
+ const cssVarsFrom = Object.entries(onEnterFrom).map(([key, value]) => `[--scroll-animation-from-${key}:${value}]`).join(" ");
115
+ const cssVarsTo = Object.entries(onEnterTo).map(([key, value]) => `[--scroll-animation-to-${key}:${value}]`).join(" ");
116
+
117
+ return {
118
+ isEnabled: triggerType != "none",
119
+ isScroll: triggerType == "scroll",
120
+ isInView: triggerType == "inView",
121
+ isInstant: triggerType == "instant",
122
+ isExitEnabled: exitEnabled,
123
+ previewInEditor: previewInEditor && mode == "edit",
124
+ editorPreviewCSSVars: {
125
+ from: cssVarsFrom,
126
+ to: cssVarsTo,
127
+ duration: `${duration/1000}s`,
128
+ delay: `${delay/1000}s`,
129
+ },
130
+ data: {
131
+ "data-animation": "true",
132
+ "data-animation-trigger-type": triggerType,
133
+ "data-animation-enter-from": JSON.stringify(onEnterFrom).replace(/"/g, '&quot;'),
134
+ "data-animation-enter-to": JSON.stringify(onEnterTo).replace(/"/g, '&quot;'),
135
+ "data-animation-exit-to": JSON.stringify(onLeaveTo).replace(/"/g, '&quot;'),
136
+ "data-animation-trigger-start": scrollTriggerStart,
137
+ "data-animation-trigger-end": scrollTriggerEnd,
138
+ "data-animation-repeat": gsapRepeat ? JSON.stringify(gsapRepeat).replace(/"/g, '&quot;') : false
139
+ },
140
+ };
141
+ };
@@ -0,0 +1,48 @@
1
+ const globalReveal = (rw) => {
2
+ const {
3
+ revealAnimationName: name,
4
+ revealAnimationDirection: direction,
5
+ revealPlay: play,
6
+ revealStart: start,
7
+ revealEnd: end,
8
+ revealDuration: duration,
9
+ revealDelay: delay,
10
+ revealEasing: easing,
11
+ revealDistance: distance,
12
+ revealDegrees: degrees,
13
+ revealScrub: scrub,
14
+ revealDebug: debug,
15
+ } = rw.props;
16
+
17
+ const { title } = rw.node;
18
+ const revealID = `reveal-${title.replace(/\s+/g, '-').toLowerCase()}`;
19
+
20
+ const gsapTriggerPoints = {
21
+ "entering-screen": "top bottom",
22
+ "middle-of-screen": "top center",
23
+ "exiting-screen": "top top",
24
+ };
25
+
26
+ const animationName = `${name}${direction.charAt(0).toUpperCase() + direction.slice(1)}In`;
27
+ const exitAnimationName = animationName.replace("In", "Out");
28
+
29
+ const data = {
30
+ "data-reveal": "",
31
+ "data-reveal-id": revealID,
32
+ "data-reveal-duration": `${duration/1000}`,
33
+ "data-reveal-delay": `${delay/1000}`,
34
+ "data-reveal-easing": easing,
35
+ "data-reveal-animation": animationName,
36
+ "data-reveal-exit-animation": exitAnimationName,
37
+ "data-reveal-play": play,
38
+ "data-reveal-start": gsapTriggerPoints[start] || gsapTriggerPoints["entering-screen"],
39
+ "data-reveal-end": gsapTriggerPoints[end] || gsapTriggerPoints["exiting-screen"],
40
+ "data-reveal-distance": distance,
41
+ "data-reveal-degrees": degrees,
42
+ "data-reveal-scrub": scrub || false,
43
+ "data-reveal-debug": debug || false,
44
+ }
45
+
46
+ return data;
47
+
48
+ };