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
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import React from "react"
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react"
|
|
2
2
|
import "../../main.css"
|
|
3
|
+
import KTooltip from "../KTooltip"
|
|
4
|
+
import KSpan from "../KSpan"
|
|
3
5
|
|
|
4
6
|
export interface KTitleSpanProps {
|
|
5
7
|
text: string
|
|
@@ -8,8 +10,9 @@ export interface KTitleSpanProps {
|
|
|
8
10
|
fontWeight?: number
|
|
9
11
|
lineHeight?: string
|
|
10
12
|
fontStyle?: string
|
|
11
|
-
letterSpacing?: string
|
|
13
|
+
letterSpacing?: string
|
|
12
14
|
bold?: boolean
|
|
15
|
+
ellipsis?: boolean
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
const KTitleSpan: React.FC<KTitleSpanProps> = (props) => {
|
|
@@ -20,14 +23,66 @@ const KTitleSpan: React.FC<KTitleSpanProps> = (props) => {
|
|
|
20
23
|
const letterSpacing = props.letterSpacing || "-0.48px"
|
|
21
24
|
const bold = props.bold || false
|
|
22
25
|
const titleClassName = bold ? "k-title-span-bold" : "k-title-span"
|
|
23
|
-
const fontWeight = props.fontWeight ? props.fontWeight :
|
|
26
|
+
const fontWeight = props.fontWeight ? props.fontWeight : bold ? 700 : 500
|
|
27
|
+
const ellipsis = props.ellipsis || false
|
|
28
|
+
const ellipsisStyle = { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }
|
|
29
|
+
|
|
30
|
+
const [isEllipsis, setIsEllipsis] = useState(false)
|
|
31
|
+
const textRef = useRef<HTMLSpanElement>(null)
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const checkEllipsis = () => {
|
|
35
|
+
if (textRef.current && ellipsis) {
|
|
36
|
+
setIsEllipsis(textRef.current.scrollWidth > textRef.current.clientWidth)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
checkEllipsis()
|
|
41
|
+
window.addEventListener("resize", checkEllipsis)
|
|
42
|
+
|
|
43
|
+
return () => {
|
|
44
|
+
window.removeEventListener("resize", checkEllipsis)
|
|
45
|
+
}
|
|
46
|
+
}, [props.text, ellipsis])
|
|
24
47
|
|
|
25
|
-
|
|
26
48
|
return (
|
|
27
|
-
<
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
49
|
+
<React.Fragment>
|
|
50
|
+
{isEllipsis ? (
|
|
51
|
+
<KTooltip
|
|
52
|
+
padding="2px 4px"
|
|
53
|
+
content={
|
|
54
|
+
<div className="w-max">
|
|
55
|
+
<KSpan text={props.text} color="#111" />
|
|
56
|
+
</div>
|
|
57
|
+
}
|
|
58
|
+
>
|
|
59
|
+
<span
|
|
60
|
+
ref={textRef}
|
|
61
|
+
className={`${titleClassName} ${ellipsis ? "block" : "flex items-center"}`}
|
|
62
|
+
style={{
|
|
63
|
+
fontSize,
|
|
64
|
+
color,
|
|
65
|
+
fontWeight,
|
|
66
|
+
lineHeight,
|
|
67
|
+
fontStyle,
|
|
68
|
+
letterSpacing,
|
|
69
|
+
...(ellipsis && ellipsisStyle)
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
{props.text}
|
|
73
|
+
</span>
|
|
74
|
+
</KTooltip>
|
|
75
|
+
) : (
|
|
76
|
+
<span
|
|
77
|
+
ref={textRef}
|
|
78
|
+
className={`${titleClassName} ${ellipsis ? "block" : "flex items-center"}`}
|
|
79
|
+
style={{ fontSize, color, fontWeight, lineHeight, fontStyle, letterSpacing, ...(ellipsis && ellipsisStyle) }}
|
|
80
|
+
>
|
|
81
|
+
{props.text}
|
|
82
|
+
</span>
|
|
83
|
+
)}
|
|
84
|
+
</React.Fragment>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
32
87
|
|
|
33
|
-
export default KTitleSpan
|
|
88
|
+
export default KTitleSpan
|
package/src/index.ts
CHANGED
|
@@ -12,7 +12,18 @@ import KSliderLabel from "./components/KSliderLabel"
|
|
|
12
12
|
import KCodeInput from "./components/KCodeInput"
|
|
13
13
|
import KSelectRange from "./components/KSelectRange"
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
export {
|
|
17
|
-
KButton,
|
|
16
|
+
KButton,
|
|
17
|
+
KSpan,
|
|
18
|
+
KLogo,
|
|
19
|
+
KTitleSpan,
|
|
20
|
+
KInput,
|
|
21
|
+
KTextArea,
|
|
22
|
+
KDropdown,
|
|
23
|
+
KSlider,
|
|
24
|
+
KSelectDate,
|
|
25
|
+
KTooltip,
|
|
26
|
+
KSliderLabel,
|
|
27
|
+
KCodeInput,
|
|
28
|
+
KSelectRange
|
|
18
29
|
}
|
package/src/main.css
CHANGED
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
display: inline;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
43
42
|
.k-input-container {
|
|
44
43
|
display: flex;
|
|
45
44
|
align-items: center;
|
|
46
45
|
align-self: stretch;
|
|
46
|
+
transition: all 0.3s;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
.k-input {
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
line-height: 20px;
|
|
57
57
|
/* 142.857% */
|
|
58
58
|
letter-spacing: -0.084px;
|
|
59
|
+
transition: all 0.3s;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
.k-input::placeholder {
|
|
@@ -72,8 +73,12 @@
|
|
|
72
73
|
align-items: center;
|
|
73
74
|
gap: 4px;
|
|
74
75
|
align-self: stretch;
|
|
76
|
+
transition: all 0.3s;
|
|
75
77
|
}
|
|
76
78
|
|
|
79
|
+
.k-button:focus {
|
|
80
|
+
outline: none !important;
|
|
81
|
+
}
|
|
77
82
|
|
|
78
83
|
.k-dropdown-container {
|
|
79
84
|
display: flex;
|