l-min-components 0.2.0

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 (137) hide show
  1. package/package.json +38 -0
  2. package/src/assets/Icon.svg +3 -0
  3. package/src/assets/friendrequest.png +0 -0
  4. package/src/assets/images/User-avatar.svg.png +0 -0
  5. package/src/assets/images/Vector19.png +0 -0
  6. package/src/assets/images/android.png +0 -0
  7. package/src/assets/images/avatar.png +0 -0
  8. package/src/assets/images/banner.png +0 -0
  9. package/src/assets/images/dashboardImage.png +0 -0
  10. package/src/assets/images/figma.png +0 -0
  11. package/src/assets/images/linkedin.png +0 -0
  12. package/src/assets/images/logo.png +0 -0
  13. package/src/assets/images/onboarding.png +0 -0
  14. package/src/assets/images/sign_up.png +0 -0
  15. package/src/assets/react.svg +1 -0
  16. package/src/assets/svg/Frame 4534413.svg +7 -0
  17. package/src/assets/svg/Property 44.svg +5 -0
  18. package/src/assets/svg/Property 55.svg +10 -0
  19. package/src/assets/svg/add.jsx +14 -0
  20. package/src/assets/svg/arrow-down.jsx +14 -0
  21. package/src/assets/svg/arrow-right.svg +4 -0
  22. package/src/assets/svg/book.jsx +34 -0
  23. package/src/assets/svg/calendar.jsx +64 -0
  24. package/src/assets/svg/close.jsx +15 -0
  25. package/src/assets/svg/coolicon.svg +3 -0
  26. package/src/assets/svg/download.jsx +32 -0
  27. package/src/assets/svg/eos-icons_machine-learning-outlined.svg +6 -0
  28. package/src/assets/svg/learning.jsx +21 -0
  29. package/src/assets/svg/logout.svg +5 -0
  30. package/src/assets/svg/material-symbols_spatial-audio-outline-rounded.svg +3 -0
  31. package/src/assets/svg/message.jsx +39 -0
  32. package/src/assets/svg/notification.jsx +32 -0
  33. package/src/assets/svg/people.jsx +17 -0
  34. package/src/assets/svg/search.jsx +24 -0
  35. package/src/assets/svg/setting.jsx +14 -0
  36. package/src/components/ApiProgress/ApiConsumption/assets/Vector.jsx +8 -0
  37. package/src/components/ApiProgress/ApiConsumption/index.jsx +60 -0
  38. package/src/components/ApiProgress/ApiConsumption/styles/index.jsx +61 -0
  39. package/src/components/ApiProgress/ApiProgressBar/index.jsx +99 -0
  40. package/src/components/ApiProgress/ApiProgressBar/styles/index.jsx +122 -0
  41. package/src/components/ApiProgress/toggle/index.jsx +34 -0
  42. package/src/components/ApiProgress/toggle/styles/index.jsx +72 -0
  43. package/src/components/AppMainLayout/index.jsx +50 -0
  44. package/src/components/AppMainLayout/index.styled.js +37 -0
  45. package/src/components/Arrow.jsx +24 -0
  46. package/src/components/apiBar/bar.jsx +46 -0
  47. package/src/components/apiBar/index.jsx +55 -0
  48. package/src/components/authentication/assets/images/sign_up.png +0 -0
  49. package/src/components/authentication/index.styled.js +32 -0
  50. package/src/components/authentication/mainLayout.jsx +14 -0
  51. package/src/components/banner/assets/Vector19.png +0 -0
  52. package/src/components/banner/assets/banner.png +0 -0
  53. package/src/components/banner/index.jsx +41 -0
  54. package/src/components/banner/styles/index.jsx +81 -0
  55. package/src/components/bar/styles.css +19 -0
  56. package/src/components/button/index.jsx +329 -0
  57. package/src/components/button/socialBtn.jsx +38 -0
  58. package/src/components/calender/input.jsx +202 -0
  59. package/src/components/calender/styles/input.jsx +127 -0
  60. package/src/components/checkBoxes/checkbox/doc.md +36 -0
  61. package/src/components/checkBoxes/checkbox/index.jsx +53 -0
  62. package/src/components/checkBoxes/checkbox/styles/index.jsx +64 -0
  63. package/src/components/checkBoxes/checkboxGroup/doc.md +55 -0
  64. package/src/components/checkBoxes/checkboxGroup/index.jsx +47 -0
  65. package/src/components/checkBoxes/checkboxGroup/styles/index.jsx +7 -0
  66. package/src/components/course/courseList/index.jsx +32 -0
  67. package/src/components/course/courseList/styles/index.jsx +10 -0
  68. package/src/components/course/coursecard/index.jsx +56 -0
  69. package/src/components/course/coursecard/styles/index.jsx +70 -0
  70. package/src/components/developerAPIdocs/assets/icons.jsx +46 -0
  71. package/src/components/developerAPIdocs/assets/learngual_developer_api_doc.png +0 -0
  72. package/src/components/developerAPIdocs/index.jsx +154 -0
  73. package/src/components/developerAPIdocs/index.styled.js +137 -0
  74. package/src/components/dropdown component/index.jsx +139 -0
  75. package/src/components/dropdown component/styles.js +82 -0
  76. package/src/components/friendRequest/friendRequestCard/doc.md +49 -0
  77. package/src/components/friendRequest/friendRequestCard/index.jsx +82 -0
  78. package/src/components/friendRequest/friendRequestCard/styles/index.jsx +109 -0
  79. package/src/components/friendRequest/friendRequestList/doc.md +61 -0
  80. package/src/components/friendRequest/friendRequestList/index.jsx +58 -0
  81. package/src/components/friendRequest/friendRequestList/styles/index.jsx +34 -0
  82. package/src/components/graph/graphData.jsx +119 -0
  83. package/src/components/graph/index.jsx +111 -0
  84. package/src/components/graph/index.styled.js +261 -0
  85. package/src/components/header/account-dropdown.jsx +86 -0
  86. package/src/components/header/assets/images/User-avatar.svg.png +0 -0
  87. package/src/components/header/assets/images/android.png +0 -0
  88. package/src/components/header/assets/images/avatar.png +0 -0
  89. package/src/components/header/assets/images/figma.png +0 -0
  90. package/src/components/header/assets/images/linkedin.png +0 -0
  91. package/src/components/header/assets/images/logo.png +0 -0
  92. package/src/components/header/assets/images/sign_up.png +0 -0
  93. package/src/components/header/assets/svg/add.jsx +14 -0
  94. package/src/components/header/assets/svg/arrow-down.jsx +14 -0
  95. package/src/components/header/assets/svg/book.jsx +34 -0
  96. package/src/components/header/assets/svg/close.jsx +15 -0
  97. package/src/components/header/assets/svg/coolicon.svg +3 -0
  98. package/src/components/header/assets/svg/message.jsx +39 -0
  99. package/src/components/header/assets/svg/notification.jsx +32 -0
  100. package/src/components/header/assets/svg/people.jsx +17 -0
  101. package/src/components/header/assets/svg/search.jsx +24 -0
  102. package/src/components/header/assets/svg/setting.jsx +14 -0
  103. package/src/components/header/index.jsx +134 -0
  104. package/src/components/header/index.styled.js +486 -0
  105. package/src/components/header/login-header.jsx +71 -0
  106. package/src/components/input/index.jsx +68 -0
  107. package/src/components/input/index.styled.js +45 -0
  108. package/src/components/loader/index.jsx +70 -0
  109. package/src/components/notificationProgressBar/index.jsx +187 -0
  110. package/src/components/notificationProgressBar/styles/index.jsx +122 -0
  111. package/src/components/notificationThreshold/index.jsx +111 -0
  112. package/src/components/notificationThreshold/index.styled.js +129 -0
  113. package/src/components/notificationThreshold/slider.jsx +46 -0
  114. package/src/components/progressBar/index.jsx +32 -0
  115. package/src/components/progressBar/styles/index.jsx +44 -0
  116. package/src/components/radio/doc.md +41 -0
  117. package/src/components/radio/index.jsx +70 -0
  118. package/src/components/radio/styles/index.jsx +56 -0
  119. package/src/components/searchBar/doc.md +68 -0
  120. package/src/components/searchBar/index.jsx +108 -0
  121. package/src/components/searchBar/styles/index.jsx +89 -0
  122. package/src/components/select/doc.md +0 -0
  123. package/src/components/select/index.jsx +122 -0
  124. package/src/components/select/styles/index.jsx +98 -0
  125. package/src/components/sideBar/sideMenu/index.jsx +95 -0
  126. package/src/components/sideBar/sideMenu/styles/index.jsx +135 -0
  127. package/src/components/sideBar/userCard/index.jsx +32 -0
  128. package/src/components/sideBar/userCard/styles/index.jsx +37 -0
  129. package/src/components/sideNav/index.jsx +28 -0
  130. package/src/components/sideNav/styles/index.jsx +159 -0
  131. package/src/components/subscriptionPreview/index.jsx +55 -0
  132. package/src/components/subscriptionPreview/style/style.js +85 -0
  133. package/src/components/successCard/assets/PartyingFace.png +0 -0
  134. package/src/components/successCard/index.jsx +29 -0
  135. package/src/components/successCard/index.styled.js +33 -0
  136. package/src/components/toggle button/index.jsx +43 -0
  137. package/src/components/toggle button/styles.js +26 -0
@@ -0,0 +1,129 @@
1
+ import styled from "styled-components";
2
+
3
+ export const ModalCardContainer = styled.div`
4
+ /* padding: 25px; */
5
+ font-family: "Nunito";
6
+ width: 100%;
7
+ max-width: 720px;
8
+ `;
9
+
10
+ export const CloseModalButton = styled.div`
11
+ background-color: rgba(255, 255, 255, 1);
12
+ width: 40px;
13
+ height: 40px;
14
+ display: flex;
15
+ align-items: center;
16
+ justify-content: center;
17
+ padding: 10px;
18
+ font-family: "Nunito";
19
+ border-radius: 50%;
20
+ margin-bottom: 8px;
21
+ margin-left: auto;
22
+ `;
23
+
24
+ export const CardContainer = styled.div`
25
+ background-color: rgba(255, 255, 255, 1);
26
+ padding: 25px;
27
+ font-family: "Nunito";
28
+ width: 100%;
29
+ max-width: 700px;
30
+ border-radius: 30px;
31
+ `;
32
+
33
+ export const CardHeader = styled.div`
34
+ width: 100%;
35
+ text-align: center;
36
+
37
+ h1 {
38
+ font-size: 22px;
39
+ font-weight: 600;
40
+ color: #000000;
41
+ margin-bottom: 10px;
42
+ }
43
+
44
+ h6 {
45
+ color: #313333;
46
+ font-size: 14px;
47
+ font-weight: 600;
48
+ margin-bottom: 65px;
49
+ }
50
+ `;
51
+
52
+ export const CardBody = styled.div`
53
+ width: 100%;
54
+ display: flex;
55
+ margin: 20px auto 10px;
56
+ justify-content: center;
57
+
58
+ .tooltip-styles {
59
+ color: #4a4d4d;
60
+ background-color: #ffffff;
61
+ opacity: 1;
62
+ border-radius: 8px;
63
+ box-shadow: rgba(0, 0, 0, 0.05) 0px 6px 24px 0px,
64
+ rgba(0, 0, 0, 0.08) 0px 0px 0px 1px;
65
+ }
66
+
67
+ /* .ReactModal__Overlay.ReactModal__Overlay--after-open {
68
+ background-color: rgba(0, 0, 0, 0.45);
69
+ } */
70
+
71
+ .slider-styles {
72
+ .rc-slider-rail,
73
+ .rc-slider-track,
74
+ .rc-slider-step {
75
+ height: 10px;
76
+ }
77
+
78
+ .rc-slider-track {
79
+ background-color: #30d568;
80
+ }
81
+
82
+ .rc-slider-handle {
83
+ width: 15px;
84
+ height: 15px;
85
+ margin-top: -3px;
86
+ background-color: #ffffff;
87
+ border: 2px solid #00c2c2;
88
+ border-radius: 50%;
89
+ }
90
+
91
+ .rc-slider-handle-dragging {
92
+ box-shadow: 0 0 0 5px #00c2c2;
93
+ }
94
+ }
95
+ form {
96
+ width: 80%;
97
+ }
98
+
99
+ .form__contents {
100
+ display: flex;
101
+ width: 100%;
102
+ margin: 30px auto 0;
103
+
104
+ .input__contents {
105
+ width: 90%;
106
+ margin-right: 20px;
107
+ }
108
+ }
109
+
110
+ .btn__footer {
111
+ display: flex;
112
+ margin-top: 30px;
113
+ justify-content: center;
114
+
115
+ button {
116
+ width: 171px;
117
+ margin: 0 20px;
118
+ }
119
+ }
120
+ `;
121
+
122
+ export const ProgressBarContainer = styled.div`
123
+ background-color: rgba(255, 255, 255, 1);
124
+ padding: 25px;
125
+ font-family: "Nunito";
126
+ width: 100%;
127
+ max-width: 700px;
128
+ border-radius: 30px;
129
+ `;
@@ -0,0 +1,46 @@
1
+ import "rc-slider/assets/index.css";
2
+ import Slider from "rc-slider";
3
+ import { Tooltip } from "react-tooltip";
4
+ import "react-tooltip/dist/react-tooltip.css";
5
+
6
+ const SliderWithTooltip = (props) => {
7
+ const { value, setValue, ...restProps } = props;
8
+ return (
9
+ <>
10
+ <Tooltip
11
+ anchorSelect=".rc-slider-handle"
12
+ place="top"
13
+ variant="info"
14
+ content={value}
15
+ id="my-tooltip"
16
+ className="tooltip-styles"
17
+ />
18
+ <Slider
19
+ onChange={(nextValues) => {
20
+ setValue(nextValues[0]);
21
+ console.log("Change:", nextValues);
22
+ }}
23
+ value={value}
24
+ min={0}
25
+ max={124080}
26
+ defaultValue={10}
27
+ step={1}
28
+ className={"slider-styles"}
29
+ range
30
+ tipFormatter={(value) => `${value}%`}
31
+ // count={3}
32
+ // value={10}
33
+ pushable
34
+ // trackStyle={[{ backgroundColor: "#30d568" }]}
35
+ // handleStyle={[
36
+ // { backgroundColor: "#ffffff" },
37
+ // { backgroundColor: "#00c2c2" },
38
+ // ]}
39
+ // railStyle={{ backgroundColor: "#00c2c2" }}
40
+ // handleRender={handleRender}
41
+ />
42
+ </>
43
+ );
44
+ };
45
+
46
+ export default SliderWithTooltip;
@@ -0,0 +1,32 @@
1
+ import React from "react";
2
+ import PropTypes from "prop-types";
3
+ import { ProgressBarContainer, ProgressBarValue } from "./styles";
4
+
5
+ const ProgressBar = ({ value, minValue, maxValue, color, size, bgColor }) => (
6
+ <ProgressBarContainer size={size} bgColor={bgColor}>
7
+ <ProgressBarValue
8
+ value={value}
9
+ minValue={minValue}
10
+ maxValue={maxValue}
11
+ color={color}
12
+ size={size}
13
+ />
14
+ </ProgressBarContainer>
15
+ );
16
+
17
+ ProgressBar.propTypes = {
18
+ value: PropTypes.number.isRequired,
19
+ minValue: PropTypes.number,
20
+ maxValue: PropTypes.number.isRequired,
21
+ color: PropTypes.string,
22
+ size: PropTypes.oneOf(["xs", "sm", "md", "lg", "xl"]),
23
+ bgColor: PropTypes.string,
24
+ };
25
+
26
+ ProgressBar.defaultProps = {
27
+ color: "#007aff",
28
+ size: "md",
29
+ bgColor: "#eee",
30
+ };
31
+
32
+ export default ProgressBar;
@@ -0,0 +1,44 @@
1
+ import styled, { css } from "styled-components";
2
+
3
+ export const sizes = {
4
+ xs: {
5
+ height: "8px",
6
+ borderRadius: "4px",
7
+ },
8
+ sm: {
9
+ height: "12px",
10
+ borderRadius: "6px",
11
+ },
12
+ md: {
13
+ height: "16px",
14
+ borderRadius: "8px",
15
+ },
16
+ lg: {
17
+ height: "24px",
18
+ borderRadius: "12px",
19
+ },
20
+ xl: {
21
+ height: "32px",
22
+ borderRadius: "16px",
23
+ },
24
+ };
25
+
26
+ export const ProgressBarContainer = styled.div`
27
+ ${({ size, bgColor }) => css`
28
+ height: ${sizes[size].height};
29
+ border-radius: ${sizes[size].borderRadius};
30
+ background-color: ${bgColor};
31
+ `}
32
+ width: 100%;
33
+ display: flex;
34
+ align-items: center;
35
+ `;
36
+
37
+ export const ProgressBarValue = styled.div`
38
+ transition: width 0.5s ease;
39
+ ${({ value, minValue, maxValue }) => css`
40
+ width: ${(((value - minValue) / (maxValue - minValue)) * 100).toFixed(2)}%;
41
+ `}border-radius: 20px;
42
+ height: 150%;
43
+ background-color: ${({ color }) => color || "#007aff"};
44
+ `;
@@ -0,0 +1,41 @@
1
+ ## Radio Component
2
+
3
+ A customizable radio input component that allows selection of one option from a group of options.
4
+
5
+ ### Props
6
+
7
+ - `options` (required): An array of objects that represent the options. Each object should have the following keys:
8
+ - `value` (required): The value of the option.
9
+ - `label` (required): The label of the option.
10
+ - `defaultValue`: The default selected value.
11
+ - `onChange`: A function that will be called when the selected value changes. The new value will be passed as the first argument.
12
+ - `color`: The color of the radio button and label.
13
+ - `direction`: The direction of the radio buttons and labels. Can be either "row" or "column".
14
+
15
+ ### Example Usage
16
+
17
+ ```jsx
18
+ import React from 'react';
19
+ import Radio from './Radio';
20
+
21
+ const options = [
22
+ { value: 'option1', label: 'Option 1' },
23
+ { value: 'option2', label: 'Option 2' },
24
+ { value: 'option3', label: 'Option 3' },
25
+ ];
26
+
27
+ function MyComponent() {
28
+ const handleOptionChange = (newValue) => {
29
+ console.log('New value:', newValue);
30
+ };
31
+
32
+ return (
33
+ <Radio
34
+ options={options}
35
+ color="#007bff"
36
+ defaultValue="option1"
37
+ onChange={handleOptionChange}
38
+ direction="row"
39
+ />
40
+ );
41
+ }
@@ -0,0 +1,70 @@
1
+ import PropTypes from "prop-types";
2
+ import React, { useState } from "react";
3
+ import {
4
+ Container,
5
+ RadioControl,
6
+ RadioInput,
7
+ RadioLabel,
8
+ RadioWrapper,
9
+ } from "./styles";
10
+
11
+ const Radio = ({
12
+ options,
13
+ defaultValue,
14
+ onChange,
15
+ direction,
16
+ ...props
17
+ }) => {
18
+ const [value, setValue] = useState(defaultValue);
19
+
20
+ const handleChange = (event) => {
21
+ const newValue = event.target.value;
22
+ setValue(newValue);
23
+ onChange && onChange(newValue);
24
+ };
25
+
26
+ return (
27
+ <Container direction={direction} {...props}>
28
+ {options.map((option) => (
29
+ <RadioWrapper key={option.value}>
30
+ <RadioInput
31
+ id={option.value}
32
+ name="radio-group"
33
+ value={option.value}
34
+ checked={value === option.value}
35
+ onChange={handleChange}
36
+ {...props}
37
+ />
38
+ <RadioControl {...props}></RadioControl>
39
+ <RadioLabel
40
+ htmlFor={option.value}
41
+ checked={value === option.value}
42
+ {...props}
43
+ >
44
+ {option.label}
45
+ </RadioLabel>
46
+ </RadioWrapper>
47
+ ))}
48
+ </Container>
49
+ );
50
+ };
51
+
52
+ Radio.propTypes = {
53
+ options: PropTypes.arrayOf(
54
+ PropTypes.shape({
55
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
56
+ .isRequired,
57
+ label: PropTypes.string.isRequired,
58
+ })
59
+ ).isRequired,
60
+ defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
61
+ onChange: PropTypes.func,
62
+ direction: PropTypes.oneOf(["row", "column"]),
63
+ };
64
+
65
+ Radio.defaultProps = {
66
+ defaultValue: null,
67
+ direction: 'row'
68
+ };
69
+
70
+ export default Radio;
@@ -0,0 +1,56 @@
1
+ import styled from "styled-components";
2
+
3
+ export const Container = styled.div`
4
+ display: flex;
5
+ flex-direction: ${(props) => props.direction};
6
+ gap: 10px;
7
+ `;
8
+
9
+ export const RadioWrapper = styled.label`
10
+ display: flex;
11
+ align-items: center;
12
+ cursor: pointer;
13
+ &:not(:last-child) {
14
+ margin-right: 16px;
15
+ }
16
+ `;
17
+
18
+ export const RadioInput = styled.input.attrs({ type: "radio" })`
19
+ position: absolute;
20
+ opacity: 0;
21
+ cursor: pointer;
22
+ `;
23
+
24
+ export const RadioControl = styled.span`
25
+ position: relative;
26
+ display: inline-block;
27
+ width: 20px;
28
+ height: 20px;
29
+ border-radius: 50%;
30
+ border: 2px solid rgba(159, 159, 159, 0.365);
31
+ transition: all 0.2s ease-in-out;
32
+
33
+ ${RadioInput}:checked + & {
34
+ border-color: ${(props) => props.color || "rgba(159, 159, 159, 0.365)"};
35
+ &::before {
36
+ content: "";
37
+ position: absolute;
38
+ top: 50%;
39
+ left: 50%;
40
+ width: 70%;
41
+ height: 70%;
42
+ border-radius: 50%;
43
+ background-color: ${(props) =>
44
+ props.color || "rgba(159, 159, 159, 0.365)"};
45
+ transform: translate(-50%, -50%);
46
+ }
47
+ }
48
+ `;
49
+
50
+ export const RadioLabel = styled.span`
51
+ margin-left: 8px;
52
+ font-size: 16px;
53
+ font-weight: bold;
54
+ color: ${(props) =>
55
+ props.checked ? props.color : "rgba(159, 159, 159, 0.365)"};
56
+ `;
@@ -0,0 +1,68 @@
1
+ # SearchBar Component
2
+
3
+ A customizable search bar component with suggestions and async results.
4
+
5
+ ## Props
6
+
7
+ - `onSubmit` (function): A function that will be called with the search value when the search bar is submitted.
8
+ - `asyncResult` (function): A function that will be called with the search value when the search input is changed. It should return a promise that resolves with an array of suggestion objects.
9
+ - `onSuggestionClick` (function): A function that will be called with the clicked suggestion.
10
+ - `placeholder` (string): The placeholder text for the search input.
11
+ - `outlineColor` (string): The color of the search bar outline when it is focused.
12
+ - `color` (string): The color of the search input text.
13
+ - `borderRadius` (string): The border radius of the search bar.
14
+ - `warning` (string): The warning message to display when no results are found.
15
+
16
+ | Prop Name | Type | Default | Description |
17
+ | --- | --- | --- | --- |
18
+ | onSubmit | function | | A function that will be called with the search value when the form is submitted |
19
+ | asyncResult | function | | A function that takes a search value as input and returns an array of suggestion items |
20
+ | onSuggestionClick | function | | A function that will be called with the suggestion item when a suggestion is clicked |
21
+ | placeholder | string | "Search" | The text to display in the search input when it is empty |
22
+ | outlineColor | string | "#2d9cdb" | The color of the search input outline when it is focused |
23
+ | color | string | "#333" | The color of the search input text |
24
+ | borderRadius | string | "4px" | The border radius of the search input |
25
+ | warning | string | | The text to display when no results are found |
26
+ | width | number | Sets width and height of the entire container |
27
+
28
+
29
+
30
+ ## Example Usage
31
+
32
+ ```jsx
33
+ import SearchBar from './components/SearchBar';
34
+
35
+ function App() {
36
+ const handleSearch = (searchValue) => {
37
+ console.log(`Searching for: ${searchValue}`);
38
+ };
39
+
40
+ const asyncResult = async (searchValue) => {
41
+ const response = await fetch(`https://google.com/search?query=${searchValue}`);
42
+ const data = await response.json();
43
+ return data.results;
44
+ };
45
+
46
+ const handleSuggestionClick = (suggestion) => {
47
+ console.log(`Clicked suggestion: ${suggestion}`);
48
+ };
49
+
50
+ return (
51
+ <div className="App">
52
+ <SearchBar
53
+ onSubmit={handleSearch}
54
+ asyncResult={asyncResult}
55
+ onSuggestionClick={handleSuggestionClick}
56
+ placeholder="Search for products"
57
+ outlineColor="#febf10"
58
+ heightSize={"20px"}
59
+ widthSize={"120px"}
60
+ color="#333"
61
+ borderRadius="10px"
62
+ warning="No results found"
63
+ />
64
+ </div>
65
+ );
66
+ }
67
+
68
+ export default App;
@@ -0,0 +1,108 @@
1
+ import React, { useState } from "react";
2
+ import PropTypes from "prop-types";
3
+ import {
4
+ SearchBarContainer,
5
+ SearchInput,
6
+ SearchIcon,
7
+ WarningText,
8
+ SuggestionList,
9
+ SuggestionItem,
10
+ Container,
11
+ OptionIcon,
12
+ } from "./styles";
13
+
14
+ const SearchBar = ({
15
+ onSubmit,
16
+ warning,
17
+ asyncResult,
18
+ ...restProps
19
+ }) => {
20
+ const [searchValue, setSearchValue] = useState("");
21
+ const [showSuggestions, setShowSuggestions] = useState(false);
22
+ const [suggestions, setSuggestions] = useState([]);
23
+
24
+ const handleInputChange = async (event) => {
25
+ const value = event.target.value;
26
+ setSearchValue(value);
27
+
28
+ if (asyncResult) {
29
+ const suggestions = await asyncResult(value);
30
+ setSuggestions(suggestions);
31
+ setShowSuggestions(true);
32
+ }
33
+ };
34
+
35
+ const handleEnterPress = (event) => {
36
+ if (event.key === "Enter") {
37
+ event.preventDefault();
38
+ onSubmit(searchValue);
39
+ setShowSuggestions(false);
40
+ }
41
+ };
42
+
43
+ const handleSuggestionClick = (suggestion) => {
44
+ setSearchValue(suggestion);
45
+ setShowSuggestions(false);
46
+ restProps.onSuggestionClick && restProps.onSuggestionClick(suggestion);
47
+ };
48
+
49
+ return (
50
+ <Container>
51
+ <SearchBarContainer
52
+ heightSize={restProps.heightSize}
53
+ widthSize={restProps.widthSize}
54
+ borderRadius={restProps.borderRadius}
55
+ outlineColor={restProps.outlineColor}
56
+ >
57
+ <SearchIcon
58
+ onClick={(e) => {
59
+ e.preventDefault();
60
+ onSubmit(searchValue);
61
+ }}/>
62
+ <SearchInput
63
+ type="search"
64
+ placeholder={restProps.placeholder || "Search"}
65
+ value={searchValue}
66
+ onChange={handleInputChange}
67
+ onKeyPress={handleEnterPress}
68
+ borderRadius={restProps.borderRadius || "12px"}
69
+ heightSize={restProps.heightSize || "50px"}
70
+ widthSize={restProps.widthSize || "100%"}
71
+ />
72
+ {showSuggestions && (
73
+ <SuggestionList>
74
+ {suggestions.map((suggestion) => (
75
+ <SuggestionItem
76
+ key={suggestion}
77
+ onClick={() => handleSuggestionClick(suggestion)}
78
+ >
79
+ {suggestion}
80
+ </SuggestionItem>
81
+ ))}
82
+ </SuggestionList>
83
+ )}
84
+ {warning && <WarningText>{warning}</WarningText>}
85
+ </SearchBarContainer>
86
+ <OptionIcon />
87
+ </Container>
88
+ );
89
+ };
90
+
91
+ SearchBar.propTypes = {
92
+ onSubmit: PropTypes.func,
93
+ warning: PropTypes.string,
94
+ asyncResult: PropTypes.func,
95
+ heightSize:PropTypes.string,
96
+ widthSize: PropTypes.string,
97
+ borderRadius: PropTypes.string,
98
+ outlineColor: PropTypes.string,
99
+ };
100
+
101
+ // SearchBar.defaultProps = {
102
+ // onSubmit: () => {},
103
+ // warning: "",
104
+ // asyncResult: null,
105
+ // size: 95,
106
+ // };
107
+
108
+ export default SearchBar;
@@ -0,0 +1,89 @@
1
+ import styled from "styled-components";
2
+ import { FiSearch } from "react-icons/fi";
3
+ import { RiEqualizerLine } from "react-icons/ri";
4
+
5
+ export const Container = styled.div`
6
+ display: flex;
7
+ // justify-content: center;
8
+ align-items: center;
9
+ gap: 10px;
10
+ `;
11
+
12
+ export const SearchBarContainer = styled.div`
13
+ display: flex;
14
+ align-items: center;
15
+ position: relative;
16
+ height: ${({ heightSize }) => heightSize || "50px"};
17
+ width: ${({ widthSize }) => widthSize || "100%"};
18
+
19
+ border-radius: ${({ borderRadius }) => borderRadius || "12px"};
20
+ background-color: #FFFFFF;
21
+ transition: box-shadow 0.2s ease;
22
+ transition: all 0.3s;
23
+ &:focus-within {
24
+ box-shadow: 0 0 0 1px ${({ outlineColor }) => outlineColor || "#FEBF10"};
25
+ transform: scale(1.01);
26
+ }
27
+ `;
28
+
29
+ export const SearchIcon = styled(FiSearch)`
30
+ position: absolute;
31
+ margin-left: 12px;
32
+ color: #ADB3B3;
33
+ font-size: 20px;
34
+ `;
35
+
36
+ export const SearchInput = styled.input`
37
+ width: 100%;
38
+ height: 100%;
39
+ margin-left: 32px;
40
+ padding: 12px;
41
+ border: none;
42
+ border-radius: ${({ borderRadius }) => borderRadius || "12px"};
43
+ font-size: 16px;
44
+ background-color: #FFFFFF;
45
+ color: #333333;
46
+ outline: none;
47
+ &::placeholder {
48
+ color: #ADB3B3;
49
+ }
50
+ `;
51
+
52
+ export const WarningText = styled.div`
53
+ // position: absolute;
54
+ // right: 10px;
55
+ // font-size: 14px;
56
+ // color: #e74c3c;
57
+
58
+ position: absolute;
59
+ right: 2%;
60
+ bottom: -40%;
61
+ font-size: 12px;
62
+ color: #e74c3c;
63
+ `;
64
+
65
+ export const SuggestionList = styled.ul`
66
+ position: absolute;
67
+ top: 55px;
68
+ left: 0;
69
+ width: 100%;
70
+ padding: 0;
71
+ margin: 0;
72
+ list-style: none;
73
+ border: 1px solid #DFE6E6;
74
+ background-color: #f1f1f1;
75
+ z-index: 10;
76
+ `;
77
+
78
+ export const SuggestionItem = styled.li`
79
+ padding: 8px 12px;
80
+ cursor: pointer;
81
+ &:hover {
82
+ background-color: #dddddd;
83
+ }
84
+ `;
85
+
86
+ export const OptionIcon = styled(RiEqualizerLine)`
87
+ color: ${({ outlineColor }) => outlineColor || "#ADB3B3"};
88
+ font-size: 16px;
89
+ `;
File without changes