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,81 @@
1
+ import styled from "styled-components";
2
+ import { FaArrowRight } from "react-icons/fa";
3
+ import BannerImg from "../assets/Vector19.png"
4
+
5
+ export const BannerWrapper = styled.div`
6
+ position: relative;
7
+ max-width: 232px;
8
+ border-radius: 36px;
9
+ padding: 30px 16px 21px;
10
+ overflow: hidden;
11
+ background-color: #ffffff;
12
+ display: flex;
13
+ flex-direction: column;
14
+ /* justify-content: center; */
15
+ align-items: center;
16
+ text-align: center;
17
+ color: #23ffc8;
18
+ background-image: url(${BannerImg});
19
+ background-repeat: no-repeat;
20
+ background-position: bottom right;
21
+ background-size: contain;
22
+ border: 1px solid #C6CCCC;
23
+
24
+ `;
25
+
26
+ export const BannerTitle = styled.h1`
27
+ font-size: 32px;
28
+ margin: 0;
29
+ font-weight: 800;
30
+ line-height: 42px;
31
+ color: #00C2C2;
32
+
33
+ `;
34
+
35
+ export const BannerSubtitle = styled.p`
36
+ font-size: 18px;
37
+ margin: 29px 0;
38
+ color: #00C2C2;
39
+ font-weight: 600;
40
+ `;
41
+
42
+ export const BannerImage = styled.img`
43
+ width: 100%;
44
+ max-width: 800px;
45
+ margin-bottom: -5px;
46
+ margin-top: 22px;
47
+ opacity: 2;
48
+ display: block;
49
+ opacity: 1.0;
50
+ `;
51
+
52
+ export const BannerCTA = styled.button`
53
+ background-color: #ffbf1e;
54
+ color: #fff;
55
+ border: none;
56
+ padding: 10px 25px;
57
+ border-radius: 10px;
58
+ font-size: 1.2rem;
59
+ display: flex;
60
+ align-items: center;
61
+ transition: all 0.2s ease-in-out;
62
+ margin: auto 0 30px;
63
+ opacity: 1.0;
64
+
65
+ &:hover {
66
+ background-color: #0062cc;
67
+ cursor: pointer;
68
+ }
69
+ `;
70
+
71
+ export const ArrowIcon = styled(FaArrowRight)`
72
+ margin-left: 0.5rem;
73
+ `;
74
+
75
+ export const AbsoluteSVG = styled.svg`
76
+ position: absolute;
77
+ bottom: 0;
78
+ left: 0;
79
+ width: 100%;
80
+ height: auto;
81
+ `;
@@ -0,0 +1,19 @@
1
+ .color-bar {
2
+ height: 50px;
3
+ width: 100%;
4
+ }
5
+
6
+ .color-controls {
7
+ display: flex;
8
+ flex-direction: row;
9
+ justify-content: space-between;
10
+ align-items: center;
11
+ margin-top: 10px;
12
+ }
13
+
14
+ label {
15
+ font-size: 14px;
16
+ font-weight: bold;
17
+ margin-right: 5px;
18
+ }
19
+
@@ -0,0 +1,329 @@
1
+ import { useCallback, CSSProperties } from "react";
2
+ import styled from "styled-components";
3
+ /**
4
+ * @param {{
5
+ * type?: ("primary" | "secondary" | "tertiary"),
6
+ * text: string,
7
+ * disabled: boolean,
8
+ * onClick: Function,
9
+ * styles: CSSProperties,
10
+ * icon: {
11
+ * jsx: typeof HTMLElement,
12
+ * left: boolean,
13
+ * right: boolean,
14
+ * width: number,
15
+ * height: number,
16
+ * stroke: string
17
+ * }
18
+ * }} props - properties of Button Component
19
+ *
20
+ */
21
+ const ButtonComponent = (props) => {
22
+ const handleClick = useCallback(() => {
23
+ props.onClick && props.onClick();
24
+ }, []);
25
+ // console.log(props);
26
+ switch (props.type) {
27
+ case "primary":
28
+ return (
29
+ <Button
30
+ disabled={props.disabled}
31
+ onClick={handleClick}
32
+ style={props.styles}>
33
+ {props.icon?.left && props.icon.jsx ? (
34
+ <props.icon.jsx
35
+ {...{
36
+ width: props.icon.width,
37
+ height: props.icon.height,
38
+ stroke: props.icon.stroke,
39
+ }}
40
+ />
41
+ ) : (
42
+ props.icon?.left && (
43
+ <TestIcon
44
+ {...{
45
+ width: props.icon.width,
46
+ height: props.icon.height,
47
+ stroke: props.icon.stroke,
48
+ }}
49
+ />
50
+ )
51
+ )}
52
+ {props.text ?? "Text"}
53
+ {props.icon?.right && props.icon.jsx ? (
54
+ <props.icon.jsx
55
+ {...{
56
+ width: props.icon.width,
57
+ height: props.icon.height,
58
+ stroke: props.icon.stroke,
59
+ }}
60
+ />
61
+ ) : (
62
+ props.icon?.right && (
63
+ <TestIcon
64
+ {...{
65
+ width: props.icon.width,
66
+ height: props.icon.height,
67
+ stroke: props.icon.stroke,
68
+ }}
69
+ />
70
+ )
71
+ )}
72
+ </Button>
73
+ );
74
+ case "secondary":
75
+ return (
76
+ <SecondaryButton
77
+ disabled={props.disabled}
78
+ onClick={handleClick}
79
+ style={props.styles}>
80
+ {props.icon?.left && props.icon.jsx ? (
81
+ <props.icon.jsx
82
+ {...{
83
+ width: props.icon.width,
84
+ height: props.icon.height,
85
+ stroke: props.icon.stroke,
86
+ }}
87
+ />
88
+ ) : (
89
+ props.icon?.left && (
90
+ <TestIcon
91
+ {...{
92
+ width: props.icon.width,
93
+ height: props.icon.height,
94
+ stroke: props.icon.stroke,
95
+ }}
96
+ />
97
+ )
98
+ )}
99
+ {props.text ?? "Text"}
100
+ {props.icon?.right && props.icon.jsx ? (
101
+ <props.icon.jsx
102
+ {...{
103
+ width: props.icon.width,
104
+ height: props.icon.height,
105
+ stroke: props.icon.stroke,
106
+ }}
107
+ />
108
+ ) : (
109
+ props.icon?.right && (
110
+ <TestIcon
111
+ {...{
112
+ width: props.icon.width,
113
+ height: props.icon.height,
114
+ stroke: props.icon.stroke,
115
+ }}
116
+ />
117
+ )
118
+ )}
119
+ </SecondaryButton>
120
+ );
121
+ case "tertiary":
122
+ return (
123
+ <TertiaryButton
124
+ disabled={props.disabled}
125
+ onClick={handleClick}
126
+ style={props.styles}>
127
+ {props.icon?.left && props.icon.jsx ? (
128
+ <props.icon.jsx
129
+ {...{
130
+ width: props.icon.width,
131
+ height: props.icon.height,
132
+ stroke: props.icon.stroke,
133
+ }}
134
+ />
135
+ ) : (
136
+ props.icon?.left && (
137
+ <TestIcon
138
+ {...{
139
+ width: props.icon.width,
140
+ height: props.icon.height,
141
+ stroke: props.icon.stroke,
142
+ }}
143
+ />
144
+ )
145
+ )}
146
+ {props.text ?? "Text"}
147
+ {props.icon?.right && props.icon.jsx ? (
148
+ <props.icon.jsx
149
+ {...{
150
+ width: props.icon.width,
151
+ height: props.icon.height,
152
+ stroke: props.icon.stroke,
153
+ }}
154
+ />
155
+ ) : (
156
+ props.icon?.right && (
157
+ <TestIcon
158
+ {...{
159
+ width: props.icon.width,
160
+ height: props.icon.height,
161
+ stroke: props.icon.stroke,
162
+ }}
163
+ />
164
+ )
165
+ )}
166
+ </TertiaryButton>
167
+ );
168
+ default:
169
+ return (
170
+ <Button
171
+ disabled={props.disabled}
172
+ onClick={handleClick}
173
+ style={props.styles}>
174
+ {props.icon?.left && props.icon.jsx ? (
175
+ <props.icon.jsx
176
+ {...{
177
+ width: props.icon.width,
178
+ height: props.icon.height,
179
+ stroke: props.icon.stroke,
180
+ }}
181
+ />
182
+ ) : (
183
+ props.icon?.left && (
184
+ <TestIcon
185
+ {...{
186
+ width: props.icon.width,
187
+ height: props.icon.height,
188
+ stroke: props.icon.stroke,
189
+ }}
190
+ />
191
+ )
192
+ )}
193
+ {props.text ?? "Text"}
194
+ {props.icon?.right && props.icon.jsx ? (
195
+ <props.icon.jsx
196
+ {...{
197
+ width: props.icon.width,
198
+ height: props.icon.height,
199
+ stroke: props.icon.stroke,
200
+ }}
201
+ />
202
+ ) : (
203
+ props.icon?.right && (
204
+ <TestIcon
205
+ {...{
206
+ width: props.icon.width,
207
+ height: props.icon.height,
208
+ stroke: props.icon.stroke,
209
+ }}
210
+ />
211
+ )
212
+ )}
213
+ </Button>
214
+ );
215
+ }
216
+ };
217
+ export default ButtonComponent;
218
+
219
+ const Button = styled.button`
220
+ padding: 9px 40px;
221
+ font-size: 16px;
222
+ font-weight: 700;
223
+ border-radius: 12px;
224
+ border: 1px solid transparent;
225
+ background-color: #febf10;
226
+ color: #ffffff;
227
+ transition: 0.5s;
228
+ cursor: pointer;
229
+ display: flex;
230
+ align-items: center;
231
+ justify-content: center;
232
+ gap: 8px;
233
+ &:hover {
234
+ background-color: #e5ad0e;
235
+ border-color: transparent;
236
+ }
237
+ &:disabled {
238
+ background-color: #c6cccc;
239
+ cursor: not-allowed;
240
+ }
241
+ & svg {
242
+ & path {
243
+ stroke: white;
244
+ }
245
+ }
246
+ `;
247
+
248
+ const SecondaryButton = styled(Button)`
249
+ background-color: #ffffff;
250
+ color: #febf10;
251
+ border: 1px solid #febf10;
252
+ &:hover {
253
+ background-color: #ffffff;
254
+ color: #e5ad0e;
255
+ border-color: #e5ad0e;
256
+ & svg {
257
+ & path {
258
+ stroke: #e5ad0e;
259
+ }
260
+ }
261
+ }
262
+ &:disabled {
263
+ background-color: #ffffff;
264
+ color: #c6cccc;
265
+ border-color: #c6cccc;
266
+ & svg {
267
+ & path {
268
+ stroke: #c6cccc;
269
+ }
270
+ }
271
+ }
272
+ & svg {
273
+ & path {
274
+ stroke: #febf10;
275
+ }
276
+ }
277
+ `;
278
+
279
+ const TertiaryButton = styled(Button)`
280
+ &:hover {
281
+ background-color: #ffffff;
282
+ color: #febf10;
283
+ border: 1px solid #febf10;
284
+ & svg {
285
+ & path {
286
+ stroke: #febf10;
287
+ }
288
+ }
289
+ }
290
+ &:disabled {
291
+ border-color: #7c8080;
292
+ color: #7c8080;
293
+ background-color: #ffffff;
294
+ & svg {
295
+ & path {
296
+ stroke: #7c8080;
297
+ }
298
+ }
299
+ }
300
+ `;
301
+
302
+ const TestIcon = ({ stroke, ...props }) => {
303
+ return (
304
+ <Svg xmlns="http://www.w3.org/2000/svg" {...props}>
305
+ <path
306
+ d="M17 20.5H7C4 20.5 2 19 2 15.5V8.5C2 5 4 3.5 7 3.5H17C20 3.5 22 5 22 8.5V15.5C22 19 20 20.5 17 20.5"
307
+ strokeWidth="1.5"
308
+ strokeLinecap="round"
309
+ strokeLinejoin="round"
310
+ />
311
+ <path
312
+ d="M17 9L13.87 11.5C12.84 12.32 11.15 12.32 10.12 11.5L7 9"
313
+ strokeWidth="1.5"
314
+ strokeLinecap="round"
315
+ strokeLinejoin="round"
316
+ />
317
+ </Svg>
318
+ );
319
+ };
320
+
321
+ const Svg = styled.svg.attrs((props) => {
322
+ return {
323
+ width: props.width ?? 24,
324
+ height: props.height ?? 24,
325
+ fill: props.fill ?? "none",
326
+ };
327
+ })`
328
+ transition: 0.5s;
329
+ `;
@@ -0,0 +1,38 @@
1
+ import styled from "styled-components";
2
+
3
+ const SocialBtn = ({ customStyle, onClick = () => {}, children }) => {
4
+ return (
5
+ <BtnBody style={customStyle} onClick={onClick}>
6
+ {children ?? <Fb />}
7
+ </BtnBody>
8
+ );
9
+ };
10
+
11
+ const BtnBody = styled.button`
12
+ background-color: rgba(33, 150, 243, 0.1);
13
+ max-width: 159.5px;
14
+ padding: 11px;
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: center;
18
+ border-radius: 9px;
19
+ border: 0px;
20
+ cursor: pointer;
21
+ `;
22
+
23
+ const Fb = ({ width, height }) => {
24
+ return (
25
+ <svg
26
+ width={width ?? "19"}
27
+ height={height ?? "19"}
28
+ viewBox="0 0 19 19"
29
+ fill="none"
30
+ xmlns="http://www.w3.org/2000/svg">
31
+ <path
32
+ d="M16.6122 12.8524C16.6122 15.5781 14.9872 17.203 12.2615 17.203H11.3704C10.9586 17.203 10.6216 16.866 10.6216 16.4542V12.1335C10.6216 11.9313 10.7863 11.7591 10.9885 11.7591L12.3065 11.7366C12.4113 11.7291 12.5012 11.6542 12.5236 11.5494L12.7857 10.1192C12.8082 9.98437 12.7033 9.85707 12.5611 9.85707L10.9661 9.87953C10.7564 9.87953 10.5917 9.7148 10.5842 9.51261L10.5542 7.67799C10.5542 7.55818 10.6516 7.45335 10.7789 7.45335L12.576 7.42339C12.7033 7.42339 12.8007 7.32605 12.8007 7.19875L12.7707 5.40156C12.7707 5.27426 12.6734 5.17692 12.5461 5.17692L10.5243 5.20688C9.28122 5.22935 8.29278 6.24774 8.31525 7.49078L8.35268 9.55005C8.36017 9.75972 8.19544 9.92446 7.98576 9.93195L7.08717 9.94692C6.95987 9.94692 6.86253 10.0443 6.86253 10.1716L6.88499 11.5943C6.88499 11.7216 6.98233 11.819 7.10963 11.819L8.00823 11.804C8.2179 11.804 8.38262 11.9687 8.39011 12.1709L8.4575 16.4392C8.46499 16.8586 8.12802 17.203 7.70868 17.203H5.9864C3.26068 17.203 1.63574 15.5781 1.63574 12.8449V6.57722C1.63574 3.85151 3.26068 2.22656 5.9864 2.22656H12.2615C14.9872 2.22656 16.6122 3.85151 16.6122 6.57722V12.8524Z"
33
+ fill="#2196F3"
34
+ />
35
+ </svg>
36
+ );
37
+ };
38
+ export default SocialBtn;
@@ -0,0 +1,202 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import {
3
+ MdDateRange,
4
+ MdKeyboardArrowLeft,
5
+ MdKeyboardArrowRight,
6
+ } from "react-icons/md";
7
+ import {
8
+ CalendarBody,
9
+ CalendarContainer,
10
+ CalendarDayCell,
11
+ CalendarHeader,
12
+ CalendarIcon,
13
+ DateInput,
14
+ DateInputContainer,
15
+ } from "./styles/input";
16
+
17
+ /**
18
+ * @param {{
19
+ * size: string,
20
+ * value: string | number,
21
+ * onChange: Function,
22
+ * selected: string,
23
+ * }} props - properties of Header Component
24
+ *
25
+ */
26
+
27
+ const Calender = ({ size, value, color, active, icon, onChange }) => {
28
+ const [showCalendar, setShowCalendar] = useState(false);
29
+ const [selectedDate, setSelectedDate] = useState(value);
30
+
31
+ const handleDateSelect = (date) => {
32
+ setSelectedDate(date);
33
+ onChange(date);
34
+ setShowCalendar(false);
35
+ };
36
+
37
+ const monthNames = [
38
+ "January",
39
+ "February",
40
+ "March",
41
+ "April",
42
+ "May",
43
+ "June",
44
+ "July",
45
+ "August",
46
+ "September",
47
+ "October",
48
+ "November",
49
+ "December",
50
+ ];
51
+ const weekdays = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
52
+
53
+ const renderCalendar = () => {
54
+ const today = new Date();
55
+ const year = selectedDate
56
+ ? selectedDate.getFullYear()
57
+ : today.getFullYear();
58
+ const month = selectedDate ? selectedDate.getMonth() : today.getMonth();
59
+
60
+ const firstDayOfMonth = new Date(year, month, 1);
61
+ const lastDayOfMonth = new Date(year, month + 1, 0);
62
+ const daysInMonth = lastDayOfMonth.getDate();
63
+ const startDayOfWeek = firstDayOfMonth.getDay();
64
+
65
+ const calendarDays = [];
66
+
67
+ for (let i = 0; i < startDayOfWeek; i++) {
68
+ calendarDays.push(null);
69
+ }
70
+
71
+ for (let i = 1; i <= daysInMonth; i++) {
72
+ calendarDays.push(new Date(year, month, i));
73
+ }
74
+
75
+ const handlePrevMonthClick = () => {
76
+ setSelectedDate(new Date(year, month - 1, 1));
77
+ };
78
+
79
+ const handleNextMonthClick = () => {
80
+ setSelectedDate(new Date(year, month + 1, 1));
81
+ };
82
+
83
+ return (
84
+ <CalendarContainer>
85
+ <CalendarHeader>
86
+ <div>
87
+ {monthNames[month]} {year}
88
+ </div>
89
+ <div className="buttons">
90
+ <button onClick={handlePrevMonthClick}>
91
+ <MdKeyboardArrowLeft />
92
+ </button>
93
+ <button onClick={handleNextMonthClick}>
94
+ <MdKeyboardArrowRight />
95
+ </button>
96
+ </div>
97
+ </CalendarHeader>
98
+ <CalendarBody>
99
+ {weekdays.map((day) => (
100
+ <CalendarDayCell className="weekdays" key={day}>
101
+ {day}
102
+ </CalendarDayCell>
103
+ ))}
104
+ {calendarDays.map((date) =>
105
+ date ? (
106
+ <CalendarDayCell
107
+ key={date}
108
+ onClick={() => handleDateSelect(date)}
109
+ color={color}
110
+ selected={
111
+ selectedDate &&
112
+ date.toDateString() === selectedDate.toDateString()
113
+ }
114
+ >
115
+ {date.getDate()}
116
+ </CalendarDayCell>
117
+ ) : (
118
+ <CalendarDayCell
119
+ color={color}
120
+ key={Math.random()}
121
+ ></CalendarDayCell>
122
+ )
123
+ )}
124
+ </CalendarBody>
125
+ </CalendarContainer>
126
+ );
127
+ };
128
+
129
+ const handleKeyPress = (e) => {
130
+ if (e.key === "ArrowLeft") {
131
+ setSelectedDate(
132
+ new Date(
133
+ selectedDate.getFullYear(),
134
+ selectedDate.getMonth(),
135
+ selectedDate.getDate() - 1
136
+ )
137
+ );
138
+ } else if (e.key === "ArrowRight") {
139
+ setSelectedDate(
140
+ new Date(
141
+ selectedDate.getFullYear(),
142
+ selectedDate.getMonth(),
143
+ selectedDate.getDate() + 1
144
+ )
145
+ );
146
+ } else if (e.key === "ArrowUp") {
147
+ setSelectedDate(
148
+ new Date(
149
+ selectedDate.getFullYear(),
150
+ selectedDate.getMonth(),
151
+ selectedDate.getDate() - 7
152
+ )
153
+ );
154
+ } else if (e.key === "ArrowDown") {
155
+ setSelectedDate(
156
+ new Date(
157
+ selectedDate.getFullYear(),
158
+ selectedDate.getMonth(),
159
+ selectedDate.getDate() + 7
160
+ )
161
+ );
162
+ }
163
+ };
164
+
165
+ useEffect(() => {
166
+ document.addEventListener("keydown", handleKeyPress);
167
+
168
+ return () => {
169
+ document.removeEventListener("keydown", handleKeyPress);
170
+ };
171
+ }, [handleKeyPress]);
172
+
173
+ return (
174
+ <DateInputContainer size={size}>
175
+ <DateInput
176
+ size={size}
177
+ value={
178
+ selectedDate
179
+ ? `${selectedDate.getDate()} ${monthNames[
180
+ selectedDate.getMonth()
181
+ ].slice(0, 3)} ${selectedDate.getFullYear()}`
182
+ : ""
183
+ }
184
+ color={color}
185
+ active={active}
186
+ onFocus={() => setShowCalendar(true)}
187
+ onBlur={() => setShowCalendar(false)}
188
+ onKeyDown={handleKeyPress} // add this
189
+ />
190
+
191
+ <CalendarIcon
192
+ color={color}
193
+ onClick={() => setShowCalendar(!showCalendar)}
194
+ >
195
+ {icon ? icon : <MdDateRange />}
196
+ </CalendarIcon>
197
+ {showCalendar && renderCalendar()}
198
+ </DateInputContainer>
199
+ );
200
+ };
201
+
202
+ export default Calender;