kahuna-base-react-components 0.1.8

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 (57) hide show
  1. package/.storybook/main.ts +19 -0
  2. package/.storybook/preview.ts +15 -0
  3. package/README.md +23 -0
  4. package/babel.config.js +7 -0
  5. package/dist/components/KButton/KButton.d.ts +19 -0
  6. package/dist/components/KButton/index.d.ts +1 -0
  7. package/dist/components/KDropdown/KDropdown.d.ts +30 -0
  8. package/dist/components/KDropdown/index.d.ts +1 -0
  9. package/dist/components/KInput/KInput.d.ts +21 -0
  10. package/dist/components/KInput/index.d.ts +1 -0
  11. package/dist/components/KLogo/KLogo.d.ts +11 -0
  12. package/dist/components/KLogo/index.d.ts +1 -0
  13. package/dist/components/KSlider/KSlider.d.ts +16 -0
  14. package/dist/components/KSlider/index.d.ts +1 -0
  15. package/dist/components/KSpan/KSpan.d.ts +13 -0
  16. package/dist/components/KSpan/index.d.ts +1 -0
  17. package/dist/components/KTitleSpan/KTitleSpan.d.ts +13 -0
  18. package/dist/components/KTitleSpan/index.d.ts +1 -0
  19. package/dist/index.d.ts +8 -0
  20. package/dist/index.esm.js +10 -0
  21. package/dist/index.esm.js.map +1 -0
  22. package/dist/index.js +10 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/types.d.ts +112 -0
  25. package/package.json +68 -0
  26. package/postcss.config.js +6 -0
  27. package/rollup.config.js +48 -0
  28. package/src/assets/chevron-left.svg +7 -0
  29. package/src/assets/chevron-right.svg +7 -0
  30. package/src/assets/logo.svg +14 -0
  31. package/src/assets/slider-dots.svg +7 -0
  32. package/src/assets/tracks.svg +5 -0
  33. package/src/components/KButton/KButton.stories.tsx +78 -0
  34. package/src/components/KButton/KButton.tsx +44 -0
  35. package/src/components/KButton/index.ts +1 -0
  36. package/src/components/KDropdown/KDropdown.stories.tsx +62 -0
  37. package/src/components/KDropdown/KDropdown.tsx +93 -0
  38. package/src/components/KDropdown/index.ts +1 -0
  39. package/src/components/KInput/KInput.stories.tsx +54 -0
  40. package/src/components/KInput/KInput.tsx +67 -0
  41. package/src/components/KInput/index.ts +1 -0
  42. package/src/components/KLogo/KLogo.stories.tsx +36 -0
  43. package/src/components/KLogo/KLogo.tsx +31 -0
  44. package/src/components/KLogo/index.ts +1 -0
  45. package/src/components/KSlider/KSlider.stories.tsx +18 -0
  46. package/src/components/KSlider/KSlider.tsx +40 -0
  47. package/src/components/KSlider/index.ts +1 -0
  48. package/src/components/KSpan/KSpan.stories.tsx +23 -0
  49. package/src/components/KSpan/KSpan.tsx +29 -0
  50. package/src/components/KSpan/index.ts +1 -0
  51. package/src/components/KTitleSpan/KTitleSpan.stories.tsx +23 -0
  52. package/src/components/KTitleSpan/KTitleSpan.tsx +29 -0
  53. package/src/components/KTitleSpan/index.ts +1 -0
  54. package/src/index.ts +11 -0
  55. package/src/main.css +93 -0
  56. package/tailwind.config.js +9 -0
  57. package/tsconfig.json +25 -0
@@ -0,0 +1,112 @@
1
+ import React from 'react';
2
+ import { MultiValue } from 'react-select';
3
+
4
+ interface KButtonProps {
5
+ onClick: () => void;
6
+ text?: string;
7
+ icon?: string;
8
+ rightIcon?: string;
9
+ leftIcon?: string;
10
+ background?: string;
11
+ borderRadius?: number;
12
+ width?: string;
13
+ height?: string;
14
+ disabled?: boolean;
15
+ textColor?: string;
16
+ padding?: string;
17
+ shadowDisabled?: boolean;
18
+ }
19
+ declare const KButton: React.FC<KButtonProps>;
20
+
21
+ interface KSpanProps {
22
+ text: string;
23
+ fontSize?: number;
24
+ color?: string;
25
+ fontWeight?: number;
26
+ lineHeight?: string;
27
+ fontStyle?: string;
28
+ letterSpacing?: string;
29
+ }
30
+ declare const KSpan: React.FC<KSpanProps>;
31
+
32
+ interface KTitleSpanProps {
33
+ text: string;
34
+ fontSize?: number;
35
+ color?: string;
36
+ fontWeight?: number;
37
+ lineHeight?: string;
38
+ fontStyle?: string;
39
+ letterSpacing?: string;
40
+ }
41
+ declare const KTitleSpan: React.FC<KTitleSpanProps>;
42
+
43
+ interface KLogoProps {
44
+ width?: number;
45
+ height?: number;
46
+ borderRadius?: number;
47
+ primaryText?: string;
48
+ secondaryText?: string;
49
+ }
50
+ declare const KLogo: React.FC<KLogoProps>;
51
+
52
+ interface KInputProps {
53
+ value: string;
54
+ onChange: (value: string) => void;
55
+ width?: number;
56
+ height?: number;
57
+ leftIcon?: string;
58
+ rightIcon?: string;
59
+ background?: string;
60
+ activeBackground?: string;
61
+ borderRadius?: number;
62
+ placeholder?: string;
63
+ shadowDisabled?: boolean;
64
+ type?: string;
65
+ leftIconClick?: () => void;
66
+ rightIconClick?: () => void;
67
+ accentColor?: string;
68
+ }
69
+ declare const KInput: React.FC<KInputProps>;
70
+
71
+ interface KSelectOption {
72
+ label: string;
73
+ value: number;
74
+ type?: string;
75
+ label2?: string;
76
+ value2?: string;
77
+ }
78
+ interface KDropdownProps {
79
+ defaultValue?: KSelectOption | MultiValue<KSelectOption>;
80
+ selected?: KSelectOption | MultiValue<KSelectOption>;
81
+ onSelect: (selected: KSelectOption | MultiValue<KSelectOption>) => void;
82
+ options: KSelectOption[];
83
+ width?: number;
84
+ height?: number;
85
+ leftIcon?: string;
86
+ rightIcon?: string;
87
+ background?: string;
88
+ activeBackground?: string;
89
+ borderRadius?: number;
90
+ placeholder?: string;
91
+ isMulti?: boolean;
92
+ label?: string;
93
+ textColor?: string;
94
+ shadowDisabled?: boolean;
95
+ }
96
+ declare const KDropdown: React.FC<KDropdownProps>;
97
+
98
+ interface SliderOption {
99
+ label: string;
100
+ value: number;
101
+ }
102
+ interface KSliderProps {
103
+ options: SliderOption[];
104
+ onChange: (option: SliderOption) => void;
105
+ value?: number;
106
+ disabled?: boolean;
107
+ width?: string;
108
+ height?: string;
109
+ }
110
+ declare const KSlider: React.FC<KSliderProps>;
111
+
112
+ export { KButton, KDropdown, KInput, KLogo, KSlider, KSpan, KTitleSpan };
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "kahuna-base-react-components",
3
+ "version": "0.1.8",
4
+ "description": "Kahuna Base React Components",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.esm.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "test": "echo \"Error: no test specified\" && exit 1",
10
+ "build": "rollup -c --bundleConfigAsCjs && npm run remove-stories",
11
+ "remove-stories": "find dist/ -name '*.stories.*' -type f -delete",
12
+ "storybook": "storybook dev -p 6006",
13
+ "build-storybook": "storybook build"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/Kahuna-Music/kahuna-base-react-components.git"
18
+ },
19
+ "author": "barin",
20
+ "license": "ISC",
21
+ "bugs": {
22
+ "url": "https://github.com/Kahuna-Music/kahuna-base-react-components/issues"
23
+ },
24
+ "homepage": "https://github.com/Kahuna-Music/kahuna-base-react-components#readme",
25
+ "peerDependencies": {
26
+ "react": "^18.2.0",
27
+ "react-dom": "^18.2.0"
28
+ },
29
+ "devDependencies": {
30
+ "@babel/core": "^7.24.0",
31
+ "@babel/preset-env": "^7.24.0",
32
+ "@babel/preset-react": "^7.23.3",
33
+ "@babel/preset-typescript": "^7.23.3",
34
+ "@rollup/plugin-commonjs": "^25.0.7",
35
+ "@rollup/plugin-image": "^3.0.3",
36
+ "@rollup/plugin-node-resolve": "^15.2.3",
37
+ "@rollup/plugin-terser": "^0.4.4",
38
+ "@rollup/plugin-typescript": "^11.1.6",
39
+ "@storybook/addon-essentials": "^7.6.17",
40
+ "@storybook/addon-interactions": "^7.6.17",
41
+ "@storybook/addon-links": "^7.6.17",
42
+ "@storybook/addon-onboarding": "^1.0.11",
43
+ "@storybook/blocks": "^7.6.17",
44
+ "@storybook/react": "^7.6.17",
45
+ "@storybook/react-vite": "^7.6.17",
46
+ "@storybook/test": "^7.6.17",
47
+ "@testing-library/react": "^14.2.1",
48
+ "@types/jest": "^29.5.12",
49
+ "@types/react": "^18.2.64",
50
+ "autoprefixer": "^10.4.18",
51
+ "babel-jest": "^29.7.0",
52
+ "identity-obj-proxy": "^3.0.0",
53
+ "jest": "^29.7.0",
54
+ "jest-environment-jsdom": "^29.7.0",
55
+ "postcss": "^8.4.35",
56
+ "rollup": "^4.12.1",
57
+ "rollup-plugin-dts": "^6.1.0",
58
+ "rollup-plugin-peer-deps-external": "^2.2.4",
59
+ "rollup-plugin-postcss": "^4.0.2",
60
+ "storybook": "^7.6.17",
61
+ "tailwindcss": "^3.4.1",
62
+ "tslib": "^2.6.2",
63
+ "typescript": "^5.4.2"
64
+ },
65
+ "dependencies": {
66
+ "react-select": "^5.8.0"
67
+ }
68
+ }
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ }
6
+ }
@@ -0,0 +1,48 @@
1
+ // rollup.config.js
2
+ import resolve from "@rollup/plugin-node-resolve";
3
+ import commonjs from "@rollup/plugin-commonjs";
4
+ import typescript from "@rollup/plugin-typescript";
5
+ import dts from "rollup-plugin-dts";
6
+ import terser from "@rollup/plugin-terser";
7
+ import peerDepsExternal from "rollup-plugin-peer-deps-external";
8
+ import postcss from "rollup-plugin-postcss";
9
+ import image from '@rollup/plugin-image';
10
+
11
+
12
+ const packageJson = require("./package.json");
13
+
14
+ export default [
15
+ {
16
+ input: "src/index.ts",
17
+ output: [
18
+ {
19
+ file: packageJson.main,
20
+ format: "cjs",
21
+ sourcemap: true,
22
+ },
23
+ {
24
+ file: packageJson.module,
25
+ format: "esm",
26
+ sourcemap: true,
27
+ },
28
+ ],
29
+ plugins: [
30
+ peerDepsExternal(),
31
+ resolve(),
32
+ commonjs(),
33
+ image(),
34
+ typescript({tsconfig: "./tsconfig.json"}),
35
+ terser(),
36
+ postcss({
37
+ extensions: [".css"]
38
+ })
39
+ ],
40
+ external: ["react", "react-dom"],
41
+ },
42
+ {
43
+ input: "src/index.ts",
44
+ output: [{file: "dist/types.d.ts", format: "es"}],
45
+ plugins: [dts.default()],
46
+ external: [/\.css$/],
47
+ },
48
+ ];
@@ -0,0 +1,7 @@
1
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="chevron-left">
3
+ <path id="Vector" fill-rule="evenodd" clip-rule="evenodd"
4
+ d="M10.8072 5.80811L11.6911 6.69199L8.383 10L11.6911 13.3081L10.8072 14.192L6.61523 10L10.8072 5.80811Z"
5
+ fill="#111111"/>
6
+ </g>
7
+ </svg>
@@ -0,0 +1,7 @@
1
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="chevron-right">
3
+ <path id="Vector" fill-rule="evenodd" clip-rule="evenodd"
4
+ d="M9.19282 5.80762L8.30894 6.6915L11.617 9.99956L8.30894 13.3076L9.19282 14.1915L13.3848 9.99956L9.19282 5.80762Z"
5
+ fill="#111111"/>
6
+ </g>
7
+ </svg>
@@ -0,0 +1,14 @@
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>
14
+ </svg>
@@ -0,0 +1,7 @@
1
+ <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="dots, grid, slide">
3
+ <path id="Vector" fill-rule="evenodd" clip-rule="evenodd"
4
+ d="M4 5C4.55228 5 5 4.55228 5 4C5 3.44772 4.55228 3 4 3C3.44772 3 3 3.44772 3 4C3 4.55228 3.44772 5 4 5ZM4 9C4.55228 9 5 8.55229 5 8C5 7.44772 4.55228 7 4 7C3.44772 7 3 7.44772 3 8C3 8.55229 3.44772 9 4 9ZM9 8C9 8.55229 8.55229 9 8 9C7.44772 9 7 8.55229 7 8C7 7.44772 7.44772 7 8 7C8.55229 7 9 7.44772 9 8ZM8 5C8.55229 5 9 4.55228 9 4C9 3.44772 8.55229 3 8 3C7.44772 3 7 3.44772 7 4C7 4.55228 7.44772 5 8 5Z"
5
+ fill="#111111"/>
6
+ </g>
7
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="tracks">
3
+ <path id="Vector" fill-rule="evenodd" clip-rule="evenodd" d="M4.58398 9.99984C4.58398 8.15889 6.07637 6.6665 7.91732 6.6665C8.22791 6.6665 8.52857 6.70898 8.81383 6.78845C8.00161 7.61543 7.50065 8.74913 7.50065 9.99984C7.50065 11.2505 8.00161 12.3842 8.81383 13.2112C8.52857 13.2907 8.22791 13.3332 7.91732 13.3332C6.07637 13.3332 4.58398 11.8408 4.58398 9.99984ZM10.0007 14.0834C9.3756 14.4029 8.6675 14.5832 7.91732 14.5832C5.38601 14.5832 3.33398 12.5311 3.33398 9.99984C3.33398 7.46853 5.38601 5.4165 7.91732 5.4165C8.6675 5.4165 9.3756 5.59674 10.0007 5.91626C10.6257 5.59674 11.3338 5.4165 12.084 5.4165C14.6153 5.4165 16.6673 7.46853 16.6673 9.99984C16.6673 12.5311 14.6153 14.5832 12.084 14.5832C11.3338 14.5832 10.6257 14.4029 10.0007 14.0834ZM11.1875 6.78845C11.4727 6.70898 11.7734 6.6665 12.084 6.6665C13.9249 6.6665 15.4173 8.15889 15.4173 9.99984C15.4173 11.8408 13.9249 13.3332 12.084 13.3332C11.7734 13.3332 11.4727 13.2907 11.1875 13.2112C11.9997 12.3842 12.5007 11.2505 12.5007 9.99984C12.5007 8.74913 11.9997 7.61543 11.1875 6.78845ZM10.0007 7.3976C10.7627 8.00848 11.2507 8.94718 11.2507 9.99984C11.2507 11.0525 10.7627 11.9912 10.0007 12.6021C9.2386 11.9912 8.75065 11.0525 8.75065 9.99984C8.75065 8.94718 9.2386 8.00848 10.0007 7.3976Z" fill="#111111"/>
4
+ </g>
5
+ </svg>
@@ -0,0 +1,78 @@
1
+ import {Meta, StoryFn} from "@storybook/react";
2
+ import KButton from "./KButton";
3
+ // @ts-ignore
4
+ import ChevronRightIcon from "../../assets/chevron-right.svg"
5
+ // @ts-ignore
6
+ import ChevronLeftIcon from "../../assets/chevron-left.svg"
7
+ // @ts-ignore
8
+ import TracksIcon from "../../assets/tracks.svg"
9
+
10
+ export default {
11
+ title: "ReactComponentLibrary/KButton",
12
+ component: KButton,
13
+ } as Meta<typeof KButton>;
14
+
15
+ const Template: StoryFn<typeof KButton> = (args) => <KButton {...args} />;
16
+
17
+ export const KButtonText = Template.bind({});
18
+ KButtonText.args = {
19
+ onClick: () => {
20
+ alert("clicked")
21
+ },
22
+ text: "Hello World",
23
+ background: "#F2FE67",
24
+ borderRadius: 10,
25
+ width: "160px",
26
+ height: "44px"
27
+ };
28
+
29
+ export const KButtonIcon = Template.bind({});
30
+ KButtonIcon.args = {
31
+ onClick: () => {
32
+ alert("clicked")
33
+ },
34
+ icon: TracksIcon,
35
+ width: "50px"
36
+ };
37
+
38
+ export const KButtonLeftIconText = Template.bind({});
39
+ KButtonLeftIconText.args = {
40
+ onClick: () => {
41
+ alert("clicked")
42
+ },
43
+ leftIcon: ChevronLeftIcon,
44
+ text: "Hello World",
45
+ width: "160px"
46
+ };
47
+
48
+ export const KButtonRightIconText = Template.bind({});
49
+ KButtonRightIconText.args = {
50
+ onClick: () => {
51
+ alert("clicked")
52
+ },
53
+ rightIcon: ChevronRightIcon,
54
+ text: "Hello World",
55
+ width: "160px"
56
+ };
57
+
58
+ export const KButtonLeftRightIconText = Template.bind({});
59
+ KButtonLeftRightIconText.args = {
60
+ onClick: () => {
61
+ alert("clicked")
62
+ },
63
+ leftIcon: ChevronLeftIcon,
64
+ rightIcon: ChevronRightIcon,
65
+ text: "Hello World",
66
+ width: "160px"
67
+ };
68
+
69
+ export const KButtonLeftRightMiddleIcon = Template.bind({});
70
+ KButtonLeftRightMiddleIcon.args = {
71
+ onClick: () => {
72
+ alert("clicked")
73
+ },
74
+ leftIcon: ChevronLeftIcon,
75
+ rightIcon: ChevronRightIcon,
76
+ icon: TracksIcon,
77
+ width: "160px"
78
+ };
@@ -0,0 +1,44 @@
1
+ import React from "react";
2
+ import "../../main.css"
3
+ import KSpan from "../KSpan";
4
+
5
+ export interface KButtonProps {
6
+ onClick: () => void
7
+ text?: string
8
+ icon?: string
9
+ rightIcon?: string
10
+ leftIcon?: string
11
+ background?: string
12
+ borderRadius?: number
13
+ width?: string
14
+ height?: string
15
+ disabled?: boolean
16
+ textColor?: string
17
+ padding?: string
18
+ shadowDisabled?: boolean
19
+ }
20
+
21
+ const KButton: React.FC<KButtonProps> = (props) => {
22
+ const disabled = props.disabled || false
23
+ const background = disabled ? "#F0F0F0" : props.background || "#F2FE67"
24
+ const borderRadius = props.borderRadius || 10
25
+ const width = props.width || "100%"
26
+ const height = props.height || "44px"
27
+ const textColor = disabled ? "#D6D6D6" : props.textColor || "#111"
28
+ const padding = props.padding || "12px 16px"
29
+ const boxShadow = props.shadowDisabled ? "" : "0 0 0 1px rgba(17, 17, 17, 0.04), 0 1px 1px 0 rgba(17, 17, 17, 0.04)"
30
+
31
+ return (
32
+ <button className={"k-button"} disabled={disabled} onClick={props.onClick}
33
+ style={{background, borderRadius, width, height, padding, boxShadow}}>
34
+ <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"}/>}
39
+ </div>
40
+ </button>
41
+ );
42
+ };
43
+
44
+ export default KButton;
@@ -0,0 +1 @@
1
+ export {default} from './KButton';
@@ -0,0 +1,62 @@
1
+ import {Meta, StoryFn} from "@storybook/react";
2
+ import KDropdown, {KSelectOption} from "./KDropdown";
3
+ // @ts-ignore
4
+ import TracksIcon from "../../assets/tracks.svg";
5
+ import {MultiValue} from "react-select";
6
+
7
+ export default {
8
+ title: "ReactComponentLibrary/KDropdown",
9
+ component: KDropdown,
10
+ parameters: {
11
+ layout: 'centered',
12
+ },
13
+ } as Meta<typeof KDropdown>;
14
+
15
+ const Template: StoryFn<typeof KDropdown> = (args) => <KDropdown {...args} />;
16
+
17
+ export const KDropdownSingle = Template.bind({});
18
+ KDropdownSingle.args = {
19
+ onSelect: (value: KSelectOption | MultiValue<KSelectOption>) => {
20
+
21
+ },
22
+ placeholder: "Placeholder...",
23
+ options: [{label: "Label 1", value: 1}, {label: "Label 2", value: 2}, {label: "Label 3", value: 3}]
24
+ };
25
+
26
+ export const KDropdownMulti = Template.bind({});
27
+ KDropdownMulti.args = {
28
+ onSelect: (value: KSelectOption | MultiValue<KSelectOption>) => {
29
+
30
+ },
31
+ placeholder: "Multi...",
32
+ options: [{label: "Label 1", value: 1}, {label: "Label 2", value: 2}, {label: "Label 3", value: 3}],
33
+ isMulti: true
34
+ };
35
+
36
+ export const KDropdownLeftIcon = Template.bind({});
37
+ KDropdownLeftIcon.args = {
38
+ onSelect: (value: KSelectOption | MultiValue<KSelectOption>) => {
39
+
40
+ },
41
+ placeholder: "Placeholder...",
42
+ leftIcon: TracksIcon,
43
+ };
44
+
45
+ export const KDropdownRightIcon = Template.bind({});
46
+ KDropdownRightIcon.args = {
47
+ onSelect: (value: KSelectOption | MultiValue<KSelectOption>) => {
48
+
49
+ },
50
+ placeholder: "Placeholder...",
51
+ rightIcon: TracksIcon,
52
+ };
53
+
54
+ export const KDropdownLeftRightIcon = Template.bind({});
55
+ KDropdownLeftRightIcon.args = {
56
+ onSelect: (value: KSelectOption | MultiValue<KSelectOption>) => {
57
+
58
+ },
59
+ placeholder: "Placeholder...",
60
+ leftIcon: TracksIcon,
61
+ rightIcon: TracksIcon,
62
+ };
@@ -0,0 +1,93 @@
1
+ import React, {useEffect, useState} from "react";
2
+ import "../../main.css"
3
+ import Select, {MultiValue} from 'react-select'
4
+
5
+
6
+ export interface KSelectOption {
7
+ label: string
8
+ value: number
9
+ type?: string
10
+ label2?: string
11
+ value2?: string
12
+ }
13
+
14
+ export interface KDropdownProps {
15
+ defaultValue?: KSelectOption | MultiValue<KSelectOption>
16
+ selected?: KSelectOption | MultiValue<KSelectOption>
17
+ onSelect: (selected: KSelectOption | MultiValue<KSelectOption>) => void
18
+ options: KSelectOption[]
19
+ width?: number
20
+ height?: number
21
+ leftIcon?: string
22
+ rightIcon?: string
23
+ background?: string
24
+ activeBackground?: string
25
+ borderRadius?: number
26
+ placeholder?: string
27
+ isMulti?: boolean
28
+ label?: string
29
+ textColor?: string
30
+ shadowDisabled?: boolean
31
+ }
32
+
33
+ const KDropdown: React.FC<KDropdownProps> = (props) => {
34
+ const [background, setBackground] = useState("#F5F5F5")
35
+
36
+ useEffect(() => {
37
+ const emptyBackground = props.background || "#F5F5F5"
38
+ const activeBackground = props.activeBackground || "#FFF"
39
+
40
+ const background = props.selected ? activeBackground : emptyBackground
41
+ setBackground(background)
42
+ }, [props.selected])
43
+
44
+ const width = props.width || "100%"
45
+ const height = props.height || "auto"
46
+ const borderRadius = props.borderRadius || 10
47
+ const isMulti = props.isMulti || false
48
+ const textColor = props.textColor || "#111"
49
+ const boxShadow = props.shadowDisabled ? "" : "0 0 0 1px rgba(17, 17, 17, 0.04), 0 1px 1px 0 rgba(17, 17, 17, 0.04)"
50
+
51
+ 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"}/>}
54
+
55
+ <Select
56
+ defaultValue={props.defaultValue}
57
+ isMulti={isMulti}
58
+ name={props.label || ""}
59
+ placeholder={props.placeholder || ""}
60
+ options={props.options}
61
+ className={"k-dropdown"}
62
+ styles={{
63
+ control: (baseStyles, state) => ({
64
+ ...baseStyles,
65
+ background: "transparent !important",
66
+ border: 0,
67
+ boxShadow: "none",
68
+ fontSize: 16,
69
+ cursor: "pointer"
70
+ }),
71
+ singleValue: provided => ({
72
+ ...provided,
73
+ color: textColor
74
+ })
75
+ }}
76
+ components={{
77
+ IndicatorSeparator: () => null,
78
+ DropdownIndicator: () => null
79
+ }}
80
+ onChange={(event) => {
81
+ if (!event) {
82
+ return
83
+ }
84
+ props.onSelect(event)
85
+ }}
86
+ />
87
+
88
+ {props.rightIcon && <img src={props.rightIcon} width={24} className={"mr-2"} alt={"r-icon"}/>}
89
+ </div>
90
+ );
91
+ };
92
+
93
+ export default KDropdown;
@@ -0,0 +1 @@
1
+ export {default} from './KDropdown';
@@ -0,0 +1,54 @@
1
+ import {Meta, StoryFn} from "@storybook/react";
2
+ import KInput from "./KInput";
3
+ // @ts-ignore
4
+ import TracksIcon from "../../assets/tracks.svg";
5
+
6
+ export default {
7
+ title: "ReactComponentLibrary/KInput",
8
+ component: KInput,
9
+ parameters: {
10
+ layout: 'centered',
11
+ },
12
+ } as Meta<typeof KInput>;
13
+
14
+ const Template: StoryFn<typeof KInput> = (args) => <KInput {...args} />;
15
+
16
+ export const KInputPrimary = Template.bind({});
17
+ KInputPrimary.args = {
18
+ onChange: (value: string) => {
19
+
20
+ },
21
+ placeholder: "Placeholder..."
22
+ };
23
+
24
+ export const KInputLeftIcon = Template.bind({});
25
+ KInputLeftIcon.args = {
26
+ onChange: (value: string) => {
27
+
28
+ },
29
+ placeholder: "Placeholder...",
30
+ leftIcon: TracksIcon,
31
+ leftIconClick: () => {alert("left icon clicked")}
32
+ };
33
+
34
+ export const KInputRightIcon = Template.bind({});
35
+ KInputRightIcon.args = {
36
+ onChange: (value: string) => {
37
+
38
+ },
39
+ placeholder: "Placeholder...",
40
+ rightIcon: TracksIcon,
41
+ rightIconClick: () => {alert("right icon clicked")}
42
+ };
43
+
44
+ export const KInputLeftRightIcon = Template.bind({});
45
+ KInputLeftRightIcon.args = {
46
+ onChange: (value: string) => {
47
+
48
+ },
49
+ placeholder: "Placeholder...",
50
+ leftIcon: TracksIcon,
51
+ rightIcon: TracksIcon,
52
+ leftIconClick: () => {alert("left icon clicked")},
53
+ rightIconClick: () => {alert("right icon clicked")}
54
+ };