hisd3-ui-kit 1.0.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.
@@ -0,0 +1,109 @@
1
+ import styled from "styled-components";
2
+ import { Avatar, List } from "antd";
3
+
4
+ export const StyledDropdownList = styled(List)`
5
+ & .ant-list-item {
6
+ padding: 5px 12px;
7
+ cursor: pointer;
8
+ }
9
+ `;
10
+
11
+ export const StyledCrUserInfo = styled.div`
12
+ background-color: transparent;
13
+ padding: 7px 12px;
14
+ height: 56px;
15
+ display: flex;
16
+ flex-direction: column;
17
+ justify-content: center;
18
+ transition: all 0.2s ease;
19
+
20
+ @media screen and (min-width: ${({ theme }) => theme.breakpoints.md}px) {
21
+ padding-top: 10px;
22
+ padding-bottom: 10px;
23
+ height: 71px;
24
+ }
25
+
26
+ & .ant-dropdown-link {
27
+ color: inherit;
28
+
29
+ & .anticon {
30
+ font-size: ${({ theme }) => theme.font.size.sm};
31
+ }
32
+ }
33
+
34
+ &.light {
35
+ & .ant-dropdown-link {
36
+ color: inherit;
37
+ }
38
+ }
39
+ `;
40
+
41
+ export const StyledCrUserInfoInner = styled.a`
42
+ display: flex;
43
+ align-items: center;
44
+ `;
45
+
46
+ export const StyledCrUserInfoAvatar = styled(Avatar)`
47
+ font-size: 24px;
48
+ background-color: ${({ theme }) => theme.palette.orange[6]};
49
+ width: 40px;
50
+ height: 40px;
51
+ display: flex;
52
+ align-items: center;
53
+ justify-content: center;
54
+ `;
55
+
56
+ export const StyledCrUserInfoContent = styled.span`
57
+ width: calc(100% - 62px);
58
+ margin-left: 16px;
59
+ transition: all 0.2s ease;
60
+
61
+ [dir="rtl"] & {
62
+ margin-left: 0;
63
+ margin-right: 16px;
64
+ }
65
+ `;
66
+
67
+ export const StyledUsernameInfo = styled.span`
68
+ display: flex;
69
+ align-items: center;
70
+ justify-content: space-between;
71
+ `;
72
+
73
+ export const StyledUsername = styled.h3`
74
+ margin-bottom: 0;
75
+ font-size: ${({ theme }) => theme.font.size.sm};
76
+ font-weight: ${({ theme }) => theme.font.weight.lg};
77
+ color: #000000e0;
78
+
79
+ &.light {
80
+ color: #000000e0;
81
+ }
82
+ `;
83
+
84
+ export const StyledUserArrow = styled.span`
85
+ margin-left: 12px;
86
+ width: 24px;
87
+ display: flex;
88
+ align-items: center;
89
+ justify-content: center;
90
+
91
+ [dir="rtl"] & {
92
+ margin-left: 0;
93
+ margin-right: 12px;
94
+ }
95
+
96
+ & svg {
97
+ display: block;
98
+ }
99
+ `;
100
+
101
+ export const StyledCrUserDesignation = styled.span`
102
+ margin-top: -2px;
103
+ color: #000000e0;
104
+ font-size: ${({ theme }) => theme.font.size.sm};
105
+
106
+ .ant-layout-sider-dark & {
107
+ color: #000000e0;
108
+ }
109
+ `;
@@ -0,0 +1,168 @@
1
+ import {
2
+ DownOutlined,
3
+ ExclamationCircleOutlined,
4
+ LogoutOutlined,
5
+ SettingOutlined,
6
+ } from "@ant-design/icons";
7
+ import { ProConfigProvider, ProLayout } from "@ant-design/pro-components";
8
+ import { Dropdown, Modal } from "antd";
9
+ import React, { useEffect, useState } from "react";
10
+
11
+ import { ThemeProvider } from "styled-components";
12
+ import { IUserEmployee } from "../../types/account";
13
+ import { StyledTheme } from "../../types/theme";
14
+ import {
15
+ StyledCrUserDesignation,
16
+ StyledCrUserInfo,
17
+ StyledCrUserInfoAvatar,
18
+ StyledCrUserInfoContent,
19
+ StyledCrUserInfoInner,
20
+ StyledUserArrow,
21
+ StyledUsername,
22
+ StyledUsernameInfo,
23
+ } from "./index.styled";
24
+
25
+ interface HISD3SidebarProps {
26
+ account: IUserEmployee;
27
+ logoUrl: string;
28
+ appName: string;
29
+ menuItems: any[];
30
+ onLogout: () => Promise<void>;
31
+ pathname: string;
32
+ styledTheme: StyledTheme;
33
+ collapsed?: boolean;
34
+ loading?: boolean;
35
+ hideSidebar?: boolean;
36
+ layoutTop?: boolean;
37
+ avatarSrc?: string;
38
+ settingsUrl?: string;
39
+ children: React.ReactNode;
40
+ }
41
+
42
+ export const HISD3Sidebar: React.FC<HISD3SidebarProps> = ({
43
+ children,
44
+ account,
45
+ logoUrl,
46
+ appName,
47
+ menuItems,
48
+ onLogout,
49
+ pathname,
50
+ avatarSrc,
51
+ styledTheme,
52
+ settingsUrl,
53
+ collapsed = false,
54
+ loading = false,
55
+ hideSidebar = false,
56
+ layoutTop = false,
57
+ }) => {
58
+ const [isCollapsed, setIsCollapsed] = useState(collapsed);
59
+
60
+ useEffect(() => {
61
+ if (collapsed !== isCollapsed) {
62
+ setIsCollapsed(collapsed);
63
+ }
64
+ }, [collapsed]);
65
+
66
+ const confirmLogout = () => {
67
+ Modal.confirm({
68
+ title: "Are you sure you want to logout?",
69
+ content: "Please click OK to continue",
70
+ icon: <ExclamationCircleOutlined />,
71
+ onOk: onLogout,
72
+ });
73
+ };
74
+
75
+ if (typeof document === "undefined") {
76
+ return null;
77
+ }
78
+
79
+ return (
80
+ <ThemeProvider theme={styledTheme}>
81
+ <ProConfigProvider hashed={false}>
82
+ {!hideSidebar ? (
83
+ <ProLayout
84
+ layout={layoutTop ? "top" : "side"}
85
+ title={appName}
86
+ logo={logoUrl}
87
+ location={{ pathname }}
88
+ loading={loading}
89
+ collapsed={isCollapsed}
90
+ onCollapse={(collapse) => setIsCollapsed(collapse)}
91
+ menuDataRender={() => menuItems}
92
+ menu={{
93
+ collapsedShowGroupTitle: true,
94
+ }}
95
+ token={{
96
+ header: {
97
+ colorBgMenuItemSelected: "rgba(0,0,0,0.04)",
98
+ },
99
+ sider: {
100
+ colorBgMenuItemActive: "#e0f7f7",
101
+ colorBgMenuItemHover: "#e0f7f7",
102
+ colorTextMenuItemHover: "#00796b",
103
+ colorBgMenuItemSelected: "#e0f7f7",
104
+ colorTextMenuSelected: "#00796b",
105
+ },
106
+ }}
107
+ headerTitleRender={(logo, title) => (
108
+ <a href="/">
109
+ {logo}
110
+ {title}
111
+ </a>
112
+ )}
113
+ menuFooterRender={() => (
114
+ <StyledCrUserInfo className="cr-user-info-light">
115
+ <Dropdown
116
+ trigger={["click"]}
117
+ placement="topRight"
118
+ menu={{
119
+ items: [
120
+ {
121
+ key: "settings",
122
+ icon: <SettingOutlined />,
123
+ label: "Settings",
124
+ onClick: () =>
125
+ (window.location.href = settingsUrl ?? "/settings"),
126
+ },
127
+ {
128
+ key: "logout",
129
+ icon: <LogoutOutlined />,
130
+ label: "Logout",
131
+ onClick: confirmLogout,
132
+ },
133
+ ],
134
+ }}
135
+ >
136
+ <StyledCrUserInfoInner className="ant-dropdown-link">
137
+ {avatarSrc && (
138
+ <StyledCrUserInfoAvatar src={avatarSrc} size="small" />
139
+ )}
140
+ <StyledCrUserInfoContent>
141
+ <StyledUsernameInfo>
142
+ <StyledUsername>{account.fullName}</StyledUsername>
143
+ <StyledUserArrow>
144
+ <DownOutlined />
145
+ </StyledUserArrow>
146
+ </StyledUsernameInfo>
147
+ <StyledCrUserDesignation>
148
+ {account.positionType}
149
+ </StyledCrUserDesignation>
150
+ </StyledCrUserInfoContent>
151
+ </StyledCrUserInfoInner>
152
+ </Dropdown>
153
+ </StyledCrUserInfo>
154
+ )}
155
+ menuItemRender={(item, dom) => <a href={item.path || "/"}>{dom}</a>}
156
+ >
157
+ {children}
158
+ </ProLayout>
159
+ ) : (
160
+ // If no sidebar, just render children
161
+ <>{children}</>
162
+ )}
163
+ </ProConfigProvider>
164
+ </ThemeProvider>
165
+ );
166
+ };
167
+
168
+ export default HISD3Sidebar;
@@ -0,0 +1,427 @@
1
+ export enum ThemeStyle {
2
+ MODERN = "modern",
3
+ STANDARD = "standard",
4
+ }
5
+ export enum ThemeStyleRadius {
6
+ MODERN = "30px",
7
+ STANDARD = "16px",
8
+ }
9
+ export enum ThemeMode {
10
+ LIGHT = "light",
11
+ SEMI_DARK = "semi-dark",
12
+ DARK = "dark",
13
+ }
14
+ export enum LayoutType {
15
+ FULL_WIDTH = "full-width",
16
+ BOXED = "boxed",
17
+ FRAMED = "framed",
18
+ }
19
+
20
+ export enum MenuStyle {
21
+ DEFAULT = "default",
22
+ STANDARD = "standard",
23
+ ROUNDED = "rounded",
24
+ ROUNDED_REVERSE = "rounded-reverse",
25
+ CURVED_MENU = "curved-menu",
26
+ }
27
+
28
+ export enum NavStyle {
29
+ DEFAULT = "default",
30
+ MINI = "mini",
31
+ MINI_SIDEBAR_TOGGLE = "mini-sidebar-toggle",
32
+ STANDARD = "standard",
33
+ HEADER_USER = "user-header",
34
+ HEADER_USER_MINI = "user-mini-header",
35
+ DRAWER = "drawer",
36
+ BIT_BUCKET = "bit-bucket",
37
+ H_DEFAULT = "h-default",
38
+ HOR_HEADER_FIXED = "hor-header-fixed",
39
+ HOR_DARK_LAYOUT = "hor-dark-layout",
40
+ }
41
+ export enum FooterType {
42
+ FIXED = "fixed",
43
+ FLUID = "fluid",
44
+ }
45
+ export enum LayoutDirection {
46
+ RTL = "rtl",
47
+ LTR = "ltr",
48
+ }
49
+ export enum HeaderType {
50
+ DARK = "dark",
51
+ LIGHT = "light",
52
+ }
53
+ export enum RouteTransition {
54
+ NONE = "none",
55
+ FADE = "fade",
56
+ SLIDE_LEFT = "slideLeft",
57
+ SLIDE_RIGHT = "slideRight",
58
+ SLIDE_UP = "slideUp",
59
+ SLIDE_DOWN = "slideDown",
60
+ }
61
+ export enum Fonts {
62
+ LIGHT = "300",
63
+ REGULAR = "400",
64
+ MEDIUM = "500",
65
+ BOLD = "600",
66
+ }
67
+
68
+ export enum AuthType {
69
+ FIREBASE = "firebase",
70
+ AWS_COGNITO = "aws_cognito",
71
+ AUTH0 = "auth0",
72
+ JWT_AUTH = "jwt_auth",
73
+ }
74
+
75
+ export enum AppAnimates {
76
+ SLIDEUPIN = "transition.slideUpIn",
77
+ SLIDEUPOUT = "transition.slideUpOut",
78
+ SLIDEDOWNIN = "transition.slideDownIn",
79
+ SLIDEDOWNOUT = "transition.slideDownOut",
80
+ SLIDELEFTIN = "transition.slideLeftIn",
81
+ SLIDELEFTOUT = "transition.slideLeftOut",
82
+ SLIDERIGHTIN = "transition.slideRightIn",
83
+ SLIDERIGHTOUT = "transition.slideRightOut",
84
+ FADEIN = "transition.fadeIn",
85
+ FADEOUT = "transition.fadeOut",
86
+ }
87
+
88
+ export const AppAnimateGroups = {
89
+ SLIDEUPIN: {
90
+ hidden: {
91
+ y: 0,
92
+ },
93
+ visible: {
94
+ opacity: 1,
95
+ y: 0,
96
+ transition: {
97
+ ease: "easeIn",
98
+ delay: 0,
99
+ when: "beforeChildren",
100
+ duration: 0.2,
101
+ staggerChildren: 0.05,
102
+ },
103
+ },
104
+ },
105
+ SLIDEUPOUT: {
106
+ hidden: {
107
+ y: 0,
108
+ },
109
+ visible: {
110
+ opacity: 0,
111
+ y: "100vh",
112
+ transition: {
113
+ ease: "easeOut",
114
+ delay: 0,
115
+ when: "beforeChildren",
116
+ duration: 0.4,
117
+ staggerChildren: 0.15,
118
+ },
119
+ },
120
+ },
121
+ SLIDEDOWNIN: {
122
+ hidden: {
123
+ opacity: 0,
124
+ y: "-100vh",
125
+ },
126
+ visible: {
127
+ opacity: 1,
128
+ y: 0,
129
+ transition: {
130
+ ease: "easeIn",
131
+ delay: 0,
132
+ when: "beforeChildren",
133
+ duration: 0.4,
134
+ staggerChildren: 0.15,
135
+ },
136
+ },
137
+ },
138
+ SLIDEDOWNOUT: {
139
+ hidden: {
140
+ y: 0,
141
+ },
142
+ visible: {
143
+ opacity: 0,
144
+ y: "-100vh",
145
+ transition: {
146
+ ease: "easeOut",
147
+ delay: 0,
148
+ when: "beforeChildren",
149
+ duration: 0.4,
150
+ staggerChildren: 0.15,
151
+ },
152
+ },
153
+ },
154
+ SLIDELEFTIN: {
155
+ hidden: {
156
+ x: "100vw",
157
+ },
158
+ visible: {
159
+ opacity: 1,
160
+ x: 0,
161
+ transition: {
162
+ ease: "easeIn",
163
+ delay: 0,
164
+ when: "beforeChildren",
165
+ duration: 0.4,
166
+ staggerChildren: 0.15,
167
+ },
168
+ },
169
+ },
170
+ SLIDELEFTOUT: {
171
+ hidden: {
172
+ x: 0,
173
+ },
174
+ visible: {
175
+ opacity: 0,
176
+ x: "100vw",
177
+ transition: {
178
+ ease: "easeOut",
179
+ delay: 0,
180
+ when: "beforeChildren",
181
+ duration: 0.4,
182
+ staggerChildren: 0.15,
183
+ },
184
+ },
185
+ },
186
+ SLIDERIGHTIN: {
187
+ hidden: {
188
+ x: "-100vw",
189
+ },
190
+ visible: {
191
+ opacity: 1,
192
+ x: 0,
193
+ transition: {
194
+ ease: "easeIn",
195
+ delay: 0,
196
+ when: "beforeChildren",
197
+ duration: 0.4,
198
+ staggerChildren: 0.15,
199
+ },
200
+ },
201
+ },
202
+ SLIDERIGHTOUT: {
203
+ hidden: {
204
+ x: 0,
205
+ },
206
+ visible: {
207
+ opacity: 0,
208
+ x: "-100vw",
209
+ transition: {
210
+ ease: "easeOut",
211
+ delay: 0,
212
+ when: "beforeChildren",
213
+ duration: 0.4,
214
+ staggerChildren: 0.15,
215
+ },
216
+ },
217
+ },
218
+ FADEIN: {
219
+ hidden: {
220
+ opacity: 0,
221
+ scale: 1,
222
+ },
223
+ visible: {
224
+ opacity: 1,
225
+ scale: 1,
226
+ transition: {
227
+ ease: "easeIn",
228
+ when: "beforeChildren",
229
+ staggerChildren: 0.15,
230
+ },
231
+ },
232
+ },
233
+ FADEOUT: {
234
+ hidden: {
235
+ opacity: 1,
236
+ scale: 1,
237
+ },
238
+ visible: {
239
+ opacity: 0,
240
+ scale: 1,
241
+ transition: {
242
+ ease: "easeOut",
243
+ when: "beforeChildren",
244
+ staggerChildren: 0.15,
245
+ },
246
+ },
247
+ },
248
+ NOANIMATION: {
249
+ hidden: {
250
+ opacity: 1,
251
+ },
252
+ visible: {
253
+ opacity: 1,
254
+ },
255
+ },
256
+ };
257
+
258
+ export const AppMotionAnimate = {
259
+ SLIDEUPIN: {
260
+ variants: {
261
+ hidden: {
262
+ y: 100,
263
+ opacity: 0,
264
+ },
265
+ visible: {
266
+ opacity: 1,
267
+ y: 0,
268
+ },
269
+ },
270
+ transition: {
271
+ ease: "easeIn",
272
+ when: "beforeChildren",
273
+ },
274
+ },
275
+ SLIDEUPOUT: {
276
+ variants: {
277
+ hidden: {
278
+ y: 0,
279
+ opacity: 1,
280
+ },
281
+ visible: {
282
+ opacity: 0,
283
+ y: "-100vh",
284
+ },
285
+ },
286
+ transition: {
287
+ ease: "easeOut",
288
+ when: "beforeChildren",
289
+ },
290
+ },
291
+ SLIDEDOWNIN: {
292
+ variants: {
293
+ hidden: {
294
+ y: -100,
295
+ opacity: 0,
296
+ },
297
+ visible: {
298
+ opacity: 1,
299
+ y: 0,
300
+ },
301
+ },
302
+ transition: {
303
+ ease: "easeIn",
304
+ when: "beforeChildren",
305
+ },
306
+ },
307
+ SLIDEDOWNOUT: {
308
+ variants: {
309
+ hidden: {
310
+ y: 0,
311
+ opacity: 1,
312
+ },
313
+ visible: {
314
+ opacity: 0,
315
+ y: "100vh",
316
+ },
317
+ },
318
+ transition: {
319
+ ease: "easeOut",
320
+ when: "beforeChildren",
321
+ },
322
+ },
323
+ SLIDELEFTIN: {
324
+ variants: {
325
+ hidden: {
326
+ x: 100,
327
+ opacity: 0,
328
+ },
329
+ visible: {
330
+ opacity: 1,
331
+ x: 0,
332
+ },
333
+ },
334
+ transition: {
335
+ ease: "easeIn",
336
+ when: "beforeChildren",
337
+ },
338
+ },
339
+ SLIDELEFTOUT: {
340
+ variants: {
341
+ hidden: {
342
+ x: 0,
343
+ opacity: 1,
344
+ },
345
+ visible: {
346
+ opacity: 0,
347
+ x: "-100vw",
348
+ },
349
+ },
350
+ transition: {
351
+ ease: "easeOut",
352
+ when: "beforeChildren",
353
+ },
354
+ },
355
+ SLIDERIGHTIN: {
356
+ variants: {
357
+ hidden: {
358
+ x: -100,
359
+ opacity: 0,
360
+ },
361
+ visible: {
362
+ opacity: 1,
363
+ x: 0,
364
+ },
365
+ },
366
+ transition: {
367
+ ease: "easeIn",
368
+ when: "beforeChildren",
369
+ },
370
+ },
371
+ SLIDERIGHTOUT: {
372
+ variants: {
373
+ hidden: {
374
+ x: 0,
375
+ opacity: 1,
376
+ },
377
+ visible: {
378
+ opacity: 0,
379
+ x: "-100vw",
380
+ },
381
+ },
382
+ transition: {
383
+ ease: "easeOut",
384
+ when: "beforeChildren",
385
+ },
386
+ },
387
+ FADEIN: {
388
+ variants: {
389
+ hidden: {
390
+ opacity: 0,
391
+ },
392
+ visible: {
393
+ opacity: 1,
394
+ },
395
+ },
396
+ transition: {
397
+ duration: 0.1,
398
+ ease: "easeIn",
399
+ when: "beforeChildren",
400
+ },
401
+ },
402
+ FADEOUT: {
403
+ variants: {
404
+ hidden: {
405
+ opacity: 1,
406
+ },
407
+ visible: {
408
+ opacity: 0,
409
+ },
410
+ },
411
+ transition: {
412
+ duration: 0.1,
413
+ ease: "easeOut",
414
+ when: "beforeChildren",
415
+ },
416
+ },
417
+ };
418
+
419
+ export enum MessageType {
420
+ MEDIA = 1,
421
+ TEXT = 2,
422
+ }
423
+
424
+ export enum RoutePermittedRole {
425
+ Admin = "admin",
426
+ User = "user",
427
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { default as HISD3Sidebar } from "./components/Sidebar";
2
+ // export { default as Form } from "./components/Form";
3
+ // export { default as CustomButton } from "./components/CustomButton";
@@ -0,0 +1,7 @@
1
+ export interface IUserEmployee {
2
+ id: string;
3
+ fullName: string;
4
+ gender: "MALE" | "FEMALE";
5
+ positionType?: string;
6
+ [key: string]: any;
7
+ }
@@ -0,0 +1,7 @@
1
+ // styled-components.d.ts
2
+ import "styled-components";
3
+ import { StyledTheme } from "./theme";
4
+
5
+ declare module "styled-components" {
6
+ export interface DefaultTheme extends StyledTheme {}
7
+ }