rharuow-ds 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.
- package/README.md +26 -0
- package/package.json +18 -6
- package/src/components/Button.tsx +0 -24
- package/src/components/Input.tsx +0 -104
- package/src/components/index.ts +0 -2
- package/src/lib/utils.ts +0 -5
- package/src/stories/Button.stories.tsx +0 -25
- package/src/stories/Input.stories.tsx +0 -29
- package/src/styles/tailwind.css +0 -3
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# rharuow-ds
|
|
2
|
+
|
|
3
|
+
Design System em React com integração a React Hook Form, Tailwind CSS e shadcn/ui.
|
|
4
|
+
|
|
5
|
+
## Instalação
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install rharuow-ds
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Uso básico
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Button, Input } from "rharuow-ds";
|
|
15
|
+
|
|
16
|
+
<Button variant="default">Clique aqui</Button>
|
|
17
|
+
<Input label="E-mail" name="email" />
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Documentação
|
|
21
|
+
|
|
22
|
+
Acesse a documentação interativa dos componentes em [GitHub Pages](#) _(link será atualizado após o deploy)_.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
Desenvolvido por Harysson.
|
package/package.json
CHANGED
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rharuow-ds",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"main": "
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"main": "dist/rharuow-ds.cjs.js",
|
|
5
|
+
"module": "dist/rharuow-ds.es.js",
|
|
6
|
+
"types": "dist/types/src/components/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/rharuow-ds.es.js",
|
|
10
|
+
"require": "./dist/rharuow-ds.cjs.js",
|
|
11
|
+
"types": "./dist/types/src/components/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
5
14
|
"scripts": {
|
|
6
15
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
7
16
|
"build": "vite build && tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
|
|
8
17
|
"storybook": "storybook dev -p 6006",
|
|
18
|
+
"deploy-storybook": "npx gh-pages -d storybook-static",
|
|
9
19
|
"build-storybook": "storybook build"
|
|
10
20
|
},
|
|
11
21
|
"keywords": [],
|
|
12
22
|
"author": "",
|
|
13
23
|
"license": "ISC",
|
|
14
24
|
"description": "",
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
27
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
28
|
+
"react-hook-form": "^7.59.0"
|
|
29
|
+
},
|
|
15
30
|
"dependencies": {
|
|
16
31
|
"clsx": "^2.1.1",
|
|
17
|
-
"react": "^19.1.0",
|
|
18
|
-
"react-dom": "^19.1.0",
|
|
19
|
-
"react-hook-form": "^7.59.0",
|
|
20
32
|
"shadcn-ui": "^0.9.5"
|
|
21
33
|
},
|
|
22
34
|
"devDependencies": {
|
|
@@ -25,6 +37,7 @@
|
|
|
25
37
|
"@types/react-dom": "^19.1.6",
|
|
26
38
|
"@vitejs/plugin-react": "^4.6.0",
|
|
27
39
|
"autoprefixer": "^10.4.21",
|
|
40
|
+
"gh-pages": "^6.3.0",
|
|
28
41
|
"postcss": "^8.5.6",
|
|
29
42
|
"storybook": "^9.0.14",
|
|
30
43
|
"tailwindcss": "^3.4.3",
|
|
@@ -32,7 +45,6 @@
|
|
|
32
45
|
},
|
|
33
46
|
"files": [
|
|
34
47
|
"dist",
|
|
35
|
-
"src",
|
|
36
48
|
"package.json",
|
|
37
49
|
"README.md"
|
|
38
50
|
]
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { cn } from "../lib/utils";
|
|
3
|
-
|
|
4
|
-
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
5
|
-
variant?: "default" | "outline";
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const Button: React.FC<ButtonProps> = ({
|
|
9
|
-
children,
|
|
10
|
-
variant = "default",
|
|
11
|
-
className = "",
|
|
12
|
-
...props
|
|
13
|
-
}) => {
|
|
14
|
-
const base = "px-4 py-2 rounded font-medium transition";
|
|
15
|
-
const variants = {
|
|
16
|
-
default: "bg-blue-600 text-white hover:bg-blue-700",
|
|
17
|
-
outline: "border border-blue-600 text-blue-600 bg-white hover:bg-blue-50",
|
|
18
|
-
};
|
|
19
|
-
return (
|
|
20
|
-
<button className={cn(base, variants[variant], className)} {...props}>
|
|
21
|
-
{children}
|
|
22
|
-
</button>
|
|
23
|
-
);
|
|
24
|
-
};
|
package/src/components/Input.tsx
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
import { cn } from "../lib/utils";
|
|
5
|
-
import { useFormContext, useWatch } from "react-hook-form";
|
|
6
|
-
|
|
7
|
-
export interface InputProps
|
|
8
|
-
extends React.InputHTMLAttributes<HTMLInputElement> {}
|
|
9
|
-
|
|
10
|
-
export interface CustomProps {
|
|
11
|
-
label?: string;
|
|
12
|
-
Icon?: React.ElementType;
|
|
13
|
-
iconClassName?: string;
|
|
14
|
-
containerClassName?: string;
|
|
15
|
-
iconAction?: React.MouseEventHandler<HTMLDivElement>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const Input = React.forwardRef<HTMLInputElement, InputProps & CustomProps>(
|
|
19
|
-
(
|
|
20
|
-
{
|
|
21
|
-
className,
|
|
22
|
-
type = "text",
|
|
23
|
-
label,
|
|
24
|
-
onFocus,
|
|
25
|
-
onBlur,
|
|
26
|
-
Icon,
|
|
27
|
-
iconClassName,
|
|
28
|
-
iconAction,
|
|
29
|
-
containerClassName,
|
|
30
|
-
...props
|
|
31
|
-
},
|
|
32
|
-
ref
|
|
33
|
-
) => {
|
|
34
|
-
const [focused, setFocused] = React.useState(false);
|
|
35
|
-
|
|
36
|
-
const form = useFormContext();
|
|
37
|
-
const control = form?.control;
|
|
38
|
-
const valueWatch =
|
|
39
|
-
control && props.name
|
|
40
|
-
? useWatch({ control, name: String(props.name) })
|
|
41
|
-
: undefined;
|
|
42
|
-
|
|
43
|
-
const value = props.value ?? valueWatch ?? "";
|
|
44
|
-
const error = form?.formState?.errors?.[props.name as string]?.message;
|
|
45
|
-
|
|
46
|
-
// Floating label: label sobe se input está focado ou tem valor
|
|
47
|
-
const isFloating = focused || !!value;
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<div className={cn("relative", containerClassName)}>
|
|
51
|
-
<input
|
|
52
|
-
id={props.id || props.name}
|
|
53
|
-
type={type}
|
|
54
|
-
className={cn(
|
|
55
|
-
"peer flex h-12 w-full border border-input rounded-md bg-transparent px-3 pt-6 pb-2 text-sm text-white placeholder-transparent transition focus:outline-none focus:border-blue-500 disabled:cursor-not-allowed disabled:opacity-50",
|
|
56
|
-
className
|
|
57
|
-
)}
|
|
58
|
-
onFocus={(event) => {
|
|
59
|
-
setFocused(true);
|
|
60
|
-
onFocus && onFocus(event);
|
|
61
|
-
}}
|
|
62
|
-
onBlur={(event) => {
|
|
63
|
-
setFocused(false);
|
|
64
|
-
onBlur && onBlur(event);
|
|
65
|
-
}}
|
|
66
|
-
ref={ref}
|
|
67
|
-
{...props}
|
|
68
|
-
/>
|
|
69
|
-
{label && (
|
|
70
|
-
<label
|
|
71
|
-
htmlFor={props.id || props.name}
|
|
72
|
-
className={cn(
|
|
73
|
-
"absolute left-3 top-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",
|
|
74
|
-
isFloating
|
|
75
|
-
? "scale-90 -translate-y-3 text-xs text-blue-400"
|
|
76
|
-
: "scale-100 translate-y-0"
|
|
77
|
-
)}
|
|
78
|
-
>
|
|
79
|
-
{label}
|
|
80
|
-
</label>
|
|
81
|
-
)}
|
|
82
|
-
{Icon && (
|
|
83
|
-
<div
|
|
84
|
-
className={cn(
|
|
85
|
-
"absolute top-1/2 right-3 -translate-y-1/2 text-white",
|
|
86
|
-
iconClassName
|
|
87
|
-
)}
|
|
88
|
-
onClick={iconAction}
|
|
89
|
-
>
|
|
90
|
-
<Icon />
|
|
91
|
-
</div>
|
|
92
|
-
)}
|
|
93
|
-
{error && (
|
|
94
|
-
<span className="text-red-500 text-xs mt-1 block">
|
|
95
|
-
{error as string}
|
|
96
|
-
</span>
|
|
97
|
-
)}
|
|
98
|
-
</div>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
);
|
|
102
|
-
Input.displayName = "Input";
|
|
103
|
-
|
|
104
|
-
export { Input };
|
package/src/components/index.ts
DELETED
package/src/lib/utils.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { Button } from "../components/Button";
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof Button> = {
|
|
5
|
-
title: "Components/Button",
|
|
6
|
-
component: Button,
|
|
7
|
-
tags: ["autodocs"],
|
|
8
|
-
};
|
|
9
|
-
export default meta;
|
|
10
|
-
|
|
11
|
-
type Story = StoryObj<typeof Button>;
|
|
12
|
-
|
|
13
|
-
export const Default: Story = {
|
|
14
|
-
args: {
|
|
15
|
-
children: "Botão padrão",
|
|
16
|
-
variant: "default",
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const Outline: Story = {
|
|
21
|
-
args: {
|
|
22
|
-
children: "Botão outline",
|
|
23
|
-
variant: "outline",
|
|
24
|
-
},
|
|
25
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { Input } from "../components/Input";
|
|
3
|
-
import { FormProvider, useForm } from "react-hook-form";
|
|
4
|
-
|
|
5
|
-
const meta: Meta<typeof Input> = {
|
|
6
|
-
title: "Components/Input",
|
|
7
|
-
component: Input,
|
|
8
|
-
tags: ["autodocs"],
|
|
9
|
-
};
|
|
10
|
-
export default meta;
|
|
11
|
-
|
|
12
|
-
type Story = StoryObj<typeof Input>;
|
|
13
|
-
|
|
14
|
-
const Template = (args: any) => {
|
|
15
|
-
const methods = useForm();
|
|
16
|
-
return (
|
|
17
|
-
<FormProvider {...methods}>
|
|
18
|
-
<Input {...args} name="email" />
|
|
19
|
-
</FormProvider>
|
|
20
|
-
);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const Default: Story = {
|
|
24
|
-
render: Template,
|
|
25
|
-
args: {
|
|
26
|
-
label: "E-mail",
|
|
27
|
-
placeholder: "Digite seu e-mail",
|
|
28
|
-
},
|
|
29
|
-
};
|
package/src/styles/tailwind.css
DELETED