kahuna-base-react-components 0.2.13 → 0.2.14

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.
Files changed (33) hide show
  1. package/dist/components/KLogo/KLogo.d.ts +1 -2
  2. package/dist/components/KLogo/KLogo.stories.d.ts +7 -2
  3. package/dist/components/KSliderLabel/KSliderLabel.d.ts +19 -0
  4. package/dist/components/KSliderLabel/KSliderLabel.stories.d.ts +4 -0
  5. package/dist/components/KSliderLabel/index.d.ts +1 -0
  6. package/dist/components/KTitleSpan/KTitleSpan.d.ts +1 -0
  7. package/dist/index.d.ts +2 -1
  8. package/dist/index.esm.js +2 -2
  9. package/dist/index.esm.js.map +1 -1
  10. package/dist/index.js +2 -2
  11. package/dist/index.js.map +1 -1
  12. package/dist/types.d.ts +20 -3
  13. package/package.json +1 -1
  14. package/src/assets/fonts/AeonikPro/AeonikPro-Medium.otf +0 -0
  15. package/src/assets/kahuna-text.svg +3 -0
  16. package/src/assets/logo-gray.svg +10 -0
  17. package/src/assets/logo-small-hovered.svg +4 -0
  18. package/src/assets/logo-small.svg +11 -0
  19. package/src/assets/logo.svg +10 -13
  20. package/src/assets/slider-thumb.svg +3 -0
  21. package/src/assets/vector.svg +3 -0
  22. package/src/components/KLogo/KLogo.stories.tsx +35 -16
  23. package/src/components/KLogo/KLogo.tsx +115 -17
  24. package/src/components/KSlider/KSlider.stories.tsx +2 -1
  25. package/src/components/KSliderLabel/KSliderLabel.stories.tsx +57 -0
  26. package/src/components/KSliderLabel/KSliderLabel.tsx +134 -0
  27. package/src/components/KSliderLabel/index.ts +1 -0
  28. package/src/components/KTitleSpan/KTitleSpan.stories.tsx +2 -2
  29. package/src/components/KTitleSpan/KTitleSpan.tsx +7 -3
  30. package/src/index.ts +2 -1
  31. package/src/main.css +45 -3
  32. /package/src/assets/fonts/{AeonikPro-Bold → AeonikPro}/AeonikPro-Bold.otf +0 -0
  33. /package/src/assets/fonts/{AeonikPro-Bold → AeonikPro}/CoType EULA Desktop.pdf +0 -0
package/dist/types.d.ts CHANGED
@@ -45,6 +45,7 @@ interface KTitleSpanProps {
45
45
  lineHeight?: string;
46
46
  fontStyle?: string;
47
47
  letterSpacing?: string;
48
+ bold?: boolean;
48
49
  }
49
50
  declare const KTitleSpan: React.FC<KTitleSpanProps>;
50
51
 
@@ -52,8 +53,7 @@ interface KLogoProps {
52
53
  width?: number;
53
54
  height?: number;
54
55
  borderRadius?: number;
55
- primaryText?: string;
56
- secondaryText?: string;
56
+ logoType: string;
57
57
  }
58
58
  declare const KLogo: React.FC<KLogoProps>;
59
59
 
@@ -158,4 +158,21 @@ interface KTooltipProps {
158
158
  }
159
159
  declare const KTooltip: React.FC<KTooltipProps>;
160
160
 
161
- export { KButton, KDropdown, KInput, KLogo, KSelectDate, KSlider, KSpan, KTitleSpan, KTooltip };
161
+ interface SliderLabelOption {
162
+ label: string;
163
+ value: number;
164
+ }
165
+ interface SliderLabelProps {
166
+ options: SliderLabelOption[];
167
+ onChange: (option: SliderLabelOption) => void;
168
+ value?: number;
169
+ disabled?: boolean;
170
+ width?: string;
171
+ titleText?: string;
172
+ valueText?: string;
173
+ fontSize?: number;
174
+ color?: string;
175
+ }
176
+ declare const KSliderLabel: React.FC<SliderLabelProps>;
177
+
178
+ export { KButton, KDropdown, KInput, KLogo, KSelectDate, KSlider, KSliderLabel, KSpan, KTitleSpan, KTooltip };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kahuna-base-react-components",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
4
4
  "description": "Kahuna Base React Components",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="77" height="16" viewBox="0 0 77 16" fill="none">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M0.707764 15.8631V0H3.28184V8.18083L10.4681 0H13.6018L7.84865 6.66212L14.0272 15.8631H10.9152L5.99013 8.58845L3.28184 11.6708V15.8631H0.707764ZM33.2155 4.12439C35.7679 4.12439 37.8495 5.52913 37.8495 9.40476V9.40579V15.8641H35.4313V9.6096C35.4313 7.41051 34.468 6.23254 32.6776 6.23254C30.7747 6.23254 29.611 7.66031 29.611 9.99423V15.8631H27.1929V0H29.611V5.93782C30.3276 4.9407 31.4241 4.12439 33.2155 4.12439ZM58.5928 4.12439C61.1224 4.12439 63.204 5.52913 63.204 9.40476V15.8631H60.7642V9.60857C60.7642 7.40944 59.8462 6.2315 58.0331 6.2315C56.1085 6.2315 54.9666 7.65928 54.9666 10.0162V15.8631H52.5484V4.26025H54.6527L54.9212 5.77893C55.6377 4.87172 56.7342 4.12439 58.5928 4.12439ZM75.8007 13.733H76.2922V15.8631H75.016C73.4486 15.8631 72.9117 15.1607 72.9117 14.0047C72.1508 15.1827 70.9871 15.9989 69.1286 15.9989C66.6216 15.9989 64.8756 14.7531 64.8756 12.5999C64.8756 10.22 66.5772 8.88321 69.778 8.88321H72.666V8.18083C72.666 6.88896 71.7481 6.09564 70.159 6.09564C68.7269 6.09564 67.7636 6.77502 67.585 7.79514H65.2122C65.458 5.52913 67.3836 4.12439 70.2716 4.12439C73.3165 4.12439 75.0625 5.59812 75.0625 8.33969V12.9856C75.0625 13.5741 75.3082 13.733 75.8007 13.733ZM72.666 11.1043V10.6966H69.6665C68.1663 10.6966 67.3382 11.2631 67.3382 12.4411C67.3382 13.4162 68.1446 14.0956 69.4652 14.0956C71.4796 14.0956 72.6433 12.8947 72.666 11.1043ZM47.8267 4.26128V10.0622V10.0632C47.8267 12.4651 46.6403 13.8699 44.8717 13.8699C43.1029 13.8699 42.2078 12.7139 42.2078 10.4479V4.26128H39.7896V10.7196C39.7896 14.6851 41.8722 16 44.312 16C46.0807 16 47.1328 15.2757 47.8494 14.3914L48.1179 15.8641H50.2449V4.26128H47.8267ZM25.9559 13.733H25.4644C24.9719 13.733 24.7262 13.5751 24.7262 12.9856V8.33969C24.7262 5.59708 22.9802 4.12439 19.9353 4.12439C17.0474 4.12439 15.1217 5.52913 14.876 7.79514H17.2487C17.4273 6.77502 18.3896 6.09564 19.8228 6.09564C21.4118 6.09564 22.3297 6.88896 22.3297 8.18083V8.88321H19.4418C16.241 8.88321 14.5394 10.22 14.5394 12.5999C14.5394 14.7531 16.2854 15.9989 18.7923 15.9989C20.6498 15.9989 21.8145 15.1827 22.5755 14.0047C22.5755 15.1607 23.1123 15.8631 24.6797 15.8631H25.9559V13.733ZM22.3287 10.6966V11.1043C22.307 12.8947 21.1423 14.0956 19.1279 14.0956C17.8073 14.0956 17.0009 13.4152 17.0009 12.4411C17.0009 11.2631 17.829 10.6966 19.3292 10.6966H22.3287Z" fill="#111111"/>
3
+ </svg>
@@ -0,0 +1,10 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="88" height="88" viewBox="0 0 88 88" fill="none">
2
+ <g clip-path="url(#clip0_4001_21322)">
3
+ <path d="M59.0563 20.0887H28.9455C27.4794 20.0887 26.29 21.2798 26.29 22.7442V65.2523C26.29 66.7201 27.4811 67.9112 28.9455 67.9112H59.0563C60.5241 67.9112 61.7118 66.7202 61.7118 65.2558V22.7442C61.7118 21.2764 60.5207 20.0887 59.0563 20.0887ZM49.7458 29.2806V60.3419C49.7458 61.6756 48.7558 62.8031 47.4307 62.975L32.8849 64.8656C31.295 65.0719 29.8857 63.8344 29.8857 62.2325V26.0562C29.8857 24.3564 31.4566 23.0948 33.1169 23.4627L47.6627 26.687C48.8778 26.9552 49.7441 28.0328 49.7441 29.2806H49.7475H49.7458Z" fill="#F3F3F3"/>
4
+ </g>
5
+ <defs>
6
+ <clipPath id="clip0_4001_21322">
7
+ <rect width="88" height="88" fill="white"/>
8
+ </clipPath>
9
+ </defs>
10
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="none">
2
+ <rect x="4" y="4" width="40" height="40" rx="8" fill="#F7F7F7"/>
3
+ <path d="M30.8005 13H17.1995C16.5372 13 16 13.5479 16 14.2216V33.7768C16 34.4521 16.538 35 17.1995 35H30.8005C31.4635 35 32 34.4521 32 33.7784V14.2216C32 13.5464 31.462 13 30.8005 13ZM26.595 17.2286V31.5178C26.595 32.1314 26.1478 32.6501 25.5492 32.7292L18.9789 33.5989C18.2608 33.6938 17.6241 33.1245 17.6241 32.3876V15.7453C17.6241 14.9633 18.3337 14.3829 19.0837 14.5521L25.654 16.0354C26.2029 16.1588 26.5942 16.6545 26.5942 17.2286H26.5958H26.595Z" fill="#111111"/>
4
+ </svg>
@@ -0,0 +1,11 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="none">
2
+ <g clip-path="url(#clip0_4002_7556)">
3
+ <rect width="48" height="48" rx="8" fill="white"/>
4
+ <path d="M31.6506 12H16.3494C15.6044 12 15 12.5978 15 13.3327V34.6656C15 35.4022 15.6053 36 16.3494 36H31.6506C32.3965 36 33 35.4022 33 34.6673V13.3327C33 12.596 32.3947 12 31.6506 12ZM26.9194 16.613V32.2013C26.9194 32.8706 26.4163 33.4365 25.7429 33.5227L18.3513 34.4715C17.5434 34.575 16.8272 33.954 16.8272 33.1501V14.9948C16.8272 14.1417 17.6255 13.5086 18.4692 13.6932L25.8608 15.3114C26.4783 15.4459 26.9185 15.9868 26.9185 16.613H26.9202H26.9194Z" fill="#111111"/>
5
+ </g>
6
+ <defs>
7
+ <clipPath id="clip0_4002_7556">
8
+ <rect width="48" height="48" fill="white"/>
9
+ </clipPath>
10
+ </defs>
11
+ </svg>
@@ -1,14 +1,11 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="88" height="88" viewBox="0 0 88 88" fill="none">
2
- <g clip-path="url(#clip0_186_2030)">
3
- <path d="M0 13.75C0 6.15609 6.15609 0 13.75 0H74.25C81.8439 0 88 6.15609 88 13.75V74.25C88 81.8439 81.8439 88 74.25 88H13.75C6.15609 88 0 81.8439 0 74.25V13.75Z"
4
- fill="#111111"/>
5
- <path fill-rule="evenodd" clip-rule="evenodd"
6
- d="M32.2133 28.2489V23.7515L36.1429 21.4987L40.0726 19.25V23.7515V28.2489V32.7504V37.2519L36.1429 39.5006L32.2139 41.7489L32.2144 41.7492L36.144 44.002L40.0736 46.2507V50.7522V55.2496V59.7511V64.2526L36.144 66.5013L32.2144 68.75V64.2526V59.7511V55.2496V50.7522L28.2847 53.0009L24.3593 55.2496V59.7511V64.2526L20.4296 66.5013L16.5 68.75V64.2526V59.7511V55.2496V50.7522L20.4296 48.4994L24.3593 46.2507L20.4296 44.002L16.5 41.7492V37.2518V32.7503L20.4296 30.5016L24.3593 28.2488V32.7503V37.2518L28.2847 39.5005L32.2133 41.7486V37.2519V32.7504V28.2489ZM55.7856 32.7504V28.2489V23.7515L51.8601 21.4987L47.9305 19.25V23.7515V28.2489V32.7504V37.2519L51.8601 39.5006L55.7856 41.7493L51.8601 44.002L47.9305 46.2507V50.7522V55.2496V59.7511V64.2526L51.8601 66.5013L55.7856 68.75V64.2526V59.7511V56.7515V55.2496V50.7522L59.7153 53.0009L63.6449 55.2496V59.7511V64.2526L67.5745 66.5013L71.5 68.75V64.2526V59.7511V55.2496V50.7522L67.5745 48.4994L63.6449 46.2507L67.5745 44.002L71.5 41.7492V37.2518V32.7503L67.5745 30.5016L63.6449 28.2488V32.7503V37.2518L59.7153 39.5005L55.7856 41.7492V37.2519V32.7504ZM40.3712 40.265C41.2017 38.2759 43.5004 37.3314 45.5055 38.1553C47.5106 38.9792 48.4627 41.2595 47.6322 43.2486C46.8017 45.2377 44.503 46.1823 42.4979 45.3584C40.4928 44.5345 39.5407 42.2541 40.3712 40.265Z"
7
- fill="white"/>
8
- </g>
9
- <defs>
10
- <clipPath id="clip0_186_2030">
11
- <rect width="88" height="88" fill="white"/>
12
- </clipPath>
13
- </defs>
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="72" height="72" viewBox="0 0 72 72" fill="none">
2
+ <g clip-path="url(#clip0_4001_25558)">
3
+ <path d="M68.5322 0H3.46781C1.55259 0 0 1.55259 0 3.46781V68.5322C0 70.4474 1.55259 72 3.46781 72H68.5322C70.4474 72 72 70.4474 72 68.5322V3.46781C72 1.55259 70.4474 0 68.5322 0Z" fill="#111111"/>
4
+ <path d="M48.3185 16.4362H23.6824C22.4829 16.4362 21.5098 17.4107 21.5098 18.6089V53.3882C21.5098 54.5892 22.4843 55.5637 23.6824 55.5637H48.3185C49.5195 55.5637 50.4912 54.5892 50.4912 53.3911V18.6089C50.4912 17.4079 49.5166 16.4362 48.3185 16.4362ZM40.7009 23.9568V49.3706C40.7009 50.4618 39.8909 51.3843 38.8066 51.525L26.9055 53.0718C25.6048 53.2406 24.4516 52.2281 24.4516 50.9175V21.3187C24.4516 19.9279 25.737 18.8957 27.0954 19.1967L38.9965 21.8348C39.9907 22.0542 40.6995 22.9359 40.6995 23.9568H40.7023H40.7009Z" fill="white"/>
5
+ </g>
6
+ <defs>
7
+ <clipPath id="clip0_4001_25558">
8
+ <rect width="72" height="72" fill="white"/>
9
+ </clipPath>
10
+ </defs>
14
11
  </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="2" height="16" viewBox="0 0 2 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="2" height="16" rx="1" fill="#666666"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="2" height="14" viewBox="0 0 2 14" fill="none">
2
+ <path d="M1.29199 1V13" stroke="#B7B7B7" stroke-linecap="round"/>
3
+ </svg>
@@ -11,26 +11,45 @@ export default {
11
11
 
12
12
  const Template: StoryFn<typeof KLogo> = (args) => <KLogo {...args} />;
13
13
 
14
+ export const KLogoText = Template.bind({});
15
+ KLogoText.args = {
16
+ logoType: "hover-text",
17
+ width: 77,
18
+ height: 77
19
+ };
20
+
21
+ export const KLogoHover = Template.bind({});
22
+ KLogoHover.args = {
23
+ logoType: "hover"
24
+ };
25
+
14
26
  export const KLogoPrimary = Template.bind({});
15
27
  KLogoPrimary.args = {
16
- width: 88,
17
- height: 88,
18
- borderRadius: 10,
28
+ logoType: "black"
29
+
19
30
  };
31
+ export const KLogoWhite = Template.bind({});
32
+ KLogoWhite.args = {
33
+ logoType: "white"
20
34
 
21
- export const KLogoPrimaryText = Template.bind({});
22
- KLogoPrimaryText.args = {
23
- width: 88,
24
- height: 88,
25
- borderRadius: 10,
26
- primaryText: "Kahuna"
27
35
  };
36
+ export const KLogoWhiteText = Template.bind({});
37
+ KLogoWhiteText.args = {
38
+ logoType: "white-text"
28
39
 
29
- export const KLogoAllText = Template.bind({});
30
- KLogoAllText.args = {
31
- width: 88,
32
- height: 88,
33
- borderRadius: 10,
34
- primaryText: "Kahuna",
35
- secondaryText: "for artists"
36
40
  };
41
+ export const KLogoGray = Template.bind({});
42
+ KLogoGray.args = {
43
+ logoType: "gray"
44
+
45
+ };
46
+ export const KLogoGrayText = Template.bind({});
47
+ KLogoGrayText.args = {
48
+ logoType: "gray-text"
49
+
50
+ };
51
+ export const KLogoBlackText = Template.bind({});
52
+ KLogoBlackText.args = {
53
+ logoType: "black-text"
54
+
55
+ };
@@ -1,31 +1,129 @@
1
- import React from "react";
1
+ import React, { useState } from "react"
2
2
  import "../../main.css"
3
- // @ts-ignore
3
+ //@ts-ignore
4
4
  import Logo from "../../assets/logo.svg"
5
- import KTitleSpan from "../KTitleSpan";
6
- import KSpan from "../KSpan";
5
+ //@ts-ignore
6
+ import KahunaIcon from "../../assets/kahuna-text.svg"
7
+ //@ts-ignore
8
+ import VectorIcon from "../../assets/vector.svg"
9
+ //@ts-ignore
10
+ import LogoWhite from "../../assets/logo-small.svg"
11
+ //@ts-ignore
12
+ import LogoWhiteHovered from "../../assets/logo-small-hovered.svg"
13
+ //@ts-ignore
14
+ import LogoGray from "../../assets/logo-gray.svg"
15
+ import KTitleSpan from "../KTitleSpan"
16
+ import KSpan from "../KSpan"
7
17
 
8
18
  export interface KLogoProps {
9
19
  width?: number
10
20
  height?: number
11
21
  borderRadius?: number
12
- primaryText?: string
13
- secondaryText?: string
22
+ logoType: string
14
23
  }
15
24
 
16
25
  const KLogo: React.FC<KLogoProps> = (props) => {
17
- const width = props.width || 88
18
- const height = props.height || 88
19
- const borderRadius = props.borderRadius || 10
26
+ const [onHover, setOnHover] = useState(false)
27
+ const logoType = props.logoType || "black"
28
+ const width = props.width || "48px"
29
+ const height = props.height || "48px"
30
+ const borderRadius = props.borderRadius || 0
31
+
32
+ const renderText = () => {
33
+ return (
34
+ <div
35
+ className="flex flex-row items-center gap-2.5"
36
+ style={{
37
+ borderRadius: !props.borderRadius ? "" : props.borderRadius
38
+ }}
39
+ >
40
+ <img src={KahunaIcon} alt="kahuna-icon" />
41
+ <img src={VectorIcon} alt="vector" />
42
+ <span>
43
+ <KSpan text="for artists" color="#000" lineHeight="16px" />
44
+ </span>
45
+ </div>
46
+ )
47
+ }
48
+
49
+ const renderLogo = () => {
50
+ return (
51
+ <div
52
+ style={{
53
+ width,
54
+ height,
55
+ borderRadius
56
+ }}
57
+ >
58
+ <img
59
+ src={logoType === "black" ? Logo : logoType === "gray" ? LogoGray : LogoWhite}
60
+ alt="Logo"
61
+ style={{
62
+ width,
63
+ height,
64
+ borderRadius
65
+ }}
66
+ />
67
+ </div>
68
+ )
69
+ }
70
+
71
+ const renderHoveredLogo = () => {
72
+ return (
73
+ <div className="flex flex-row gap-1.5"
74
+ style={{
75
+ borderRadius
76
+ }}
77
+ onMouseEnter={() => setOnHover(true)}
78
+ onMouseLeave={() => setOnHover(false)}
79
+ >
80
+ <img
81
+ style={{
82
+ width,
83
+ height,
84
+ borderRadius
85
+ }}
86
+ src={!onHover ? LogoWhite : LogoWhiteHovered}
87
+ alt="logo-icon"
88
+ />
89
+ {logoType === "hover-text" && <div className="flex items-center"><img src={KahunaIcon} alt="kahuna-icon"/></div>}
90
+ </div>
91
+ )
92
+ }
93
+
94
+ const renderLogoAndText = () => {
95
+ return (
96
+ <div className="flex flex-row gap-1.5">
97
+ <div
98
+ style={{
99
+ width,
100
+ height,
101
+ borderRadius
102
+ }}
103
+ >
104
+ <img
105
+ style={{
106
+ width,
107
+ height,
108
+ borderRadius
109
+ }}
110
+ src={logoType === "black-text" ? Logo : logoType === "gray-text" ? LogoGray : LogoWhite}
111
+ alt="logo-icon"
112
+ />
113
+ </div>
114
+ <img src={KahunaIcon} alt="kahuna-icon" />
115
+ </div>
116
+ )
117
+ }
118
+
20
119
  return (
21
120
  <div className={"flex items-center"}>
22
- <img src={Logo} alt={"kahuna-logo"} style={{borderRadius, width, height}}/>
23
- {props.primaryText && <div className={"ml-2 mr-2"}><KTitleSpan fontSize={20} text={props.primaryText}/></div>}
24
- {props.secondaryText && <div className={"pl-2"} style={{borderLeft: "1px solid #E7E7E7"}}>
25
- <KSpan fontSize={14} text={props.secondaryText}/>
26
- </div>}
121
+ {(logoType === "black" || logoType === "gray" || logoType === "white") && renderLogo()}
122
+ {(logoType === "hover" || logoType === "hover-text") && renderHoveredLogo()}
123
+ {(logoType === "black-text" || logoType === "gray-text" || logoType === "white-text") && renderLogoAndText()}
124
+ {logoType === "text" && renderText()}
27
125
  </div>
28
- );
29
- };
126
+ )
127
+ }
30
128
 
31
- export default KLogo;
129
+ export default KLogo
@@ -14,5 +14,6 @@ KSliderPrimary.args = {
14
14
  onChange: (option: SliderOption) => {
15
15
  // Do Nothing
16
16
  },
17
- width: "200px"
17
+ width: "200px",
18
+ value: 3
18
19
  };
@@ -0,0 +1,57 @@
1
+ import { Meta, StoryFn } from "@storybook/react"
2
+ import KSliderLabel, { SliderLabelOption, SliderLabelProps } from "./KSliderLabel"
3
+ import { useState } from "react"
4
+
5
+ export default {
6
+ title: "ReactComponentLibrary/KSliderLabel",
7
+ component: KSliderLabel,
8
+ parameters: {
9
+ layout: "centered"
10
+ }
11
+ } as Meta<typeof KSliderLabel>
12
+
13
+ const KSliderLabelWrapper: React.FC<SliderLabelProps> = (args) => {
14
+ const [lengthOfContract, setLengthOfContract] = useState<number>(args.value || 1)
15
+ const lengthOfContractOptions: SliderLabelOption[] = [
16
+ { value: 1, label: "6 months" },
17
+ { value: 2, label: "1 year" },
18
+ { value: 3, label: "2 years" },
19
+ { value: 4, label: "3 years" },
20
+ { value: 5, label: "5 years" }
21
+ ]
22
+
23
+ return (
24
+ <div className="w-[616px]">
25
+ <KSliderLabel
26
+ options={lengthOfContractOptions}
27
+ value={lengthOfContract}
28
+ onChange={(sliderOption: SliderLabelOption) => {
29
+ console.log("DENEME")
30
+ setLengthOfContract(sliderOption.value)
31
+ }}
32
+ titleText={"Contract Duration"}
33
+ valueText={lengthOfContractOptions.find((option) => option.value === lengthOfContract)?.label || ""}
34
+ />
35
+ </div>
36
+ )
37
+ }
38
+
39
+ const Template: StoryFn<typeof KSliderLabelWrapper> = (args) => <KSliderLabelWrapper {...args} />
40
+
41
+ export const KSliderLabelPrimary = Template.bind({})
42
+ KSliderLabelPrimary.args = {
43
+ value: 1,
44
+ options: [
45
+ { value: 1, label: "6 months" },
46
+ { value: 2, label: "1 year" },
47
+ { value: 3, label: "2 years" },
48
+ { value: 4, label: "3 years" },
49
+ { value: 5, label: "5 years" }
50
+ ],
51
+ titleText: "Contract Duration",
52
+ onChange: (option: SliderLabelOption) => {
53
+ // Do
54
+ console.log("0")
55
+ },
56
+ fontSize: 10
57
+ }
@@ -0,0 +1,134 @@
1
+ import React, { useEffect, useRef, useState } from "react"
2
+ import "../../main.css"
3
+ //@ts-ignore
4
+ import ThumbIcon from "../../assets/slider-thumb.svg"
5
+ import KSpan from "../KSpan"
6
+
7
+ export interface SliderLabelOption {
8
+ label: string
9
+ value: number
10
+ }
11
+
12
+ export interface SliderLabelProps {
13
+ options: SliderLabelOption[]
14
+ onChange: (option: SliderLabelOption) => void
15
+ value?: number
16
+ disabled?: boolean
17
+ width?: string
18
+ titleText?: string
19
+ valueText?: string,
20
+ fontSize?: number,
21
+ color?: string
22
+ }
23
+
24
+ const KSliderLabel: React.FC<SliderLabelProps> = (props) => {
25
+ const disabled = props.disabled || false
26
+ const width = props.width || "100%"
27
+ const height = "48px"
28
+ const fontSize = props.fontSize || 14
29
+ const color = props.color || "#000"
30
+
31
+ const [titleFits, setTitleFits] = useState<boolean>(false)
32
+ const [valueFits, setValueFits] = useState<boolean>(false)
33
+
34
+ const titleTextRef = useRef<HTMLDivElement>(null)
35
+ const valueTextRef = useRef<HTMLDivElement>(null)
36
+ const progressRef = useRef<HTMLDivElement>(null)
37
+ const mainDivRef = useRef<HTMLDivElement>(null)
38
+
39
+ useEffect(() => {
40
+
41
+ if (!titleTextRef.current || !progressRef.current || !valueTextRef.current || !mainDivRef.current) return
42
+
43
+ const titleWidth = titleTextRef.current.getBoundingClientRect().width
44
+ const progressWidth = progressRef.current.getBoundingClientRect().width
45
+
46
+ setTitleFits(titleWidth < progressWidth - 30)
47
+
48
+ const valueWidth = valueTextRef.current.getBoundingClientRect().width
49
+ const restWidth = mainDivRef.current.getBoundingClientRect().width - progressWidth
50
+
51
+ setValueFits(valueWidth < restWidth)
52
+
53
+ }, [props.value])
54
+
55
+ const calculateSpanWidth = (): string => {
56
+ if (!props.value) return "32px"
57
+ const min = props.options[0].value
58
+ const max = props.options[props.options.length - 1].value
59
+ const spanWidth = `calc((((${props.value! - min}) / (${max - min})) * (100% - 32px)) + 32px)`
60
+ return spanWidth
61
+ }
62
+
63
+ return (
64
+ <div className="flex flex-col gap-1 w-full">
65
+ <div className={"flex flex-row items-center justify-between z-[200]"}>
66
+ <div
67
+ ref={titleTextRef}
68
+ className="relative pl-4"
69
+ style={{
70
+ top: titleFits ? "40px" : "0px"
71
+ }}
72
+ >
73
+ <KSpan
74
+ text={props.titleText || ""}
75
+ color={color}
76
+ fontSize={fontSize}
77
+ lineHeight="20px"
78
+ letterSpacing="-0.084px"
79
+ fontWeight={500}
80
+ />
81
+ </div>
82
+ <div
83
+ ref={valueTextRef}
84
+ className="relative pr-4"
85
+ style={{
86
+ top: valueFits ? "40px" : "0px"
87
+ }}
88
+ >
89
+ <KSpan
90
+ text={props.valueText || ""}
91
+ color={color}
92
+ fontSize={fontSize}
93
+ lineHeight="20px"
94
+ letterSpacing="-0.084px"
95
+ fontWeight={500}
96
+ />
97
+ </div>
98
+ </div>
99
+
100
+ <div ref={mainDivRef} className="inline-block bg-[#f7f7f7] rounded-[8px] relative z-0" style={{ width, height }}>
101
+ <span className="w-full flex justify-between absolute top-0 z-0 items-center" style={{ height }} />
102
+ <span
103
+ ref={progressRef}
104
+ className="block items-center z-50 top-0 relative"
105
+ style={{
106
+ height,
107
+ width: calculateSpanWidth(),
108
+ borderRadius: "8px",
109
+ backgroundColor: "rgba(102, 102, 102, 0.05)"
110
+ }}
111
+ >
112
+ <span className="flex justify-center h-4 w-4 absolute right-2 top-4 z-[1000]">
113
+ <img src={ThumbIcon} alt="thumb" className="" />
114
+ </span>
115
+ </span>
116
+ <input
117
+ disabled={disabled}
118
+ style={{ width, height }}
119
+ className={"k-slider-label-input absolute top-0 !z-50"}
120
+ onChange={(e) => {
121
+ const option = props.options.find((option) => option.value.toString() === e.target.value)
122
+ if (option) return props.onChange(option)
123
+ }}
124
+ value={props.value}
125
+ type="range"
126
+ min={props.options[0].value}
127
+ max={props.options[props.options.length - 1].value}
128
+ />
129
+ </div>
130
+ </div>
131
+ )
132
+ }
133
+
134
+ export default KSliderLabel
@@ -0,0 +1 @@
1
+ export {default} from './KSliderLabel';
@@ -16,8 +16,8 @@ KTitleSpanPrimary.args = {
16
16
  text: "Hello World",
17
17
  fontSize: 48,
18
18
  color: "#111",
19
- fontWeight: 700,
20
19
  lineHeight: "56px",
21
20
  fontStyle: "normal",
22
- letterSpacing: "-0.48px"
21
+ letterSpacing: "-0.48px",
22
+ bold: false
23
23
  };
@@ -8,19 +8,23 @@ export interface KTitleSpanProps {
8
8
  fontWeight?: number
9
9
  lineHeight?: string
10
10
  fontStyle?: string
11
- letterSpacing?: string
11
+ letterSpacing?: string,
12
+ bold?: boolean
12
13
  }
13
14
 
14
15
  const KTitleSpan: React.FC<KTitleSpanProps> = (props) => {
15
16
  const fontSize = props.fontSize || 48
16
17
  const color = props.color || "#111111"
17
- const fontWeight = props.fontWeight || 700
18
18
  const lineHeight = props.lineHeight || "56px"
19
19
  const fontStyle = props.fontStyle || "normal"
20
20
  const letterSpacing = props.letterSpacing || "-0.48px"
21
+ const bold = props.bold || false
22
+ const titleClassName = bold ? "k-title-span-bold" : "k-title-span"
23
+ const fontWeight = props.fontWeight ? props.fontWeight : (bold ? 700 : 500)
21
24
 
25
+
22
26
  return (
23
- <span className={"k-title-span"} style={{fontSize, color, fontWeight, lineHeight, fontStyle, letterSpacing}}>
27
+ <span className={`${titleClassName} flex items-center`} style={{fontSize, color, fontWeight, lineHeight, fontStyle, letterSpacing}}>
24
28
  {props.text}
25
29
  </span>
26
30
  );
package/src/index.ts CHANGED
@@ -7,7 +7,8 @@ import KDropdown from "./components/KDropdown"
7
7
  import KSlider from "./components/KSlider"
8
8
  import KSelectDate from "./components/KSelectDate"
9
9
  import KTooltip from "./components/KTooltip"
10
+ import KSliderLabel from "./components/KSliderLabel"
10
11
 
11
12
  export {
12
- KButton, KSpan, KLogo, KTitleSpan, KInput, KDropdown, KSlider, KSelectDate, KTooltip
13
+ KButton, KSpan, KLogo, KTitleSpan, KInput, KDropdown, KSlider, KSelectDate, KTooltip, KSliderLabel
13
14
  }
package/src/main.css CHANGED
@@ -10,14 +10,21 @@
10
10
 
11
11
  @font-face {
12
12
  font-family: "Aeonik Pro";
13
- src: local("Aeonik Pro"), url("./assets/fonts/AeonikPro-Bold/AeonikPro-Bold.otf") format("truetype");
13
+ src: local("Aeonik Pro"), url("./assets/fonts/AeonikPro/AeonikPro-Medium.otf") format("truetype");
14
+ }
15
+ @font-face {
16
+ font-family: "Aeonik Pro Bold";
17
+ src: local("Aeonik Pro Bold"), url("./assets/fonts/AeonikPro/AeonikPro-Bold.otf") format("truetype");
14
18
  }
15
-
16
19
 
17
20
  .k-title-span {
18
21
  font-feature-settings: 'ss11' on, 'cv09' on, 'liga' off, 'calt' off;
19
22
  font-family: "Aeonik Pro";
20
23
  }
24
+ .k-title-span-bold {
25
+ font-feature-settings: 'ss11' on, 'cv09' on, 'liga' off, 'calt' off;
26
+ font-family: "Aeonik Pro Bold";
27
+ }
21
28
 
22
29
  .k-span {
23
30
  font-feature-settings: 'ss11' on, 'cv09' on, 'liga' off, 'calt' off;
@@ -197,4 +204,39 @@
197
204
  transform-origin: center;
198
205
  transform: translateX(-50%) rotateZ(45deg);
199
206
  z-index: -100;
200
- }
207
+ }
208
+ .k-slider-label-input {
209
+ -webkit-appearance: none;
210
+ appearance: none;
211
+ width: 100%;
212
+ outline: none;
213
+ border-radius: 16px;
214
+ background: transparent;
215
+ overflow: visible;
216
+ }
217
+ .k-slider-label-input:active {
218
+ cursor: default !important;
219
+ }
220
+ .k-slider-label-input::-webkit-slider-runnable-track {
221
+ border-radius: 20px;
222
+ height: 48px;
223
+ z-index: 0;
224
+ }
225
+
226
+ .k-slider-label-input::-webkit-slider-thumb {
227
+ -webkit-appearance: none;
228
+ margin-top: -4px;
229
+ /* Align the thumb vertically with the track */
230
+ /* Width of the thumb */
231
+ background: url('data:image/svg+xml,%3Csvg%20width%3D%222%22%20height%3D%2216%22%20viewBox%3D%220%200%202%2016%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Crect%20width%3D%222%22%20height%3D%2216%22%20rx%3D%221%22%20fill%3D%22%23666666%22%2F%3E%3C%2Fsvg%3E') no-repeat;
232
+ /* Height of the thumb */
233
+ background-size: contain;
234
+ margin-top: 16px ;
235
+ background-position: center;
236
+ position: relative;
237
+ opacity: 0;
238
+ cursor: grab;
239
+ }
240
+ .k-slider-label-input::-webkit-slider-thumb:active {
241
+ cursor: grabbing;
242
+ }