kahuna-base-react-components 1.2.0 → 1.2.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/dist/components/KButton/KButton.d.ts +4 -0
- package/dist/components/KDropdown/KDropdown.d.ts +3 -0
- package/dist/components/KInput/KInput.d.ts +2 -0
- package/dist/components/KSpan/KSpan.d.ts +1 -4
- package/dist/components/KTitleSpan/KTitleSpan.d.ts +1 -0
- package/dist/index.esm.js +2 -2
- 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 +11 -4
- package/package.json +1 -1
- package/src/components/KButton/KButton.stories.tsx +6 -2
- package/src/components/KButton/KButton.tsx +23 -3
- package/src/components/KDropdown/KDropdown.stories.tsx +48 -9
- package/src/components/KDropdown/KDropdown.tsx +21 -2
- package/src/components/KInput/KInput.stories.tsx +44 -18
- package/src/components/KInput/KInput.tsx +16 -2
- package/src/components/KSpan/KSpan.stories.tsx +16 -17
- package/src/components/KSpan/KSpan.tsx +9 -41
- package/src/components/KTitleSpan/KTitleSpan.stories.tsx +25 -2
- package/src/components/KTitleSpan/KTitleSpan.tsx +65 -10
- package/src/index.ts +13 -2
- package/src/main.css +6 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { KeyboardEvent } from 'react';
|
|
2
2
|
import { MultiValue } from 'react-select';
|
|
3
3
|
|
|
4
4
|
interface KButtonProps {
|
|
@@ -19,6 +19,10 @@ interface KButtonProps {
|
|
|
19
19
|
fontWeight?: number;
|
|
20
20
|
textDecoration?: string;
|
|
21
21
|
gap?: string;
|
|
22
|
+
activeBackground?: string;
|
|
23
|
+
border?: string;
|
|
24
|
+
hoverBorder?: string;
|
|
25
|
+
activeBorder?: string;
|
|
22
26
|
}
|
|
23
27
|
declare const KButton: React.FC<KButtonProps>;
|
|
24
28
|
|
|
@@ -30,9 +34,6 @@ interface KSpanProps {
|
|
|
30
34
|
lineHeight?: string;
|
|
31
35
|
fontStyle?: string;
|
|
32
36
|
letterSpacing?: string;
|
|
33
|
-
hoverText?: string;
|
|
34
|
-
hoverTextColor?: string;
|
|
35
|
-
hoverStyle?: CSSProperties;
|
|
36
37
|
textDecoration?: string;
|
|
37
38
|
ellipsis?: boolean;
|
|
38
39
|
}
|
|
@@ -47,6 +48,7 @@ interface KTitleSpanProps {
|
|
|
47
48
|
fontStyle?: string;
|
|
48
49
|
letterSpacing?: string;
|
|
49
50
|
bold?: boolean;
|
|
51
|
+
ellipsis?: boolean;
|
|
50
52
|
}
|
|
51
53
|
declare const KTitleSpan: React.FC<KTitleSpanProps>;
|
|
52
54
|
|
|
@@ -93,6 +95,8 @@ interface KInputProps {
|
|
|
93
95
|
fontSize?: string;
|
|
94
96
|
iconSize?: string;
|
|
95
97
|
checked?: boolean;
|
|
98
|
+
hoverBorder?: string;
|
|
99
|
+
activeBorder?: string;
|
|
96
100
|
}
|
|
97
101
|
declare const KInput$1: React.FC<KInputProps>;
|
|
98
102
|
|
|
@@ -158,6 +162,7 @@ interface KDropdownProps {
|
|
|
158
162
|
menuBackground?: string;
|
|
159
163
|
padding?: string;
|
|
160
164
|
gap?: string;
|
|
165
|
+
onBlur?: (value: KSelectOption | MultiValue<KSelectOption> | undefined) => void;
|
|
161
166
|
hideChosenOptionIcon?: boolean;
|
|
162
167
|
isClearable?: boolean;
|
|
163
168
|
isEllipsis?: boolean;
|
|
@@ -167,6 +172,8 @@ interface KDropdownProps {
|
|
|
167
172
|
placeholderColor?: string;
|
|
168
173
|
enableIndicator?: boolean;
|
|
169
174
|
allowContainerShrink?: boolean;
|
|
175
|
+
border?: string;
|
|
176
|
+
activeBorder?: string;
|
|
170
177
|
}
|
|
171
178
|
declare const KDropdown: React.FC<KDropdownProps>;
|
|
172
179
|
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@ const Template: StoryFn<typeof KButton> = (args) => <KButton {...args} />;
|
|
|
17
17
|
export const KButtonText = Template.bind({});
|
|
18
18
|
KButtonText.args = {
|
|
19
19
|
onClick: () => {
|
|
20
|
-
alert("clicked")
|
|
20
|
+
//alert("clicked")
|
|
21
21
|
},
|
|
22
22
|
text: "Hello World",
|
|
23
23
|
background: "#F2FE67",
|
|
@@ -25,7 +25,11 @@ KButtonText.args = {
|
|
|
25
25
|
width: "160px",
|
|
26
26
|
height: "44px",
|
|
27
27
|
hoverBackground: "#A2FE67",
|
|
28
|
-
textDecoration: "underline"
|
|
28
|
+
textDecoration: "underline",
|
|
29
|
+
activeBackground: "#F00",
|
|
30
|
+
border: "1px solid black",
|
|
31
|
+
hoverBorder: "1px solid red",
|
|
32
|
+
activeBorder: "1px solid transparent",
|
|
29
33
|
};
|
|
30
34
|
|
|
31
35
|
export const KButtonIcon = Template.bind({});
|
|
@@ -20,10 +20,15 @@ export interface KButtonProps {
|
|
|
20
20
|
fontWeight?: number
|
|
21
21
|
textDecoration?: string
|
|
22
22
|
gap?: string
|
|
23
|
+
activeBackground?: string
|
|
24
|
+
border?: string
|
|
25
|
+
hoverBorder?: string
|
|
26
|
+
activeBorder?: string
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
const KButton: React.FC<KButtonProps> = (props) => {
|
|
26
30
|
const [hover, setHover] = useState(false)
|
|
31
|
+
const [active, setActive] = useState(false)
|
|
27
32
|
|
|
28
33
|
const disabled = props.disabled || false
|
|
29
34
|
const background = disabled ? "#F0F0F0" : props.background || "#F2FE67"
|
|
@@ -37,16 +42,31 @@ const KButton: React.FC<KButtonProps> = (props) => {
|
|
|
37
42
|
const fontWeight = props.fontWeight || 500
|
|
38
43
|
const textDecoration = props.textDecoration || "none"
|
|
39
44
|
const gap = props.gap || "0px"
|
|
45
|
+
const activeBackground = props.activeBackground || background
|
|
46
|
+
const border = props.border || "none"
|
|
47
|
+
const hoverBorder = props.hoverBorder || border
|
|
48
|
+
const activeBorder = props.activeBorder || border
|
|
49
|
+
|
|
40
50
|
return (
|
|
41
51
|
<button
|
|
42
52
|
onMouseEnter={() => setHover(true)}
|
|
43
53
|
onMouseLeave={() => setHover(false)}
|
|
44
|
-
|
|
54
|
+
onMouseDown={() => setActive(true)}
|
|
55
|
+
onMouseUp={() => setActive(false)}
|
|
56
|
+
className={`k-button`}
|
|
45
57
|
disabled={disabled}
|
|
46
58
|
onClick={props.onClick}
|
|
47
|
-
style={{
|
|
59
|
+
style={{
|
|
60
|
+
background: active ? activeBackground : hover ? hoverBackground : background,
|
|
61
|
+
border: active ? activeBorder : hover ? hoverBorder : border,
|
|
62
|
+
borderRadius,
|
|
63
|
+
width,
|
|
64
|
+
height,
|
|
65
|
+
padding,
|
|
66
|
+
boxShadow
|
|
67
|
+
}}
|
|
48
68
|
>
|
|
49
|
-
<div className={"flex items-center"} style={{gap}}>
|
|
69
|
+
<div className={"flex items-center"} style={{ gap }}>
|
|
50
70
|
{props.leftIcon && <img src={props.leftIcon} alt={"button-left-icon"} />}
|
|
51
71
|
{props.text && (
|
|
52
72
|
<KSpan text={props.text} color={textColor} fontWeight={fontWeight} textDecoration={textDecoration} />
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Meta, StoryFn } from "@storybook/react"
|
|
2
|
-
import KDropdown, { KSelectOption } from "./KDropdown"
|
|
2
|
+
import KDropdown, { KDropdownProps, KSelectOption } from "./KDropdown"
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
import TracksIcon from "../../assets/tracks.svg"
|
|
5
5
|
// @ts-ignore
|
|
@@ -20,6 +20,7 @@ import SpotifyLogo from "../../assets/platforms/SpotifyLogo.png"
|
|
|
20
20
|
import SpotifyIcon from "../../assets/platforms/SpotifyIcon.png"
|
|
21
21
|
|
|
22
22
|
import { MultiValue } from "react-select"
|
|
23
|
+
import { useState } from "react"
|
|
23
24
|
|
|
24
25
|
export default {
|
|
25
26
|
title: "ReactComponentLibrary/KDropdown",
|
|
@@ -29,7 +30,40 @@ export default {
|
|
|
29
30
|
}
|
|
30
31
|
} as Meta<typeof KDropdown>
|
|
31
32
|
|
|
32
|
-
const
|
|
33
|
+
const KDropdownWrapper: React.FC<KDropdownProps> = (args) => {
|
|
34
|
+
const [selectedOption, setSelectedOption] = useState<KSelectOption | undefined>(undefined)
|
|
35
|
+
|
|
36
|
+
const options = [
|
|
37
|
+
{ label: "Label 1", value: 1, icon: TracksIcon },
|
|
38
|
+
{ label: "Label 4", value: 2, icon: TracksIcon },
|
|
39
|
+
{ label: "Label 3", value: 3 },
|
|
40
|
+
{ label: "Label 2", value: 4 },
|
|
41
|
+
{ label: "R&B", value: 5 },
|
|
42
|
+
{ label: "Çınar", value: 6 },
|
|
43
|
+
{ label: "ELEKTRONIC ", value: 7 },
|
|
44
|
+
{ label: "TANIK", value: 8 },
|
|
45
|
+
{ label: "Very very very very very long content.", value: 9 },
|
|
46
|
+
{ label: "EVREN TANIK EVREN TANIK", value: 10 },
|
|
47
|
+
{ label: "TANIK", value: 11 },
|
|
48
|
+
{ label: "Spotify", value: 12, value2: "spo-spotify", icon: SpotifyIcon, iconLabel: SpotifyLogo },
|
|
49
|
+
{ label: "All", value: 12, value2: "spo-spotify", icon: SpotifyIcon }
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div className="w-24">
|
|
54
|
+
<KDropdown
|
|
55
|
+
{...args}
|
|
56
|
+
options={options}
|
|
57
|
+
onSelect={(selected: KSelectOption | MultiValue<KSelectOption> | undefined) => {
|
|
58
|
+
setSelectedOption(selected as KSelectOption)
|
|
59
|
+
}}
|
|
60
|
+
selected={selectedOption}
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const Template: StoryFn<typeof KDropdownWrapper> = (args) => <KDropdownWrapper {...args} />
|
|
33
67
|
|
|
34
68
|
export const KDropdownSingle = Template.bind({})
|
|
35
69
|
KDropdownSingle.args = {
|
|
@@ -46,9 +80,10 @@ KDropdownSingle.args = {
|
|
|
46
80
|
isClearable: true,
|
|
47
81
|
isEllipsis: true,
|
|
48
82
|
allowContainerShrink: true,
|
|
49
|
-
defaultValuePrimitive: 7,
|
|
50
83
|
hideChosenOptionIcon: true,
|
|
51
|
-
|
|
84
|
+
onBlur: (value: any) => {
|
|
85
|
+
console.log(value)
|
|
86
|
+
},
|
|
52
87
|
options: [
|
|
53
88
|
{ label: "Label 1", value: 1, icon: TracksIcon },
|
|
54
89
|
{ label: "Label 4", value: 2, icon: TracksIcon },
|
|
@@ -62,8 +97,9 @@ KDropdownSingle.args = {
|
|
|
62
97
|
{ label: "EVREN TANIK EVREN TANIK", value: 10 },
|
|
63
98
|
{ label: "TANIK", value: 11 },
|
|
64
99
|
{ label: "Spotify", value: 12, value2: "spo-spotify", icon: SpotifyIcon, iconLabel: SpotifyLogo },
|
|
65
|
-
{ label: "All", value: 12, value2: "spo-spotify", icon: SpotifyIcon}
|
|
100
|
+
{ label: "All", value: 12, value2: "spo-spotify", icon: SpotifyIcon }
|
|
66
101
|
]
|
|
102
|
+
//selected: { label: "Label 1", value: 1, icon: TracksIcon }
|
|
67
103
|
}
|
|
68
104
|
|
|
69
105
|
export const KDropdownMulti = Template.bind({})
|
|
@@ -74,7 +110,7 @@ const options = [
|
|
|
74
110
|
{ label: "Label 2", value: 4, icon: AppleIcon },
|
|
75
111
|
{ label: "Label 2", value: 5, icon: MetaIcon },
|
|
76
112
|
{ label: "Spotify", value: 6, value2: "spo-spotify", icon: SpotifyIcon, iconLabel: SpotifyLogo },
|
|
77
|
-
{ label: "Label 7", value: 7 }
|
|
113
|
+
{ label: "Label 7", value: 7 }
|
|
78
114
|
]
|
|
79
115
|
KDropdownMulti.args = {
|
|
80
116
|
onSelect: (value: KSelectOption | MultiValue<KSelectOption> | undefined) => {},
|
|
@@ -86,7 +122,10 @@ KDropdownMulti.args = {
|
|
|
86
122
|
placeholderColor: "#000",
|
|
87
123
|
enableIndicator: true,
|
|
88
124
|
showOnlyIconsInMulti: true,
|
|
89
|
-
rightIcon: CaretDownIcon
|
|
125
|
+
rightIcon: CaretDownIcon,
|
|
126
|
+
onBlur: (value: any) => {
|
|
127
|
+
console.log(value)
|
|
128
|
+
}
|
|
90
129
|
}
|
|
91
130
|
|
|
92
131
|
export const KDropdownLeftIcon = Template.bind({})
|
|
@@ -103,7 +142,7 @@ KDropdownRightIcon.args = {
|
|
|
103
142
|
placeholder: "Placeholder...",
|
|
104
143
|
rightIcon: TracksIcon,
|
|
105
144
|
placeholderColor: "#F00",
|
|
106
|
-
allowContainerShrink: true,
|
|
145
|
+
allowContainerShrink: true,
|
|
107
146
|
width: 250,
|
|
108
147
|
menuWidth: 200,
|
|
109
148
|
options: [
|
|
@@ -124,6 +163,6 @@ KDropdownLeftRightIcon.args = {
|
|
|
124
163
|
placeholder: "Placeholder...",
|
|
125
164
|
leftIcon: TracksIcon,
|
|
126
165
|
rightIcon: TracksIcon,
|
|
127
|
-
enableIndicator:true,
|
|
166
|
+
enableIndicator: true,
|
|
128
167
|
gap: "15px"
|
|
129
168
|
}
|
|
@@ -39,28 +39,39 @@ export interface KDropdownProps {
|
|
|
39
39
|
menuBackground?: string
|
|
40
40
|
padding?: string
|
|
41
41
|
gap?: string
|
|
42
|
+
onBlur?: (value: KSelectOption | MultiValue<KSelectOption> | undefined) => void
|
|
42
43
|
hideChosenOptionIcon?: boolean // hides the selected option's icon in the container, not menu
|
|
43
44
|
isClearable?: boolean // makes possible to clear the selected option
|
|
44
45
|
isEllipsis?: boolean // adds ellipsis to the container if label overflows, width should be fixed value
|
|
45
46
|
showOnlyIconsInMulti?: boolean // adds only icons of selected options to the container, not labels
|
|
46
|
-
menuWidth?: string | number
|
|
47
|
+
menuWidth?: string | number
|
|
47
48
|
menuLeftMargin?: number // lets to change menu's position horizontally
|
|
48
49
|
placeholderColor?: string
|
|
49
50
|
enableIndicator?: boolean // if rightIcon is provided, lets it to open-close menu
|
|
50
51
|
allowContainerShrink?: boolean // allows container to shrink if label is smaller than width, width should be fixed value
|
|
52
|
+
border?: string
|
|
53
|
+
activeBorder?: string
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
const KDropdown: React.FC<KDropdownProps> = (props) => {
|
|
54
57
|
const [selectedOption, setSelectedOption] = useState<KSelectOption | MultiValue<KSelectOption>>()
|
|
55
58
|
const [iconCount, setIconCount] = useState<number>(0)
|
|
56
59
|
const [background, setBackground] = useState("#F5F5F5")
|
|
60
|
+
const [border, setBorder] = useState("none")
|
|
57
61
|
|
|
58
62
|
useEffect(() => {
|
|
59
63
|
const emptyBackground = props.background || "#F5F5F5"
|
|
60
64
|
const activeBackground = props.activeBackground || "#FFF"
|
|
61
65
|
|
|
66
|
+
const emptyBorder = props.border || "none"
|
|
67
|
+
const activeBorder = props.activeBorder || emptyBorder
|
|
68
|
+
|
|
62
69
|
const background = props.selected ? activeBackground : emptyBackground
|
|
70
|
+
const border = props.selected ? activeBorder : emptyBorder
|
|
71
|
+
|
|
63
72
|
setBackground(background)
|
|
73
|
+
setBorder(border)
|
|
74
|
+
|
|
64
75
|
}, [props.selected])
|
|
65
76
|
|
|
66
77
|
const width = props.width || "100%"
|
|
@@ -204,7 +215,8 @@ const KDropdown: React.FC<KDropdownProps> = (props) => {
|
|
|
204
215
|
height,
|
|
205
216
|
boxShadow,
|
|
206
217
|
padding,
|
|
207
|
-
gap
|
|
218
|
+
gap,
|
|
219
|
+
border
|
|
208
220
|
}}
|
|
209
221
|
>
|
|
210
222
|
{props.leftIcon && <img src={props.leftIcon} width={20} alt={"l-icon"} />}
|
|
@@ -216,6 +228,9 @@ const KDropdown: React.FC<KDropdownProps> = (props) => {
|
|
|
216
228
|
placeholder={props.placeholder || ""}
|
|
217
229
|
options={props.options}
|
|
218
230
|
className={"k-dropdown"}
|
|
231
|
+
onBlur={() => {
|
|
232
|
+
if (props.onBlur) props.onBlur(selectedOption)
|
|
233
|
+
}}
|
|
219
234
|
filterOption={customFilterOption}
|
|
220
235
|
isClearable={isClearable}
|
|
221
236
|
hideSelectedOptions={!isMulti ? false : showOnlyIconsInMulti ? false : true}
|
|
@@ -261,8 +276,12 @@ const KDropdown: React.FC<KDropdownProps> = (props) => {
|
|
|
261
276
|
marginTop: 4,
|
|
262
277
|
borderRadius: 10,
|
|
263
278
|
color: "#111",
|
|
279
|
+
transition: "all 0.3s",
|
|
264
280
|
"&:hover": {
|
|
265
281
|
background: "#F7F7F7"
|
|
282
|
+
},
|
|
283
|
+
"&:active": {
|
|
284
|
+
background: "white"
|
|
266
285
|
}
|
|
267
286
|
}),
|
|
268
287
|
valueContainer: (base) => ({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Meta, StoryFn } from "@storybook/react"
|
|
2
|
-
import KInput from "./KInput"
|
|
2
|
+
import KInput, { KInputProps } from "./KInput"
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
import TracksIcon from "../../assets/tracks.svg"
|
|
5
|
-
import { KeyboardEvent } from "react"
|
|
5
|
+
import { KeyboardEvent, useState } from "react"
|
|
6
6
|
|
|
7
7
|
export default {
|
|
8
8
|
title: "ReactComponentLibrary/KInput",
|
|
@@ -12,7 +12,41 @@ export default {
|
|
|
12
12
|
}
|
|
13
13
|
} as Meta<typeof KInput>
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
const KInputWrapper: React.FC<KInputProps> = (args) => {
|
|
17
|
+
|
|
18
|
+
const [textValue, setTextValue] = useState<string>("")
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<KInput
|
|
22
|
+
{...args}
|
|
23
|
+
value={textValue}
|
|
24
|
+
onChange={(text) => {
|
|
25
|
+
setTextValue(text)
|
|
26
|
+
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const Template: StoryFn<typeof KInputWrapper> = (args) => <KInputWrapper {...args} />
|
|
33
|
+
|
|
34
|
+
export const KInputPrimary = Template.bind({})
|
|
35
|
+
KInputPrimary.args = {
|
|
36
|
+
|
|
37
|
+
onKeyDown: (event: KeyboardEvent) => {
|
|
38
|
+
if (event.key === "Enter") {
|
|
39
|
+
console.log("Enter is clicked and our value is:", event.currentTarget)
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
placeholder: "Placeholder...",
|
|
43
|
+
hoverBackground: "white",
|
|
44
|
+
activeBackground: "red",
|
|
45
|
+
border: "1px solid black",
|
|
46
|
+
hoverBorder: "1px solid red",
|
|
47
|
+
activeBorder: "1px solid transparent",
|
|
48
|
+
}
|
|
49
|
+
|
|
16
50
|
|
|
17
51
|
export const KInputRange = Template.bind({})
|
|
18
52
|
KInputRange.args = {
|
|
@@ -35,20 +69,6 @@ KInputCheckbox.args = {
|
|
|
35
69
|
checked: false
|
|
36
70
|
}
|
|
37
71
|
|
|
38
|
-
export const KInputPrimary = Template.bind({})
|
|
39
|
-
KInputPrimary.args = {
|
|
40
|
-
onChange: (value: string) => {
|
|
41
|
-
console.log("value:", value)
|
|
42
|
-
},
|
|
43
|
-
onKeyDown: (event: KeyboardEvent) => {
|
|
44
|
-
if (event.key === "Enter") {
|
|
45
|
-
console.log("Enter is clicked and our value is:", event.currentTarget)
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
placeholder: "Placeholder...",
|
|
49
|
-
hoverBackground: "white"
|
|
50
|
-
}
|
|
51
|
-
|
|
52
72
|
export const KInputLeftIcon = Template.bind({})
|
|
53
73
|
KInputLeftIcon.args = {
|
|
54
74
|
onChange: (value: string) => {},
|
|
@@ -56,7 +76,13 @@ KInputLeftIcon.args = {
|
|
|
56
76
|
leftIcon: TracksIcon,
|
|
57
77
|
leftIconClick: () => {
|
|
58
78
|
alert("left icon clicked")
|
|
59
|
-
}
|
|
79
|
+
},
|
|
80
|
+
activeBackground: "red",
|
|
81
|
+
hoverBackground: "white",
|
|
82
|
+
border: "1px solid black",
|
|
83
|
+
activeBorder: "1px solid blue",
|
|
84
|
+
hoverBorder: "1px solid yellow"
|
|
85
|
+
|
|
60
86
|
}
|
|
61
87
|
|
|
62
88
|
export const KInputRightIcon = Template.bind({})
|
|
@@ -28,18 +28,25 @@ export interface KInputProps {
|
|
|
28
28
|
fontSize?: string
|
|
29
29
|
iconSize?: string
|
|
30
30
|
checked?: boolean
|
|
31
|
+
hoverBorder?: string
|
|
32
|
+
activeBorder?: string
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
const KInput: React.FC<KInputProps> = (props) => {
|
|
34
36
|
const [background, setBackground] = useState("#F5F5F5")
|
|
37
|
+
const [border, setBorder] = useState("none")
|
|
35
38
|
const [hover, setHover] = useState(false)
|
|
36
39
|
|
|
37
40
|
useEffect(() => {
|
|
38
41
|
const emptyBackground = props.background || "#F5F5F5"
|
|
39
42
|
const activeBackground = props.activeBackground || "#FFF"
|
|
43
|
+
const emptyBorder = props.border || "none"
|
|
44
|
+
const activeBorder = props.activeBorder || emptyBorder
|
|
40
45
|
|
|
41
46
|
const background = props.value ? activeBackground : emptyBackground
|
|
47
|
+
const border = props.value ? activeBorder : emptyBorder
|
|
42
48
|
setBackground(background)
|
|
49
|
+
setBorder(border)
|
|
43
50
|
}, [props.value])
|
|
44
51
|
|
|
45
52
|
const width = props.width || "100%"
|
|
@@ -56,16 +63,23 @@ const KInput: React.FC<KInputProps> = (props) => {
|
|
|
56
63
|
const hoverBackground = props.hoverBackground || background
|
|
57
64
|
const padding = props.padding || "8px"
|
|
58
65
|
const gap = props.gap || "12px"
|
|
59
|
-
const border = props.border || "none"
|
|
60
66
|
const fontSize = props.fontSize || "14px"
|
|
61
67
|
const iconSize = props.iconSize || "20px"
|
|
68
|
+
const hoverBorder = props.hoverBorder || border
|
|
62
69
|
|
|
63
70
|
return (
|
|
64
71
|
<div
|
|
65
72
|
onMouseEnter={() => setHover(true)}
|
|
66
73
|
onMouseLeave={() => setHover(false)}
|
|
67
74
|
className={"k-input-container"}
|
|
68
|
-
style={{
|
|
75
|
+
style={{
|
|
76
|
+
background: hover ? hoverBackground : background,
|
|
77
|
+
borderRadius,
|
|
78
|
+
boxShadow,
|
|
79
|
+
padding,
|
|
80
|
+
gap,
|
|
81
|
+
border: hover ? hoverBorder : border
|
|
82
|
+
}}
|
|
69
83
|
>
|
|
70
84
|
{props.leftIcon && (
|
|
71
85
|
<img
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Meta, StoryFn } from "@storybook/react"
|
|
2
|
-
import KSpan from "./KSpan"
|
|
2
|
+
import KSpan, { KSpanProps } from "./KSpan"
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
title: "ReactComponentLibrary/KSpan",
|
|
@@ -9,29 +9,28 @@ export default {
|
|
|
9
9
|
}
|
|
10
10
|
} as Meta<typeof KSpan>
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const KSpanWrapper: React.FC<KSpanProps> = (args) => {
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
fontStyle: "normal",
|
|
22
|
-
letterSpacing: "-0.084px",
|
|
23
|
-
textDecoration: "underline"
|
|
14
|
+
return (
|
|
15
|
+
<div className="min-[1000px]:w-[400px] min-[800px]:w-[300px] min-[700px]:w-[150px] w-28">
|
|
16
|
+
<div className="w-[100%] flex ">
|
|
17
|
+
<KSpan {...args} />
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
)
|
|
24
21
|
}
|
|
25
22
|
|
|
23
|
+
const Template: StoryFn<typeof KSpanWrapper> = (args) => <KSpanWrapper {...args} />
|
|
26
24
|
|
|
27
|
-
export const
|
|
28
|
-
|
|
29
|
-
text: "Hello World",
|
|
25
|
+
export const KSpanPrimary = Template.bind({})
|
|
26
|
+
KSpanPrimary.args = {
|
|
27
|
+
text: "Hello World, how are you? Is everything alright?",
|
|
30
28
|
fontSize: 14,
|
|
29
|
+
color: "#737373",
|
|
31
30
|
fontWeight: 400,
|
|
32
31
|
lineHeight: "20px",
|
|
33
|
-
color: "#111",
|
|
34
32
|
fontStyle: "normal",
|
|
35
33
|
letterSpacing: "-0.084px",
|
|
36
|
-
|
|
34
|
+
textDecoration: "underline",
|
|
35
|
+
ellipsis: true
|
|
37
36
|
}
|
|
@@ -9,15 +9,11 @@ export interface KSpanProps {
|
|
|
9
9
|
lineHeight?: string
|
|
10
10
|
fontStyle?: string
|
|
11
11
|
letterSpacing?: string
|
|
12
|
-
hoverText?: string
|
|
13
|
-
hoverTextColor?: string
|
|
14
|
-
hoverStyle?: CSSProperties,
|
|
15
12
|
textDecoration?: string,
|
|
16
13
|
ellipsis?: boolean
|
|
17
14
|
}
|
|
18
15
|
|
|
19
16
|
const KSpan: React.FC<KSpanProps> = (props) => {
|
|
20
|
-
const [onHover, setOnHover] = useState(false)
|
|
21
17
|
|
|
22
18
|
const fontSize = props.fontSize || 14
|
|
23
19
|
const color = props.color || "#737373"
|
|
@@ -25,47 +21,19 @@ const KSpan: React.FC<KSpanProps> = (props) => {
|
|
|
25
21
|
const lineHeight = props.lineHeight || "20px"
|
|
26
22
|
const fontStyle = props.fontStyle || "normal"
|
|
27
23
|
const letterSpacing = props.letterSpacing || "-0.084px"
|
|
28
|
-
const hoverTextColor = props.hoverTextColor || "#737373"
|
|
29
|
-
const hoverStyle = props.hoverStyle || {}
|
|
30
24
|
const textDecoration = props.textDecoration || "none"
|
|
31
25
|
const ellipsis = props.ellipsis || false
|
|
32
26
|
|
|
33
27
|
const ellipsisStyle = {overflow:"hidden", textOverflow:"ellipsis", whiteSpace:"nowrap"}
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
>
|
|
44
|
-
{props.text}
|
|
45
|
-
</span>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return props.hoverText ? (
|
|
50
|
-
<div className="grid justify-items-center">
|
|
51
|
-
{renderBaseSpan()}
|
|
52
|
-
{onHover && (
|
|
53
|
-
<span
|
|
54
|
-
className={"k-span"}
|
|
55
|
-
style={{
|
|
56
|
-
fontSize: fontSize - 2,
|
|
57
|
-
color: hoverTextColor,
|
|
58
|
-
fontWeight,
|
|
59
|
-
lineHeight,
|
|
60
|
-
fontStyle,
|
|
61
|
-
letterSpacing
|
|
62
|
-
}}
|
|
63
|
-
>
|
|
64
|
-
{props.hoverText}
|
|
65
|
-
</span>
|
|
66
|
-
)}
|
|
67
|
-
</div>
|
|
68
|
-
) : renderBaseSpan()
|
|
29
|
+
return (
|
|
30
|
+
<span
|
|
31
|
+
className={"k-span"}
|
|
32
|
+
style={{ fontSize, color, fontWeight, lineHeight, fontStyle, letterSpacing, textDecoration, ...(ellipsis && ellipsisStyle)}}
|
|
33
|
+
>
|
|
34
|
+
{props.text}
|
|
35
|
+
</span>
|
|
36
|
+
)
|
|
69
37
|
}
|
|
70
38
|
|
|
71
|
-
export default KSpan
|
|
39
|
+
export default KSpan
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {Meta, StoryFn} from "@storybook/react";
|
|
2
|
-
import KTitleSpan from "./KTitleSpan";
|
|
2
|
+
import KTitleSpan, { KTitleSpanProps } from "./KTitleSpan";
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
title: "ReactComponentLibrary/KTitleSpan",
|
|
@@ -9,10 +9,33 @@ export default {
|
|
|
9
9
|
},
|
|
10
10
|
} as Meta<typeof KTitleSpan>;
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const KTitleSpanWrapper: React.FC<KTitleSpanProps> = (args) => {
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className="min-[1000px]:w-[300px] min-[800px]:w-[200px] min-[700px]:w-[150px] w-[100px]">
|
|
16
|
+
<div className="w-[100%]">
|
|
17
|
+
<KTitleSpan {...args} />
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const Template: StoryFn<typeof KTitleSpanWrapper> = (args) => <KTitleSpanWrapper {...args} />;
|
|
13
24
|
|
|
14
25
|
export const KTitleSpanPrimary = Template.bind({});
|
|
15
26
|
KTitleSpanPrimary.args = {
|
|
27
|
+
text: "Hello how?",
|
|
28
|
+
fontSize: 48,
|
|
29
|
+
color: "#111",
|
|
30
|
+
lineHeight: "56px",
|
|
31
|
+
fontStyle: "normal",
|
|
32
|
+
letterSpacing: "-0.48px",
|
|
33
|
+
bold: false,
|
|
34
|
+
ellipsis: true
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const KTitleSpanSecondary = Template.bind({});
|
|
38
|
+
KTitleSpanSecondary.args = {
|
|
16
39
|
text: "Hello World",
|
|
17
40
|
fontSize: 48,
|
|
18
41
|
color: "#111",
|