zc-ui-library 0.0.1 → 0.0.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.
- package/package.json +1 -1
- package/src/App.tsx +2 -24
- package/src/components/Button/ZcButton.tsx +52 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -1,33 +1,11 @@
|
|
|
1
|
-
import {useState} from 'react'
|
|
2
|
-
import reactLogo from './assets/react.svg'
|
|
3
|
-
import viteLogo from '/vite.svg'
|
|
4
1
|
import './App.css'
|
|
2
|
+
import {ZcButton} from "./components/Button/ZcButton.tsx";
|
|
5
3
|
|
|
6
4
|
function App() {
|
|
7
|
-
const [count, setCount] = useState(0)
|
|
8
5
|
|
|
9
6
|
return (
|
|
10
7
|
<>
|
|
11
|
-
<
|
|
12
|
-
<a href="https://vite.dev" target="_blank">
|
|
13
|
-
<img src={viteLogo} className="logo" alt="Vite logo"/>
|
|
14
|
-
</a>
|
|
15
|
-
<a href="https://react.dev" target="_blank">
|
|
16
|
-
<img src={reactLogo} className="logo react" alt="React logo"/>
|
|
17
|
-
</a>
|
|
18
|
-
</div>
|
|
19
|
-
<h1>Vite + React</h1>
|
|
20
|
-
<div className="card">
|
|
21
|
-
<button onClick={() => setCount((count) => count + 1)}>
|
|
22
|
-
count is {count}
|
|
23
|
-
</button>
|
|
24
|
-
<p>
|
|
25
|
-
Edit <code>src/App.tsx</code> and save to test HMR
|
|
26
|
-
</p>
|
|
27
|
-
</div>
|
|
28
|
-
<p className="read-the-docs">
|
|
29
|
-
Click on the Vite and React logos to learn more
|
|
30
|
-
</p>
|
|
8
|
+
<ZcButton>Click me</ZcButton>
|
|
31
9
|
</>
|
|
32
10
|
)
|
|
33
11
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
|
|
3
|
+
export type ButtonVariant = 'primary' | 'secondary'
|
|
4
|
+
export type ButtonSize = 'sm' | 'md' | 'lg'
|
|
5
|
+
|
|
6
|
+
export interface ButtonProps
|
|
7
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
8
|
+
variant?: ButtonVariant
|
|
9
|
+
size?: ButtonSize
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const ZcButton = React.forwardRef<
|
|
13
|
+
HTMLButtonElement,
|
|
14
|
+
ButtonProps
|
|
15
|
+
>(function ZcButton(
|
|
16
|
+
{
|
|
17
|
+
variant = 'primary',
|
|
18
|
+
size = 'md',
|
|
19
|
+
disabled,
|
|
20
|
+
children,
|
|
21
|
+
...props
|
|
22
|
+
},
|
|
23
|
+
ref
|
|
24
|
+
) {
|
|
25
|
+
return (
|
|
26
|
+
<button
|
|
27
|
+
ref={ref}
|
|
28
|
+
disabled={disabled}
|
|
29
|
+
data-variant={variant}
|
|
30
|
+
data-size={size}
|
|
31
|
+
style={{
|
|
32
|
+
padding:
|
|
33
|
+
size === 'sm'
|
|
34
|
+
? '6px 10px'
|
|
35
|
+
: size === 'lg'
|
|
36
|
+
? '12px 18px'
|
|
37
|
+
: '8px 14px',
|
|
38
|
+
borderRadius: 6,
|
|
39
|
+
border: '1px solid transparent',
|
|
40
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
41
|
+
background:
|
|
42
|
+
variant === 'secondary' ? '#fff' : '#2563eb',
|
|
43
|
+
color:
|
|
44
|
+
variant === 'secondary' ? '#111' : '#fff',
|
|
45
|
+
opacity: disabled ? 0.6 : 1,
|
|
46
|
+
}}
|
|
47
|
+
{...props}
|
|
48
|
+
>
|
|
49
|
+
{children}
|
|
50
|
+
</button>
|
|
51
|
+
)
|
|
52
|
+
})
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ZcButton = './components/Button/ZcButton.tsx';
|