@yosang/react-ui 1.0.0
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 +31 -0
- package/readme.md +51 -0
- package/src/button/button.css +43 -0
- package/src/button/button.jsx +12 -0
- package/src/button.stories.jsx +40 -0
- package/src/icon.stories.jsx +50 -0
- package/src/icons/action/ArrowLeft.jsx +5 -0
- package/src/icons/action/ArrowRight.jsx +5 -0
- package/src/icons/action/CrossIcon.jsx +5 -0
- package/src/icons/content/EditIcon.jsx +5 -0
- package/src/icons/content/TrashIcon.jsx +5 -0
- package/src/icons/forms/InfoIcon.jsx +5 -0
- package/src/icons/forms/PlusIcon.jsx +5 -0
- package/src/icons/forms/TickIcon.jsx +5 -0
- package/src/icons/index.js +10 -0
- package/src/icons/interface/HomeIcon.jsx +5 -0
- package/src/icons/interface/MenuIcon.jsx +5 -0
- package/src/icons/interface/SettingsIcon.jsx +5 -0
- package/src/main.css +38 -0
- package/src/main.js +4 -0
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yosang/react-ui",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A small web component ui library",
|
|
5
|
+
"main": "src/main.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"src"
|
|
8
|
+
],
|
|
9
|
+
"type": "module",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "ladle serve",
|
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"web-components",
|
|
16
|
+
"ui",
|
|
17
|
+
"library"
|
|
18
|
+
],
|
|
19
|
+
"author": "Yosmel Chiang",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"react": "^18 || ^19",
|
|
23
|
+
"react-dom": "^18 || ^19"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"lucide-react": "^1.7.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@ladle/react": "^5.1.1"
|
|
30
|
+
}
|
|
31
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Demo ui lib
|
|
2
|
+
|
|
3
|
+
## Consuming the library
|
|
4
|
+
|
|
5
|
+
To consume this library simply install it on your app.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @yosang/react-ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
then import the components as needed.
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
import { Button } from '@yosang/react-ui'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
# Testing the components locally
|
|
18
|
+
This library uses [@ladle/react](https://www.npmjs.com/package/@ladle/react) for component testing.
|
|
19
|
+
|
|
20
|
+
Simply do `npm install` inside the library to install it before using it.
|
|
21
|
+
|
|
22
|
+
Create a component story like this example `button.stories.jsx` and make sure you import the component.
|
|
23
|
+
|
|
24
|
+
Now we simply just export normal functions that apply this component in the different scenarios we want to test them.
|
|
25
|
+
|
|
26
|
+
```jsx
|
|
27
|
+
import { Button } from "./button.jsx";
|
|
28
|
+
import './button.css';
|
|
29
|
+
|
|
30
|
+
export const Primary = () => (
|
|
31
|
+
<Button variant="primary">Primary Button</Button>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export const Secondary = () => (
|
|
35
|
+
<Button variant="secondary">Secondary Button</Button>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export const Clickable = () => (
|
|
39
|
+
<Button
|
|
40
|
+
variant="primary"
|
|
41
|
+
onClick={() => alert("Button clicked!")}
|
|
42
|
+
>
|
|
43
|
+
Click me
|
|
44
|
+
</Button>
|
|
45
|
+
);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Run ladle with `npx ladle serve` or use the script provided `npm start`.
|
|
49
|
+
|
|
50
|
+
# Dependencies
|
|
51
|
+
- [lucide-react](https://lucide.dev/icons/)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* Global styles */
|
|
2
|
+
.ui-button {
|
|
3
|
+
padding: var(--spacing-sm) var(--spacing-md);
|
|
4
|
+
border: none;
|
|
5
|
+
border-radius: var(--radius);
|
|
6
|
+
font-size: var(--font-size);
|
|
7
|
+
color: var(--color-text);
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
transition: all 0.2s;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/* Variants */
|
|
13
|
+
.ui-button.primary {
|
|
14
|
+
background: var(--color-primary);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.ui-button.primary:hover {
|
|
18
|
+
background: var(--color-primary-hover);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.ui-button.secondary {
|
|
22
|
+
background: var(--color-secondary);
|
|
23
|
+
}
|
|
24
|
+
.ui-button.secondary:hover {
|
|
25
|
+
background: var(--color-secondary-hover);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.ui-button-icon-with-text:hover {
|
|
29
|
+
margin-right: 8px;
|
|
30
|
+
position: relative;
|
|
31
|
+
top: 5px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.ui-button-icon-text {
|
|
35
|
+
margin-right: 8px;
|
|
36
|
+
position: relative;
|
|
37
|
+
top: 5px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.ui-button-icon {
|
|
41
|
+
position: relative;
|
|
42
|
+
top: 5px;
|
|
43
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import './button.css'
|
|
2
|
+
import '../main.css'
|
|
3
|
+
|
|
4
|
+
export function Button({ children, variant = "primary", onClick, icon, hasText, ...props }) {
|
|
5
|
+
return (
|
|
6
|
+
<button className={`ui-button ${variant}`} onClick={onClick} {...props} >
|
|
7
|
+
{icon && hasText && <span className='ui-button-icon-text'>{icon}</span>}
|
|
8
|
+
{icon && !hasText && <span className='ui-button-icont'>{icon}</span>}
|
|
9
|
+
{children}
|
|
10
|
+
</button>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Button } from "./button/button.jsx";
|
|
2
|
+
import { CrossIcon } from "./icons/action/CrossIcon.jsx";
|
|
3
|
+
import { TrashIcon } from "./icons/content/TrashIcon.jsx";
|
|
4
|
+
|
|
5
|
+
export const Primary = () => (
|
|
6
|
+
<Button variant="primary">Primary Button</Button>
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export const Secondary = () => (
|
|
10
|
+
<Button variant="secondary">Secondary Button</Button>
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export const Clickable = () => (
|
|
14
|
+
<Button
|
|
15
|
+
variant="primary"
|
|
16
|
+
onClick={() => alert("Button clicked!")}
|
|
17
|
+
>
|
|
18
|
+
Click me
|
|
19
|
+
</Button>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export const Custom = () => (
|
|
23
|
+
<Button variant="primary" style={{ backgroundColor: "red" }}>
|
|
24
|
+
Custom color
|
|
25
|
+
</Button>
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
export const IconWithText = () => (
|
|
29
|
+
<Button variant="primary" icon={<CrossIcon />} hasText={true}>
|
|
30
|
+
Button with an icon
|
|
31
|
+
</Button>
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
export const IconWithoutText = () => (
|
|
35
|
+
<Button variant="primary" icon={<CrossIcon />} />
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
export const TrashIconWithoutText = () => (
|
|
39
|
+
<Button variant="primary" icon={<TrashIcon />} />
|
|
40
|
+
)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ArrowRightIcon } from "./icons/action/ArrowRight";
|
|
2
|
+
import { ArrowLeftIcon } from "./icons/action/ArrowLeft";
|
|
3
|
+
import { MenuIcon } from "./icons/interface/MenuIcon";
|
|
4
|
+
import { HomeIcon } from "./icons/interface/HomeIcon"
|
|
5
|
+
import { SettingsIcon } from "./icons/interface/SettingsIcon"
|
|
6
|
+
import { TickIcon } from "./icons/forms/TickIcon";
|
|
7
|
+
import { PlusIcon } from "./icons/forms/PlusIcon";
|
|
8
|
+
import { InfoIcon } from "./icons/forms/InfoIcon"
|
|
9
|
+
import { TrashIcon } from "./icons/content/TrashIcon"
|
|
10
|
+
import { EditIcon } from "./icons/content/EditIcon"
|
|
11
|
+
|
|
12
|
+
export function Menu() {
|
|
13
|
+
return <MenuIcon />
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function ArrowLeft() {
|
|
17
|
+
return <ArrowLeftIcon />
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function ArrowRight() {
|
|
21
|
+
return <ArrowRightIcon />
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function Home() {
|
|
25
|
+
return <HomeIcon />
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function Settings() {
|
|
29
|
+
return <SettingsIcon />
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function Tick() {
|
|
33
|
+
return <TickIcon />
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function Plus() {
|
|
37
|
+
return <PlusIcon />
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function Info() {
|
|
41
|
+
return <InfoIcon />
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function Trash() {
|
|
45
|
+
return <TrashIcon />
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function Edit() {
|
|
49
|
+
return <EditIcon />
|
|
50
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./action/ArrowRight";
|
|
2
|
+
export * from "./action/ArrowLeft";
|
|
3
|
+
export * from "./interface/MenuIcon";
|
|
4
|
+
export * from "./interface/HomeIcon";
|
|
5
|
+
export * from "./interface/SettingsIcon";
|
|
6
|
+
export * from "./forms/TickIcon";
|
|
7
|
+
export * from "./forms/PlusIcon";
|
|
8
|
+
export * from "./forms/InfoIcon";
|
|
9
|
+
export * from "./content/TrashIcon";
|
|
10
|
+
export * from "./content/EditIcon";
|
package/src/main.css
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* CSS Reset */
|
|
2
|
+
* {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
margin: 0;
|
|
5
|
+
padding: 0;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/* Design Tokens */
|
|
9
|
+
|
|
10
|
+
:root {
|
|
11
|
+
/* Colors */
|
|
12
|
+
--color-primary: #004A99;
|
|
13
|
+
--color-primary-hover: #0362c6;
|
|
14
|
+
|
|
15
|
+
--color-secondary: #536070;
|
|
16
|
+
--color-secondary-hover: #373c41;
|
|
17
|
+
|
|
18
|
+
--color-text: #ecedef;
|
|
19
|
+
--color-bg: #ffffff;
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/* Spacing */
|
|
23
|
+
--radius: 8px;
|
|
24
|
+
--spacing-sm: 8px;
|
|
25
|
+
--spacing-md: 16px;
|
|
26
|
+
|
|
27
|
+
/* Typography */
|
|
28
|
+
--font-size: 1rem;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@media (max-width: 640px){
|
|
32
|
+
:root {
|
|
33
|
+
--spacing-sm: 8px;
|
|
34
|
+
--spacing-md: 12px;
|
|
35
|
+
|
|
36
|
+
--font-size: 0.95rem;
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/main.js
ADDED