@vnejs/uis.react 0.1.2 → 0.1.3

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 (36) hide show
  1. package/package.json +1 -1
  2. package/src/components/base/PageSelector/PageSelector.jsx +3 -15
  3. package/src/components/base/SmoothText/SmoothText.jsx +3 -8
  4. package/src/components/base/Sprite/Sprite.change.stories.jsx +1 -1
  5. package/src/components/base/Sprite/Sprite.default.stories.jsx +2 -10
  6. package/src/components/base/Sprite/Sprite.jsx +26 -14
  7. package/src/components/base/Sprite/Sprite.move.stories.jsx +0 -2
  8. package/src/components/base/WrapWithContent/WrapWithContent.jsx +2 -8
  9. package/src/components/complex/Screen/Screen.jsx +2 -1
  10. package/src/components/complex/Screen/Screen.styl +5 -3
  11. package/src/components/primitives/Backdrop/Backdrop.jsx +2 -5
  12. package/src/components/primitives/Cursor/Cursor.jsx +3 -8
  13. package/src/components/primitives/Cursor/Cursor.styl +1 -4
  14. package/src/components/primitives/Flex/Flex.jsx +11 -67
  15. package/src/components/primitives/Icon/Icon.jsx +5 -23
  16. package/src/components/primitives/Image/Image.jsx +17 -3
  17. package/src/components/primitives/Image/Image.styl +3 -2
  18. package/src/components/primitives/PositionBox/PositionBox.jsx +13 -39
  19. package/src/components/primitives/PositionBox/PositionBox.stories.jsx +0 -5
  20. package/src/components/primitives/PositionBox/PositionBox.styl +3 -1
  21. package/src/components/primitives/Range/Range.jsx +6 -22
  22. package/src/components/primitives/Scrollbar/Scrollbar.jsx +5 -31
  23. package/src/components/primitives/Scrollbar/Scrollbar.styl +14 -14
  24. package/src/components/primitives/Scrollbar/hooks/thumb.hook.jsx +6 -3
  25. package/src/components/primitives/Svg/Svg.jsx +2 -7
  26. package/src/components/primitives/Text/Text.jsx +6 -29
  27. package/src/components/primitives/Text/Text.styl +1 -1
  28. package/src/components/primitives/Toggle/Toggle.jsx +4 -9
  29. package/src/components/primitives/Toggle/Toggle.styl +1 -1
  30. package/src/components/primitives/View/View.stories.jsx +4 -1
  31. package/src/components/primitives/Wrap/Wrap.jsx +12 -64
  32. package/src/components/primitives/Wrap/Wrap.stories.jsx +2 -1
  33. package/src/components/primitives/Wrap/Wrap.styl +4 -4
  34. package/src/components/screens/Coraline/Interface.stories.jsx +4 -3
  35. package/src/components/storybook/VneWrap/VneWrap.jsx +0 -16
  36. package/src/components/storybook/VneWrap/VneWrap.styl +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/uis.react",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "main": "src/index.js",
5
5
  "scripts": {
6
6
  "storybook": "storybook dev -p 6006",
@@ -32,24 +32,12 @@ export const PageSelector = ({ page, pagesCount, pagesMinCount, gap = 120, size
32
32
  const styleArrow = useMemo(() => {
33
33
  const result = {};
34
34
 
35
- if (size) {
36
- const { length, count, isEmpty = false } = getVneLength(size);
37
-
38
- if (isEmpty) console.warn("Wrong Page Selector Size:", size);
39
- else result.height = `calc(${count}px * var(--vne-length-${length}))`;
40
- }
41
-
42
- if (itemWidth) {
43
- const { length, count, isEmpty = false } = getVneLength(itemWidth);
44
-
45
- if (isEmpty) console.warn("Wrong Page Selector Item Width:", itemWidth);
46
- else result.width = `calc(${count}px * var(--vne-length-${length}))`;
47
- }
48
-
35
+ if (size) result.height = getVneLength(size);
36
+ if (itemWidth) result.width = getVneLength(itemWidth);
49
37
  if (transition) result.transition = `${transition}ms`;
50
38
 
51
39
  return result;
52
- }, [size, transition, itemWidth]);
40
+ }, [size, itemWidth, transition]);
53
41
 
54
42
  const showArrowLeft = page > pagesMinCount;
55
43
  const showArrowRight = page < pagesCount;
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useMemo, useState } from "react";
2
2
 
3
- import { getVneLength, cn } from "@vnejs/uis.utils";
3
+ import { cn, getVneLength } from "@vnejs/uis.utils";
4
4
 
5
5
  import { Char, Scrollbar } from "../../primitives";
6
6
 
@@ -40,13 +40,8 @@ export const SmoothText = ({
40
40
  if (color) result.color = color;
41
41
 
42
42
  if (size) {
43
- const { length, count, isEmpty = false } = getVneLength(size);
44
-
45
- if (isEmpty) console.warn("Wrong SmoothText Size:", size);
46
- else {
47
- result.fontSize = `calc(${count}px * var(--vne-length-${length}) * var(--vne-text-size-multiplicator, 1))`;
48
- result.lineHeight = `calc(${count * 1.25}px * var(--vne-length-${length}) * var(--vne-text-size-multiplicator, 1))`;
49
- }
43
+ result.fontSize = `round(down, calc(${getVneLength(size)} * var(--vne-text-size-multiplicator, 1)), 1px)`;
44
+ result.lineHeight = `round(down, calc(${getVneLength(1.25 * size)} * var(--vne-text-size-multiplicator, 1)), 1px)`;
50
45
  }
51
46
 
52
47
  if (transition && !isForce) result.transition = `${transition}ms`;
@@ -15,7 +15,7 @@ export const Common = {
15
15
  },
16
16
  };
17
17
 
18
- const BOX_PROPS = { top: "100%", left: "50%", scale: 1, translateX: -50, translateY: -100, canvasWidth: 3840, canvasHeight: 2160, transition: 0 };
18
+ const BOX_PROPS = { top: "100%", left: "50%", scale: 1, translateX: -50, translateY: -100, transition: 0 };
19
19
  const SPRITE_PREFIX = "./speaker/original-4k/co";
20
20
 
21
21
  export default {
@@ -17,12 +17,9 @@ export const Common = {
17
17
  boxTransition: 0,
18
18
  partsTransition: 0,
19
19
 
20
- canvasHeight: 2160,
21
- canvasWidth: 3840,
22
20
  top: 100,
23
21
  left: 50,
24
22
  scale: 1,
25
- scaleWithCanvas: false,
26
23
  translateX: -50,
27
24
  translateY: -100,
28
25
  },
@@ -32,14 +29,11 @@ export default {
32
29
  title: "Base/Sprite/Default",
33
30
  render: renderWithVneWrap(
34
31
  ({
35
- canvasHeight,
36
- canvasWidth,
37
32
  translateX,
38
33
  translateY,
39
34
  top,
40
35
  left,
41
36
  scale,
42
- scaleWithCanvas,
43
37
  boxTransition,
44
38
  partsTransition,
45
39
 
@@ -77,8 +71,8 @@ export default {
77
71
  const indexSrc = useMemo(() => `./speaker/original-4k/co/${spritePose}/index.png`, [spritePose]);
78
72
 
79
73
  const boxProps = useMemo(
80
- () => ({ top: `${top}%`, left: `${left}%`, scale, scaleWithCanvas, translateX, translateY, canvasWidth, canvasHeight, transition: boxTransition }),
81
- [top, left, scale, scaleWithCanvas, translateX, translateY, canvasWidth, canvasHeight, boxTransition],
74
+ () => ({ top: `${top}%`, left: `${left}%`, scale, translateX, translateY, transition: boxTransition }),
75
+ [top, left, scale, translateX, translateY, boxTransition],
82
76
  );
83
77
 
84
78
  const partsProps = useMemo(() => ({ transition: partsTransition }), [partsTransition]);
@@ -109,8 +103,6 @@ export default {
109
103
 
110
104
  // PositionBox
111
105
  boxTransition: { control: { type: "number", min: 0, max: 1000, step: 50 } },
112
- canvasHeight: { control: { type: "number", min: 180, max: 2160, step: 90 } },
113
- canvasWidth: { control: { type: "number", min: 160, max: 3840, step: 160 } },
114
106
  top: { control: { type: "number", min: 0, max: 100, step: 5 } },
115
107
  left: { control: { type: "number", min: 0, max: 100, step: 5 } },
116
108
  scale: { control: { type: "number", min: 0.1, max: 2, step: 0.1 } },
@@ -1,19 +1,31 @@
1
+ import { useMemo } from "react";
1
2
  import { Image, PositionBox } from "../../primitives";
2
3
 
3
4
  const POSE_STYLE = { opacity: 0, visibility: "hidden" };
4
5
 
5
- export const Sprite = ({ parts = [], indexSrc = "", boxProps = {}, partsProps = {} }) => (
6
- <PositionBox {...boxProps}>
7
- {parts.map((props, i) => (
8
- <Image
9
- key={i}
10
- {...props}
11
- {...partsProps}
6
+ export const Sprite = ({ parts = [], indexSrc = "", boxProps = {}, partsProps = {}, transition = null, transitionBox = null }) => {
7
+ const realBoxProps = useMemo(() => {
8
+ const result = { ...boxProps };
9
+
10
+ if (transitionBox !== null) result.transition = transitionBox;
11
+
12
+ return result;
13
+ }, [boxProps, transitionBox]);
14
+
15
+ return (
16
+ <PositionBox {...realBoxProps}>
17
+ {parts.map((props, i) => (
18
+ <Image
19
+ key={i}
20
+ {...props}
21
+ {...partsProps}
22
+ transition={transition}
23
+ />
24
+ ))}
25
+ <img
26
+ src={indexSrc}
27
+ style={POSE_STYLE}
12
28
  />
13
- ))}
14
- <img
15
- src={indexSrc}
16
- style={POSE_STYLE}
17
- />
18
- </PositionBox>
19
- );
29
+ </PositionBox>
30
+ );
31
+ };
@@ -102,8 +102,6 @@ export default {
102
102
  scale: 1,
103
103
  translateX: -50 + boxTranslateXShift,
104
104
  translateY: -100,
105
- canvasWidth: 3840,
106
- canvasHeight: 2160,
107
105
  transition: boxTransition,
108
106
  opacity: boxOpacity,
109
107
  }),
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useMemo } from "react";
2
2
 
3
- import { getVneLength, cn } from "@vnejs/uis.utils";
3
+ import { cn, getVneLength } from "@vnejs/uis.utils";
4
4
 
5
5
  import { Text, Wrap } from "../../primitives";
6
6
 
@@ -8,13 +8,7 @@ import "./WrapWithContent.styl";
8
8
 
9
9
  const b = cn("WrapWithContent");
10
10
 
11
- const getCssPosition = (value) => () => {
12
- if (!value) return "0";
13
-
14
- const { length, count, isEmpty = false } = getVneLength(value);
15
-
16
- return isEmpty ? "0" : `calc(${count}px * var(--vne-length-${length}))`;
17
- };
11
+ const getCssPosition = (value) => () => value ? getVneLength(value) : "0";
18
12
 
19
13
  const renderOneItem = (props, style, renderFunc) =>
20
14
  renderFunc && (
@@ -21,6 +21,7 @@ export const Screen = ({
21
21
  withDark = false,
22
22
  withBackgroundDark = false,
23
23
  withBackgroundBlur = false,
24
+ withPointerEventsNone = false,
24
25
  isDisableAutoread = true,
25
26
  isIgnoreOnScreenshot = true,
26
27
  isAllowAutoread = true,
@@ -38,7 +39,7 @@ export const Screen = ({
38
39
 
39
40
  return (
40
41
  <View
41
- className={b({ view, withBlur, withDark }, [className])}
42
+ className={b({ view, withBlur, withDark, withPointerEventsNone }, [className])}
42
43
  top={0}
43
44
  right={0}
44
45
  bottom={0}
@@ -12,9 +12,8 @@
12
12
 
13
13
  &-background
14
14
  background-position: center
15
- background-size: contain
16
15
  background-repeat: no-repeat
17
- background-size: 100% 100%
16
+ background-size: cover
18
17
 
19
18
  &_withBlur
20
19
  filter: blur(var(--vne-screen-blur))
@@ -32,4 +31,7 @@
32
31
  backdrop-filter: brightness(var(--vne-screen-brightness))
33
32
 
34
33
  &_withBlur&_withDark
35
- backdrop-filter: blur(var(--vne-screen-blur)) brightness(var(--vne-screen-brightness))
34
+ backdrop-filter: blur(var(--vne-screen-blur)) brightness(var(--vne-screen-brightness))
35
+
36
+ &_withPointerEventsNone
37
+ pointer-events: none
@@ -1,6 +1,6 @@
1
1
  import { useMemo } from "react";
2
2
 
3
- import { getVneLength, cn } from "@vnejs/uis.utils";
3
+ import { cn, getVneLength } from "@vnejs/uis.utils";
4
4
 
5
5
  import "./Backdrop.styl";
6
6
 
@@ -12,10 +12,7 @@ export const Backdrop = ({ zIndex = null, transition = null, type = "", size = 3
12
12
 
13
13
  const result = { ["--vne-backdrop-degree"]: `${TYPE_TO_DEGREE[type || Backdrop.TYPE.TOP]}deg`, opacity };
14
14
 
15
- const { length, count, isEmpty = false } = getVneLength(size);
16
-
17
- if (isEmpty) console.warn("Wrong Backdrop Size:", size);
18
- else result["--vne-backdrop-length"] = `calc(${count}px * var(--vne-length-${length}))`;
15
+ result["--vne-backdrop-length"] = getVneLength(size);
19
16
 
20
17
  if (color1) result["--vne-backdrop-color-1"] = color1;
21
18
  if (color2) result["--vne-backdrop-color-2"] = color2;
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useMemo, useState } from "react";
2
2
 
3
- import { getVneLength, cn } from "@vnejs/uis.utils";
3
+ import { cn, getVneLength } from "@vnejs/uis.utils";
4
4
 
5
5
  import "./Cursor.styl";
6
6
 
@@ -37,13 +37,8 @@ export const Cursor = ({ isShow = false, transition = 500, size = 120, forceX, f
37
37
  if (transition) result.transition = `background-image ${transition}ms, opacity ${transition}ms`;
38
38
 
39
39
  if (size) {
40
- const { length, count, isEmpty = false } = getVneLength(size);
41
-
42
- if (isEmpty) console.warn("Wrong Cursor Size:", size);
43
- else {
44
- result.width = `calc(${count}px * var(--vne-length-${length}))`;
45
- result.height = `calc(${count}px * var(--vne-length-${length}))`;
46
- }
40
+ result.width = getVneLength(size);
41
+ result.height = getVneLength(size);
47
42
  }
48
43
 
49
44
  result["--vne-cursor-src"] = `url('${cursorType === "pointer" ? srcPointer : srcDefault}')`;
@@ -1,6 +1,3 @@
1
- #app
2
- cursor: none !important
3
-
4
1
  .Cursor
5
2
  position: fixed
6
3
  translate: calc(-50% + 1px * var(--vne-cursor-left)) calc(-50% + 1px * var(--vne-cursor-top))
@@ -19,4 +16,4 @@
19
16
  opacity: 0
20
17
 
21
18
  &_isShow
22
- opacity 1
19
+ opacity 1
@@ -1,6 +1,6 @@
1
1
  import { useMemo } from "react";
2
2
 
3
- import { getVneLength, cn } from "@vnejs/uis.utils";
3
+ import { cn, getVneLength } from "@vnejs/uis.utils";
4
4
 
5
5
  import "./Flex.styl";
6
6
 
@@ -26,75 +26,19 @@ export const Flex = ({
26
26
  const style = useMemo(() => {
27
27
  const result = {};
28
28
 
29
- if (width) {
30
- if (typeof width === "string") {
31
- result.width = width;
32
- } else {
33
- const { length, count, isEmpty = false } = getVneLength(width);
34
- if (isEmpty) console.warn("Wrong Flex Width:", width);
35
- else result.width = `calc(${count}px * var(--vne-length-${length}))`;
36
- }
37
- }
38
-
39
- if (height) {
40
- if (typeof height === "string") {
41
- result.height = height;
42
- } else {
43
- const { length, count, isEmpty = false } = getVneLength(height);
44
- if (isEmpty) console.warn("Wrong Flex Height:", height);
45
- else result.height = `calc(${count}px * var(--vne-length-${length}))`;
46
- }
47
- }
48
-
49
- if (gap) {
50
- const { length, count, isEmpty = false } = getVneLength(gap);
51
- if (isEmpty) console.warn("Wrong Flex Gap:", gap);
52
- else {
53
- result.gap = `calc(${count}px * var(--vne-length-${length}))`;
54
- }
55
- }
56
-
57
- if (gapHorizontal) {
58
- const { length, count, isEmpty = false } = getVneLength(gapHorizontal);
59
- if (isEmpty) console.warn("Wrong Flex Gap Horizontal:", gapHorizontal);
60
- else {
61
- result.columnGap = `calc(${count}px * var(--vne-length-${length}))`;
62
- }
63
- }
64
-
65
- if (gapVertical) {
66
- const { length, count, isEmpty = false } = getVneLength(gapVertical);
67
- if (isEmpty) console.warn("Wrong Flex Gap Vertical:", gapVertical);
68
- else {
69
- result.rowGap = `calc(${count}px * var(--vne-length-${length}))`;
70
- }
71
- }
72
-
73
- if (padding) {
74
- const { length, count, isEmpty = false } = getVneLength(padding);
75
-
76
- if (isEmpty) console.warn("Wrong Flex Padding:", padding);
77
- else result.padding = `calc(${count}px * var(--vne-length-${length}))`;
78
- }
79
-
29
+ if (width) result.width = typeof width === "string" ? width : getVneLength(width);
30
+ if (height) result.height = typeof height === "string" ? height : getVneLength(height);
31
+ if (gap) result.gap = getVneLength(gap);
32
+ if (gapHorizontal) result.columnGap = getVneLength(gapHorizontal);
33
+ if (gapVertical) result.rowGap = getVneLength(gapVertical);
34
+ if (padding) result.padding = getVneLength(padding);
80
35
  if (paddingHorizontal) {
81
- const { length, count, isEmpty = false } = getVneLength(paddingHorizontal);
82
-
83
- if (isEmpty) console.warn("Wrong Flex Padding Horizontal:", paddingHorizontal);
84
- else {
85
- result.paddingLeft = `calc(${count}px * var(--vne-length-${length}))`;
86
- result.paddingRight = `calc(${count}px * var(--vne-length-${length}))`;
87
- }
36
+ result.paddingLeft = getVneLength(paddingHorizontal);
37
+ result.paddingRight = getVneLength(paddingHorizontal);
88
38
  }
89
-
90
39
  if (paddingVertical) {
91
- const { length, count, isEmpty = false } = getVneLength(paddingVertical);
92
-
93
- if (isEmpty) console.warn("Wrong Flex Padding Vertical:", paddingVertical);
94
- else {
95
- result.paddingTop = `calc(${count}px * var(--vne-length-${length}))`;
96
- result.paddingBottom = `calc(${count}px * var(--vne-length-${length}))`;
97
- }
40
+ result.paddingTop = getVneLength(paddingVertical);
41
+ result.paddingBottom = getVneLength(paddingVertical);
98
42
  }
99
43
 
100
44
  if (transition !== null) result.transition = `${transition}ms`;
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useMemo } from "react";
2
2
 
3
- import { getVneLength, cn } from "@vnejs/uis.utils";
3
+ import { cn, getVneLength } from "@vnejs/uis.utils";
4
4
 
5
5
  import "./Icon.styl";
6
6
 
@@ -33,32 +33,14 @@ export const Icon = ({
33
33
  const style = useMemo(() => {
34
34
  const result = {};
35
35
 
36
- if (width) {
37
- const { length, count, isEmpty = false } = getVneLength(width);
38
-
39
- if (isEmpty) console.warn("Wrong Icon Width:", width);
40
- else result.width = `calc(${count}px * var(--vne-length-${length}))`;
41
- }
42
-
43
- if (height) {
44
- const { length, count, isEmpty = false } = getVneLength(height);
45
-
46
- if (isEmpty) console.warn("Wrong Icon Height:", height);
47
- else result.height = `calc(${count}px * var(--vne-length-${length}))`;
48
- }
49
-
50
- if (scale) {
51
- result.transform = `scale(${scale})`;
52
- }
53
-
54
- if (transformOriginX !== null || transformOriginY !== null) {
55
- result.transformOrigin = `${transformOriginX || 0} ${transformOriginY || 0}`;
56
- }
36
+ if (width) result.width = getVneLength(width);
37
+ if (height) result.height = getVneLength(height);
57
38
 
39
+ if (scale) result.transform = `scale(${scale})`;
40
+ if (transformOriginX !== null || transformOriginY !== null) result.transformOrigin = `${transformOriginX || 0} ${transformOriginY || 0}`;
58
41
  if (aspectRatioX || aspectRatioY) result.aspectRatio = `${aspectRatioX || 1} / ${aspectRatioY || 1}`;
59
42
  if (zIndex !== null) result.zIndex = zIndex;
60
43
  if (opacity !== null) result.opacity = opacity;
61
-
62
44
  if (transition) result.transition = `${transition}ms`;
63
45
 
64
46
  if (src) result["--vne-icon-src"] = `url("${src}")`;
@@ -8,7 +8,18 @@ const b = cn("Image");
8
8
 
9
9
  const TRANSPARENT_IMAGE = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxIDEiLz4=";
10
10
 
11
- export const Image = ({ translateX = 0, translateY = 0, scale = 1, transition = 0, src = "", className = "", filter = "", isSwitchDisabled = false }) => {
11
+ export const Image = ({
12
+ translateX = 0,
13
+ translateY = 0,
14
+ scale = 1,
15
+ transition = 0,
16
+ opacity = null,
17
+ src = "",
18
+ className = "",
19
+ filter = "",
20
+ isSwitchDisabled = false,
21
+ isAllSrcRendered = false,
22
+ }) => {
12
23
  const [srcIndex, setSrcIndex] = useState(0);
13
24
  const [switchInProcess, setSwitchInProcess] = useState(false);
14
25
  const [switchTransition, setSwitchTransition] = useState(0);
@@ -25,15 +36,18 @@ export const Image = ({ translateX = 0, translateY = 0, scale = 1, transition =
25
36
  const style = useMemo(() => {
26
37
  const result = {
27
38
  translate: `${translateX}% ${translateY}%`,
28
- transition: `${realTransition}ms`,
39
+ transition: !realTransition ? "none" : `${realTransition}ms`,
29
40
  transform: `scale(${scale})`,
30
41
  transformOrigin: `${-translateX}% ${-translateY}%`,
31
42
  backgroundImage: `url(${realSrc})`,
32
43
  filter,
33
44
  };
34
45
 
46
+ if (isAllSrcRendered) result.backgroundImage = src.map((s, i) => `url(${src[src.length - i - 1].url})`).join(", ");
47
+ if (opacity !== null) result.opacity = opacity;
48
+
35
49
  return result;
36
- }, [scale, translateX, translateY, realTransition, realSrc, filter]);
50
+ }, [scale, translateX, translateY, realTransition, transition, realSrc, filter, opacity, isAllSrcRendered]);
37
51
 
38
52
  useEffect(() => {
39
53
  setSwitchInProcess(!isSwitchDisabled && !transition);
@@ -5,5 +5,6 @@
5
5
  width: 100%
6
6
  height: 100%
7
7
 
8
- background-size: 100%
9
- background-repeat: no-repeat
8
+ background-size: cover
9
+ background-repeat: no-repeat
10
+ background-position: center
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useMemo } from "react";
2
2
 
3
- import { getVneLength, cn } from "@vnejs/uis.utils";
3
+ import { cn, getVneLength } from "@vnejs/uis.utils";
4
4
 
5
5
  import "./PositionBox.styl";
6
6
 
@@ -15,10 +15,7 @@ const setPositionField = (result, field, value) => {
15
15
  if (value === 0) return setField(result, field, "0");
16
16
  if (typeof value === "string") return setField(result, field, value);
17
17
 
18
- const { length, count, isEmpty = false } = getVneLength(value);
19
-
20
- if (isEmpty) console.warn(`Wrong Position Box Filed(${field}):`, value);
21
- else setField(result, field, `calc(${count}px * var(--vne-length-${length}))`);
18
+ setField(result, field, getVneLength(value));
22
19
  };
23
20
 
24
21
  export const PositionBox = ({
@@ -31,15 +28,12 @@ export const PositionBox = ({
31
28
  transformOriginX = null,
32
29
  transformOriginY = null,
33
30
  scale = null,
34
- scaleWithCanvas = false,
35
31
  transition = null,
36
32
  zIndex = null,
37
33
  opacity = null,
38
34
  boxRef = null,
39
- canvasHeight = 2160,
40
- canvasWidth = 3840,
41
35
  isCentered = false,
42
- iscenteredVertical = false,
36
+ isCenteredVertical = false,
43
37
  isCenteredHorizontal = false,
44
38
  isNotRender = false,
45
39
  background = null,
@@ -56,44 +50,24 @@ export const PositionBox = ({
56
50
  setPositionField(result, "bottom", bottom);
57
51
  setPositionField(result, "left", left);
58
52
 
59
- if (scale) {
60
- result["--vne-bounding-box-scale-y"] = `calc(${scale} * var(${scaleWithCanvas ? `--vne-length-100vh` : `--vne-length-2160`}) / ${canvasHeight})`;
61
- result["--vne-bounding-box-scale-x"] = `calc(${scale} * var(${scaleWithCanvas ? `--vne-length-100vw` : `--vne-length-3840`}) / ${canvasWidth})`;
62
- }
63
-
64
53
  if (translateX !== null || translateY !== null) {
65
- result.translate = `${translateX || 0} ${translateY || 0}`;
66
- result.transformOrigin = `${-translateX || 0} ${-translateY || 0}`;
54
+ result["--vne-position-box-transform-x"] = translateX || "0%";
55
+ result["--vne-position-box-transform-y"] = translateY || "0%";
56
+ result["--vne-position-box-translate-x"] = translateX || "0%";
57
+ result["--vne-position-box-translate-y"] = translateY || "0%";
67
58
  }
68
-
69
59
  if (transformOriginX !== null || transformOriginY !== null) {
70
- result.transformOrigin = `${transformOriginX || 0} ${transformOriginY || 0}`;
60
+ result["--vne-position-box-transform-x"] = transformOriginX || 0;
61
+ result["--vne-position-box-transform-y"] = transformOriginY || 0;
71
62
  }
72
-
73
- if (transition !== null) result.transition = `${transition}ms`;
63
+ if (scale) result["--vne-position-box-scale"] = scale;
64
+ if (transition !== null) result.transition = transition === 0 ? "none" : `${transition}ms`;
74
65
  if (zIndex !== null) result.zIndex = zIndex;
75
66
  if (opacity !== null) result.opacity = opacity;
76
67
  if (background !== null) result.background = background;
77
68
 
78
69
  return result;
79
- }, [
80
- top,
81
- right,
82
- bottom,
83
- left,
84
- scale,
85
- scaleWithCanvas,
86
- canvasHeight,
87
- canvasWidth,
88
- translateX,
89
- translateY,
90
- transformOriginX,
91
- transformOriginY,
92
- transition,
93
- zIndex,
94
- opacity,
95
- background,
96
- ]);
70
+ }, [top, right, bottom, left, translateX, translateY, transformOriginX, transformOriginY, zIndex, scale, transition, opacity, background]);
97
71
 
98
72
  const onClickHandler = useCallback(() => onClick && onClick(value), [onClick, value]);
99
73
 
@@ -101,7 +75,7 @@ export const PositionBox = ({
101
75
 
102
76
  return (
103
77
  <div
104
- className={b({ isCentered, isCenteredHorizontal, iscenteredVertical, isHided: opacity === 0 }, [className])}
78
+ className={b({ isCentered, isCenteredHorizontal, isCenteredVertical, isHided: opacity === 0 }, [className])}
105
79
  style={style}
106
80
  onClick={onClickHandler}
107
81
  ref={boxRef}
@@ -6,8 +6,6 @@ export const Common = {
6
6
  args: {
7
7
  ...VneWrap.DEFAULT_ARGS,
8
8
 
9
- canvasHeight: 2160,
10
- canvasWidth: 3840,
11
9
  top: null,
12
10
  useTop: false,
13
11
  right: null,
@@ -17,7 +15,6 @@ export const Common = {
17
15
  left: null,
18
16
  useLeft: false,
19
17
  scale: null,
20
- scaleWithCanvas: false,
21
18
  transition: 300,
22
19
  translateX: null,
23
20
  translateY: null,
@@ -41,8 +38,6 @@ export default {
41
38
  ...VneWrap.ARGS,
42
39
 
43
40
  // PositionBox
44
- canvasHeight: { control: { type: "number", min: 180, max: 2160, step: 90 } },
45
- canvasWidth: { control: { type: "number", min: 160, max: 3840, step: 160 } },
46
41
  top: { control: { type: "number", min: -720, max: 2160, step: 60 } },
47
42
  right: { control: { type: "number", min: -720, max: 2160, step: 60 } },
48
43
  bottom: { control: { type: "number", min: -720, max: 2160, step: 60 } },
@@ -2,7 +2,9 @@
2
2
  display: inline-block
3
3
  position: absolute
4
4
 
5
- transform: scaleY(var(--vne-bounding-box-scale-y, 1)) scaleX(var(--vne-bounding-box-scale-x, 1))
5
+ transform: scaleY(var(--vne-position-box-scale, 1)) scaleX(var(--vne-position-box-scale, 1))
6
+ transform-origin: var(--vne-position-box-transform-x, 0) var(--vne-position-box-transform-y, 0)
7
+ translate: var(--vne-position-box-translate-x, 0%) var(--vne-position-box-translate-y, 0%)
6
8
 
7
9
  &-children
8
10
  position: relative
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useMemo } from "react";
2
2
 
3
- import { getVneLength, cn } from "@vnejs/uis.utils";
3
+ import { cn, getVneLength } from "@vnejs/uis.utils";
4
4
 
5
5
  import "./Range.styl";
6
6
 
@@ -10,21 +10,10 @@ export const Range = ({ isSelected = false, width = 360, height = 6, transition
10
10
  const style = useMemo(() => {
11
11
  const result = {};
12
12
 
13
- if (width) {
14
- const { length, count, isEmpty = false } = getVneLength(width);
15
-
16
- if (isEmpty) console.warn("Wrong Range Width:", width);
17
- else result.width = `calc(${count}px * var(--vne-length-${length}))`;
18
- }
19
-
13
+ if (width) result.width = getVneLength(width);
20
14
  if (height) {
21
- const { length, count, isEmpty = false } = getVneLength(height);
22
-
23
- if (isEmpty) console.warn("Wrong Range Height:", height);
24
- else {
25
- result.height = `calc(${count}px * var(--vne-length-${length}))`;
26
- result.borderRadius = `calc(${count}px * var(--vne-length-${length}))`;
27
- }
15
+ result.height = getVneLength(height);
16
+ result.borderRadius = getVneLength(height);
28
17
  }
29
18
 
30
19
  if (transition) result.transition = `${transition}ms`;
@@ -38,13 +27,8 @@ export const Range = ({ isSelected = false, width = 360, height = 6, transition
38
27
  const result = { translate: `-${curPercent + 0.75 * (50 - curPercent)}% -25%`, left: `${curPercent}%` };
39
28
 
40
29
  if (height) {
41
- const { length, count, isEmpty = false } = getVneLength(height);
42
-
43
- if (isEmpty) console.warn("Wrong Range Height:", height);
44
- else {
45
- result.height = `calc(${count * 2}px * var(--vne-length-${length}))`;
46
- result.width = `calc(${count * 2}px * var(--vne-length-${length}))`;
47
- }
30
+ result.height = getVneLength(height);
31
+ result.width = getVneLength(height);
48
32
  }
49
33
 
50
34
  return result;
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useMemo } from "react";
2
2
 
3
- import { getVneLength, cn } from "@vnejs/uis.utils";
3
+ import { cn, getVneLength } from "@vnejs/uis.utils";
4
4
 
5
5
  import { useThumbHook } from "./hooks/thumb.hook";
6
6
  import { useScrollHook } from "./hooks/scroll.hook";
@@ -21,21 +21,8 @@ export const Scrollbar = ({ className = "", children, width = 0, height = 0, scr
21
21
  const style = useMemo(() => {
22
22
  const result = {};
23
23
 
24
- if (width) {
25
- const { length, count, isEmpty = false } = getVneLength(width);
26
- if (isEmpty) console.warn("Wrong Scrollbar Width:", width);
27
- else {
28
- result.width = `calc(${count}px * var(--vne-length-${length}))`;
29
- }
30
- }
31
-
32
- if (height) {
33
- const { length, count, isEmpty = false } = getVneLength(height);
34
- if (isEmpty) console.warn("Wrong Scrollbar Height:", height);
35
- else {
36
- result.height = `calc(${count}px * var(--vne-length-${length}))`;
37
- }
38
- }
24
+ if (width) result.width = getVneLength(width);
25
+ if (height) result.height = getVneLength(height);
39
26
 
40
27
  return result;
41
28
  }, [width, height]);
@@ -46,21 +33,8 @@ export const Scrollbar = ({ className = "", children, width = 0, height = 0, scr
46
33
  if (shouldRenderHorizontal) result.overflowX = "auto";
47
34
  if (shouldRenderVertical) result.overflowY = "auto";
48
35
 
49
- if (width) {
50
- const { length, count, isEmpty = false } = getVneLength(width);
51
- if (isEmpty) console.warn("Wrong Scrollbar Width:", width);
52
- else {
53
- result.maxWidth = `calc(${count}px * var(--vne-length-${length}))`;
54
- }
55
- }
56
-
57
- if (height) {
58
- const { length, count, isEmpty = false } = getVneLength(height);
59
- if (isEmpty) console.warn("Wrong Scrollbar Height:", height);
60
- else {
61
- result.maxHeight = `calc(${count}px * var(--vne-length-${length}))`;
62
- }
63
- }
36
+ if (width) result.maxWidth = getVneLength(width);
37
+ if (height) result.maxHeight = getVneLength(height);
64
38
 
65
39
  return result;
66
40
  }, [width, height, scrollbarWrapRef.current, shouldRenderHorizontal, shouldRenderVertical]);
@@ -14,42 +14,42 @@
14
14
 
15
15
  transition: 1000ms
16
16
 
17
- border-radius: calc(1px * var(--vne-length-8))
17
+ border-radius: s('round(down, min(calc(8 * 100vw / 3840), calc(8 * 100vh / 2160)), 1px)')
18
18
  opacity: 0
19
19
 
20
20
  &-thumb
21
21
  position: absolute
22
22
 
23
23
  background: var(--vne-scrollbar-color-thumb)
24
- border-radius: calc(1px * var(--vne-length-12))
24
+ border-radius: s('round(down, min(calc(12 * 100vw / 3840), calc(12 * 100vh / 2160)), 1px)')
25
25
 
26
26
  &-scroll_vertical
27
- right: calc(-1px * var(--vne-length-24))
27
+ right: s('round(down, min(calc(-24 * 100vw / 3840), calc(-24 * 100vh / 2160)), 1px)')
28
28
  top: 0;
29
- bottom: calc(1px * var(--vne-length-36));
29
+ bottom: s('round(down, min(calc(36 * 100vw / 3840), calc(36 * 100vh / 2160)), 1px)')
30
30
 
31
- width: calc(1px * var(--vne-length-12))
31
+ width: s('round(down, min(calc(12 * 100vw / 3840), calc(12 * 100vh / 2160)), 1px)')
32
32
 
33
33
  background: var(--vne-scrollbar-color-vertical)
34
34
 
35
35
  &-thumb_vertical
36
- right: calc(-1px * var(--vne-length-6))
37
- width: calc(1px * var(--vne-length-24))
38
- height: calc(2px * var(--vne-length-48))
36
+ right: s('round(down, min(calc(-6 * 100vw / 3840), calc(-6 * 100vh / 2160)), 1px)')
37
+ width: s('round(down, min(calc(24 * 100vw / 3840), calc(24 * 100vh / 2160)), 1px)')
38
+ height: s('round(down, min(calc(96 * 100vw / 3840), calc(96 * 100vh / 2160)), 1px)')
39
39
 
40
40
  &-scroll_horizontal
41
- bottom: calc(-1px * var(--vne-length-24))
41
+ bottom: s('round(down, min(calc(-24 * 100vw / 3840), calc(-24 * 100vh / 2160)), 1px)')
42
42
  left: 0;
43
- right: calc(1px * var(--vne-length-36));
43
+ right: s('round(down, min(calc(36 * 100vw / 3840), calc(36 * 100vh / 2160)), 1px)')
44
44
 
45
- height: calc(1px * var(--vne-length-12))
45
+ height: s('round(down, min(calc(12 * 100vw / 3840), calc(12 * 100vh / 2160)), 1px)')
46
46
 
47
47
  background: var(--vne-scrollbar-color-horizontal)
48
48
 
49
49
  &-thumb_horizontal
50
- top: calc(-1px * var(--vne-length-6))
51
- width: calc(2px * var(--vne-length-48))
52
- height: calc(1px * var(--vne-length-24))
50
+ top: s('round(down, min(calc(-6 * 100vw / 3840), calc(-6 * 100vh / 2160)), 1px)')
51
+ width: s('round(down, min(calc(96 * 100vw / 3840), calc(96 * 100vh / 2160)), 1px)')
52
+ height: s('round(down, min(calc(24 * 100vw / 3840), calc(24 * 100vh / 2160)), 1px)')
53
53
 
54
54
  &-scroll_isVisible
55
55
  opacity: 1
@@ -1,22 +1,25 @@
1
- import { useEffect, useRef } from "react";
1
+ import { getVneLength } from "@vnejs/uis.utils";
2
+ import { useEffect } from "react";
2
3
 
3
4
  export const useThumbHook = (scrollbarWrapRef, thumbVerticalRef, thumbHorizontalRef) => {
4
5
  useEffect(() => {
5
6
  const handleScroll = () => {
6
7
  if (!scrollbarWrapRef.current) return;
7
8
 
9
+ const l24 = getVneLength(24);
10
+
8
11
  if (thumbHorizontalRef.current) {
9
12
  const maxScrollLeft = scrollbarWrapRef.current.scrollWidth - scrollbarWrapRef.current.clientWidth;
10
13
  const percentleft = 100 * (scrollbarWrapRef.current.scrollLeft / maxScrollLeft);
11
14
 
12
- thumbHorizontalRef.current.style.left = `calc(${percentleft}% + ${(100 - percentleft) / 100}px * var(--vne-length-24) - ${percentleft / 100}px * 5 * var(--vne-length-24))`;
15
+ thumbHorizontalRef.current.style.left = `calc(${percentleft}% + ${(100 - percentleft) / 100}px * ${l24} - ${percentleft / 100}px * 5 * ${l24})`;
13
16
  }
14
17
 
15
18
  if (thumbVerticalRef.current) {
16
19
  const maxScrollTop = scrollbarWrapRef.current.scrollHeight - scrollbarWrapRef.current.clientHeight;
17
20
  const percentTop = 100 * (scrollbarWrapRef.current.scrollTop / maxScrollTop);
18
21
 
19
- thumbVerticalRef.current.style.top = `calc(${percentTop}% + ${(100 - percentTop) / 100}px * var(--vne-length-24) - ${percentTop / 100}px * 5 * var(--vne-length-24))`;
22
+ thumbVerticalRef.current.style.top = `calc(${percentTop}% + ${(100 - percentTop) / 100}px * ${l24} - ${percentTop / 100}px * 5 * ${l24})`;
20
23
  }
21
24
  };
22
25
 
@@ -13,13 +13,8 @@ const useHooks = ({ isNotRender = false, color = null, size = 60, opacity = null
13
13
  if (opacity !== null) result.opacity = opacity;
14
14
 
15
15
  if (size) {
16
- const { length, count, isEmpty = false } = getVneLength(size);
17
-
18
- if (isEmpty) console.warn("Wrong Svg Size:", size);
19
- else {
20
- result.width = `calc(${count}px * var(--vne-length-${length}))`;
21
- result.height = `calc(${count}px * var(--vne-length-${length}))`;
22
- }
16
+ result.width = getVneLength(size);
17
+ result.height = getVneLength(size);
23
18
  }
24
19
 
25
20
  return result;
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useMemo } from "react";
2
2
 
3
- import { getVneLength, cn } from "@vnejs/uis.utils";
3
+ import { cn, getVneLength } from "@vnejs/uis.utils";
4
4
 
5
5
  import "./Text.styl";
6
6
 
@@ -43,35 +43,12 @@ export const Text = ({
43
43
  if (opacity !== null) result.opacity = opacity;
44
44
 
45
45
  if (size) {
46
- const { length, count, isEmpty = false } = getVneLength(size);
47
-
48
- if (isEmpty) console.warn("Wrong Text Size:", size);
49
- else {
50
- result.fontSize = `calc(${count}px * var(--vne-length-${length}) * var(--vne-text-size-multiplicator, 1))`;
51
- result.lineHeight = `calc(${count * 1.25}px * var(--vne-length-${length}))`;
52
- }
53
- }
54
-
55
- if (padding) {
56
- const { length, count, isEmpty = false } = getVneLength(padding);
57
-
58
- if (isEmpty) console.warn("Wrong Text Padding:", padding);
59
- else result.padding = `calc(${count}px * var(--vne-length-${length}))`;
60
- }
61
-
62
- if (width) {
63
- const { length, count, isEmpty = false } = getVneLength(width);
64
-
65
- if (isEmpty) console.warn("Wrong Text Width:", width);
66
- else result.width = `calc(${count}px * var(--vne-length-${length}))`;
67
- }
68
-
69
- if (marginTop) {
70
- const { length, count, isEmpty = false } = getVneLength(marginTop);
71
-
72
- if (isEmpty) console.warn("Wrong Text Margin Top:", marginTop);
73
- else result.marginTop = `calc(${count}px * var(--vne-length-${length}))`;
46
+ result.fontSize = `round(down, calc(${getVneLength(size)} * var(--vne-text-size-multiplicator, 1)), 1px)`;
47
+ result.lineHeight = `round(down, calc(${getVneLength(1.25 * size)} * var(--vne-text-size-multiplicator, 1)), 1px)`;
74
48
  }
49
+ if (padding) result.padding = getVneLength(padding);
50
+ if (width) result.width = getVneLength(width);
51
+ if (marginTop) result.marginTop = getVneLength(marginTop);
75
52
 
76
53
  return result;
77
54
  }, [font, color, whiteSpace, size, weight, padding, marginTop, opacity, width, transition]);
@@ -24,7 +24,7 @@
24
24
 
25
25
  &_isSelected
26
26
  font-weight: bold
27
- text-shadow: 0 0 calc(1px * var(--vne-length-24)) rgba(255, 255, 255, 90%)
27
+ text-shadow: 0 0 s('round(down, min(calc(12 * 100vw / 3840), calc(12 * 100vh / 2160)), 1px)') rgba(255, 255, 255, 90%)
28
28
 
29
29
  &_isHoverable[vne-cursor-target],
30
30
  .TextHoverParent[vne-cursor-target] &,
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useMemo } from "react";
2
2
 
3
- import { getVneLength, cn } from "@vnejs/uis.utils";
3
+ import { cn, getVneLength } from "@vnejs/uis.utils";
4
4
 
5
5
  import "./Toggle.styl";
6
6
 
@@ -11,14 +11,9 @@ export const Toggle = ({ isSelected = false, size = 96, transition = 300, classN
11
11
  const result = {};
12
12
 
13
13
  if (size) {
14
- const { length, count, isEmpty = false } = getVneLength(size);
15
-
16
- if (isEmpty) console.warn("Wrong Toggle Size:", size);
17
- else {
18
- result.width = `calc(${count * 2}px * var(--vne-length-${length}))`;
19
- result.height = `calc(${count}px * var(--vne-length-${length}))`;
20
- result.borderRadius = `calc(${count * 0.5}px * var(--vne-length-${length}))`;
21
- }
14
+ result.width = getVneLength(2 * size);
15
+ result.height = getVneLength(size);
16
+ result.borderRadius = getVneLength(0.5 * size);
22
17
  }
23
18
 
24
19
  if (transition) result.transition = `${transition}ms`;
@@ -5,7 +5,7 @@
5
5
  --vne-toggle-color-toggled: var(--vne-color-primary, rgba(255, 255, 255, 60%))
6
6
  --vne-toggle-color-button: var(--vne-color-active, rgba(255, 255, 255, 90%))
7
7
 
8
- --vne-toggle-shadow-selected: var(--vne-shadow-selected, 0 0 calc(1px * var(--vne-length-24)) var(--vne-color-active, rgba(255, 255, 255, 90%)))
8
+ --vne-toggle-shadow-selected: var(--vne-shadow-selected, 0 0 s('round(down, min(calc(24 * 100vw / 3840), calc(24 * 100vh / 2160)), 1px)') var(--vne-color-active, rgba(255, 255, 255, 90%)))
9
9
 
10
10
  background: var(--vne-toggle-color-untoggled)
11
11
 
@@ -1,5 +1,7 @@
1
1
  import { useMemo } from "react";
2
2
 
3
+ import { getVneLength } from "@vnejs/uis.utils";
4
+
3
5
  import { renderWithVneWrap, VneWrap } from "../../storybook/VneWrap/VneWrap";
4
6
 
5
7
  import { View } from "../";
@@ -43,10 +45,11 @@ export default {
43
45
  }, [top, right, bottom, left, isUseTop, isUseRight, isUseBottom, isUseLeft]);
44
46
 
45
47
  const props = useMemo(() => ({ ...positionProps, ...args }), [positionProps, args]);
48
+ const style = useMemo(() => ({ width: getVneLength(720), height: getVneLength(540), background: "red" }), []);
46
49
 
47
50
  return (
48
51
  <View {...props}>
49
- <div style={{ width: `calc(2px * var(--vne-length-360))`, height: `calc(2px * var(--vne-length-270))`, background: "red" }} />
52
+ <div style={style} />
50
53
  </View>
51
54
  );
52
55
  },
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useMemo } from "react";
2
2
 
3
- import { getVneLength, cn } from "@vnejs/uis.utils";
3
+ import { cn, getVneLength } from "@vnejs/uis.utils";
4
4
 
5
5
  import "./Wrap.styl";
6
6
 
@@ -33,74 +33,22 @@ export const Wrap = ({
33
33
  result.backgroundColor = "";
34
34
  result.backgroundImage = `url("${imageSrc}")`;
35
35
  }
36
+ if (transition) result.transition = `${transition}ms`;
37
+ if (opacity !== null) result.opacity = opacity;
36
38
 
37
- if (padding) {
38
- const { length, count, isEmpty = false } = getVneLength(padding);
39
-
40
- if (isEmpty) console.warn("Wrong Wrap Padding:", padding);
41
- else result.padding = `calc(${count}px * var(--vne-length-${length}))`;
42
- }
43
-
39
+ if (padding) result.padding = getVneLength(padding);
44
40
  if (paddingHorizontal) {
45
- const { length, count, isEmpty = false } = getVneLength(paddingHorizontal);
46
-
47
- if (isEmpty) console.warn("Wrong Wrap Padding Horizontal:", paddingHorizontal);
48
- else {
49
- result.paddingLeft = `calc(${count}px * var(--vne-length-${length}))`;
50
- result.paddingRight = `calc(${count}px * var(--vne-length-${length}))`;
51
- }
41
+ result.paddingLeft = getVneLength(paddingHorizontal);
42
+ result.paddingRight = getVneLength(paddingHorizontal);
52
43
  }
53
-
54
44
  if (paddingVertical) {
55
- const { length, count, isEmpty = false } = getVneLength(paddingVertical);
56
-
57
- if (isEmpty) console.warn("Wrong Wrap Padding Vertical:", paddingVertical);
58
- else {
59
- result.paddingTop = `calc(${count}px * var(--vne-length-${length}))`;
60
- result.paddingBottom = `calc(${count}px * var(--vne-length-${length}))`;
61
- }
62
- }
63
-
64
- if (borderWidth) {
65
- const { length, count, isEmpty = false } = getVneLength(borderWidth);
66
-
67
- if (isEmpty) console.warn("Wrong Wrap BorderWidth:", borderWidth);
68
- else result.borderWidth = `calc(${count}px * var(--vne-length-${length}))`;
45
+ result.paddingTop = getVneLength(paddingVertical);
46
+ result.paddingBottom = getVneLength(paddingVertical);
69
47
  }
70
-
71
- if (borderRadius !== null) {
72
- if (borderRadius === 0) result.borderRadius = "0";
73
- else {
74
- const { length, count, isEmpty = false } = getVneLength(borderRadius);
75
-
76
- if (isEmpty) console.warn("Wrong Wrap BorderRadius:", borderRadius);
77
- else result.borderRadius = `calc(${count}px * var(--vne-length-${length}))`;
78
- }
79
- }
80
-
81
- if (width) {
82
- if (typeof width === "string") {
83
- result.width = width;
84
- } else {
85
- const { length, count, isEmpty = false } = getVneLength(width);
86
- if (isEmpty) console.warn("Wrong Wrap Width:", width);
87
- else result.width = `calc(${count}px * var(--vne-length-${length}))`;
88
- }
89
- }
90
-
91
- if (height) {
92
- if (typeof height === "string") {
93
- result.height = height;
94
- } else {
95
- const { length, count, isEmpty = false } = getVneLength(height);
96
- if (isEmpty) console.warn("Wrong Wrap Height:", height);
97
- else result.height = `calc(${count}px * var(--vne-length-${length}))`;
98
- }
99
- }
100
-
101
- if (transition) result.transition = `${transition}ms`;
102
-
103
- if (opacity !== null) result.opacity = opacity;
48
+ if (borderWidth) result.borderWidth = getVneLength(borderWidth);
49
+ if (borderRadius !== null) result.borderRadius = borderRadius === 0 ? "0" : getVneLength(borderRadius);
50
+ if (width) result.width = typeof width === "string" ? width : getVneLength(width);
51
+ if (height) result.height = typeof height === "string" ? height : getVneLength(height);
104
52
 
105
53
  return result;
106
54
  }, [padding, paddingHorizontal, paddingVertical, borderWidth, borderRadius, width, height, imageSrc, transition, opacity]);
@@ -1,6 +1,7 @@
1
1
  import { renderWithVneWrap, VneWrap } from "../../storybook/VneWrap/VneWrap";
2
2
 
3
3
  import { Wrap } from "../";
4
+ import { getVneLength } from "@vnejs/uis.utils";
4
5
 
5
6
  export const Common = {
6
7
  args: {
@@ -23,7 +24,7 @@ export default {
23
24
  title: "Primitives/Wrap",
24
25
  render: renderWithVneWrap((args) => (
25
26
  <Wrap {...args}>
26
- <div style={{ width: "calc(15px * var(--vne-length-80))", height: "calc(15px * var(--vne-length-45))", background: "transparent" }} />
27
+ <div style={{ width: getVneLength(15 * 80), height: getVneLength(15 * 45), background: "transparent" }} />
27
28
  </Wrap>
28
29
  )),
29
30
  argTypes: {
@@ -7,11 +7,11 @@
7
7
  --vne-wrap-border-color-selected: var(--vne-color-selected, rgba(255, 255, 255, 75%))
8
8
  --vne-wrap-border-color-active: var(--vne-color-active, rgba(255, 255, 255, 90%));
9
9
 
10
- --vne-wrap-border-radius-primary: var(--vne-length-24);
11
- --vne-wrap-border-radius-selected: var(--vne-length-36);
12
- --vne-wrap-border-radius-active: var(--vne-length-48);
10
+ --vne-wrap-border-radius-primary: s('round(down, min(calc(24 * 100vw / 3840), calc(24 * 100vh / 2160)), 1px)');
11
+ --vne-wrap-border-radius-selected: s('round(down, min(calc(36 * 100vw / 3840), calc(36 * 100vh / 2160)), 1px)');
12
+ --vne-wrap-border-radius-active: s('round(down, min(calc(48 * 100vw / 3840), calc(48 * 100vh / 2160)), 1px)')
13
13
 
14
- --vne-wrap-shadow-selected: var(--vne-shadow-selected, 0 0 calc(1px * var(--vne-length-24)) var(--vne-color-active, rgba(255, 255, 255, 90%)))
14
+ --vne-wrap-shadow-selected: var(--vne-shadow-selected, 0 0 s('round(down, min(calc(24 * 100vw / 3840), calc(24 * 100vh / 2160)), 1px)') var(--vne-color-active, rgba(255, 255, 255, 90%)))
15
15
 
16
16
  background-color: var(--vne-wrap-background-color-primary);
17
17
  border: 0px solid var(--vne-wrap-border-color-primary);
@@ -3,6 +3,7 @@ import { useEffect, useMemo, useState } from "react";
3
3
  import { renderWithVneWrap, VneWrap } from "../../storybook";
4
4
 
5
5
  import { Backdrop, Flex, Icon, PositionBox, Text, SmoothText, Screen } from "../../";
6
+ import { getVneLength } from "@vnejs/uis.utils";
6
7
 
7
8
  const VIEWS = { DIALOG: "dialog", LINE: "line", WALL: "wall" };
8
9
 
@@ -91,7 +92,7 @@ export default {
91
92
  width: "100%",
92
93
  height: "100%",
93
94
  background: "rgba(0, 0, 0, 0.3)",
94
- borderRadius: view === VIEWS.WALL ? "calc(1px * var(--vne-length-48))" : "0",
95
+ borderRadius: view === VIEWS.WALL ? getVneLength(48) : "0",
95
96
  }}
96
97
  />
97
98
  </PositionBox>
@@ -116,8 +117,8 @@ export default {
116
117
  >
117
118
  <div
118
119
  style={{
119
- height: "calc(1px * var(--vne-length-6))",
120
- width: "calc(5px * var(--vne-length-360))",
120
+ height: getVneLength(6),
121
+ width: getVneLength(1800),
121
122
  background: "linear-gradient(to right, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%)",
122
123
  }}
123
124
  />
@@ -1,7 +1,5 @@
1
1
  import { useEffect, useMemo, useRef, useState } from "react";
2
2
 
3
- import { HEIGHT, WIDTH, LENGTH_ARRAY } from "@vnejs/uis.utils";
4
-
5
3
  import { Flex } from "../../primitives";
6
4
 
7
5
  import "./VneWrap.styl";
@@ -15,20 +13,6 @@ export const VneWrap = ({ children, height, width, textSize, aspectRatio, backgr
15
13
  const style = useMemo(() => {
16
14
  const result = { width: `${realWidth}px`, height: `${height}px`, position: "relative", background };
17
15
 
18
- LENGTH_ARRAY.forEach((len) => {
19
- const h = Math.max(Math.floor((height * len) / HEIGHT), 1);
20
- const w = Math.max(Math.floor((realWidth * len) / WIDTH), 1);
21
-
22
- result[`--vne-length-${len}`] = Math.min(h, w);
23
- });
24
-
25
- console.log(childrenRef.current);
26
-
27
- if (childrenRef.current) {
28
- result[`--vne-length-100vh`] = childrenRef.current.clientHeight;
29
- result[`--vne-length-100vw`] = childrenRef.current.clientWidth;
30
- }
31
-
32
16
  if (textSize) result["--vne-text-size-multiplicator"] = textSize;
33
17
 
34
18
  return result;
@@ -14,7 +14,7 @@
14
14
  --vne-color-negative-active: rgba(0, 0, 0, 90%);
15
15
  --vne-color-negative-main: rgba(0, 0, 0, 100%);
16
16
 
17
- --vne-shadow-selected: 0 0 calc(1px * var(--vne-length-24)) var(--vne-color-active, rgba(255, 255, 255, 90%))
17
+ --vne-shadow-selected: 0 0 s('round(down, min(calc(12 * 100vw / 3840), calc(12 * 100vh / 2160)), 1px)') var(--vne-color-active, rgba(255, 255, 255, 90%))
18
18
 
19
19
  font-family: Montserrat
20
20