pixedi 1.0.0 → 1.0.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.
Files changed (113) hide show
  1. package/README.md +65 -60
  2. package/README.npm.md +80 -0
  3. package/dist/lib/index.js +1602 -0
  4. package/dist/lib/index.umd.js +28 -0
  5. package/package.json +9 -4
  6. package/.github/workflows/deploy.yml +0 -54
  7. package/.prettierr +0 -9
  8. package/.storybook/main.ts +0 -16
  9. package/.storybook/preview.ts +0 -53
  10. package/.vscode/extensions.json +0 -6
  11. package/eslint.config.js +0 -22
  12. package/index.html +0 -13
  13. package/pnpm-workspace.yaml +0 -2
  14. package/public/favicon.svg +0 -1
  15. package/src/app/App.tsx +0 -10
  16. package/src/app/entries/index.ts +0 -145
  17. package/src/app/providers/RouterProvider.tsx +0 -6
  18. package/src/app/providers/index.ts +0 -1
  19. package/src/app/router/AppRouter.tsx +0 -12
  20. package/src/app/router/index.ts +0 -0
  21. package/src/app/styles/index.css +0 -4
  22. package/src/features/gallery/GalleryPage.tsx +0 -33
  23. package/src/features/gallery/ImageEditPage.tsx +0 -37
  24. package/src/features/gallery/index.ts +0 -2
  25. package/src/main.tsx +0 -10
  26. package/src/shared/components/ImageCard/ImageCard.tsx +0 -54
  27. package/src/shared/components/ImageCard/index.ts +0 -1
  28. package/src/shared/components/ImageEditor/ImageEditor.tsx +0 -48
  29. package/src/shared/components/ImageEditor/assets/icons.tsx +0 -114
  30. package/src/shared/components/ImageEditor/constants.ts +0 -118
  31. package/src/shared/components/ImageEditor/crop/Crop.tsx +0 -60
  32. package/src/shared/components/ImageEditor/crop/CropBorders.tsx +0 -28
  33. package/src/shared/components/ImageEditor/crop/CropLines.tsx +0 -8
  34. package/src/shared/components/ImageEditor/crop/CropPointer.tsx +0 -21
  35. package/src/shared/components/ImageEditor/crop/CropPointers.tsx +0 -44
  36. package/src/shared/components/ImageEditor/crop/CropTools.tsx +0 -138
  37. package/src/shared/components/ImageEditor/crop/crop.css +0 -180
  38. package/src/shared/components/ImageEditor/crop/index.ts +0 -8
  39. package/src/shared/components/ImageEditor/crop/useCropInteraction.ts +0 -230
  40. package/src/shared/components/ImageEditor/eventBus.ts +0 -8
  41. package/src/shared/components/ImageEditor/frame/Frame.tsx +0 -48
  42. package/src/shared/components/ImageEditor/frame/frame.css +0 -40
  43. package/src/shared/components/ImageEditor/frame/index.ts +0 -1
  44. package/src/shared/components/ImageEditor/header/Header.tsx +0 -81
  45. package/src/shared/components/ImageEditor/header/header.css +0 -27
  46. package/src/shared/components/ImageEditor/header/index.ts +0 -1
  47. package/src/shared/components/ImageEditor/hooks/index.ts +0 -5
  48. package/src/shared/components/ImageEditor/hooks/useAbove.tsx +0 -18
  49. package/src/shared/components/ImageEditor/hooks/useBellow.tsx +0 -18
  50. package/src/shared/components/ImageEditor/hooks/useImageLoader.tsx +0 -110
  51. package/src/shared/components/ImageEditor/hooks/useImageProcessor.test.tsx +0 -147
  52. package/src/shared/components/ImageEditor/hooks/useImageProcessor.ts +0 -225
  53. package/src/shared/components/ImageEditor/hooks/useMobile.tsx +0 -33
  54. package/src/shared/components/ImageEditor/index.css +0 -145
  55. package/src/shared/components/ImageEditor/index.ts +0 -1
  56. package/src/shared/components/ImageEditor/provider/ImageEditorProvider.test.tsx +0 -126
  57. package/src/shared/components/ImageEditor/provider/ImageEditorProvider.tsx +0 -107
  58. package/src/shared/components/ImageEditor/provider/StoreContext.tsx +0 -20
  59. package/src/shared/components/ImageEditor/provider/initialState.ts +0 -30
  60. package/src/shared/components/ImageEditor/provider/useImageEditorContext.tsx +0 -12
  61. package/src/shared/components/ImageEditor/resize/ResizeTools.tsx +0 -183
  62. package/src/shared/components/ImageEditor/resize/index.ts +0 -1
  63. package/src/shared/components/ImageEditor/resize/resize.css +0 -56
  64. package/src/shared/components/ImageEditor/sidebar/Sidebar.tsx +0 -54
  65. package/src/shared/components/ImageEditor/sidebar/SidebarCrop.tsx +0 -57
  66. package/src/shared/components/ImageEditor/sidebar/SidebarPresets.tsx +0 -54
  67. package/src/shared/components/ImageEditor/sidebar/SidebarResize.tsx +0 -26
  68. package/src/shared/components/ImageEditor/sidebar/index.ts +0 -1
  69. package/src/shared/components/ImageEditor/sidebar/sidebar.css +0 -101
  70. package/src/shared/components/ImageEditor/types.ts +0 -59
  71. package/src/shared/components/ImageEditor/ui/button/Button.stories.tsx +0 -42
  72. package/src/shared/components/ImageEditor/ui/button/Button.tsx +0 -21
  73. package/src/shared/components/ImageEditor/ui/button/button.css +0 -69
  74. package/src/shared/components/ImageEditor/ui/button-crop/ButtonCrop.stories.tsx +0 -26
  75. package/src/shared/components/ImageEditor/ui/button-crop/ButtonCrop.tsx +0 -29
  76. package/src/shared/components/ImageEditor/ui/button-crop/button-crop.css +0 -38
  77. package/src/shared/components/ImageEditor/ui/index.ts +0 -6
  78. package/src/shared/components/ImageEditor/ui/input/Input.stories.tsx +0 -45
  79. package/src/shared/components/ImageEditor/ui/input/Input.tsx +0 -20
  80. package/src/shared/components/ImageEditor/ui/input/input.css +0 -48
  81. package/src/shared/components/ImageEditor/ui/input-pixel/InputPixel.stories.tsx +0 -33
  82. package/src/shared/components/ImageEditor/ui/input-pixel/InputPixel.tsx +0 -23
  83. package/src/shared/components/ImageEditor/ui/input-pixel/input-pixel.css +0 -24
  84. package/src/shared/components/ImageEditor/ui/select/Select.stories.tsx +0 -67
  85. package/src/shared/components/ImageEditor/ui/select/Select.tsx +0 -161
  86. package/src/shared/components/ImageEditor/ui/select/select.css +0 -147
  87. package/src/shared/components/ImageEditor/ui/separator/Separator.stories.tsx +0 -37
  88. package/src/shared/components/ImageEditor/ui/separator/Separator.tsx +0 -27
  89. package/src/shared/components/ImageEditor/ui/separator/separator.css +0 -19
  90. package/src/shared/components/ImageEditor/utils.test.ts +0 -136
  91. package/src/shared/components/ImageEditor/utils.ts +0 -497
  92. package/src/shared/components/ui/index.ts +0 -1
  93. package/src/shared/components/ui/preloader.tsx +0 -78
  94. package/src/shared/config/index.ts +0 -3
  95. package/src/shared/config/routes.ts +0 -4
  96. package/src/shared/features/gallery/GalleryPage.tsx +0 -33
  97. package/src/shared/features/gallery/ImageEditPage.tsx +0 -37
  98. package/src/shared/features/gallery/index.ts +0 -2
  99. package/src/shared/hooks/index.ts +0 -1
  100. package/src/shared/hooks/useImagePreload.tsx +0 -49
  101. package/src/shared/types/index.ts +0 -11
  102. package/src/test/setup.ts +0 -14
  103. package/src/virtual-css-injected-by-js.d.ts +0 -8
  104. package/src/widget.tsx +0 -119
  105. package/tsconfig.app.json +0 -29
  106. package/tsconfig.json +0 -12
  107. package/tsconfig.lib.json +0 -18
  108. package/tsconfig.node.json +0 -23
  109. package/vite-env.d.ts +0 -1
  110. package/vite.config.ts +0 -24
  111. package/vite.lib.config.ts +0 -33
  112. package/vite.widget.config.ts +0 -39
  113. package/wrangler.json +0 -5
@@ -1,136 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import {
3
- degree2Rad,
4
- getCropByNewSizes,
5
- getCropPoints,
6
- getInitalCrop,
7
- } from "./utils";
8
-
9
- const element = {
10
- offsetLeft: 10,
11
- offsetTop: 20,
12
- offsetWidth: 80,
13
- offsetHeight: 60,
14
- } as HTMLElement;
15
-
16
- describe("getInitalCrop", () => {
17
- it.each([
18
- [1, 200, 100, { x: 30, y: 10, w: 40, h: 80 }],
19
- [
20
- 16 / 9,
21
- 200,
22
- 100,
23
- { x: 14.444444444444446, y: 10, w: 71.11111111111111, h: 80 },
24
- ],
25
- [9 / 16, 200, 100, { x: 38.75, y: 10, w: 22.5, h: 80 }],
26
- [1, 100, 200, { x: 10, y: 30, w: 80, h: 40 }],
27
- ])(
28
- "centers a %s crop inside a %sx%s frame",
29
- (ratio, width, height, expected) => {
30
- const crop = getInitalCrop(ratio, width, height);
31
-
32
- expect(crop.x).toBeCloseTo(expected.x);
33
- expect(crop.y).toBeCloseTo(expected.y);
34
- expect(crop.w).toBeCloseTo(expected.w);
35
- expect(crop.h).toBeCloseTo(expected.h);
36
- expect(crop.x + crop.w / 2).toBeCloseTo(50);
37
- expect(crop.y + crop.h / 2).toBeCloseTo(50);
38
- },
39
- );
40
- });
41
-
42
- describe("getCropPoints", () => {
43
- it("keeps free-form edge resizing within the frame and minimum width", () => {
44
- const crop = getCropPoints(
45
- "r",
46
- true,
47
- 1,
48
- 100,
49
- 0,
50
- -100,
51
- 0,
52
- 100,
53
- 100,
54
- { x: 10, y: 20, w: 40, h: 50 },
55
- element,
56
- );
57
-
58
- expect(crop).toEqual({ x: 10, y: 20, w: 32, h: 50 });
59
- });
60
-
61
- it("keeps free-form corner resizing within parent bounds", () => {
62
- const crop = getCropPoints(
63
- "br",
64
- true,
65
- 1,
66
- 0,
67
- 0,
68
- 200,
69
- 200,
70
- 100,
71
- 100,
72
- { x: 20, y: 30, w: 40, h: 40 },
73
- element,
74
- );
75
-
76
- expect(crop).toEqual({ x: 20, y: 30, w: 80, h: 70 });
77
- });
78
-
79
- it("preserves fixed ratios when the requested resize remains valid", () => {
80
- const crop = getCropPoints(
81
- "r",
82
- false,
83
- 2,
84
- 100,
85
- 0,
86
- 120,
87
- 0,
88
- 200,
89
- 200,
90
- { x: 50, y: 50, w: 80, h: 40 },
91
- element,
92
- );
93
-
94
- expect(crop).toEqual({ x: 50, y: 45, w: 100, h: 50 });
95
- expect(crop.w / crop.h).toBe(2);
96
- });
97
-
98
- it("restores the element rectangle for invalid fixed-ratio resizes", () => {
99
- const crop = getCropPoints(
100
- "r",
101
- false,
102
- 2,
103
- 100,
104
- 0,
105
- 200,
106
- 0,
107
- 100,
108
- 100,
109
- { x: 10, y: 20, w: 80, h: 40 },
110
- element,
111
- );
112
-
113
- expect(crop).toEqual({ x: 10, y: 20, w: 80, h: 60 });
114
- });
115
- });
116
-
117
- describe("crop utility helpers", () => {
118
- it("rescales crop rectangles and clamps their visible bounds", () => {
119
- expect(
120
- getCropByNewSizes({ x: -1, y: 10, w: 80, h: 60 }, 100, 50, 50),
121
- ).toEqual({
122
- x: 0,
123
- y: 20,
124
- w: 100,
125
- h: 50,
126
- });
127
- });
128
-
129
- it.each([
130
- [0, 0],
131
- [90, Math.PI / 2],
132
- [180, Math.PI],
133
- ])("converts %s degrees to radians", (degrees, radians) => {
134
- expect(degree2Rad(degrees)).toBeCloseTo(radians);
135
- });
136
- });
@@ -1,497 +0,0 @@
1
- import type { CropRect, Direction } from "./types";
2
-
3
- const minSize = 32;
4
-
5
- const getDefaultCrop = (el: HTMLElement): CropRect => ({
6
- x: el.offsetLeft,
7
- y: el.offsetTop,
8
- w: el.offsetWidth,
9
- h: el.offsetHeight,
10
- });
11
-
12
- const getCropR = (
13
- isFree: boolean,
14
- ratio: number,
15
- startX: number,
16
- clientX: number,
17
- width: number,
18
- height: number,
19
- crop: CropRect,
20
- el: HTMLElement,
21
- ): CropRect => {
22
- const { x } = crop;
23
- let { y, w, h } = crop;
24
-
25
- if (isFree) {
26
- w += clientX - startX;
27
- if (w + x > width) w = width - x;
28
- if (w < minSize) w = minSize;
29
- } else {
30
- const difW = clientX - startX;
31
- const difH = Math.round(difW / ratio);
32
- w += difW;
33
- h += difH;
34
- y -= difH / 2;
35
- if (
36
- y < 0 ||
37
- h + y > height ||
38
- w + x > width ||
39
- w < minSize ||
40
- h < minSize
41
- ) {
42
- return getDefaultCrop(el);
43
- }
44
- }
45
-
46
- return { x, y, w, h };
47
- };
48
-
49
- const getCropL = (
50
- isFree: boolean,
51
- ratio: number,
52
- startX: number,
53
- clientX: number,
54
- width: number,
55
- height: number,
56
- crop: CropRect,
57
- el: HTMLElement,
58
- ): CropRect => {
59
- let { x, y, w, h } = crop;
60
-
61
- if (isFree) {
62
- const right = width - crop.w - crop.x;
63
- x += clientX - startX;
64
- if (x < 0) x = 0;
65
- w = width - x - right;
66
- if (w < minSize) {
67
- w = minSize;
68
- x = width - right - minSize;
69
- }
70
- } else {
71
- const difW = clientX - startX;
72
- const difH = Math.round(difW / ratio);
73
- w -= difW;
74
- h -= difH;
75
- x += difW;
76
- y += difH / 2;
77
- if (y < 0 || x < 0 || h + y > height || w < minSize || h < minSize) {
78
- return getDefaultCrop(el);
79
- }
80
- }
81
-
82
- return { x, y, w, h };
83
- };
84
-
85
- const getCropT = (
86
- isFree: boolean,
87
- ratio: number,
88
- startY: number,
89
- clientY: number,
90
- width: number,
91
- height: number,
92
- crop: CropRect,
93
- el: HTMLElement,
94
- ): CropRect => {
95
- let { x, y, w, h } = crop;
96
-
97
- const bottom = height - h - y;
98
- if (isFree) {
99
- y += clientY - startY;
100
- if (y < 0) y = 0;
101
- h = height - y - bottom;
102
- if (h < minSize) {
103
- h = minSize;
104
- y = height - bottom - minSize;
105
- }
106
- } else {
107
- const difH = clientY - startY;
108
- const difW = Math.round(difH * ratio);
109
- h -= difH;
110
- w -= difW;
111
- x += difW / 2;
112
- y += difH;
113
- if (y < 0 || x < 0 || w + x > width || w < minSize || h < minSize) {
114
- return getDefaultCrop(el);
115
- }
116
- }
117
-
118
- return { x, y, w, h };
119
- };
120
-
121
- const getCropB = (
122
- isFree: boolean,
123
- ratio: number,
124
- startY: number,
125
- clientY: number,
126
- width: number,
127
- height: number,
128
- crop: CropRect,
129
- el: HTMLElement,
130
- ): CropRect => {
131
- const { y } = crop;
132
- let { x, w, h } = crop;
133
-
134
- if (isFree) {
135
- h += clientY - startY;
136
- if (h + y > height) h = height - y;
137
- if (h < minSize) h = minSize;
138
- } else {
139
- const difH = clientY - startY;
140
- const difW = Math.round(difH * ratio);
141
- h += difH;
142
- w += difW;
143
- x -= difW / 2;
144
- if (
145
- h + y > height ||
146
- x < 0 ||
147
- w + x > width ||
148
- w < minSize ||
149
- h < minSize
150
- ) {
151
- return getDefaultCrop(el);
152
- }
153
- }
154
-
155
- return { x, y, w, h };
156
- };
157
-
158
- const getCropTL = (
159
- isFree: boolean,
160
- ratio: number,
161
- startX: number,
162
- startY: number,
163
- clientX: number,
164
- clientY: number,
165
- width: number,
166
- height: number,
167
- crop: CropRect,
168
- el: HTMLElement,
169
- ): CropRect => {
170
- let { x, y, w, h } = crop;
171
-
172
- if (isFree) {
173
- const right = width - crop.w - crop.x;
174
- x += clientX - startX;
175
- if (x < 0) x = 0;
176
- w = width - x - right;
177
- if (w < minSize) {
178
- w = minSize;
179
- x = width - right - minSize;
180
- }
181
-
182
- const bottom = height - h - y;
183
- y += clientY - startY;
184
- if (y < 0) y = 0;
185
- h = height - y - bottom;
186
- if (h < minSize) {
187
- h = minSize;
188
- y = height - bottom - minSize;
189
- }
190
- } else {
191
- if (ratio >= 1) {
192
- const difW = clientX - startX;
193
- const difH = Math.round(difW / ratio);
194
- w -= difW;
195
- h -= difH;
196
- x += difW;
197
- y += difH;
198
- } else {
199
- const difH = clientY - startY;
200
- const difW = Math.round(difH * ratio);
201
- w -= difW;
202
- h -= difH;
203
- x += difW;
204
- y += difH;
205
- }
206
- if (x < 0 || y < 0 || w < minSize || h < minSize) {
207
- return getDefaultCrop(el);
208
- }
209
- }
210
-
211
- return { x, y, w, h };
212
- };
213
-
214
- const getCropTR = (
215
- isFree: boolean,
216
- ratio: number,
217
- startX: number,
218
- startY: number,
219
- clientX: number,
220
- clientY: number,
221
- width: number,
222
- height: number,
223
- crop: CropRect,
224
- el: HTMLElement,
225
- ): CropRect => {
226
- const { x } = crop;
227
- let { y, w, h } = crop;
228
-
229
- if (isFree) {
230
- w += clientX - startX;
231
- if (w + x > width) w = width - x;
232
- if (w < minSize) w = minSize;
233
-
234
- const bottom = height - h - y;
235
- y += clientY - startY;
236
- if (y < 0) y = 0;
237
- h = height - y - bottom;
238
- if (h < minSize) {
239
- h = minSize;
240
- y = height - bottom - minSize;
241
- }
242
- } else {
243
- if (ratio > 1) {
244
- const difW = clientX - startX;
245
- const difH = Math.round(difW / ratio);
246
- w += difW;
247
- h += difH;
248
- y -= difH;
249
- } else {
250
- const difH = clientY - startY;
251
- const difW = Math.round(difH * ratio);
252
- w -= difW;
253
- h -= difH;
254
- y += difH;
255
- }
256
- if (w + x > width || y < 0 || w < minSize || h < minSize) {
257
- return getDefaultCrop(el);
258
- }
259
- }
260
-
261
- return { x, y, w, h };
262
- };
263
-
264
- const getCropBL = (
265
- isFree: boolean,
266
- ratio: number,
267
- startX: number,
268
- startY: number,
269
- clientX: number,
270
- clientY: number,
271
- width: number,
272
- height: number,
273
- crop: CropRect,
274
- el: HTMLElement,
275
- ): CropRect => {
276
- const { y } = crop;
277
- let { x, w, h } = crop;
278
-
279
- if (isFree) {
280
- h += clientY - startY;
281
- if (h + y > height) h = height - y;
282
- if (h < minSize) h = minSize;
283
-
284
- const right = width - crop.w - crop.x;
285
- x += clientX - startX;
286
- if (x < 0) x = 0;
287
- w = width - x - right;
288
- if (w < minSize) {
289
- w = minSize;
290
- x = width - right - minSize;
291
- }
292
- } else {
293
- if (ratio >= 1) {
294
- const difW = clientX - startX;
295
- const difH = Math.round(difW / ratio);
296
- w -= difW;
297
- h -= difH;
298
- x += difW;
299
- } else {
300
- const difH = clientY - startY;
301
- const difW = Math.round(difH * ratio);
302
- w += difW;
303
- h += difH;
304
- x -= difW;
305
- }
306
- if (h + y > height || x < 0 || w < minSize || h < minSize) {
307
- return getDefaultCrop(el);
308
- }
309
- }
310
-
311
- return { x, y, w, h };
312
- };
313
-
314
- const getCropBR = (
315
- isFree: boolean,
316
- ratio: number,
317
- startX: number,
318
- startY: number,
319
- clientX: number,
320
- clientY: number,
321
- width: number,
322
- height: number,
323
- crop: CropRect,
324
- el: HTMLElement,
325
- ): CropRect => {
326
- const { x, y } = crop;
327
- let { w, h } = crop;
328
-
329
- if (isFree) {
330
- w += clientX - startX;
331
- if (w + x > width) w = width - x;
332
- if (w < minSize) w = minSize;
333
-
334
- h += clientY - startY;
335
- if (h + y > height) h = height - y;
336
- if (h < minSize) h = minSize;
337
- } else {
338
- if (ratio >= 1) {
339
- const difW = clientX - startX;
340
- const difH = Math.round(difW / ratio);
341
- w += difW;
342
- h += difH;
343
- } else {
344
- const difH = clientY - startY;
345
- const difW = Math.round(difH * ratio);
346
- w += difW;
347
- h += difH;
348
- }
349
- if (h + y > height || w + x > width || w < minSize || h < minSize) {
350
- return getDefaultCrop(el);
351
- }
352
- }
353
-
354
- return { x, y, w, h };
355
- };
356
-
357
- export const getCropPoints = (
358
- dir: Direction,
359
- isFree: boolean,
360
- ratio: number,
361
- startX: number,
362
- startY: number,
363
- clientX: number,
364
- clientY: number,
365
- width: number,
366
- height: number,
367
- crop: CropRect,
368
- el: HTMLElement,
369
- ): CropRect => {
370
- if (dir === "r")
371
- return getCropR(isFree, ratio, startX, clientX, width, height, crop, el);
372
- if (dir === "l")
373
- return getCropL(isFree, ratio, startX, clientX, width, height, crop, el);
374
- if (dir === "t")
375
- return getCropT(isFree, ratio, startY, clientY, width, height, crop, el);
376
- if (dir === "b")
377
- return getCropB(isFree, ratio, startY, clientY, width, height, crop, el);
378
- if (dir === "tl")
379
- return getCropTL(
380
- isFree,
381
- ratio,
382
- startX,
383
- startY,
384
- clientX,
385
- clientY,
386
- width,
387
- height,
388
- crop,
389
- el,
390
- );
391
- if (dir === "tr")
392
- return getCropTR(
393
- isFree,
394
- ratio,
395
- startX,
396
- startY,
397
- clientX,
398
- clientY,
399
- width,
400
- height,
401
- crop,
402
- el,
403
- );
404
- if (dir === "bl")
405
- return getCropBL(
406
- isFree,
407
- ratio,
408
- startX,
409
- startY,
410
- clientX,
411
- clientY,
412
- width,
413
- height,
414
- crop,
415
- el,
416
- );
417
- if (dir === "br")
418
- return getCropBR(
419
- isFree,
420
- ratio,
421
- startX,
422
- startY,
423
- clientX,
424
- clientY,
425
- width,
426
- height,
427
- crop,
428
- el,
429
- );
430
- return { x: 0, y: 0, w: 0, h: 0 };
431
- };
432
-
433
- export const getInitalCrop = (
434
- cropRatio: number,
435
- width: number,
436
- height: number,
437
- ): CropRect => {
438
- const offsetPercent = 0.1;
439
- const frameRatio = width / height;
440
- let wPx = 0;
441
- let hPx = 0;
442
-
443
- if (cropRatio === 1) {
444
- wPx = (frameRatio > 1 ? height : width) * (1 - offsetPercent * 2);
445
- hPx = wPx;
446
- }
447
-
448
- if (cropRatio > 1) {
449
- if (frameRatio > cropRatio) {
450
- hPx = height * (1 - offsetPercent * 2);
451
- wPx = hPx * cropRatio;
452
- } else {
453
- wPx = width * (1 - offsetPercent * 2);
454
- hPx = wPx / cropRatio;
455
- }
456
- }
457
-
458
- if (cropRatio < 1) {
459
- if (frameRatio > cropRatio) {
460
- hPx = height * (1 - offsetPercent * 2);
461
- wPx = hPx * cropRatio;
462
- } else {
463
- wPx = width * (1 - offsetPercent * 2);
464
- hPx = wPx / cropRatio;
465
- }
466
- }
467
-
468
- const w = (wPx / width) * 100;
469
- const h = (hPx / height) * 100;
470
- const x = ((width - wPx) / 2 / width) * 100;
471
- const y = ((height - hPx) / 2 / height) * 100;
472
- const xPx = Math.round((width - wPx) / 2);
473
- const yPx = Math.round((height - hPx) / 2);
474
-
475
- return { x, y, w, h, xPx, yPx, wPx, hPx };
476
- };
477
-
478
- export const getCropByNewSizes = (
479
- crop: CropRect,
480
- width: number,
481
- height: number,
482
- frameWidth: number,
483
- ): CropRect => {
484
- const diffPercent = width / frameWidth;
485
- const x = Math.floor(crop.x * diffPercent);
486
- const y = Math.floor(crop.y * diffPercent);
487
- const w = Math.ceil(crop.w * diffPercent);
488
- const h = Math.ceil(crop.h * diffPercent);
489
- return {
490
- x: x < 0 ? 0 : x,
491
- y: y < 0 ? 0 : y,
492
- w: w > width ? width : w,
493
- h: h > height ? height : h,
494
- };
495
- };
496
-
497
- export const degree2Rad = (degree: number): number => (degree * Math.PI) / 180;
@@ -1 +0,0 @@
1
- export { Preloader } from "./preloader";
@@ -1,78 +0,0 @@
1
- type PreloaderProps = {
2
- size?: number;
3
- color?: string;
4
- className?: string;
5
- style?: React.CSSProperties;
6
- };
7
-
8
- function Preloader({
9
- size = 36,
10
- className,
11
- style,
12
- color = "currentColor",
13
- }: PreloaderProps) {
14
- return (
15
- <svg
16
- xmlns="http://www.w3.org/2000/svg"
17
- x="0px"
18
- y="0px"
19
- viewBox="0 0 80 80"
20
- width={size}
21
- height={size}
22
- fill={color}
23
- className={className}
24
- style={style}
25
- >
26
- <path
27
- d="M10,40c0,0,0-0.4,0-1.1c0-0.3,0-0.8,0-1.3c0-0.3,0-0.5,0-0.8c0-0.3,0.1-0.6,0.1-0.9c0.1-0.6,0.1-1.4,0.2-2.1
28
- c0.2-0.8,0.3-1.6,0.5-2.5c0.2-0.9,0.6-1.8,0.8-2.8c0.3-1,0.8-1.9,1.2-3c0.5-1,1.1-2,1.7-3.1c0.7-1,1.4-2.1,2.2-3.1
29
- c1.6-2.1,3.7-3.9,6-5.6c2.3-1.7,5-3,7.9-4.1c0.7-0.2,1.5-0.4,2.2-0.7c0.7-0.3,1.5-0.3,2.3-0.5c0.8-0.2,1.5-0.3,2.3-0.4l1.2-0.1
30
- l0.6-0.1l0.3,0l0.1,0l0.1,0l0,0c0.1,0-0.1,0,0.1,0c1.5,0,2.9-0.1,4.5,0.2c0.8,0.1,1.6,0.1,2.4,0.3c0.8,0.2,1.5,0.3,2.3,0.5
31
- c3,0.8,5.9,2,8.5,3.6c2.6,1.6,4.9,3.4,6.8,5.4c1,1,1.8,2.1,2.7,3.1c0.8,1.1,1.5,2.1,2.1,3.2c0.6,1.1,1.2,2.1,1.6,3.1
32
- c0.4,1,0.9,2,1.2,3c0.3,1,0.6,1.9,0.8,2.7c0.2,0.9,0.3,1.6,0.5,2.4c0.1,0.4,0.1,0.7,0.2,1c0,0.3,0.1,0.6,0.1,0.9
33
- c0.1,0.6,0.1,1,0.1,1.4C74,39.6,74,40,74,40c0.2,2.2-1.5,4.1-3.7,4.3s-4.1-1.5-4.3-3.7c0-0.1,0-0.2,0-0.3l0-0.4c0,0,0-0.3,0-0.9
34
- c0-0.3,0-0.7,0-1.1c0-0.2,0-0.5,0-0.7c0-0.2-0.1-0.5-0.1-0.8c-0.1-0.6-0.1-1.2-0.2-1.9c-0.1-0.7-0.3-1.4-0.4-2.2
35
- c-0.2-0.8-0.5-1.6-0.7-2.4c-0.3-0.8-0.7-1.7-1.1-2.6c-0.5-0.9-0.9-1.8-1.5-2.7c-0.6-0.9-1.2-1.8-1.9-2.7c-1.4-1.8-3.2-3.4-5.2-4.9
36
- c-2-1.5-4.4-2.7-6.9-3.6c-0.6-0.2-1.3-0.4-1.9-0.6c-0.7-0.2-1.3-0.3-1.9-0.4c-1.2-0.3-2.8-0.4-4.2-0.5l-2,0c-0.7,0-1.4,0.1-2.1,0.1
37
- c-0.7,0.1-1.4,0.1-2,0.3c-0.7,0.1-1.3,0.3-2,0.4c-2.6,0.7-5.2,1.7-7.5,3.1c-2.2,1.4-4.3,2.9-6,4.7c-0.9,0.8-1.6,1.8-2.4,2.7
38
- c-0.7,0.9-1.3,1.9-1.9,2.8c-0.5,1-1,1.9-1.4,2.8c-0.4,0.9-0.8,1.8-1,2.6c-0.3,0.9-0.5,1.6-0.7,2.4c-0.2,0.7-0.3,1.4-0.4,2.1
39
- c-0.1,0.3-0.1,0.6-0.2,0.9c0,0.3-0.1,0.6-0.1,0.8c0,0.5-0.1,0.9-0.1,1.3C10,39.6,10,40,10,40z"
40
- >
41
- <animateTransform
42
- attributeType="xml"
43
- attributeName="transform"
44
- type="rotate"
45
- from="0 40 40"
46
- to="360 40 40"
47
- dur="0.8s"
48
- repeatCount="indefinite"
49
- />
50
- </path>
51
- <path
52
- fill="currentColor"
53
- d="M62,40.1c0,0,0,0.2-0.1,0.7c0,0.2,0,0.5-0.1,0.8c0,0.2,0,0.3,0,0.5c0,0.2-0.1,0.4-0.1,0.7
54
- c-0.1,0.5-0.2,1-0.3,1.6c-0.2,0.5-0.3,1.1-0.5,1.8c-0.2,0.6-0.5,1.3-0.7,1.9c-0.3,0.7-0.7,1.3-1,2.1c-0.4,0.7-0.9,1.4-1.4,2.1
55
- c-0.5,0.7-1.1,1.4-1.7,2c-1.2,1.3-2.7,2.5-4.4,3.6c-1.7,1-3.6,1.8-5.5,2.4c-2,0.5-4,0.7-6.2,0.7c-1.9-0.1-4.1-0.4-6-1.1
56
- c-1.9-0.7-3.7-1.5-5.2-2.6c-1.5-1.1-2.9-2.3-4-3.7c-0.6-0.6-1-1.4-1.5-2c-0.4-0.7-0.8-1.4-1.2-2c-0.3-0.7-0.6-1.3-0.8-2
57
- c-0.2-0.6-0.4-1.2-0.6-1.8c-0.1-0.6-0.3-1.1-0.4-1.6c-0.1-0.5-0.1-1-0.2-1.4c-0.1-0.9-0.1-1.5-0.1-2c0-0.5,0-0.7,0-0.7
58
- s0,0.2,0.1,0.7c0.1,0.5,0,1.1,0.2,2c0.1,0.4,0.2,0.9,0.3,1.4c0.1,0.5,0.3,1,0.5,1.6c0.2,0.6,0.4,1.1,0.7,1.8
59
- c0.3,0.6,0.6,1.2,0.9,1.9c0.4,0.6,0.8,1.3,1.2,1.9c0.5,0.6,1,1.3,1.6,1.8c1.1,1.2,2.5,2.3,4,3.2c1.5,0.9,3.2,1.6,5,2.1
60
- c1.8,0.5,3.6,0.6,5.6,0.6c1.8-0.1,3.7-0.4,5.4-1c1.7-0.6,3.3-1.4,4.7-2.4c1.4-1,2.6-2.1,3.6-3.3c0.5-0.6,0.9-1.2,1.3-1.8
61
- c0.4-0.6,0.7-1.2,1-1.8c0.3-0.6,0.6-1.2,0.8-1.8c0.2-0.6,0.4-1.1,0.5-1.7c0.1-0.5,0.2-1,0.3-1.5c0.1-0.4,0.1-0.8,0.1-1.2
62
- c0-0.2,0-0.4,0.1-0.5c0-0.2,0-0.4,0-0.5c0-0.3,0-0.6,0-0.8c0-0.5,0-0.7,0-0.7c0-1.1,0.9-2,2-2s2,0.9,2,2C62,40,62,40.1,62,40.1z"
63
- >
64
- <animateTransform
65
- attributeType="xml"
66
- attributeName="transform"
67
- type="rotate"
68
- from="0 40 40"
69
- to="-360 40 40"
70
- dur="0.6s"
71
- repeatCount="indefinite"
72
- />
73
- </path>
74
- </svg>
75
- );
76
- }
77
-
78
- export { Preloader };
@@ -1,3 +0,0 @@
1
- import { ROUTES } from "./routes";
2
-
3
- export { ROUTES };
@@ -1,4 +0,0 @@
1
- export const ROUTES = {
2
- HOME: "/",
3
- IMAGE_EDIT: "images/:id",
4
- };