@yosang/react-ui 1.1.0 → 1.2.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 +1 -1
- package/readme.md +2 -1
- package/src/Forms/Input.css +34 -0
- package/src/Forms/Input.jsx +12 -0
- package/src/button/{button.css → Button.css} +19 -1
- package/src/button/{button.jsx → Button.jsx} +3 -3
- package/src/button.stories.jsx +13 -2
- package/src/input.stories.jsx +5 -0
- package/src/layout-components/LoginContainer.css +18 -0
- package/src/layout-components/LoginContainer.jsx +10 -0
- package/src/login.stories.jsx +15 -0
- package/src/main.css +10 -0
- package/src/main.js +5 -2
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -48,4 +48,5 @@ export const Clickable = () => (
|
|
|
48
48
|
Run ladle with `npx ladle serve` or use the script provided `npm start`.
|
|
49
49
|
|
|
50
50
|
# Dependencies
|
|
51
|
-
- [lucide-react](https://lucide.dev/icons/)
|
|
51
|
+
- [lucide-react](https://lucide.dev/icons/)
|
|
52
|
+
- [m3-ripple](https://github.com/SaltyAom/m3-ripple)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.ui-input {
|
|
2
|
+
padding: var(--spacing-sm) var(--spacing-md);
|
|
3
|
+
border-radius: var(--radius);
|
|
4
|
+
border: 1px solid var(--color-border);
|
|
5
|
+
background-color: var(--color-bg);
|
|
6
|
+
font-size: var(--font-size);
|
|
7
|
+
transition: var(--transition-speed);
|
|
8
|
+
width: 100%;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.ui-input.primary {
|
|
12
|
+
border-color: var(--color-primary);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.ui-input.secondary {
|
|
16
|
+
border-color: var(--color-secondary);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.ui-input:focus {
|
|
20
|
+
outline: none;
|
|
21
|
+
border-color: var(--color-primary);
|
|
22
|
+
box-shadow: 0 0 0 2px rgba(3, 98, 198, 0.2);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.ui-input:disabled {
|
|
26
|
+
background-color: var(--color-tertiary);
|
|
27
|
+
color: var(--color-muted);
|
|
28
|
+
cursor: not-allowed;
|
|
29
|
+
opacity: 0.7;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.ui-input:hover:not(:disabled) {
|
|
33
|
+
background-color: var(--color-highlight);
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import './Input.css'
|
|
2
|
+
import '../main.css'
|
|
3
|
+
|
|
4
|
+
export function Input({ variant = "primary", type ="text", placeholder, ...props}) {
|
|
5
|
+
return (
|
|
6
|
+
<input className={`ui-input ${variant}`} placeholder={placeholder} type={type } {...props} />
|
|
7
|
+
)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Todos:
|
|
11
|
+
// Add disabled functionality
|
|
12
|
+
// Add icon inside the input functionality
|
|
@@ -6,11 +6,16 @@
|
|
|
6
6
|
font-size: var(--font-size);
|
|
7
7
|
color: var(--color-text);
|
|
8
8
|
cursor: pointer;
|
|
9
|
-
transition: all
|
|
9
|
+
transition: all var(--transition-speed);
|
|
10
10
|
display: inline-flex;
|
|
11
11
|
align-items: center;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
.ui-button:focus {
|
|
15
|
+
outline: 2px solid var(--color-primary-hover);
|
|
16
|
+
outline-offset: 2px;
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
/* Variants */
|
|
15
20
|
.ui-button.primary {
|
|
16
21
|
background: var(--color-primary);
|
|
@@ -36,4 +41,17 @@
|
|
|
36
41
|
.ui-button-icon {
|
|
37
42
|
position: relative;
|
|
38
43
|
top: 1px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.ui-button.disabled {
|
|
47
|
+
background-color: var(--color-tertiary);
|
|
48
|
+
color: var(--color-muted);
|
|
49
|
+
cursor: not-allowed;
|
|
50
|
+
pointer-events: none;
|
|
51
|
+
opacity: 0.7;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.ui-button.disabled:hover {
|
|
55
|
+
background-color: var(--color-tertiary);
|
|
56
|
+
color: var(--color-muted);
|
|
39
57
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import './
|
|
1
|
+
import './Button.css'
|
|
2
2
|
import '../main.css'
|
|
3
3
|
|
|
4
4
|
import { Ripple } from 'm3-ripple';
|
|
5
5
|
import 'm3-ripple/ripple.css'
|
|
6
6
|
|
|
7
|
-
export function Button({ children, variant = "primary", onClick, icon, hasText, rippleEffect = true
|
|
7
|
+
export function Button({ children, variant = "primary", onClick, icon, hasText, rippleEffect = true, ...props }) {
|
|
8
8
|
return (
|
|
9
|
-
<button className={`ui-button ${variant}`} onClick={onClick} {...props} style={ { position: "relative" } }>
|
|
9
|
+
<button className={`ui-button ${variant} ${props.disabled ? 'disabled':''}`} onClick={onClick} {...props} style={ { position: "relative" } } disabled={props.disabled}>
|
|
10
10
|
{rippleEffect && <Ripple hoverOpacity={0}/>}
|
|
11
11
|
{icon && hasText && <span className='ui-button-icon-text'>{icon}</span>}
|
|
12
12
|
{icon && !hasText && <span className='ui-button-icon'>{icon}</span>}
|
package/src/button.stories.jsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button } from "./button/
|
|
1
|
+
import { Button } from "./button/Button.jsx";
|
|
2
2
|
import { CrossIcon } from "./icons/action/CrossIcon.jsx";
|
|
3
3
|
import { TrashIcon } from "./icons/content/TrashIcon.jsx";
|
|
4
4
|
|
|
@@ -43,4 +43,15 @@ export const IconWithoutText = () => (
|
|
|
43
43
|
|
|
44
44
|
export const TrashIconWithoutText = () => (
|
|
45
45
|
<Button variant="primary" icon={<TrashIcon />} />
|
|
46
|
-
)
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
export const DisabledButton = () => (
|
|
49
|
+
<Button variant="primary" disabled={true}>
|
|
50
|
+
Button
|
|
51
|
+
</Button>
|
|
52
|
+
)
|
|
53
|
+
export const DisabledButtonWithIcon = () => (
|
|
54
|
+
<Button variant="primary" icon={<CrossIcon />} hasText={true} disabled={true}>
|
|
55
|
+
Button with an icon
|
|
56
|
+
</Button>
|
|
57
|
+
)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.ui-logincontainer {
|
|
2
|
+
padding: var(--spacing-sm) var(--spacing-md);
|
|
3
|
+
border-radius: var(--radius);
|
|
4
|
+
border: 1px solid var(--color-border);
|
|
5
|
+
background-color: var(--color-bg);
|
|
6
|
+
font-size: var(--font-size);
|
|
7
|
+
width: 100%;
|
|
8
|
+
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
gap: 1rem;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
align-items: center;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.ui-logincontainer.non-centered {
|
|
17
|
+
align-items: flex-start;
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Button } from "./button/Button";
|
|
2
|
+
import { Input } from "./Forms/Input";
|
|
3
|
+
import { LoginContainer } from "./layout-components/LoginContainer";
|
|
4
|
+
|
|
5
|
+
export function AuthExample() {
|
|
6
|
+
return (
|
|
7
|
+
<LoginContainer centered={true}>
|
|
8
|
+
<p>Username</p>
|
|
9
|
+
<Input style={{ maxWidth: "200px"}}/>
|
|
10
|
+
<p>Password</p>
|
|
11
|
+
<Input style={{ maxWidth: "200px"}}/>
|
|
12
|
+
<Button>Login</Button>
|
|
13
|
+
</LoginContainer>
|
|
14
|
+
)
|
|
15
|
+
}
|
package/src/main.css
CHANGED
|
@@ -17,6 +17,12 @@
|
|
|
17
17
|
|
|
18
18
|
--color-text: #ecedef;
|
|
19
19
|
--color-bg: #ffffff;
|
|
20
|
+
--color-border: #c4c4c4;
|
|
21
|
+
--color-highlight: #f5f5f5;
|
|
22
|
+
|
|
23
|
+
--color-tertiary: #c4c4c4;
|
|
24
|
+
|
|
25
|
+
--color-muted: #7a7a7a;
|
|
20
26
|
|
|
21
27
|
|
|
22
28
|
/* Spacing */
|
|
@@ -26,8 +32,12 @@
|
|
|
26
32
|
|
|
27
33
|
/* Typography */
|
|
28
34
|
--font-size: 1rem;
|
|
35
|
+
|
|
36
|
+
/* Effects */
|
|
37
|
+
--transition-speed: 0.2s;
|
|
29
38
|
}
|
|
30
39
|
|
|
40
|
+
|
|
31
41
|
@media (max-width: 640px){
|
|
32
42
|
:root {
|
|
33
43
|
--spacing-sm: 8px;
|
package/src/main.js
CHANGED