kahuna-base-react-components 0.1.10 → 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/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
 
@@ -26,6 +27,8 @@ interface KSpanProps {
26
27
  lineHeight?: string;
27
28
  fontStyle?: string;
28
29
  letterSpacing?: string;
30
+ hoverText?: string;
31
+ hoverTextColor?: string;
29
32
  }
30
33
  declare const KSpan: React.FC<KSpanProps>;
31
34
 
@@ -67,6 +70,7 @@ interface KInputProps {
67
70
  leftIconClick?: () => void;
68
71
  rightIconClick?: () => void;
69
72
  accentColor?: string;
73
+ hoverBackground?: string;
70
74
  }
71
75
  declare const KInput: React.FC<KInputProps>;
72
76
 
@@ -76,6 +80,7 @@ interface KSelectOption {
76
80
  type?: string;
77
81
  label2?: string;
78
82
  value2?: string;
83
+ icon?: string;
79
84
  }
80
85
  interface KDropdownProps {
81
86
  defaultValue?: KSelectOption | MultiValue<KSelectOption>;
@@ -94,6 +99,7 @@ interface KDropdownProps {
94
99
  label?: string;
95
100
  textColor?: string;
96
101
  shadowDisabled?: boolean;
102
+ menuBackground?: string;
97
103
  }
98
104
  declare const KDropdown: React.FC<KDropdownProps>;
99
105
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kahuna-base-react-components",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Kahuna Base React Components",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -65,4 +65,4 @@
65
65
  "dependencies": {
66
66
  "react-select": "^5.8.0"
67
67
  }
68
- }
68
+ }
@@ -0,0 +1,3 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M12.0199 6.01961L6.66638 11.3732L3.97949 8.68627L4.6866 7.97917L6.66638 9.95895L11.3128 5.3125L12.0199 6.01961Z" fill="#111111"/>
3
+ </svg>
@@ -23,7 +23,8 @@ KButtonText.args = {
23
23
  background: "#F2FE67",
24
24
  borderRadius: 10,
25
25
  width: "160px",
26
- height: "44px"
26
+ height: "44px",
27
+ hoverBackground: "#A2FE67"
27
28
  };
28
29
 
29
30
  export const KButtonIcon = Template.bind({});
@@ -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 className={"k-button"} disabled={disabled} onClick={props.onClick}
33
- style={{background, borderRadius, width, height, padding, boxShadow}}>
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
@@ -19,8 +19,9 @@ KDropdownSingle.args = {
19
19
  onSelect: (value: KSelectOption | MultiValue<KSelectOption>) => {
20
20
 
21
21
  },
22
- placeholder: "Placeholder...",
23
- options: [{label: "Label 1", value: 1}, {label: "Label 2", value: 2}, {label: "Label 3", value: 3}]
22
+ width: 250,
23
+ placeholder: "Select single...",
24
+ options: [{label: "Label 1", value: 1, icon: TracksIcon}, {label: "Label 2", value: 2, icon: TracksIcon}, {label: "Label 3", value: 3}]
24
25
  };
25
26
 
26
27
  export const KDropdownMulti = Template.bind({});
@@ -28,8 +29,9 @@ KDropdownMulti.args = {
28
29
  onSelect: (value: KSelectOption | MultiValue<KSelectOption>) => {
29
30
 
30
31
  },
32
+ width: 250,
31
33
  placeholder: "Multi...",
32
- options: [{label: "Label 1", value: 1}, {label: "Label 2", value: 2}, {label: "Label 3", value: 3}],
34
+ options: [{label: "Label 1", value: 1, icon: TracksIcon}, {label: "Label 2", value: 2, icon: TracksIcon}, {label: "Label 3", value: 3}],
33
35
  isMulti: true
34
36
  };
35
37
 
@@ -49,6 +51,8 @@ KDropdownRightIcon.args = {
49
51
  },
50
52
  placeholder: "Placeholder...",
51
53
  rightIcon: TracksIcon,
54
+ width: 250,
55
+ options: [{label: "Label 1", value: 1, icon: TracksIcon}, {label: "Label 2", value: 2, icon: TracksIcon}, {label: "Label 3", value: 3}],
52
56
  };
53
57
 
54
58
  export const KDropdownLeftRightIcon = Template.bind({});
@@ -1,7 +1,8 @@
1
- import React, {useEffect, useState} from "react";
1
+ import React, { useEffect, useState } from "react"
2
2
  import "../../main.css"
3
- import Select, {MultiValue} from 'react-select'
4
-
3
+ import Select, { MultiValue } from "react-select"
4
+ // @ts-ignore
5
+ import CheckIcon from "../../assets/check.svg"
5
6
 
6
7
  export interface KSelectOption {
7
8
  label: string
@@ -9,6 +10,7 @@ export interface KSelectOption {
9
10
  type?: string
10
11
  label2?: string
11
12
  value2?: string
13
+ icon?: string
12
14
  }
13
15
 
14
16
  export interface KDropdownProps {
@@ -28,9 +30,11 @@ export interface KDropdownProps {
28
30
  label?: string
29
31
  textColor?: string
30
32
  shadowDisabled?: boolean
33
+ menuBackground?: string
31
34
  }
32
35
 
33
36
  const KDropdown: React.FC<KDropdownProps> = (props) => {
37
+ const [selectedOption, setSelectedOption] = useState<KSelectOption | MultiValue<KSelectOption>>()
34
38
  const [background, setBackground] = useState("#F5F5F5")
35
39
 
36
40
  useEffect(() => {
@@ -47,10 +51,26 @@ const KDropdown: React.FC<KDropdownProps> = (props) => {
47
51
  const isMulti = props.isMulti || false
48
52
  const textColor = props.textColor || "#111"
49
53
  const boxShadow = props.shadowDisabled ? "" : "0 0 0 1px rgba(17, 17, 17, 0.04), 0 1px 1px 0 rgba(17, 17, 17, 0.04)"
54
+ const menuBackground = props.menuBackground || "#dddddd"
55
+
56
+ const getOptionLabels = (option: KSelectOption) => {
57
+ return (
58
+ <div className="flex justify-between" style={{ width: "100%" }}>
59
+ <div className="flex">
60
+ {option.icon && <img src={option.icon} className="mr-2" width={20} alt={"option-icon"} />}
61
+ <span>{option.label}</span>
62
+ </div>
63
+ {
64
+ //@ts-ignore
65
+ !isMulti && selectedOption?.value === option.value && <img src={CheckIcon} width={24} alt={"check-icon"} />
66
+ }
67
+ </div>
68
+ )
69
+ }
50
70
 
51
71
  return (
52
- <div className={"k-dropdown-container"} style={{background, borderRadius, width, height, boxShadow}}>
53
- {props.leftIcon && <img src={props.leftIcon} width={24} className={"ml-2"} alt={"l-icon"}/>}
72
+ <div className={"k-dropdown-container"} style={{ background, borderRadius, width, height, boxShadow }}>
73
+ {props.leftIcon && <img src={props.leftIcon} width={24} className={"ml-2"} alt={"l-icon"} />}
54
74
 
55
75
  <Select
56
76
  defaultValue={props.defaultValue}
@@ -68,26 +88,47 @@ const KDropdown: React.FC<KDropdownProps> = (props) => {
68
88
  fontSize: 16,
69
89
  cursor: "pointer"
70
90
  }),
71
- singleValue: provided => ({
91
+ menu: (base) => ({
92
+ ...base,
93
+ borderRadius: 10,
94
+ background: menuBackground
95
+ }),
96
+ singleValue: (provided) => ({
72
97
  ...provided,
73
98
  color: textColor
99
+ }),
100
+ option: (provided, state) => ({
101
+ ...provided,
102
+ display: "flex",
103
+ alignItems: "center",
104
+ background: "transparent",
105
+ color: "#111"
74
106
  })
75
107
  }}
76
108
  components={{
77
109
  IndicatorSeparator: () => null,
78
- DropdownIndicator: () => null
110
+ DropdownIndicator: () => null,
111
+ SingleValue: ({ data, ...props }) => (
112
+ <div className="flex ml-3" style={{ position: "absolute" }}>
113
+ {data.icon && <img src={data.icon} className="mr-2" width={20} alt={"data-icon"} />}
114
+ <span>{data.label}</span>
115
+ </div>
116
+ )
79
117
  }}
80
118
  onChange={(event) => {
81
119
  if (!event) {
82
120
  return
83
121
  }
122
+ setSelectedOption(event)
84
123
  props.onSelect(event)
85
124
  }}
125
+ //@ts-ignore
126
+ getOptionLabel={(option: KSelectOption) => getOptionLabels(option)}
86
127
  />
87
128
 
88
- {props.rightIcon && <img src={props.rightIcon} width={24} className={"mr-2"} alt={"r-icon"}/>}
129
+ {props.rightIcon && <img src={props.rightIcon} width={24} className={"mr-2"} alt={"r-icon"} />}
89
130
  </div>
90
- );
91
- };
131
+ )
132
+ }
92
133
 
93
- export default KDropdown;
134
+ export default KDropdown
@@ -18,7 +18,8 @@ KInputPrimary.args = {
18
18
  onChange: (value: string) => {
19
19
 
20
20
  },
21
- placeholder: "Placeholder..."
21
+ placeholder: "Placeholder...",
22
+ hoverBackground: "white"
22
23
  };
23
24
 
24
25
  export const KInputLeftIcon = Template.bind({});
@@ -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 className={"k-input-container"} style={{background, borderRadius, boxShadow}}>
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 src={props.leftIcon} alt={"l-icon"} className={props.leftIconClick && "cursor-pointer"} onClick={() => {
47
- if (props.leftIconClick) props.leftIconClick()
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 src={props.rightIcon} alt={"r-icon"} className={props.rightIconClick && "cursor-pointer"} onClick={() => {
67
- if (props.rightIconClick) props.rightIconClick()
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
@@ -1,17 +1,17 @@
1
- import {Meta, StoryFn} from "@storybook/react";
2
- import KSpan from "./KSpan";
1
+ import { Meta, StoryFn } from "@storybook/react"
2
+ import KSpan from "./KSpan"
3
3
 
4
4
  export default {
5
5
  title: "ReactComponentLibrary/KSpan",
6
6
  component: KSpan,
7
7
  parameters: {
8
- layout: 'centered',
9
- },
10
- } as Meta<typeof KSpan>;
8
+ layout: "centered"
9
+ }
10
+ } as Meta<typeof KSpan>
11
11
 
12
- const Template: StoryFn<typeof KSpan> = (args) => <KSpan {...args} />;
12
+ const Template: StoryFn<typeof KSpan> = (args) => <KSpan {...args} />
13
13
 
14
- export const KSpanPrimary = Template.bind({});
14
+ export const KSpanPrimary = Template.bind({})
15
15
  KSpanPrimary.args = {
16
16
  text: "Hello World",
17
17
  fontSize: 14,
@@ -20,4 +20,17 @@ KSpanPrimary.args = {
20
20
  lineHeight: "20px",
21
21
  fontStyle: "normal",
22
22
  letterSpacing: "-0.084px"
23
- };
23
+ }
24
+
25
+
26
+ export const KSpanHoverText = Template.bind({})
27
+ KSpanHoverText.args = {
28
+ text: "Hello World",
29
+ fontSize: 14,
30
+ fontWeight: 400,
31
+ lineHeight: "20px",
32
+ color: "#111",
33
+ fontStyle: "normal",
34
+ letterSpacing: "-0.084px",
35
+ hoverText: "Hover"
36
+ }
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { useState } from "react"
2
2
  import "../../main.css"
3
3
 
4
4
  export interface KSpanProps {
@@ -9,21 +9,45 @@ export interface KSpanProps {
9
9
  lineHeight?: string
10
10
  fontStyle?: string
11
11
  letterSpacing?: string
12
+ hoverText?: string
13
+ hoverTextColor?: string
12
14
  }
13
15
 
14
16
  const KSpan: React.FC<KSpanProps> = (props) => {
17
+ const [onHover, setOnHover] = useState(false)
18
+
15
19
  const fontSize = props.fontSize || 14
16
20
  const color = props.color || "#737373"
17
21
  const fontWeight = props.fontWeight || 400
18
22
  const lineHeight = props.lineHeight || "20px"
19
23
  const fontStyle = props.fontStyle || "normal"
20
24
  const letterSpacing = props.letterSpacing || "-0.084px"
25
+ const hoverTextColor = props.hoverTextColor || "#737373"
21
26
 
22
- return (
23
- <span className={"k-span"} style={{fontSize, color, fontWeight, lineHeight, fontStyle, letterSpacing}}>
27
+ return props.hoverText ? (
28
+ <div className="grid justify-items-center k-span-hover-div">
29
+ <span className={"k-span"} style={{ fontSize, color, fontWeight, lineHeight, fontStyle, letterSpacing }}>
30
+ {props.text}
31
+ </span>
32
+ <span
33
+ className={"k-span-hover"}
34
+ style={{
35
+ fontSize: fontSize - 2,
36
+ color: hoverTextColor,
37
+ fontWeight,
38
+ lineHeight,
39
+ fontStyle,
40
+ letterSpacing
41
+ }}
42
+ >
43
+ {props.hoverText}
44
+ </span>
45
+ </div>
46
+ ) : (
47
+ <span className={"k-span"} style={{ fontSize, color, fontWeight, lineHeight, fontStyle, letterSpacing }}>
24
48
  {props.text}
25
49
  </span>
26
- );
27
- };
50
+ )
51
+ }
28
52
 
29
- export default KSpan;
53
+ export default KSpan
package/src/main.css CHANGED
@@ -13,6 +13,15 @@
13
13
  font-family: "Inter";
14
14
  }
15
15
 
16
+ .k-span-hover {
17
+ display: none;
18
+ }
19
+
20
+ .k-span-hover-div:hover .k-span-hover {
21
+ display: inline;
22
+ }
23
+
24
+
16
25
  .k-input-container {
17
26
  display: flex;
18
27
  padding: 8px;