@vnejs/uis.react.backdrop 0.2.0 → 0.2.1

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.
@@ -1,5 +1,5 @@
1
1
  import { BackdropType, type BackdropProps } from "./Backdrop.types.js";
2
- export declare function Backdrop({ zIndex, transition, type, size, opacity, color1, color2, className, children, }: BackdropProps): import("react").JSX.Element;
2
+ export declare function Backdrop({ zIndex, transition, type, opacity, color1, color2, stop1, stop2, scaleX, scaleY, translateX, translateY, borderRadius, className, children, }: BackdropProps): import("react").JSX.Element;
3
3
  export declare namespace Backdrop {
4
4
  export { BackdropType as TYPE };
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Backdrop.d.ts","sourceRoot":"","sources":["../src/Backdrop.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;iCAI9C,EACvB,MAAa,EACb,UAAiB,EACjB,IAAS,EACT,IAAU,EACV,OAAW,EACX,MAAM,EACN,MAAM,EACN,SAAS,EACT,QAAQ,GACT,EAAE,aAAa;;aAkCA,YAAY"}
1
+ {"version":3,"file":"Backdrop.d.ts","sourceRoot":"","sources":["../src/Backdrop.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;iCAkB9C,EACvB,MAAa,EACb,UAAiB,EACjB,IAAS,EACT,OAAW,EACX,MAAM,EACN,MAAM,EACN,KAAS,EACT,KAAW,EACX,MAAU,EACV,MAAU,EACV,UAAiB,EACjB,UAAiB,EACjB,YAAmB,EACnB,SAAS,EACT,QAAQ,GACT,EAAE,aAAa;;aAwCA,YAAY"}
package/dist/Backdrop.js CHANGED
@@ -3,7 +3,20 @@ import { useMemo } from "react";
3
3
  import { getVneLength } from "@vnejs/uis.utils";
4
4
  import { BackdropType } from "./Backdrop.types.js";
5
5
  import { b } from "./Backdrop.styles.js";
6
- export const Backdrop = ({ zIndex = null, transition = null, type = "", size = 360, opacity = 1, color1, color2, className, children, }) => {
6
+ const setLengthField = (result, field, value) => {
7
+ if (value === null || value === undefined)
8
+ return;
9
+ if (value === 0) {
10
+ result[field] = "0";
11
+ return;
12
+ }
13
+ if (typeof value === "string") {
14
+ result[field] = value;
15
+ return;
16
+ }
17
+ result[field] = getVneLength(value);
18
+ };
19
+ export const Backdrop = ({ zIndex = null, transition = null, type = "", opacity = 1, color1, color2, stop1 = 0, stop2 = 100, scaleX = 1, scaleY = 1, translateX = null, translateY = null, borderRadius = null, className, children, }) => {
7
20
  const style = useMemo(() => {
8
21
  const TYPE_TO_DEGREE = {
9
22
  [BackdropType.BOTTOM]: 0,
@@ -13,9 +26,12 @@ export const Backdrop = ({ zIndex = null, transition = null, type = "", size = 3
13
26
  };
14
27
  const result = {
15
28
  ["--vne-backdrop-degree"]: `${TYPE_TO_DEGREE[type || BackdropType.TOP]}deg`,
29
+ ["--vne-backdrop-stop-1"]: `${stop1 ?? 0}%`,
30
+ ["--vne-backdrop-stop-2"]: `${stop2 ?? 100}%`,
31
+ ["--vne-backdrop-scale-x"]: scaleX ?? 1,
32
+ ["--vne-backdrop-scale-y"]: scaleY ?? 1,
16
33
  opacity,
17
34
  };
18
- result["--vne-backdrop-length"] = getVneLength(size);
19
35
  if (color1)
20
36
  result["--vne-backdrop-color-1"] = color1;
21
37
  if (color2)
@@ -24,9 +40,12 @@ export const Backdrop = ({ zIndex = null, transition = null, type = "", size = 3
24
40
  result.zIndex = zIndex;
25
41
  if (transition !== null)
26
42
  result.transition = transition === 0 ? "none" : `${transition}ms`;
43
+ setLengthField(result, "--vne-backdrop-translate-x", translateX);
44
+ setLengthField(result, "--vne-backdrop-translate-y", translateY);
45
+ setLengthField(result, "--vne-backdrop-border-radius", borderRadius);
27
46
  return result;
28
- }, [zIndex, size, type, color1, color2, opacity]);
29
- return (_jsx("div", { className: b({ type }, [className]), style: style, children: children }));
47
+ }, [zIndex, type, color1, color2, stop1, stop2, opacity, transition, scaleX, scaleY, translateX, translateY, borderRadius]);
48
+ return (_jsx("div", { className: b({}, [className]), style: style, children: children }));
30
49
  };
31
50
  Backdrop.TYPE = BackdropType;
32
51
  //# sourceMappingURL=Backdrop.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Backdrop.js","sourceRoot":"","sources":["../src/Backdrop.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAsB,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAC;AAEzC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,MAAM,GAAG,IAAI,EACb,UAAU,GAAG,IAAI,EACjB,IAAI,GAAG,EAAE,EACT,IAAI,GAAG,GAAG,EACV,OAAO,GAAG,CAAC,EACX,MAAM,EACN,MAAM,EACN,SAAS,EACT,QAAQ,GACM,EAAE,EAAE;IAClB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE;QACzB,MAAM,cAAc,GAAG;YACrB,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;YACxB,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE;YACvB,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,GAAG;YACvB,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,GAAG;SAC1B,CAAC;QAEF,MAAM,MAAM,GAAwB;YAClC,CAAC,uBAAuB,CAAC,EAAE,GAAG,cAAc,CAAC,IAAI,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK;YAC3E,OAAO;SACR,CAAC;QAEF,MAAM,CAAC,uBAAuB,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QAErD,IAAI,MAAM;YAAE,MAAM,CAAC,wBAAwB,CAAC,GAAG,MAAM,CAAC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;YAAE,MAAM,CAAC,wBAAwB,CAAC,GAAG,MAAM,CAAC;QACtD,IAAI,MAAM,KAAK,IAAI;YAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;QAC5C,IAAI,UAAU,KAAK,IAAI;YAAE,MAAM,CAAC,UAAU,GAAG,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,CAAC;QAE3F,cAAc,CAAC,MAAM,EAAE,4BAA4B,EAAE,UAAU,CAAC,CAAC;QACjE,cAAc,CAAC,MAAM,EAAE,4BAA4B,EAAE,UAAU,CAAC,CAAC;QACjE,cAAc,CAAC,MAAM,EAAE,8BAA8B,EAAE,YAAY,CAAC,CAAC;QAErE,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC;IAE5H,OAAO,CACL,cACE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAC7B,KAAK,EAAE,KAAK,YAEX,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,QAAQ,CAAC,IAAI,GAAG,YAAY,CAAC"}
@@ -1,51 +1,48 @@
1
1
  import { cn, injectStyles, sel } from "@vnejs/uis.utils";
2
2
  export const b = cn("Backdrop");
3
- const typeTop = sel(b({ type: "top" }));
4
- const typeRight = sel(b({ type: "right" }));
5
- const typeBottom = sel(b({ type: "bottom" }));
6
- const typeLeft = sel(b({ type: "left" }));
7
3
  const CSS = `
4
+ @property --vne-backdrop-color-1 {
5
+ syntax: "<color>";
6
+ inherits: true;
7
+ initial-value: rgba(0, 0, 0, 0.85);
8
+ }
9
+ @property --vne-backdrop-color-2 {
10
+ syntax: "<color>";
11
+ inherits: true;
12
+ initial-value: rgba(0, 0, 0, 0);
13
+ }
14
+ @property --vne-backdrop-stop-1 {
15
+ syntax: "<percentage>";
16
+ inherits: true;
17
+ initial-value: 0%;
18
+ }
19
+ @property --vne-backdrop-stop-2 {
20
+ syntax: "<percentage>";
21
+ inherits: true;
22
+ initial-value: 100%;
23
+ }
24
+
8
25
  ${sel(b())} {
9
- --vne-backdrop-color-1: rgba(0, 0, 0, 85%);
10
- --vne-backdrop-color-2: rgba(0, 0, 0, 0%);
26
+ --vne-backdrop-color-1: rgba(0, 0, 0, 0.85);
27
+ --vne-backdrop-color-2: rgba(0, 0, 0, 0);
11
28
  --vne-backdrop-degree: 0deg;
29
+ --vne-backdrop-stop-1: 0%;
30
+ --vne-backdrop-stop-2: 100%;
31
+ --vne-backdrop-scale-x: 1;
32
+ --vne-backdrop-scale-y: 1;
33
+ --vne-backdrop-translate-x: 0;
34
+ --vne-backdrop-translate-y: 0;
35
+ --vne-backdrop-border-radius: 0;
12
36
  display: block;
13
37
  position: absolute;
14
- background: linear-gradient(var(--vne-backdrop-degree), var(--vne-backdrop-color-1) 0%, var(--vne-backdrop-color-2) 100%);
15
- }
16
-
17
- ${typeTop},
18
- ${typeRight},
19
- ${typeLeft} {
20
38
  top: 0;
21
- }
22
-
23
- ${typeTop},
24
- ${typeRight},
25
- ${typeBottom} {
26
39
  right: 0;
27
- }
28
-
29
- ${typeRight},
30
- ${typeBottom},
31
- ${typeLeft} {
32
40
  bottom: 0;
33
- }
34
-
35
- ${typeTop},
36
- ${typeBottom},
37
- ${typeLeft} {
38
41
  left: 0;
39
- }
40
-
41
- ${typeTop},
42
- ${typeBottom} {
43
- height: var(--vne-backdrop-length);
44
- }
45
-
46
- ${typeRight},
47
- ${typeLeft} {
48
- width: var(--vne-backdrop-length);
42
+ background: linear-gradient(var(--vne-backdrop-degree), var(--vne-backdrop-color-1) var(--vne-backdrop-stop-1), var(--vne-backdrop-color-2) var(--vne-backdrop-stop-2));
43
+ border-radius: var(--vne-backdrop-border-radius);
44
+ transform: translate(var(--vne-backdrop-translate-x), var(--vne-backdrop-translate-y)) scaleX(var(--vne-backdrop-scale-x)) scaleY(var(--vne-backdrop-scale-y));
45
+ transform-origin: 50% 50%;
49
46
  }
50
47
  `;
51
48
  injectStyles(CSS);
@@ -1 +1 @@
1
- {"version":3,"file":"Backdrop.styles.js","sourceRoot":"","sources":["../src/Backdrop.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;AAEhC,MAAM,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AACxC,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;AAC5C,MAAM,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;AAC9C,MAAM,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAE1C,MAAM,GAAG,GAAG;EACV,GAAG,CAAC,CAAC,EAAE,CAAC;;;;;;;;;EASR,OAAO;EACP,SAAS;EACT,QAAQ;;;;EAIR,OAAO;EACP,SAAS;EACT,UAAU;;;;EAIV,SAAS;EACT,UAAU;EACV,QAAQ;;;;EAIR,OAAO;EACP,UAAU;EACV,QAAQ;;;;EAIR,OAAO;EACP,UAAU;;;;EAIV,SAAS;EACT,QAAQ;;;CAGT,CAAC;AAEF,YAAY,CAAC,GAAG,CAAC,CAAC"}
1
+ {"version":3,"file":"Backdrop.styles.js","sourceRoot":"","sources":["../src/Backdrop.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;AAEhC,MAAM,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;EAsBV,GAAG,CAAC,CAAC,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;CAsBT,CAAC;AAEF,YAAY,CAAC,GAAG,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
- import type { CssInsertValueLength, CssInsertValueNumber, CssInsertValueString } from "@vnejs/uis.utils";
2
+ import type { CssInsertValue, CssInsertValueNumber, CssInsertValueString } from "@vnejs/uis.utils";
3
3
  export declare const BackdropType: {
4
4
  readonly TOP: "top";
5
5
  readonly RIGHT: "right";
@@ -11,10 +11,16 @@ export type BackdropProps = {
11
11
  zIndex?: CssInsertValueNumber;
12
12
  transition?: CssInsertValueNumber;
13
13
  type?: BackdropTypeValue | "";
14
- size?: CssInsertValueLength;
15
14
  opacity?: CssInsertValueNumber;
16
15
  color1?: CssInsertValueString;
17
16
  color2?: CssInsertValueString;
17
+ stop1?: CssInsertValueNumber;
18
+ stop2?: CssInsertValueNumber;
19
+ scaleX?: CssInsertValueNumber;
20
+ scaleY?: CssInsertValueNumber;
21
+ translateX?: CssInsertValue;
22
+ translateY?: CssInsertValue;
23
+ borderRadius?: CssInsertValue;
18
24
  className?: string;
19
25
  children?: ReactNode;
20
26
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Backdrop.types.d.ts","sourceRoot":"","sources":["../src/Backdrop.types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEzG,eAAO,MAAM,YAAY;aACvB,GAAG,EAAE,KAAK;aACV,KAAK,EAAE,OAAO;a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,oBAAoB,CAAC;IAC9B,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,YAAY,CAAC,EAAE,cAAc,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/uis.react.backdrop",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -4,9 +4,15 @@ import { Backdrop } from "./Backdrop.js";
4
4
  export const Common = {
5
5
  args: {
6
6
  vneHeight: 720,
7
- type: Backdrop.TYPE.TOP,
7
+ type: Backdrop.TYPE.BOTTOM,
8
8
  zIndex: 10,
9
- size: 180,
9
+ scaleX: 1,
10
+ scaleY: 600 / 2160,
11
+ translateX: 0,
12
+ translateY: 1560,
13
+ stop1: 0,
14
+ stop2: 100,
15
+ borderRadius: 0,
10
16
  },
11
17
  };
12
18
 
@@ -24,9 +30,15 @@ export default {
24
30
  // Backdrop
25
31
  zIndex: { control: { type: "number", min: -100, max: 100, step: 5 } },
26
32
  type: { control: { type: "select" }, options: Object.values(Backdrop.TYPE) },
27
- size: { control: { type: "number", min: 120, max: 600, step: 12 } },
28
33
  color1: { control: { type: "select" }, options: ["", "red", "green", "blue", "black"] },
29
34
  color2: { control: { type: "select" }, options: ["", "red", "green", "blue", "black"] },
30
35
  transition: { control: { type: "number", min: 0, max: 600, step: 30 } },
36
+ scaleX: { control: { type: "number", min: 0, max: 1, step: 0.01 } },
37
+ scaleY: { control: { type: "number", min: 0, max: 1, step: 0.01 } },
38
+ translateX: { control: { type: "number", min: -2160, max: 2160, step: 12 } },
39
+ translateY: { control: { type: "number", min: -2160, max: 2160, step: 12 } },
40
+ stop1: { control: { type: "number", min: 0, max: 100, step: 1 } },
41
+ stop2: { control: { type: "number", min: 0, max: 100, step: 1 } },
42
+ borderRadius: { control: { type: "number", min: 0, max: 120, step: 6 } },
31
43
  },
32
44
  };
@@ -2,53 +2,49 @@ import { cn, injectStyles, sel } from "@vnejs/uis.utils";
2
2
 
3
3
  export const b = cn("Backdrop");
4
4
 
5
- const typeTop = sel(b({ type: "top" }));
6
- const typeRight = sel(b({ type: "right" }));
7
- const typeBottom = sel(b({ type: "bottom" }));
8
- const typeLeft = sel(b({ type: "left" }));
9
-
10
5
  const CSS = `
6
+ @property --vne-backdrop-color-1 {
7
+ syntax: "<color>";
8
+ inherits: true;
9
+ initial-value: rgba(0, 0, 0, 0.85);
10
+ }
11
+ @property --vne-backdrop-color-2 {
12
+ syntax: "<color>";
13
+ inherits: true;
14
+ initial-value: rgba(0, 0, 0, 0);
15
+ }
16
+ @property --vne-backdrop-stop-1 {
17
+ syntax: "<percentage>";
18
+ inherits: true;
19
+ initial-value: 0%;
20
+ }
21
+ @property --vne-backdrop-stop-2 {
22
+ syntax: "<percentage>";
23
+ inherits: true;
24
+ initial-value: 100%;
25
+ }
26
+
11
27
  ${sel(b())} {
12
- --vne-backdrop-color-1: rgba(0, 0, 0, 85%);
13
- --vne-backdrop-color-2: rgba(0, 0, 0, 0%);
28
+ --vne-backdrop-color-1: rgba(0, 0, 0, 0.85);
29
+ --vne-backdrop-color-2: rgba(0, 0, 0, 0);
14
30
  --vne-backdrop-degree: 0deg;
31
+ --vne-backdrop-stop-1: 0%;
32
+ --vne-backdrop-stop-2: 100%;
33
+ --vne-backdrop-scale-x: 1;
34
+ --vne-backdrop-scale-y: 1;
35
+ --vne-backdrop-translate-x: 0;
36
+ --vne-backdrop-translate-y: 0;
37
+ --vne-backdrop-border-radius: 0;
15
38
  display: block;
16
39
  position: absolute;
17
- background: linear-gradient(var(--vne-backdrop-degree), var(--vne-backdrop-color-1) 0%, var(--vne-backdrop-color-2) 100%);
18
- }
19
-
20
- ${typeTop},
21
- ${typeRight},
22
- ${typeLeft} {
23
40
  top: 0;
24
- }
25
-
26
- ${typeTop},
27
- ${typeRight},
28
- ${typeBottom} {
29
41
  right: 0;
30
- }
31
-
32
- ${typeRight},
33
- ${typeBottom},
34
- ${typeLeft} {
35
42
  bottom: 0;
36
- }
37
-
38
- ${typeTop},
39
- ${typeBottom},
40
- ${typeLeft} {
41
43
  left: 0;
42
- }
43
-
44
- ${typeTop},
45
- ${typeBottom} {
46
- height: var(--vne-backdrop-length);
47
- }
48
-
49
- ${typeRight},
50
- ${typeLeft} {
51
- width: var(--vne-backdrop-length);
44
+ background: linear-gradient(var(--vne-backdrop-degree), var(--vne-backdrop-color-1) var(--vne-backdrop-stop-1), var(--vne-backdrop-color-2) var(--vne-backdrop-stop-2));
45
+ border-radius: var(--vne-backdrop-border-radius);
46
+ transform: translate(var(--vne-backdrop-translate-x), var(--vne-backdrop-translate-y)) scaleX(var(--vne-backdrop-scale-x)) scaleY(var(--vne-backdrop-scale-y));
47
+ transform-origin: 50% 50%;
52
48
  }
53
49
  `;
54
50
 
package/src/Backdrop.tsx CHANGED
@@ -1,19 +1,39 @@
1
1
  import { useMemo } from "react";
2
2
 
3
- import { getVneLength } from "@vnejs/uis.utils";
3
+ import { getVneLength, type CssInsertValue } from "@vnejs/uis.utils";
4
4
 
5
5
  import { BackdropType, type BackdropProps } from "./Backdrop.types.js";
6
6
 
7
7
  import { b } from "./Backdrop.styles.js";
8
8
 
9
+ const setLengthField = (result: Record<string, string>, field: string, value: CssInsertValue) => {
10
+ if (value === null || value === undefined) return;
11
+ if (value === 0) {
12
+ result[field] = "0";
13
+ return;
14
+ }
15
+ if (typeof value === "string") {
16
+ result[field] = value;
17
+ return;
18
+ }
19
+
20
+ result[field] = getVneLength(value);
21
+ };
22
+
9
23
  export const Backdrop = ({
10
24
  zIndex = null,
11
25
  transition = null,
12
26
  type = "",
13
- size = 360,
14
27
  opacity = 1,
15
28
  color1,
16
29
  color2,
30
+ stop1 = 0,
31
+ stop2 = 100,
32
+ scaleX = 1,
33
+ scaleY = 1,
34
+ translateX = null,
35
+ translateY = null,
36
+ borderRadius = null,
17
37
  className,
18
38
  children,
19
39
  }: BackdropProps) => {
@@ -27,22 +47,28 @@ export const Backdrop = ({
27
47
 
28
48
  const result: Record<string, any> = {
29
49
  ["--vne-backdrop-degree"]: `${TYPE_TO_DEGREE[type || BackdropType.TOP]}deg`,
50
+ ["--vne-backdrop-stop-1"]: `${stop1 ?? 0}%`,
51
+ ["--vne-backdrop-stop-2"]: `${stop2 ?? 100}%`,
52
+ ["--vne-backdrop-scale-x"]: scaleX ?? 1,
53
+ ["--vne-backdrop-scale-y"]: scaleY ?? 1,
30
54
  opacity,
31
55
  };
32
56
 
33
- result["--vne-backdrop-length"] = getVneLength(size);
34
-
35
57
  if (color1) result["--vne-backdrop-color-1"] = color1;
36
58
  if (color2) result["--vne-backdrop-color-2"] = color2;
37
59
  if (zIndex !== null) result.zIndex = zIndex;
38
60
  if (transition !== null) result.transition = transition === 0 ? "none" : `${transition}ms`;
39
61
 
62
+ setLengthField(result, "--vne-backdrop-translate-x", translateX);
63
+ setLengthField(result, "--vne-backdrop-translate-y", translateY);
64
+ setLengthField(result, "--vne-backdrop-border-radius", borderRadius);
65
+
40
66
  return result;
41
- }, [zIndex, size, type, color1, color2, opacity]);
67
+ }, [zIndex, type, color1, color2, stop1, stop2, opacity, transition, scaleX, scaleY, translateX, translateY, borderRadius]);
42
68
 
43
69
  return (
44
70
  <div
45
- className={b({ type }, [className])}
71
+ className={b({}, [className])}
46
72
  style={style}
47
73
  >
48
74
  {children}
@@ -1,6 +1,6 @@
1
1
  import type { ReactNode } from "react";
2
2
 
3
- import type { CssInsertValueLength, CssInsertValueNumber, CssInsertValueString } from "@vnejs/uis.utils";
3
+ import type { CssInsertValue, CssInsertValueNumber, CssInsertValueString } from "@vnejs/uis.utils";
4
4
 
5
5
  export const BackdropType = {
6
6
  TOP: "top",
@@ -15,10 +15,16 @@ export type BackdropProps = {
15
15
  zIndex?: CssInsertValueNumber;
16
16
  transition?: CssInsertValueNumber;
17
17
  type?: BackdropTypeValue | "";
18
- size?: CssInsertValueLength;
19
18
  opacity?: CssInsertValueNumber;
20
19
  color1?: CssInsertValueString;
21
20
  color2?: CssInsertValueString;
21
+ stop1?: CssInsertValueNumber;
22
+ stop2?: CssInsertValueNumber;
23
+ scaleX?: CssInsertValueNumber;
24
+ scaleY?: CssInsertValueNumber;
25
+ translateX?: CssInsertValue;
26
+ translateY?: CssInsertValue;
27
+ borderRadius?: CssInsertValue;
22
28
  className?: string;
23
29
  children?: ReactNode;
24
30
  };