kahuna-base-react-components 0.1.11 → 0.1.12
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/dist/components/KButton/KButton.d.ts +1 -0
- package/dist/components/KInput/KInput.d.ts +1 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/KButton/KButton.stories.tsx +2 -1
- package/src/components/KButton/KButton.tsx +21 -11
- package/src/components/KInput/KInput.stories.tsx +2 -1
- package/src/components/KInput/KInput.tsx +32 -13
package/dist/types.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ interface KButtonProps {
|
|
|
15
15
|
textColor?: string;
|
|
16
16
|
padding?: string;
|
|
17
17
|
shadowDisabled?: boolean;
|
|
18
|
+
hoverBackground?: string;
|
|
18
19
|
}
|
|
19
20
|
declare const KButton: React.FC<KButtonProps>;
|
|
20
21
|
|
|
@@ -69,6 +70,7 @@ interface KInputProps {
|
|
|
69
70
|
leftIconClick?: () => void;
|
|
70
71
|
rightIconClick?: () => void;
|
|
71
72
|
accentColor?: string;
|
|
73
|
+
hoverBackground?: string;
|
|
72
74
|
}
|
|
73
75
|
declare const KInput: React.FC<KInputProps>;
|
|
74
76
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from "react"
|
|
1
|
+
import React, { useState } from "react"
|
|
2
2
|
import "../../main.css"
|
|
3
|
-
import KSpan from "../KSpan"
|
|
3
|
+
import KSpan from "../KSpan"
|
|
4
4
|
|
|
5
5
|
export interface KButtonProps {
|
|
6
6
|
onClick: () => void
|
|
@@ -16,9 +16,12 @@ export interface KButtonProps {
|
|
|
16
16
|
textColor?: string
|
|
17
17
|
padding?: string
|
|
18
18
|
shadowDisabled?: boolean
|
|
19
|
+
hoverBackground?: string
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
const KButton: React.FC<KButtonProps> = (props) => {
|
|
23
|
+
const [hover, setHover] = useState(false);
|
|
24
|
+
|
|
22
25
|
const disabled = props.disabled || false
|
|
23
26
|
const background = disabled ? "#F0F0F0" : props.background || "#F2FE67"
|
|
24
27
|
const borderRadius = props.borderRadius || 10
|
|
@@ -27,18 +30,25 @@ const KButton: React.FC<KButtonProps> = (props) => {
|
|
|
27
30
|
const textColor = disabled ? "#D6D6D6" : props.textColor || "#111"
|
|
28
31
|
const padding = props.padding || "12px 16px"
|
|
29
32
|
const boxShadow = props.shadowDisabled ? "" : "0 0 0 1px rgba(17, 17, 17, 0.04), 0 1px 1px 0 rgba(17, 17, 17, 0.04)"
|
|
33
|
+
const hoverBackground = props.hoverBackground || background
|
|
30
34
|
|
|
31
35
|
return (
|
|
32
|
-
<button
|
|
33
|
-
|
|
36
|
+
<button
|
|
37
|
+
onMouseEnter={() => setHover(true)}
|
|
38
|
+
onMouseLeave={() => setHover(false)}
|
|
39
|
+
className={"k-button"}
|
|
40
|
+
disabled={disabled}
|
|
41
|
+
onClick={props.onClick}
|
|
42
|
+
style={{ background: hover ? hoverBackground : background, borderRadius, width, height, padding, boxShadow }}
|
|
43
|
+
>
|
|
34
44
|
<div className={"flex"}>
|
|
35
|
-
{props.leftIcon && <img src={props.leftIcon} alt={"button-left-icon"}/>}
|
|
36
|
-
{props.text && <KSpan text={props.text} color={textColor}/>}
|
|
37
|
-
{props.icon && <img src={props.icon} alt={"button-icon"}/>}
|
|
38
|
-
{props.rightIcon && <img src={props.rightIcon} alt={"button-right-icon"}/>}
|
|
45
|
+
{props.leftIcon && <img src={props.leftIcon} alt={"button-left-icon"} />}
|
|
46
|
+
{props.text && <KSpan text={props.text} color={textColor} />}
|
|
47
|
+
{props.icon && <img src={props.icon} alt={"button-icon"} />}
|
|
48
|
+
{props.rightIcon && <img src={props.rightIcon} alt={"button-right-icon"} />}
|
|
39
49
|
</div>
|
|
40
50
|
</button>
|
|
41
|
-
)
|
|
42
|
-
}
|
|
51
|
+
)
|
|
52
|
+
}
|
|
43
53
|
|
|
44
|
-
export default KButton
|
|
54
|
+
export default KButton
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {useEffect, useState} from "react"
|
|
1
|
+
import React, { useEffect, useState } from "react"
|
|
2
2
|
import "../../main.css"
|
|
3
3
|
|
|
4
4
|
export interface KInputProps {
|
|
@@ -19,10 +19,12 @@ export interface KInputProps {
|
|
|
19
19
|
leftIconClick?: () => void
|
|
20
20
|
rightIconClick?: () => void
|
|
21
21
|
accentColor?: string
|
|
22
|
+
hoverBackground?: string
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
const KInput: React.FC<KInputProps> = (props) => {
|
|
25
26
|
const [background, setBackground] = useState("#F5F5F5")
|
|
27
|
+
const [hover, setHover] = useState(false)
|
|
26
28
|
|
|
27
29
|
useEffect(() => {
|
|
28
30
|
const emptyBackground = props.background || "#F5F5F5"
|
|
@@ -39,19 +41,30 @@ const KInput: React.FC<KInputProps> = (props) => {
|
|
|
39
41
|
const type = props.type || "text"
|
|
40
42
|
const accentColor = props.accentColor || ""
|
|
41
43
|
const disabled = props.disabled || false
|
|
44
|
+
const hoverBackground = props.hoverBackground || background
|
|
42
45
|
|
|
43
46
|
return (
|
|
44
|
-
<div
|
|
47
|
+
<div
|
|
48
|
+
onMouseEnter={() => setHover(true)}
|
|
49
|
+
onMouseLeave={() => setHover(false)}
|
|
50
|
+
className={"k-input-container"}
|
|
51
|
+
style={{ background: hover ? hoverBackground : background, borderRadius, boxShadow }}
|
|
52
|
+
>
|
|
45
53
|
{props.leftIcon && (
|
|
46
|
-
<img
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
<img
|
|
55
|
+
src={props.leftIcon}
|
|
56
|
+
alt={"l-icon"}
|
|
57
|
+
className={props.leftIconClick && "cursor-pointer"}
|
|
58
|
+
onClick={() => {
|
|
59
|
+
if (props.leftIconClick) props.leftIconClick()
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
49
62
|
)}
|
|
50
63
|
|
|
51
64
|
<input
|
|
52
65
|
type={type}
|
|
53
66
|
className={"k-input"}
|
|
54
|
-
style={{background, width, height, accentColor}}
|
|
67
|
+
style={{ background: hover ? hoverBackground : background, width, height, accentColor }}
|
|
55
68
|
value={props.value}
|
|
56
69
|
placeholder={props.placeholder || ""}
|
|
57
70
|
disabled={disabled}
|
|
@@ -60,15 +73,21 @@ const KInput: React.FC<KInputProps> = (props) => {
|
|
|
60
73
|
}}
|
|
61
74
|
onChange={(event) => {
|
|
62
75
|
props.onChange(event.target.value)
|
|
63
|
-
}}
|
|
76
|
+
}}
|
|
77
|
+
/>
|
|
64
78
|
|
|
65
79
|
{props.rightIcon && (
|
|
66
|
-
<img
|
|
67
|
-
|
|
68
|
-
|
|
80
|
+
<img
|
|
81
|
+
src={props.rightIcon}
|
|
82
|
+
alt={"r-icon"}
|
|
83
|
+
className={props.rightIconClick && "cursor-pointer"}
|
|
84
|
+
onClick={() => {
|
|
85
|
+
if (props.rightIconClick) props.rightIconClick()
|
|
86
|
+
}}
|
|
87
|
+
/>
|
|
69
88
|
)}
|
|
70
89
|
</div>
|
|
71
|
-
)
|
|
72
|
-
}
|
|
90
|
+
)
|
|
91
|
+
}
|
|
73
92
|
|
|
74
|
-
export default KInput
|
|
93
|
+
export default KInput
|