kahuna-base-react-components 0.2.11 → 0.2.13
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.stories.d.ts +8 -0
- package/dist/components/KDropdown/KDropdown.d.ts +2 -1
- package/dist/components/KDropdown/KDropdown.stories.d.ts +7 -0
- package/dist/components/KInput/KInput.stories.d.ts +8 -0
- package/dist/components/KLogo/KLogo.stories.d.ts +5 -0
- package/dist/components/KSelectDate/KSelectDate.d.ts +9 -0
- package/dist/components/KSelectDate/KSelectDate.stories.d.ts +5 -0
- package/dist/components/KSelectDate/index.d.ts +1 -0
- package/dist/components/KSlider/KSlider.stories.d.ts +3 -0
- package/dist/components/KSpan/KSpan.d.ts +1 -0
- package/dist/components/KSpan/KSpan.stories.d.ts +4 -0
- package/dist/components/KTitleSpan/KTitleSpan.stories.d.ts +3 -0
- package/dist/components/KTooltip/KTooltip.d.ts +19 -0
- package/dist/components/KTooltip/KTooltip.stories.d.ts +5 -0
- package/dist/components/KTooltip/index.d.ts +1 -0
- package/dist/index.d.ts +3 -1
- 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 +27 -2
- package/package.json +4 -2
- package/removeUseClient.js +22 -0
- package/rollup.config.js +2 -0
- package/src/assets/calendar-hovered.svg +3 -0
- package/src/assets/calendar.svg +3 -0
- package/src/assets/separator.svg +3 -0
- package/src/components/KDropdown/KDropdown.stories.tsx +17 -7
- package/src/components/KDropdown/KDropdown.tsx +6 -3
- package/src/components/KSelectDate/CalendarCustom.css +235 -0
- package/src/components/KSelectDate/KSelectDate.stories.tsx +54 -0
- package/src/components/KSelectDate/KSelectDate.tsx +314 -0
- package/src/components/KSelectDate/index.ts +1 -0
- package/src/components/KSpan/KSpan.tsx +6 -2
- package/src/components/KTooltip/KTooltip.stories.tsx +94 -0
- package/src/components/KTooltip/KTooltip.tsx +67 -0
- package/src/components/KTooltip/index.ts +1 -0
- package/src/index.ts +3 -1
- package/src/main.css +94 -4
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import React, { CSSProperties, useEffect, useState } from "react"
|
|
2
|
+
import Calendar from "react-calendar"
|
|
3
|
+
import "./CalendarCustom.css"
|
|
4
|
+
//@ts-ignore
|
|
5
|
+
import LeftIcon from "../../assets/chevron-left.svg"
|
|
6
|
+
//@ts-ignore
|
|
7
|
+
import SeparatorIcon from "../../assets/separator.svg"
|
|
8
|
+
//@ts-ignore
|
|
9
|
+
import CalendarIcon from "../../assets/calendar.svg"
|
|
10
|
+
//@ts-ignore
|
|
11
|
+
import RightIcon from "../../assets/chevron-right.svg"
|
|
12
|
+
import "../../main.css"
|
|
13
|
+
import KButton from "../KButton"
|
|
14
|
+
import KSpan from "../KSpan"
|
|
15
|
+
|
|
16
|
+
export interface KSelectDateProps {
|
|
17
|
+
value: Date | undefined
|
|
18
|
+
onChange: (date: Date | undefined) => void
|
|
19
|
+
}
|
|
20
|
+
interface MonthSelectorType {
|
|
21
|
+
monthName: string
|
|
22
|
+
year: string
|
|
23
|
+
date: Date
|
|
24
|
+
}
|
|
25
|
+
interface DaySelectorType {
|
|
26
|
+
dayName: string
|
|
27
|
+
dayOrderInMonth: number
|
|
28
|
+
date: Date
|
|
29
|
+
}
|
|
30
|
+
interface MonthTextType {
|
|
31
|
+
[key: string]: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const KSelectDate: React.FC<KSelectDateProps> = (props) => {
|
|
35
|
+
const [value, setValue] = useState<Date | undefined>(props.value)
|
|
36
|
+
const [calendarDate, setCalendarDate] = useState<Date | undefined>(props.value)
|
|
37
|
+
const [dummyDate, setDummyDate] = useState<Date | undefined>(props.value)
|
|
38
|
+
const [nextMonths, setNextMonths] = useState<MonthSelectorType[]>([])
|
|
39
|
+
const [weekDays, setWeekDays] = useState<DaySelectorType[]>([])
|
|
40
|
+
const [openCalendar, setOpenCalendar] = useState<boolean>(false)
|
|
41
|
+
|
|
42
|
+
const formatShortWeekday = (locale: string | undefined, date: Date): string => {
|
|
43
|
+
return date.toLocaleDateString(locale, { weekday: "short" }).charAt(0) // Return only the first letter of the weekday
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const formatMonthYear = (locale: string | undefined, date: Date): string => {
|
|
47
|
+
const formattedDate = date.toLocaleDateString(locale, { month: "short", year: "numeric" })
|
|
48
|
+
const [month, year] = formattedDate.split(" ")
|
|
49
|
+
const capitalizedMonth = month.charAt(0).toUpperCase() + month.slice(1).toLowerCase()
|
|
50
|
+
return `${capitalizedMonth}, ${year}`
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const onClickDay = (date: Date) => {
|
|
54
|
+
if (date.getTime() === calendarDate?.getTime()) {
|
|
55
|
+
setCalendarDate(undefined)
|
|
56
|
+
} else {
|
|
57
|
+
setCalendarDate(date)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const getNextMonths = (date: Date | undefined) => {
|
|
62
|
+
if (date) {
|
|
63
|
+
const updatedMonths = Array.from({ length: 4 }, (_, i) => {
|
|
64
|
+
const newDate = new Date(date.getFullYear(), date.getMonth() + (i - 1), 1)
|
|
65
|
+
return {
|
|
66
|
+
monthName: newDate.toLocaleString("en-US", { month: "long" }),
|
|
67
|
+
year: newDate.getFullYear().toString(),
|
|
68
|
+
date: newDate
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
setNextMonths(updatedMonths)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const getWeekDays = (date: Date | undefined) => {
|
|
76
|
+
if (date) {
|
|
77
|
+
const startOfWeek = new Date(date)
|
|
78
|
+
const dayOfWeek = startOfWeek.getDay()
|
|
79
|
+
const diffToMonday = dayOfWeek === 0 ? -6 : 1 - dayOfWeek // If Sunday (0), move back 6 days; otherwise move back (1 - dayOfWeek) days
|
|
80
|
+
startOfWeek.setDate(startOfWeek.getDate() + diffToMonday)
|
|
81
|
+
|
|
82
|
+
const updatedDays = Array.from({ length: 7 }, (_, i) => {
|
|
83
|
+
const day = new Date(startOfWeek)
|
|
84
|
+
day.setDate(startOfWeek.getDate() + i)
|
|
85
|
+
return {
|
|
86
|
+
dayName: day.toLocaleDateString("en-US", { weekday: "short" }),
|
|
87
|
+
dayOrderInMonth: day.getDate(),
|
|
88
|
+
date: day
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
setWeekDays(updatedDays)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const renderPopUpCalendar = () => {
|
|
97
|
+
return (
|
|
98
|
+
<div className="flex flex-col gap-0">
|
|
99
|
+
<Calendar
|
|
100
|
+
onClickDay={onClickDay}
|
|
101
|
+
locale="en-US"
|
|
102
|
+
value={calendarDate || null}
|
|
103
|
+
defaultValue={null}
|
|
104
|
+
next2Label={null}
|
|
105
|
+
prev2Label={null}
|
|
106
|
+
prevLabel={<img src={LeftIcon} />}
|
|
107
|
+
nextLabel={<img src={RightIcon} />}
|
|
108
|
+
formatShortWeekday={formatShortWeekday}
|
|
109
|
+
formatMonthYear={formatMonthYear}
|
|
110
|
+
/>
|
|
111
|
+
<div className="h-19 w-[350px] bg-[#FFF] flex flex-row gap-4 py-4 justify-center border-[1px] border-[#E7E7E7] border-t-0 rounded-b-[10px]">
|
|
112
|
+
<KButton
|
|
113
|
+
text="Cancel"
|
|
114
|
+
height="44px"
|
|
115
|
+
width="160px"
|
|
116
|
+
background="#FFF"
|
|
117
|
+
textColor="#111"
|
|
118
|
+
onClick={() => {
|
|
119
|
+
setOpenCalendar(false)
|
|
120
|
+
}}
|
|
121
|
+
/>
|
|
122
|
+
<KButton
|
|
123
|
+
text="Apply"
|
|
124
|
+
height="44px"
|
|
125
|
+
width="160px"
|
|
126
|
+
background="#F2FE67"
|
|
127
|
+
textColor="#111"
|
|
128
|
+
onClick={() => {
|
|
129
|
+
setValue(calendarDate)
|
|
130
|
+
setOpenCalendar(false)
|
|
131
|
+
}}
|
|
132
|
+
/>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const monthSelector = (month: string, year: string, date: Date) => {
|
|
139
|
+
const monthText: MonthTextType = {
|
|
140
|
+
January: "Jan",
|
|
141
|
+
February: "Feb",
|
|
142
|
+
March: "March",
|
|
143
|
+
April: "April",
|
|
144
|
+
May: "May",
|
|
145
|
+
June: "June",
|
|
146
|
+
July: "July",
|
|
147
|
+
August: "August",
|
|
148
|
+
September: "Sept",
|
|
149
|
+
October: "Oct",
|
|
150
|
+
November: "Nov",
|
|
151
|
+
December: "Dec"
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const text = `${monthText[month]}, ${year}`
|
|
155
|
+
|
|
156
|
+
const inMonth = dummyDate ? dummyDate?.getMonth() === date.getMonth() : new Date().getMonth() === date.getMonth()
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<div
|
|
160
|
+
key={`${text}-${date}`}
|
|
161
|
+
className={`w-[135px] h-9 box-sizing`}
|
|
162
|
+
style={{
|
|
163
|
+
borderRadius: 999,
|
|
164
|
+
border: inMonth ? "1px solid #111" : "1px solid #E7E7E7"
|
|
165
|
+
}}
|
|
166
|
+
>
|
|
167
|
+
<KButton
|
|
168
|
+
text={text}
|
|
169
|
+
shadowDisabled={true}
|
|
170
|
+
onClick={() => {
|
|
171
|
+
if (date.getTime()) {
|
|
172
|
+
setDummyDate(date)
|
|
173
|
+
}
|
|
174
|
+
}}
|
|
175
|
+
background={inMonth ? "#111" : "#FFF"}
|
|
176
|
+
textColor={inMonth? "#FFF" : "#111"}
|
|
177
|
+
borderRadius={999}
|
|
178
|
+
padding="8px 16px"
|
|
179
|
+
height="34px"
|
|
180
|
+
/>
|
|
181
|
+
</div>
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const daySelector = (text: string, date: Date) => {
|
|
186
|
+
return (
|
|
187
|
+
<div
|
|
188
|
+
key={`${text}-${date}`}
|
|
189
|
+
className={`w-[85px] h-[104px] flex flex-col justify-between py-3 px-2.5 rounded-[10px] ${
|
|
190
|
+
date.getTime() === value?.getTime() ? "bg-[#F8FEA3]" : "bg-[#F5F5F5]"
|
|
191
|
+
} cursor-pointer`}
|
|
192
|
+
onClick={() => {
|
|
193
|
+
if (date.getTime() === value?.getTime()) {
|
|
194
|
+
setValue(undefined)
|
|
195
|
+
} else {
|
|
196
|
+
setValue(date)
|
|
197
|
+
}
|
|
198
|
+
}}
|
|
199
|
+
>
|
|
200
|
+
<div>
|
|
201
|
+
<img src={CalendarIcon} alt="calendar" />
|
|
202
|
+
</div>
|
|
203
|
+
<KSpan text={text} fontWeight={500} color="#111" />
|
|
204
|
+
</div>
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const changeWeeks = (date: Date | undefined, isNextWeek: boolean) => {
|
|
209
|
+
if (date) {
|
|
210
|
+
const newDate = new Date(date)
|
|
211
|
+
if (isNextWeek) {
|
|
212
|
+
newDate.setDate(newDate.getDate() + 7)
|
|
213
|
+
} else {
|
|
214
|
+
newDate.setDate(newDate.getDate() - 7)
|
|
215
|
+
}
|
|
216
|
+
setDummyDate(newDate)
|
|
217
|
+
} else {
|
|
218
|
+
const newDate = new Date()
|
|
219
|
+
if (isNextWeek) {
|
|
220
|
+
newDate.setDate(newDate.getDate() + 7)
|
|
221
|
+
} else {
|
|
222
|
+
newDate.setDate(newDate.getDate() - 7)
|
|
223
|
+
}
|
|
224
|
+
setDummyDate(newDate)
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
useEffect(() => {
|
|
229
|
+
if (value) {
|
|
230
|
+
setDummyDate(value)
|
|
231
|
+
}
|
|
232
|
+
props.onChange(value)
|
|
233
|
+
}, [value])
|
|
234
|
+
|
|
235
|
+
useEffect(() => {
|
|
236
|
+
const today = new Date()
|
|
237
|
+
if (!props.value) {
|
|
238
|
+
getNextMonths(today)
|
|
239
|
+
getWeekDays(today)
|
|
240
|
+
}
|
|
241
|
+
}, [])
|
|
242
|
+
|
|
243
|
+
useEffect(() => {
|
|
244
|
+
getNextMonths(dummyDate)
|
|
245
|
+
getWeekDays(dummyDate)
|
|
246
|
+
}, [dummyDate])
|
|
247
|
+
|
|
248
|
+
return (
|
|
249
|
+
<React.Fragment>
|
|
250
|
+
{openCalendar && (
|
|
251
|
+
<div className="w-[100vw] h-[100vh] fixed left-0 top-0 flex items-center justify-center z-50">
|
|
252
|
+
<div>{renderPopUpCalendar()}</div>
|
|
253
|
+
</div>
|
|
254
|
+
)}
|
|
255
|
+
<div>
|
|
256
|
+
<div className={`flex flex-col gap-4 ${openCalendar && "blur-2xl"}`}>
|
|
257
|
+
<div className="flex flex-row justify-between gap-2 items-center">
|
|
258
|
+
<div className="flex flex-row gap-2">
|
|
259
|
+
{nextMonths.map((month, i) => {
|
|
260
|
+
return monthSelector(month.monthName, month.year, month.date)
|
|
261
|
+
})}
|
|
262
|
+
</div>
|
|
263
|
+
<div>
|
|
264
|
+
<img src={SeparatorIcon} />
|
|
265
|
+
</div>
|
|
266
|
+
<div>
|
|
267
|
+
<KButton
|
|
268
|
+
icon={CalendarIcon}
|
|
269
|
+
onClick={() => {
|
|
270
|
+
setOpenCalendar(true)
|
|
271
|
+
setCalendarDate(value)
|
|
272
|
+
}}
|
|
273
|
+
padding="8px"
|
|
274
|
+
height="36px"
|
|
275
|
+
background="#FFF"
|
|
276
|
+
/>
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
<div className="flex flex-row justify-between gap-1 items-center">
|
|
280
|
+
{weekDays.map((day, i) => {
|
|
281
|
+
return daySelector(`${day.dayOrderInMonth}, ${day.dayName}`, day.date)
|
|
282
|
+
})}
|
|
283
|
+
</div>
|
|
284
|
+
<div className="flex flex-row justify-between items-center">
|
|
285
|
+
<KButton
|
|
286
|
+
text="Previous Week"
|
|
287
|
+
padding="6px"
|
|
288
|
+
leftIcon={LeftIcon}
|
|
289
|
+
onClick={() => {
|
|
290
|
+
changeWeeks(dummyDate, false)
|
|
291
|
+
}}
|
|
292
|
+
width="130px"
|
|
293
|
+
height="32px"
|
|
294
|
+
background="#FFF"
|
|
295
|
+
/>
|
|
296
|
+
<KButton
|
|
297
|
+
text="Next Week"
|
|
298
|
+
padding="6px"
|
|
299
|
+
rightIcon={RightIcon}
|
|
300
|
+
onClick={() => {
|
|
301
|
+
changeWeeks(dummyDate, true)
|
|
302
|
+
}}
|
|
303
|
+
width="130px"
|
|
304
|
+
height="32px"
|
|
305
|
+
background="#FFF"
|
|
306
|
+
/>
|
|
307
|
+
</div>
|
|
308
|
+
</div>
|
|
309
|
+
</div>
|
|
310
|
+
</React.Fragment>
|
|
311
|
+
)
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export default KSelectDate
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default} from './KSelectDate';
|
|
@@ -12,7 +12,8 @@ export interface KSpanProps {
|
|
|
12
12
|
hoverText?: string
|
|
13
13
|
hoverTextColor?: string
|
|
14
14
|
hoverStyle?: CSSProperties,
|
|
15
|
-
textDecoration?: string
|
|
15
|
+
textDecoration?: string,
|
|
16
|
+
ellipsis?: boolean
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
const KSpan: React.FC<KSpanProps> = (props) => {
|
|
@@ -27,9 +28,12 @@ const KSpan: React.FC<KSpanProps> = (props) => {
|
|
|
27
28
|
const hoverTextColor = props.hoverTextColor || "#737373"
|
|
28
29
|
const hoverStyle = props.hoverStyle || {}
|
|
29
30
|
const textDecoration = props.textDecoration || "none"
|
|
31
|
+
const ellipsis = props.ellipsis || false
|
|
32
|
+
|
|
33
|
+
const ellipsisStyle = {overflow:"hidden", textOverflow:"ellipsis", whiteSpace:"nowrap"}
|
|
30
34
|
|
|
31
35
|
const renderBaseSpan = () => {
|
|
32
|
-
const baseSpanStyle = { fontSize, color, fontWeight, lineHeight, fontStyle, letterSpacing, textDecoration }
|
|
36
|
+
const baseSpanStyle = { fontSize, color, fontWeight, lineHeight, fontStyle, letterSpacing, textDecoration, ...(ellipsis && ellipsisStyle) }
|
|
33
37
|
return (
|
|
34
38
|
<span
|
|
35
39
|
className={"k-span"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Meta, StoryFn } from "@storybook/react"
|
|
2
|
+
import KTooltip, { KTooltipProps } from "./KTooltip"
|
|
3
|
+
import KSpan from "../KSpan"
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: "ReactComponentLibrary/KTooltip",
|
|
7
|
+
component: KTooltip,
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: "centered"
|
|
10
|
+
}
|
|
11
|
+
} as Meta<typeof KTooltip>
|
|
12
|
+
|
|
13
|
+
const Template: StoryFn<KTooltipProps> = (args) => (
|
|
14
|
+
<KTooltip {...args}>
|
|
15
|
+
<div className="bg-red-200 w-[200px] aspect-square rounded-full flex items-center justify-center">
|
|
16
|
+
Tooltip Children
|
|
17
|
+
</div>{" "}
|
|
18
|
+
{/* Here we place the children directly */}
|
|
19
|
+
</KTooltip>
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
export const KTooltipPrimary = Template.bind({})
|
|
23
|
+
KTooltipPrimary.args = {
|
|
24
|
+
content: (
|
|
25
|
+
<div className="bg-red-100 flex justify-center items-center">
|
|
26
|
+
<div className="bg-green-300 font-extrabold ">BURADA</div>
|
|
27
|
+
</div>
|
|
28
|
+
),
|
|
29
|
+
position: "top",
|
|
30
|
+
zIndex: 1000,
|
|
31
|
+
arrowColor: "green",
|
|
32
|
+
showArrow: true,
|
|
33
|
+
padding: "10px",
|
|
34
|
+
border: "1px solid red"
|
|
35
|
+
//boxShadow: "3px 3px 10px #000",
|
|
36
|
+
//borderRadius: "100px",
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const KTooltipSecondary = Template.bind({})
|
|
40
|
+
KTooltipPrimary.args = {
|
|
41
|
+
content: (
|
|
42
|
+
<div className="flex flex-col gap-2 justify-center items-start px-4 py-2">
|
|
43
|
+
<div
|
|
44
|
+
className="flex flex-row gap-1 whitespace-nowrap items-center"
|
|
45
|
+
style={{
|
|
46
|
+
opacity: true ? "1" : "0.3"
|
|
47
|
+
}}
|
|
48
|
+
>
|
|
49
|
+
<span className="bg-[#21A494] px-0.5 py-1 flex items-center justify-center w-9 rounded-[3px]">
|
|
50
|
+
<KSpan text="16-Bit" fontSize={10} lineHeight="10px" fontWeight={600} color="#FFF" />
|
|
51
|
+
</span>
|
|
52
|
+
{true ? (
|
|
53
|
+
<KSpan text="Added" fontSize={12} lineHeight="12px" color="#1F1F1F" fontWeight={600} />
|
|
54
|
+
) : (
|
|
55
|
+
<KSpan text="No File" fontSize={12} lineHeight="12px" color="#1F1F1F" fontWeight={600}></KSpan>
|
|
56
|
+
)}
|
|
57
|
+
</div>
|
|
58
|
+
<div
|
|
59
|
+
className="flex flex-row gap-1 whitespace-nowrap items-center"
|
|
60
|
+
style={{
|
|
61
|
+
opacity: true ? "1" : "0.3"
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
<span className="bg-[#BBCC13] px-0.5 py-1 flex items-center justify-center w-9 rounded-[3px]">
|
|
65
|
+
<KSpan text="24-Bit" fontSize={10} lineHeight="10px" fontWeight={600} color="#FFF" />
|
|
66
|
+
</span>
|
|
67
|
+
{true ? (
|
|
68
|
+
<KSpan text="Added" fontSize={12} lineHeight="12px" color="#1F1F1F" fontWeight={600} />
|
|
69
|
+
) : (
|
|
70
|
+
<KSpan text="No File" fontSize={12} lineHeight="12px" color="#1F1F1F" fontWeight={600}></KSpan>
|
|
71
|
+
)}
|
|
72
|
+
</div>
|
|
73
|
+
<div
|
|
74
|
+
className="flex flex-row gap-1 whitespace-nowrap items-center"
|
|
75
|
+
style={{
|
|
76
|
+
opacity: true ? "1" : "0.3"
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<span className="bg-[#30272C] px-0.5 py-1 flex items-center justify-center w-9 rounded-[3px]">
|
|
80
|
+
<KSpan text="Dolby" fontSize={10} lineHeight="10px" fontWeight={600} color="#FFF" />
|
|
81
|
+
</span>
|
|
82
|
+
{true ? (
|
|
83
|
+
<KSpan text="Added" fontSize={12} lineHeight="12px" color="#1F1F1F" fontWeight={600}></KSpan>
|
|
84
|
+
) : (
|
|
85
|
+
<KSpan text="No File" fontSize={12} lineHeight="12px" color="#1F1F1F" fontWeight={600}></KSpan>
|
|
86
|
+
)}
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
),
|
|
90
|
+
arrowColor: "red",
|
|
91
|
+
padding: "0px"
|
|
92
|
+
//boxShadow: "3px 3px 10px #000",
|
|
93
|
+
//borderRadius: "100px",
|
|
94
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React, { useState } from "react"
|
|
2
|
+
import "../../main.css"
|
|
3
|
+
|
|
4
|
+
export interface KTooltipProps {
|
|
5
|
+
children: React.ReactNode
|
|
6
|
+
content: React.ReactNode
|
|
7
|
+
position?: string
|
|
8
|
+
backgroundColor?: string
|
|
9
|
+
width?: string
|
|
10
|
+
height?: string
|
|
11
|
+
zIndex?: number
|
|
12
|
+
border?: string
|
|
13
|
+
borderRadius?: string
|
|
14
|
+
boxShadow?: string
|
|
15
|
+
showArrow?: boolean
|
|
16
|
+
arrowColor?: string
|
|
17
|
+
padding?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const KTooltip: React.FC<KTooltipProps> = (props) => {
|
|
21
|
+
const [isVisible, setIsVisible] = useState(false)
|
|
22
|
+
|
|
23
|
+
const showTooltip = () => setIsVisible(true)
|
|
24
|
+
const hideTooltip = () => setIsVisible(false)
|
|
25
|
+
|
|
26
|
+
const position = props.position || "top"
|
|
27
|
+
const width = props.width || "auto"
|
|
28
|
+
const height = props.height || "auto"
|
|
29
|
+
const background = props.backgroundColor || "#FFF"
|
|
30
|
+
const zIndex = props.zIndex || 999999
|
|
31
|
+
const boxShadow = props.boxShadow || "none"
|
|
32
|
+
const border = props.border || "1px solid #E5E7EB"
|
|
33
|
+
const borderRadius = props.borderRadius || "5px"
|
|
34
|
+
const arrowColor =
|
|
35
|
+
props.arrowColor !== undefined
|
|
36
|
+
? props.arrowColor
|
|
37
|
+
: props.backgroundColor !== undefined
|
|
38
|
+
? props.backgroundColor
|
|
39
|
+
: "#F7F7F7"
|
|
40
|
+
const showArrow = props.showArrow || false
|
|
41
|
+
const padding = props.padding || "5px"
|
|
42
|
+
|
|
43
|
+
const baseStyles = { width, height, background, zIndex, border, borderRadius, boxShadow }
|
|
44
|
+
return (
|
|
45
|
+
<div className="relative box-border" onMouseEnter={showTooltip} onMouseLeave={hideTooltip}>
|
|
46
|
+
{props.children}
|
|
47
|
+
|
|
48
|
+
<div
|
|
49
|
+
className={`k-tooltip-${position} absolute ${isVisible ? "k-tooltip-enter" : "k-tooltip-exit"}`}
|
|
50
|
+
style={baseStyles}
|
|
51
|
+
>
|
|
52
|
+
<div
|
|
53
|
+
style={{
|
|
54
|
+
padding: padding,
|
|
55
|
+
borderRadius,
|
|
56
|
+
background
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
{props.content}
|
|
60
|
+
</div>
|
|
61
|
+
{showArrow && <div className={`arrow-${position}`} style={{ backgroundColor: arrowColor, zIndex: -200 }}></div>}
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default KTooltip
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default} from './KTooltip'
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,9 @@ import KLogo from "./components/KLogo"
|
|
|
5
5
|
import KInput from "./components/KInput"
|
|
6
6
|
import KDropdown from "./components/KDropdown"
|
|
7
7
|
import KSlider from "./components/KSlider"
|
|
8
|
+
import KSelectDate from "./components/KSelectDate"
|
|
9
|
+
import KTooltip from "./components/KTooltip"
|
|
8
10
|
|
|
9
11
|
export {
|
|
10
|
-
KButton, KSpan, KLogo, KTitleSpan, KInput, KDropdown, KSlider
|
|
12
|
+
KButton, KSpan, KLogo, KTitleSpan, KInput, KDropdown, KSlider, KSelectDate, KTooltip
|
|
11
13
|
}
|
package/src/main.css
CHANGED
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
font-family: Inter;
|
|
47
47
|
font-style: normal;
|
|
48
48
|
font-weight: 400;
|
|
49
|
-
line-height: 20px;
|
|
49
|
+
line-height: 20px;
|
|
50
|
+
/* 142.857% */
|
|
50
51
|
letter-spacing: -0.084px;
|
|
51
52
|
}
|
|
52
53
|
|
|
@@ -100,11 +101,100 @@
|
|
|
100
101
|
.k-slider-input::-webkit-slider-thumb {
|
|
101
102
|
-webkit-appearance: none;
|
|
102
103
|
cursor: pointer;
|
|
103
|
-
margin-top: -4px;
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
margin-top: -4px;
|
|
105
|
+
/* Align the thumb vertically with the track */
|
|
106
|
+
width: 16px;
|
|
107
|
+
/* Width of the thumb */
|
|
108
|
+
height: 16px;
|
|
109
|
+
/* Height of the thumb */
|
|
106
110
|
border-radius: 50px;
|
|
107
111
|
background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28' fill='none'%3E%3Cg filter='url(%23filter0_di_252_33228)'%3E%3Crect x='6' y='6' width='16' height='16' rx='8' fill='white'/%3E%3Crect x='6.5' y='6.5' width='15' height='15' rx='7.5' stroke='white'/%3E%3C/g%3E%3Cg filter='url(%23filter1_d_252_33228)'%3E%3Cpath d='M11 14C11 12.3431 12.3431 11 14 11C15.6569 11 17 12.3431 17 14C17 15.6569 15.6569 17 14 17C12.3431 17 11 15.6569 11 14Z' fill='%23B5B5B5'/%3E%3C/g%3E%3Cdefs%3E%3Cfilter id='filter0_di_252_33228' x='0' y='0' width='28' height='28' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='BackgroundImageFix'/%3E%3CfeColorMatrix in='SourceAlpha' type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='hardAlpha'/%3E%3CfeOffset/%3E%3CfeGaussianBlur stdDeviation='3'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.105882 0 0 0 0 0.109804 0 0 0 0 0.113725 0 0 0 0.06 0'/%3E%3CfeBlend mode='normal' in2='BackgroundImageFix' result='effect1_dropShadow_252_33228'/%3E%3CfeBlend mode='normal' in='SourceGraphic' in2='effect1_dropShadow_252_33228' result='shape'/%3E%3CfeColorMatrix in='SourceAlpha' type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='hardAlpha'/%3E%3CfeOffset dy='-3'/%3E%3CfeGaussianBlur stdDeviation='1.5'/%3E%3CfeComposite in2='hardAlpha' operator='arithmetic' k2='-1' k3='1'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.894118 0 0 0 0 0.898039 0 0 0 0 0.905882 0 0 0 1 0'/%3E%3CfeBlend mode='normal' in2='shape' result='effect2_innerShadow_252_33228'/%3E%3C/filter%3E%3Cfilter id='filter1_d_252_33228' x='7' y='9' width='14' height='14' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='BackgroundImageFix'/%3E%3CfeColorMatrix in='SourceAlpha' type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='hardAlpha'/%3E%3CfeOffset dy='2'/%3E%3CfeGaussianBlur stdDeviation='2'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.105882 0 0 0 0 0.109804 0 0 0 0 0.113725 0 0 0 0.04 0'/%3E%3CfeBlend mode='normal' in2='BackgroundImageFix' result='effect1_dropShadow_252_33228'/%3E%3CfeBlend mode='normal' in='SourceGraphic' in2='effect1_dropShadow_252_33228' result='shape'/%3E%3C/filter%3E%3C/defs%3E%3C/svg%3E") center / cover;
|
|
108
112
|
background-size: auto;
|
|
109
113
|
background-position: center;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.k-tooltip-top {
|
|
117
|
+
bottom: 100%;
|
|
118
|
+
left: 50%;
|
|
119
|
+
transform: translateX(-50%);
|
|
120
|
+
margin-bottom: 10px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.k-tooltip-right {
|
|
124
|
+
top: 50%;
|
|
125
|
+
left: 100%;
|
|
126
|
+
transform: translateY(-50%);
|
|
127
|
+
margin-left: 10px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.k-tooltip-bottom {
|
|
131
|
+
top: 100%;
|
|
132
|
+
left: 50%;
|
|
133
|
+
transform: translateX(-50%);
|
|
134
|
+
margin-top: 10px;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.k-tooltip-left {
|
|
138
|
+
top: 50%;
|
|
139
|
+
right: 100%;
|
|
140
|
+
transform: translateY(-50%);
|
|
141
|
+
margin-right: 10px;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.k-tooltip-enter {
|
|
145
|
+
opacity: 1;
|
|
146
|
+
visibility: visible;
|
|
147
|
+
pointer-events: auto;
|
|
148
|
+
transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.k-tooltip-exit {
|
|
152
|
+
opacity: 0;
|
|
153
|
+
pointer-events: none;
|
|
154
|
+
visibility: hidden;
|
|
155
|
+
transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.arrow-left {
|
|
159
|
+
position: absolute;
|
|
160
|
+
width: 10px;
|
|
161
|
+
height: 10px;
|
|
162
|
+
top: 50%;
|
|
163
|
+
left: calc(100% - 5px);
|
|
164
|
+
transform-origin: center;
|
|
165
|
+
transform: translateY(-50%) rotateZ(45deg);
|
|
166
|
+
z-index: -100;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.arrow-right {
|
|
170
|
+
position: absolute;
|
|
171
|
+
width: 10px;
|
|
172
|
+
height: 10px;
|
|
173
|
+
top: 50%;
|
|
174
|
+
right: calc(100% - 5px);
|
|
175
|
+
transform-origin: center;
|
|
176
|
+
transform: translateY(-50%) rotateZ(45deg);
|
|
177
|
+
z-index: -100;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.arrow-top {
|
|
181
|
+
position: absolute;
|
|
182
|
+
width: 10px;
|
|
183
|
+
height: 10px;
|
|
184
|
+
top: calc(100% - 5px);
|
|
185
|
+
left: 50%;
|
|
186
|
+
transform-origin: center;
|
|
187
|
+
transform: translateX(-50%) rotateZ(45deg);
|
|
188
|
+
z-index: -100;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.arrow-bottom {
|
|
192
|
+
position: absolute;
|
|
193
|
+
width: 10px;
|
|
194
|
+
height: 10px;
|
|
195
|
+
bottom: calc(100% - 5px);
|
|
196
|
+
left: 50%;
|
|
197
|
+
transform-origin: center;
|
|
198
|
+
transform: translateX(-50%) rotateZ(45deg);
|
|
199
|
+
z-index: -100;
|
|
110
200
|
}
|