@vnejs/uis.react.button-controls 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,32 +1,26 @@
1
1
  {
2
2
  "name": "@vnejs/uis.react.button-controls",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
7
- "build": "node ../../../scripts/build-package.mjs",
8
- "publish:major:plugin": "npm run publish:major",
9
- "publish:minor:plugin": "npm run publish:minor",
10
- "publish:patch:plugin": "npm run publish:patch",
11
- "publish:major": "npm run build && npm version major && npm publish --access public",
12
- "publish:minor": "npm run build && npm version minor && npm publish --access public",
13
- "publish:patch": "npm run build && npm version patch && npm publish --access public"
7
+ "build": "npx @vnejs/monorepo package",
8
+ "publish:major:uis:react": "npm run publish:major",
9
+ "publish:minor:uis:react": "npm run publish:minor",
10
+ "publish:patch:uis:react": "npm run publish:patch",
11
+ "publish:major": "npx @vnejs/monorepo publish major --access public",
12
+ "publish:minor": "npx @vnejs/monorepo publish minor --access public",
13
+ "publish:patch": "npx @vnejs/monorepo publish patch --access public"
14
14
  },
15
15
  "peerDependencies": {
16
- "@bem-react/classname": "1.5.12",
17
- "@vnejs/uis.utils": "~0.1.0",
18
- "react": "19.2.4",
19
- "react-dom": "19.2.4",
20
- "@vnejs/uis.react": "~0.1.0"
16
+ "@vnejs/uis.utils": "~0.1.0"
21
17
  },
22
18
  "devDependencies": {
23
- "@vnejs/uis.react": "~0.1.0",
24
- "typescript": "^6.0.3",
25
- "@types/react": "^19.0.10",
26
- "@types/react-dom": "^19.0.4"
19
+ "@vnejs/uis.react": "~0.1.0"
27
20
  },
28
21
  "files": [
29
22
  "dist",
30
- "package.json"
23
+ "src",
24
+ "tsconfig.json"
31
25
  ]
32
26
  }
@@ -0,0 +1,104 @@
1
+ import { useMemo } from "react";
2
+
3
+ import { VneWrap } from "@vnejs/uis.react";
4
+
5
+ import { Flex } from "@vnejs/uis.react";
6
+
7
+ import { ButtonControls } from "./ButtonControls";
8
+
9
+ export const Common = {
10
+ args: {
11
+ vneHeight: 720,
12
+ count: 3,
13
+
14
+ gap: 48,
15
+
16
+ width: 1200,
17
+ height: 600,
18
+
19
+ activeIndex: 1,
20
+ direction: Flex.DIRECTION.ROW,
21
+ align: Flex.ALIGN.START,
22
+ justify: Flex.JUSTIFY.CENTER,
23
+
24
+ padding: 12,
25
+ textSize: 48,
26
+ borderWidth: 6,
27
+ buttonWidth: 300,
28
+ },
29
+ };
30
+
31
+ export default {
32
+ title: "Base/ButtonControls",
33
+ render: ({
34
+ vneHeight,
35
+ count,
36
+ // buttonControls
37
+ activeIndex,
38
+ // flex
39
+ gap,
40
+ direction,
41
+ align,
42
+ justify,
43
+ width,
44
+ height,
45
+ // button
46
+ padding,
47
+ textSize,
48
+ borderWidth,
49
+ buttonWidth,
50
+ }) => {
51
+ const buttons = useMemo(
52
+ () =>
53
+ [
54
+ { text: "1280 X 720", onClick: () => alert(1) },
55
+ { text: "1920 X 1080", onClick: () => alert(2) },
56
+ { text: "3840 X 2160", onClick: () => alert(3) },
57
+ ].slice(0, count),
58
+ [count],
59
+ );
60
+
61
+ const flexProps = useMemo(() => ({ direction, align, justify, width, height, gap }), [direction, align, justify, width, height, gap]);
62
+
63
+ const buttonProps = useMemo(() => ({ padding, textSize, borderWidth, width: buttonWidth, isRounded: true }), [buttonWidth, padding, textSize, borderWidth]);
64
+
65
+ return (
66
+ <VneWrap height={vneHeight}>
67
+ <Flex
68
+ align={Flex.ALIGN.CENTER}
69
+ justify={Flex.JUSTIFY.CENTER}
70
+ height={2160}
71
+ >
72
+ <ButtonControls
73
+ flexProps={flexProps}
74
+ buttonProps={buttonProps}
75
+ buttons={buttons}
76
+ activeIndex={activeIndex}
77
+ />
78
+ </Flex>
79
+ </VneWrap>
80
+ );
81
+ },
82
+ argTypes: {
83
+ // engine
84
+ vneHeight: { control: { type: "number", min: 180, max: 2160, step: 45 } },
85
+ count: { control: { type: "number", min: 1, max: 3, step: 1 } },
86
+
87
+ // Flex
88
+ gap: { control: { type: "number", min: 0, max: 144, step: 12 } },
89
+ direction: { control: { type: "select" }, options: Object.values(Flex.DIRECTION) },
90
+ align: { control: { type: "select" }, options: Object.values(Flex.ALIGN) },
91
+ justify: { control: { type: "select" }, options: Object.values(Flex.JUSTIFY) },
92
+ width: { control: { type: "number", min: 0, max: 1800, step: 60 } },
93
+ height: { control: { type: "number", min: 0, max: 1800, step: 60 } },
94
+
95
+ // Button
96
+ textSize: { control: { type: "number", min: 24, max: 180, step: 12 } },
97
+ padding: { control: { type: "number", min: 0, max: 60, step: 12 } },
98
+ borderWidth: { control: { type: "number", min: 0, max: 12, step: 6 } },
99
+ buttonWidth: { control: { type: "number", min: 0, max: 1800, step: 60 } },
100
+
101
+ // TextControls
102
+ activeIndex: { control: { type: "number", min: -1, max: 2, step: 1 } },
103
+ },
104
+ };
@@ -0,0 +1,33 @@
1
+ import { Button, Flex } from "@vnejs/uis.react";
2
+
3
+ export const ButtonControls = ({
4
+ buttons = [],
5
+ activeIndex = -1,
6
+ buttonIsRounded = true,
7
+ buttonBorderWidth = 6,
8
+ buttonPaddingVertical = 12,
9
+ buttonPaddingHorizontal = 60,
10
+ flexGap = 24,
11
+ flexProps = {},
12
+ buttonProps = {},
13
+ }) => {
14
+ return (
15
+ <Flex
16
+ gap={flexGap}
17
+ {...flexProps}
18
+ >
19
+ {buttons.map((buttonInfo, i) => (
20
+ <Button
21
+ key={i}
22
+ isRounded={buttonIsRounded}
23
+ borderWidth={buttonBorderWidth}
24
+ paddingVertical={buttonPaddingVertical}
25
+ paddingHorizontal={buttonPaddingHorizontal}
26
+ {...buttonInfo}
27
+ {...buttonProps}
28
+ isActive={activeIndex === i}
29
+ />
30
+ ))}
31
+ </Flex>
32
+ );
33
+ };
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./ButtonControls";
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": "../../../tsconfig.react.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "rootDir": "src"
6
+ },
7
+ "include": [
8
+ "src/**/*.ts",
9
+ "src/**/*.tsx",
10
+ "../../../globals.d.ts",
11
+ "../../../peer-modules.d.ts"
12
+ ],
13
+ "exclude": [
14
+ "dist",
15
+ "node_modules",
16
+ "src/**/*.stories.tsx"
17
+ ]
18
+ }