@pyreon/kinetic-presets 0.11.1 → 0.11.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyreon/kinetic-presets",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/pyreon/pyreon",
@@ -24,7 +24,8 @@
24
24
  "!lib/**/*.map",
25
25
  "!lib/analysis",
26
26
  "README.md",
27
- "LICENSE"
27
+ "LICENSE",
28
+ "src"
28
29
  ],
29
30
  "engines": {
30
31
  "node": ">= 22"
@@ -44,6 +45,6 @@
44
45
  },
45
46
  "devDependencies": {
46
47
  "@vitus-labs/tools-rolldown": "^1.15.3",
47
- "@pyreon/typescript": "^0.11.1"
48
+ "@pyreon/typescript": "^0.11.2"
48
49
  }
49
50
  }
@@ -0,0 +1,263 @@
1
+ import { describe, expect, it } from "vitest"
2
+ import { createBlur, createFade, createRotate, createScale, createSlide } from "../factories"
3
+
4
+ describe("createFade", () => {
5
+ it("creates pure opacity fade by default", () => {
6
+ const p = createFade()
7
+ expect(p.enterStyle).toEqual({ opacity: 0 })
8
+ expect(p.enterToStyle).toEqual({ opacity: 1 })
9
+ expect(p.enterTransition).toBe("all 300ms ease-out")
10
+ expect(p.leaveTransition).toBe("all 200ms ease-in")
11
+ })
12
+
13
+ it("creates directional fade", () => {
14
+ const p = createFade({ direction: "up", distance: 24 })
15
+ expect(p.enterStyle).toEqual({
16
+ opacity: 0,
17
+ transform: "translateY(24px)",
18
+ })
19
+ expect(p.enterToStyle).toEqual({
20
+ opacity: 1,
21
+ transform: "translateY(0)",
22
+ })
23
+ })
24
+
25
+ it("creates fade with all directions", () => {
26
+ expect(createFade({ direction: "up" }).enterStyle).toHaveProperty(
27
+ "transform",
28
+ "translateY(16px)",
29
+ )
30
+ expect(createFade({ direction: "down" }).enterStyle).toHaveProperty(
31
+ "transform",
32
+ "translateY(-16px)",
33
+ )
34
+ expect(createFade({ direction: "left" }).enterStyle).toHaveProperty(
35
+ "transform",
36
+ "translateX(16px)",
37
+ )
38
+ expect(createFade({ direction: "right" }).enterStyle).toHaveProperty(
39
+ "transform",
40
+ "translateX(-16px)",
41
+ )
42
+ })
43
+
44
+ it("custom duration and easing", () => {
45
+ const p = createFade({
46
+ duration: 500,
47
+ leaveDuration: 300,
48
+ easing: "linear",
49
+ })
50
+ expect(p.enterTransition).toBe("all 500ms linear")
51
+ expect(p.leaveTransition).toBe("all 300ms ease-in")
52
+ })
53
+
54
+ it("custom leave easing", () => {
55
+ const p = createFade({ leaveEasing: "linear" })
56
+ expect(p.leaveTransition).toBe("all 200ms linear")
57
+ })
58
+
59
+ it("populates all six preset fields for non-directional", () => {
60
+ const p = createFade()
61
+ expect(p.leaveStyle).toEqual({ opacity: 1 })
62
+ expect(p.leaveToStyle).toEqual({ opacity: 0 })
63
+ })
64
+
65
+ it("populates all six preset fields for directional", () => {
66
+ const p = createFade({ direction: "up" })
67
+ expect(p.leaveStyle).toEqual({ opacity: 1, transform: "translateY(0)" })
68
+ expect(p.leaveToStyle).toEqual({ opacity: 0, transform: "translateY(16px)" })
69
+ })
70
+ })
71
+
72
+ describe("createSlide", () => {
73
+ it("defaults to up direction with 16px", () => {
74
+ const p = createSlide()
75
+ expect(p.enterStyle).toEqual({
76
+ opacity: 0,
77
+ transform: "translateY(16px)",
78
+ })
79
+ })
80
+
81
+ it("custom direction and distance", () => {
82
+ const p = createSlide({ direction: "right", distance: 32 })
83
+ expect(p.enterStyle).toEqual({
84
+ opacity: 0,
85
+ transform: "translateX(-32px)",
86
+ })
87
+ expect(p.enterToStyle).toEqual({
88
+ opacity: 1,
89
+ transform: "translateX(0)",
90
+ })
91
+ })
92
+
93
+ it("is symmetric", () => {
94
+ const p = createSlide({ direction: "left", distance: 20 })
95
+ expect(p.enterStyle).toEqual(p.leaveToStyle)
96
+ expect(p.enterToStyle).toEqual(p.leaveStyle)
97
+ })
98
+
99
+ it("down direction", () => {
100
+ const p = createSlide({ direction: "down" })
101
+ expect(p.enterStyle).toEqual({
102
+ opacity: 0,
103
+ transform: "translateY(-16px)",
104
+ })
105
+ })
106
+
107
+ it("custom duration and easing", () => {
108
+ const p = createSlide({
109
+ duration: 400,
110
+ leaveDuration: 100,
111
+ easing: "linear",
112
+ leaveEasing: "ease-out",
113
+ })
114
+ expect(p.enterTransition).toBe("all 400ms linear")
115
+ expect(p.leaveTransition).toBe("all 100ms ease-out")
116
+ })
117
+ })
118
+
119
+ describe("createScale", () => {
120
+ it("defaults to scale(0.9)", () => {
121
+ const p = createScale()
122
+ expect(p.enterStyle).toEqual({
123
+ opacity: 0,
124
+ transform: "scale(0.9)",
125
+ })
126
+ expect(p.enterToStyle).toEqual({
127
+ opacity: 1,
128
+ transform: "scale(1)",
129
+ })
130
+ })
131
+
132
+ it("custom from value", () => {
133
+ const p = createScale({ from: 0.5 })
134
+ expect(p.enterStyle).toEqual({
135
+ opacity: 0,
136
+ transform: "scale(0.5)",
137
+ })
138
+ })
139
+
140
+ it("custom spring easing", () => {
141
+ const p = createScale({
142
+ from: 0.8,
143
+ easing: "cubic-bezier(0.34, 1.56, 0.64, 1)",
144
+ })
145
+ expect(p.enterTransition).toBe("all 300ms cubic-bezier(0.34, 1.56, 0.64, 1)")
146
+ })
147
+
148
+ it("is symmetric", () => {
149
+ const p = createScale({ from: 0.5 })
150
+ expect(p.enterStyle).toEqual(p.leaveToStyle)
151
+ expect(p.enterToStyle).toEqual(p.leaveStyle)
152
+ })
153
+
154
+ it("custom leave easing", () => {
155
+ const p = createScale({ leaveEasing: "linear" })
156
+ expect(p.leaveTransition).toBe("all 200ms linear")
157
+ })
158
+ })
159
+
160
+ describe("createRotate", () => {
161
+ it("defaults to 15 degrees", () => {
162
+ const p = createRotate()
163
+ expect(p.enterStyle).toEqual({
164
+ opacity: 0,
165
+ transform: "rotate(-15deg)",
166
+ })
167
+ expect(p.leaveToStyle).toEqual({
168
+ opacity: 0,
169
+ transform: "rotate(15deg)",
170
+ })
171
+ })
172
+
173
+ it("custom degrees", () => {
174
+ const p = createRotate({ degrees: 45 })
175
+ expect(p.enterStyle).toEqual({
176
+ opacity: 0,
177
+ transform: "rotate(-45deg)",
178
+ })
179
+ expect(p.leaveToStyle).toEqual({
180
+ opacity: 0,
181
+ transform: "rotate(45deg)",
182
+ })
183
+ })
184
+
185
+ it("negative degrees for counter-clockwise", () => {
186
+ const p = createRotate({ degrees: -90 })
187
+ expect(p.enterStyle).toEqual({
188
+ opacity: 0,
189
+ transform: "rotate(90deg)",
190
+ })
191
+ })
192
+
193
+ it("enterToStyle and leaveStyle are identity rotation", () => {
194
+ const p = createRotate()
195
+ expect(p.enterToStyle).toEqual({ opacity: 1, transform: "rotate(0)" })
196
+ expect(p.leaveStyle).toEqual({ opacity: 1, transform: "rotate(0)" })
197
+ })
198
+
199
+ it("custom duration", () => {
200
+ const p = createRotate({ duration: 600, leaveDuration: 400 })
201
+ expect(p.enterTransition).toBe("all 600ms ease-out")
202
+ expect(p.leaveTransition).toBe("all 400ms ease-in")
203
+ })
204
+ })
205
+
206
+ describe("createBlur", () => {
207
+ it("defaults to 8px blur", () => {
208
+ const p = createBlur()
209
+ expect(p.enterStyle).toEqual({
210
+ opacity: 0,
211
+ filter: "blur(8px)",
212
+ })
213
+ expect(p.enterToStyle).toEqual({
214
+ opacity: 1,
215
+ filter: "blur(0px)",
216
+ })
217
+ })
218
+
219
+ it("custom blur amount", () => {
220
+ const p = createBlur({ amount: 16 })
221
+ expect(p.enterStyle).toEqual({
222
+ opacity: 0,
223
+ filter: "blur(16px)",
224
+ })
225
+ })
226
+
227
+ it("blur with scale", () => {
228
+ const p = createBlur({ amount: 8, scale: 0.9 })
229
+ expect(p.enterStyle).toEqual({
230
+ opacity: 0,
231
+ filter: "blur(8px)",
232
+ transform: "scale(0.9)",
233
+ })
234
+ expect(p.enterToStyle).toEqual({
235
+ opacity: 1,
236
+ filter: "blur(0px)",
237
+ transform: "scale(1)",
238
+ })
239
+ })
240
+
241
+ it("custom duration", () => {
242
+ const p = createBlur({ duration: 500, leaveDuration: 250 })
243
+ expect(p.enterTransition).toBe("all 500ms ease-out")
244
+ expect(p.leaveTransition).toBe("all 250ms ease-in")
245
+ })
246
+
247
+ it("is symmetric without scale", () => {
248
+ const p = createBlur()
249
+ expect(p.enterStyle).toEqual(p.leaveToStyle)
250
+ expect(p.enterToStyle).toEqual(p.leaveStyle)
251
+ })
252
+
253
+ it("is symmetric with scale", () => {
254
+ const p = createBlur({ scale: 0.8 })
255
+ expect(p.enterStyle).toEqual(p.leaveToStyle)
256
+ expect(p.enterToStyle).toEqual(p.leaveStyle)
257
+ })
258
+
259
+ it("custom leave easing", () => {
260
+ const p = createBlur({ leaveEasing: "linear" })
261
+ expect(p.leaveTransition).toBe("all 200ms linear")
262
+ })
263
+ })