@atomazing-org/design-system 1.0.0 → 1.0.1
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/README.MD +1 -1
- package/build/index.d.ts +3 -0
- package/build/index.js +3 -0
- package/build/src/components/DialogBtn.d.ts +5 -0
- package/build/src/components/DialogBtn.js +8 -0
- package/build/src/components/ErrorBoundary.d.ts +20 -0
- package/build/src/components/ErrorBoundary.js +75 -0
- package/build/src/components/Loading.d.ts +1 -0
- package/build/src/components/Loading.js +26 -0
- package/build/src/components/PathName.d.ts +4 -0
- package/build/src/components/PathName.js +8 -0
- package/build/src/components/index.d.ts +3 -0
- package/build/src/components/index.js +3 -0
- package/build/src/styles/commonComponents.d.ts +2 -0
- package/build/src/styles/commonComponents.js +69 -0
- package/build/src/styles/index.d.ts +3 -0
- package/build/src/styles/index.js +3 -0
- package/build/src/styles/keyframes.d.ts +10 -0
- package/build/src/styles/keyframes.js +108 -0
- package/build/src/styles/typography.d.ts +4 -0
- package/build/src/styles/typography.js +160 -0
- package/build/src/utils/displayGreeting.d.ts +5 -0
- package/build/src/utils/displayGreeting.js +19 -0
- package/build/src/utils/getDayIdentifier.d.ts +4 -0
- package/build/src/utils/getDayIdentifier.js +9 -0
- package/build/src/utils/getSystemInfo.d.ts +7 -0
- package/build/src/utils/getSystemInfo.js +26 -0
- package/build/src/utils/index.d.ts +5 -0
- package/build/src/utils/index.js +5 -0
- package/build/src/utils/timeAgo.d.ts +9 -0
- package/build/src/utils/timeAgo.js +56 -0
- package/build/src/utils/useResponsiveDisplay.d.ts +7 -0
- package/build/src/utils/useResponsiveDisplay.js +22 -0
- package/package.json +11 -22
package/README.MD
CHANGED
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { systemInfo, timeAgo, timeAgoFromStart, displayGreeting, getDayIdentifier, useResponsiveDisplay, } from "./src/utils";
|
|
2
|
+
export { fadeIn, fadeInLeft, pulseAnimation, ring, rotate, rotateSlideBarIcons, scale, slideIn, slideInBottom, typographyProps, typographyVariants, zoomIn, commonComponentProps, } from "./src/styles";
|
|
3
|
+
export { DialogBtn, Loading, PathName } from "./src/components";
|
package/build/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { systemInfo, timeAgo, timeAgoFromStart, displayGreeting, getDayIdentifier, useResponsiveDisplay, } from "./src/utils";
|
|
2
|
+
export { fadeIn, fadeInLeft, pulseAnimation, ring, rotate, rotateSlideBarIcons, scale, slideIn, slideInBottom, typographyProps, typographyVariants, zoomIn, commonComponentProps, } from "./src/styles";
|
|
3
|
+
export { DialogBtn, Loading, PathName } from "./src/components";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const DialogBtn: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
2
|
+
ref?: ((instance: HTMLButtonElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLButtonElement> | null | undefined;
|
|
3
|
+
}, "style" | "className" | "classes" | "color" | "children" | "sx" | "variant" | "tabIndex" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "href" | "size" | "startIcon"> & {
|
|
4
|
+
theme?: import("@emotion/react").Theme;
|
|
5
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ErrorInfo } from "react";
|
|
3
|
+
interface ErrorBoundaryProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
interface ErrorBoundaryState {
|
|
7
|
+
hasError: boolean;
|
|
8
|
+
error?: Error;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* ErrorBoundary component that catches and displays errors.
|
|
12
|
+
*/
|
|
13
|
+
declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
14
|
+
constructor(props: ErrorBoundaryProps);
|
|
15
|
+
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
16
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
17
|
+
handleClearData(): void;
|
|
18
|
+
render(): string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
19
|
+
}
|
|
20
|
+
export default ErrorBoundary;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import styled from "@emotion/styled";
|
|
4
|
+
import { ErrorOutlineRounded } from "@mui/icons-material";
|
|
5
|
+
import { Box, Button } from "@mui/material";
|
|
6
|
+
/**
|
|
7
|
+
* ErrorBoundary component that catches and displays errors.
|
|
8
|
+
*/
|
|
9
|
+
class ErrorBoundary extends React.Component {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props);
|
|
12
|
+
this.state = {
|
|
13
|
+
hasError: false,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
static getDerivedStateFromError(error) {
|
|
17
|
+
return {
|
|
18
|
+
hasError: true,
|
|
19
|
+
error,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
componentDidCatch(error, errorInfo) {
|
|
23
|
+
// eslint-disable-next-line no-console -- Выводим ошибку в консоль
|
|
24
|
+
console.error("Error:", error);
|
|
25
|
+
// eslint-disable-next-line no-console -- Выводим ошибку в консоль
|
|
26
|
+
console.error("Error Info:", errorInfo);
|
|
27
|
+
}
|
|
28
|
+
handleClearData() {
|
|
29
|
+
localStorage.clear();
|
|
30
|
+
sessionStorage.clear();
|
|
31
|
+
window.location.reload();
|
|
32
|
+
}
|
|
33
|
+
render() {
|
|
34
|
+
const { state, props } = this;
|
|
35
|
+
if (state.hasError) {
|
|
36
|
+
return (_jsxs(Container, { children: [_jsx(ErrorHeader, { children: _jsx(Box, { children: "\u041E\u0448\u0438\u0431\u043A\u0430.\u00A0" }) }), _jsxs("h3", { children: [_jsxs(Box, { style: { color: "#ff3131", display: "inline-block" }, children: [_jsx(ErrorOutlineRounded, { sx: { verticalAlign: "middle", mb: "4px" } }), " ", "ERROR:"] }), " ", _jsxs(Box, { translate: "no", children: ["[", state.error?.name, "] ", state.error?.message] }), _jsxs(Box, { style: { color: "#ff3131", display: "inline-block" }, children: [_jsx(ErrorOutlineRounded, { sx: { verticalAlign: "middle", mb: "4px" } }), " ", "Stack:"] }), " ", _jsxs(Box, { translate: "no", children: ["[", state.error?.stack, "]"] })] })] }));
|
|
37
|
+
}
|
|
38
|
+
return props.children;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const Container = styled.div `
|
|
42
|
+
margin: 0 8vw;
|
|
43
|
+
@media (max-width: 768px) {
|
|
44
|
+
margin: 0;
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
const ErrorHeader = styled.h1 `
|
|
48
|
+
margin-top: 32px;
|
|
49
|
+
margin-bottom: 32px;
|
|
50
|
+
font-size: 36px;
|
|
51
|
+
color: #ff3131;
|
|
52
|
+
text-align: center;
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
justify-content: center;
|
|
56
|
+
@media (max-width: 768px) {
|
|
57
|
+
text-align: left;
|
|
58
|
+
justify-content: left;
|
|
59
|
+
font-size: 30px;
|
|
60
|
+
margin-top: 0;
|
|
61
|
+
margin-bottom: 0;
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
const StyledButton = styled(Button) `
|
|
65
|
+
padding: 10px 30px;
|
|
66
|
+
border-radius: 12px;
|
|
67
|
+
@media (max-width: 768px) {
|
|
68
|
+
width: 100%;
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
StyledButton.defaultProps = {
|
|
72
|
+
variant: "outlined",
|
|
73
|
+
size: "large",
|
|
74
|
+
};
|
|
75
|
+
export default ErrorBoundary;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Loading: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import styled from '@emotion/styled';
|
|
4
|
+
import { Box, CircularProgress } from '@mui/material';
|
|
5
|
+
export const Loading = () => {
|
|
6
|
+
const [showLoading, setShowLoading] = useState(false);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const timer = setTimeout(() => {
|
|
9
|
+
setShowLoading(true);
|
|
10
|
+
}, 100); // Show the loading spinner after 100 milliseconds
|
|
11
|
+
return () => clearTimeout(timer);
|
|
12
|
+
}, []);
|
|
13
|
+
return (_jsx(Container, { children: showLoading && (_jsxs(_Fragment, { children: [_jsx(CircularProgress, { "aria-label": "loading", size: 80, thickness: 4 }), _jsx("h3", { style: { opacity: 0.8 }, children: "Loading Page..." })] })) }));
|
|
14
|
+
};
|
|
15
|
+
const Container = styled(Box) `
|
|
16
|
+
position: absolute;
|
|
17
|
+
top: 50%;
|
|
18
|
+
left: 50%;
|
|
19
|
+
transform: translate(-50%, -50%);
|
|
20
|
+
display: flex;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
align-items: center;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
text-align: center;
|
|
25
|
+
gap: 8px;
|
|
26
|
+
`;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export const commonComponentProps = {
|
|
2
|
+
MuiTooltip: {
|
|
3
|
+
defaultProps: {
|
|
4
|
+
disableInteractive: true,
|
|
5
|
+
style: {
|
|
6
|
+
backdropFilter: "blur(6px)",
|
|
7
|
+
WebkitBackdropFilter: "blur(6px)",
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
MuiButton: {
|
|
12
|
+
defaultProps: {
|
|
13
|
+
sx: {
|
|
14
|
+
p: "12px 24px",
|
|
15
|
+
borderRadius: "14px",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
MuiSelect: {
|
|
20
|
+
defaultProps: {
|
|
21
|
+
style: {
|
|
22
|
+
borderRadius: "18px",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
MuiDialog: {
|
|
27
|
+
defaultProps: {
|
|
28
|
+
PaperProps: {
|
|
29
|
+
style: {
|
|
30
|
+
padding: "12px",
|
|
31
|
+
borderRadius: "24px",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
MuiAvatar: {
|
|
37
|
+
defaultProps: {
|
|
38
|
+
style: {
|
|
39
|
+
fontWeight: 500,
|
|
40
|
+
color: "#fff",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
MuiAlert: {
|
|
45
|
+
styleOverrides: {
|
|
46
|
+
root: {
|
|
47
|
+
borderRadius: "16px",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
MuiTextField: {
|
|
52
|
+
styleOverrides: {
|
|
53
|
+
root: {
|
|
54
|
+
"& .MuiInputBase-root": {
|
|
55
|
+
borderRadius: "16px",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
MuiMenuItem: {
|
|
61
|
+
styleOverrides: {
|
|
62
|
+
root: {
|
|
63
|
+
"& .MuiInputBase-root": {
|
|
64
|
+
borderRadius: "16px",
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const fadeInLeft: string;
|
|
2
|
+
export declare const fadeIn: string;
|
|
3
|
+
export declare const zoomIn: string;
|
|
4
|
+
export declare const slideIn: string;
|
|
5
|
+
export declare const slideInBottom: string;
|
|
6
|
+
export declare const scale: string;
|
|
7
|
+
export declare const pulseAnimation: (clr: string, shadowBlur?: number) => string;
|
|
8
|
+
export declare const rotateSlideBarIcons: string;
|
|
9
|
+
export declare const rotate: (angle: string) => string;
|
|
10
|
+
export declare const ring: string;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { keyframes } from "@emotion/css";
|
|
2
|
+
export const fadeInLeft = keyframes `
|
|
3
|
+
from {
|
|
4
|
+
opacity: 0;
|
|
5
|
+
transform: translateX(-40px)
|
|
6
|
+
}
|
|
7
|
+
to {
|
|
8
|
+
opacity: 1;
|
|
9
|
+
transform: translateX(0px)
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
export const fadeIn = keyframes `
|
|
13
|
+
from {
|
|
14
|
+
opacity: 0;
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
export const zoomIn = keyframes `
|
|
18
|
+
0% {
|
|
19
|
+
scale: 1;
|
|
20
|
+
}
|
|
21
|
+
50% {
|
|
22
|
+
scale: 1.2;
|
|
23
|
+
}
|
|
24
|
+
100% {
|
|
25
|
+
scale: 1;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
export const slideIn = keyframes `
|
|
29
|
+
from{
|
|
30
|
+
transform: translateX(-100%);
|
|
31
|
+
}
|
|
32
|
+
to {
|
|
33
|
+
transform: translateX(0);
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
export const slideInBottom = keyframes `
|
|
37
|
+
from{
|
|
38
|
+
transform: translateY(100%);
|
|
39
|
+
}
|
|
40
|
+
to {
|
|
41
|
+
transform: translateY(0);
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
export const scale = keyframes `
|
|
45
|
+
from {
|
|
46
|
+
transform: scale(0)
|
|
47
|
+
}
|
|
48
|
+
to {
|
|
49
|
+
transform: scale(1)
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
export const pulseAnimation = (clr, shadowBlur = 12) => keyframes `
|
|
53
|
+
0% {
|
|
54
|
+
transform: scale(0.95);
|
|
55
|
+
box-shadow: 0 0 0 0 ${clr}b2;
|
|
56
|
+
}
|
|
57
|
+
70% {
|
|
58
|
+
transform: scale(1);
|
|
59
|
+
box-shadow: 0 0 0 ${shadowBlur}px ${clr}00;
|
|
60
|
+
}
|
|
61
|
+
100% {
|
|
62
|
+
transform: scale(0.95);
|
|
63
|
+
box-shadow: 0 0 0 0 ${clr}00;
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
export const rotateSlideBarIcons = keyframes `
|
|
67
|
+
0% {
|
|
68
|
+
transform: scale(1) rotate(0deg);
|
|
69
|
+
}
|
|
70
|
+
50% {
|
|
71
|
+
transform: scale(0.5) rotate(90deg);
|
|
72
|
+
}
|
|
73
|
+
100% {
|
|
74
|
+
transform: scale(1) rotate(360deg);
|
|
75
|
+
}`;
|
|
76
|
+
export const rotate = (angle) => keyframes `
|
|
77
|
+
0% {
|
|
78
|
+
transform: rotate(0deg);
|
|
79
|
+
}
|
|
80
|
+
100% {
|
|
81
|
+
transform: rotate(${angle});
|
|
82
|
+
}`;
|
|
83
|
+
export const ring = keyframes `
|
|
84
|
+
0% { -webkit-transform: rotateZ(0); }
|
|
85
|
+
1% { -webkit-transform: rotateZ(30deg); }
|
|
86
|
+
3% { -webkit-transform: rotateZ(-28deg); }
|
|
87
|
+
5% { -webkit-transform: rotateZ(34deg); }
|
|
88
|
+
7% { -webkit-transform: rotateZ(-32deg); }
|
|
89
|
+
9% { -webkit-transform: rotateZ(30deg); }
|
|
90
|
+
11% { -webkit-transform: rotateZ(-28deg); }
|
|
91
|
+
13% { -webkit-transform: rotateZ(26deg); }
|
|
92
|
+
15% { -webkit-transform: rotateZ(-24deg); }
|
|
93
|
+
17% { -webkit-transform: rotateZ(22deg); }
|
|
94
|
+
19% { -webkit-transform: rotateZ(-20deg); }
|
|
95
|
+
21% { -webkit-transform: rotateZ(18deg); }
|
|
96
|
+
23% { -webkit-transform: rotateZ(-16deg); }
|
|
97
|
+
25% { -webkit-transform: rotateZ(14deg); }
|
|
98
|
+
27% { -webkit-transform: rotateZ(-12deg); }
|
|
99
|
+
29% { -webkit-transform: rotateZ(10deg); }
|
|
100
|
+
31% { -webkit-transform: rotateZ(-8deg); }
|
|
101
|
+
33% { -webkit-transform: rotateZ(6deg); }
|
|
102
|
+
35% { -webkit-transform: rotateZ(-4deg); }
|
|
103
|
+
37% { -webkit-transform: rotateZ(2deg); }
|
|
104
|
+
39% { -webkit-transform: rotateZ(-1deg); }
|
|
105
|
+
41% { -webkit-transform: rotateZ(1deg); }
|
|
106
|
+
43% { -webkit-transform: rotateZ(0); }
|
|
107
|
+
100% { -webkit-transform: rotateZ(0); }
|
|
108
|
+
`;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
export const typographyProps = {
|
|
2
|
+
MuiTypography: {
|
|
3
|
+
defaultProps: {
|
|
4
|
+
variantMapping: {
|
|
5
|
+
text_xl_regular: "p",
|
|
6
|
+
text_lg_regular: "p",
|
|
7
|
+
text_md_regular: "p",
|
|
8
|
+
text_sm_regular: "p",
|
|
9
|
+
text_xs_regular: "p",
|
|
10
|
+
text_2xs_regular: "p",
|
|
11
|
+
text_xl_bold: "p",
|
|
12
|
+
text_lg_bold: "p",
|
|
13
|
+
text_md_bold: "p",
|
|
14
|
+
text_sm_bold: "p",
|
|
15
|
+
text_xs_bold: "p",
|
|
16
|
+
text_2xs_bold: "p",
|
|
17
|
+
text_xl_semibold: "p",
|
|
18
|
+
text_lg_semibold: "p",
|
|
19
|
+
text_md_semibold: "p",
|
|
20
|
+
text_sm_semibold: "p",
|
|
21
|
+
text_xs_semibold: "p",
|
|
22
|
+
text_2xs_semibold: "p",
|
|
23
|
+
text_xl_thin: "p",
|
|
24
|
+
text_lg_thin: "p",
|
|
25
|
+
text_md_thin: "p",
|
|
26
|
+
text_sm_thin: "p",
|
|
27
|
+
text_xs_thin: "p",
|
|
28
|
+
text_2xs_thin: "p",
|
|
29
|
+
display_2xl_regular: "h1",
|
|
30
|
+
display_xl_regular: "h2",
|
|
31
|
+
display_lg_regular: "h3",
|
|
32
|
+
display_md_regular: "h4",
|
|
33
|
+
display_sm_regular: "h5",
|
|
34
|
+
display_xs_regular: "h6",
|
|
35
|
+
display_2xl_bold: "h1",
|
|
36
|
+
display_xl_bold: "h2",
|
|
37
|
+
display_lg_bold: "h3",
|
|
38
|
+
display_md_bold: "h4",
|
|
39
|
+
display_sm_bold: "h5",
|
|
40
|
+
display_xs_bold: "h6",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
export const typographyVariants = {
|
|
46
|
+
// TEXT_REGULAR
|
|
47
|
+
text_xl_regular: {
|
|
48
|
+
font: "400 20px/30px inherit inherit",
|
|
49
|
+
},
|
|
50
|
+
text_lg_regular: {
|
|
51
|
+
font: "400 18px/28px inherit inherit",
|
|
52
|
+
},
|
|
53
|
+
text_md_regular: {
|
|
54
|
+
font: "400 16px/24px inherit inherit",
|
|
55
|
+
},
|
|
56
|
+
text_sm_regular: {
|
|
57
|
+
font: "400 14px/20px inherit inherit",
|
|
58
|
+
},
|
|
59
|
+
text_xs_regular: {
|
|
60
|
+
font: "400 12px/18px inherit inherit",
|
|
61
|
+
},
|
|
62
|
+
text_2xs_regular: {
|
|
63
|
+
font: "400 10px/14px inherit inherit",
|
|
64
|
+
},
|
|
65
|
+
// TEXT_BOLD
|
|
66
|
+
text_xl_bold: {
|
|
67
|
+
font: "600 20px/30px inherit inherit",
|
|
68
|
+
},
|
|
69
|
+
text_lg_bold: {
|
|
70
|
+
font: "700 18px/28px inherit inherit",
|
|
71
|
+
},
|
|
72
|
+
text_md_bold: {
|
|
73
|
+
font: "700 16px/24px inherit inherit",
|
|
74
|
+
},
|
|
75
|
+
text_sm_bold: {
|
|
76
|
+
font: "700 14px/20px inherit inherit",
|
|
77
|
+
},
|
|
78
|
+
text_xs_bold: {
|
|
79
|
+
font: "700 12px/18px inherit inherit",
|
|
80
|
+
},
|
|
81
|
+
text_2xs_bold: {
|
|
82
|
+
font: "700 10px/14px inherit inherit",
|
|
83
|
+
},
|
|
84
|
+
// TEXT_SEMIBOLD
|
|
85
|
+
text_xl_semibold: {
|
|
86
|
+
font: "600 20px/30px inherit inherit",
|
|
87
|
+
},
|
|
88
|
+
text_lg_semibold: {
|
|
89
|
+
font: "600 18px/28px inherit inherit",
|
|
90
|
+
},
|
|
91
|
+
text_md_semibold: {
|
|
92
|
+
font: "600 16px/24px inherit inherit",
|
|
93
|
+
},
|
|
94
|
+
text_sm_semibold: {
|
|
95
|
+
font: "600 14px/20px inherit inherit",
|
|
96
|
+
},
|
|
97
|
+
text_xs_semibold: {
|
|
98
|
+
font: "600 12px/18px inherit inherit",
|
|
99
|
+
},
|
|
100
|
+
text_2xs_semibold: {
|
|
101
|
+
font: "600 10px/14px inherit inherit",
|
|
102
|
+
},
|
|
103
|
+
// TEXT_THIN
|
|
104
|
+
text_xl_thin: {
|
|
105
|
+
font: "100 20px/30px inherit inherit",
|
|
106
|
+
},
|
|
107
|
+
text_lg_thin: {
|
|
108
|
+
font: "100 18px/28px inherit inherit",
|
|
109
|
+
},
|
|
110
|
+
text_md_thin: {
|
|
111
|
+
font: "100 16px/24px inherit inherit",
|
|
112
|
+
},
|
|
113
|
+
text_sm_thin: {
|
|
114
|
+
font: "100 14px/20px inherit inherit",
|
|
115
|
+
},
|
|
116
|
+
text_xs_thin: {
|
|
117
|
+
font: "100 12px/18px inherit inherit",
|
|
118
|
+
},
|
|
119
|
+
text_2xs_thin: {
|
|
120
|
+
font: "100 10px/14px inherit inherit",
|
|
121
|
+
},
|
|
122
|
+
// DISPLAY_REGULAR
|
|
123
|
+
display_2xl_regular: {
|
|
124
|
+
font: "400 72px/90px inherit inherit",
|
|
125
|
+
},
|
|
126
|
+
display_xl_regular: {
|
|
127
|
+
font: "400 60px/72px inherit inherit",
|
|
128
|
+
},
|
|
129
|
+
display_lg_regular: {
|
|
130
|
+
font: "400 48px/60px inherit inherit",
|
|
131
|
+
},
|
|
132
|
+
display_md_regular: {
|
|
133
|
+
font: "400 36px/44px inherit inherit",
|
|
134
|
+
},
|
|
135
|
+
display_sm_regular: {
|
|
136
|
+
font: "400 30px/38px inherit inherit",
|
|
137
|
+
},
|
|
138
|
+
display_xs_regular: {
|
|
139
|
+
font: "400 24px/32px inherit inherit",
|
|
140
|
+
},
|
|
141
|
+
// DISPLAY_BOLD
|
|
142
|
+
display_2xl_bold: {
|
|
143
|
+
font: "700 72px/90px inherit inherit",
|
|
144
|
+
},
|
|
145
|
+
display_xl_bold: {
|
|
146
|
+
font: "700 60px/72px inherit inherit",
|
|
147
|
+
},
|
|
148
|
+
display_lg_bold: {
|
|
149
|
+
font: "700 48px/60px inherit inherit",
|
|
150
|
+
},
|
|
151
|
+
display_md_bold: {
|
|
152
|
+
font: "700 36px/44px inherit inherit",
|
|
153
|
+
},
|
|
154
|
+
display_sm_bold: {
|
|
155
|
+
font: "700 30px/38px inherit inherit",
|
|
156
|
+
},
|
|
157
|
+
display_xs_bold: {
|
|
158
|
+
font: "700 24px/32px inherit inherit",
|
|
159
|
+
},
|
|
160
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a greeting based on the current time.
|
|
3
|
+
* @returns {string} The appropriate greeting.
|
|
4
|
+
*/
|
|
5
|
+
export const displayGreeting = () => {
|
|
6
|
+
const currentTime = new Date();
|
|
7
|
+
const currentHour = currentTime.getHours();
|
|
8
|
+
let greeting;
|
|
9
|
+
if (currentHour < 12 && currentHour >= 5) {
|
|
10
|
+
greeting = 'Доброе утро,';
|
|
11
|
+
}
|
|
12
|
+
else if (currentHour < 18 && currentHour > 12) {
|
|
13
|
+
greeting = 'Добрый день,';
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
greeting = 'Добрый вечер,';
|
|
17
|
+
}
|
|
18
|
+
return greeting;
|
|
19
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function to extract year, month, and day from a Date object
|
|
3
|
+
*/
|
|
4
|
+
export const getDayIdentifier = (date) => {
|
|
5
|
+
const year = date.getFullYear();
|
|
6
|
+
const month = String(date.getMonth() + 1).padStart(2, "0"); // Months are zero-based in JavaScript
|
|
7
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
8
|
+
return `${year}-${month}-${day}`;
|
|
9
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const { userAgent } = window.navigator;
|
|
2
|
+
const getOperatingSystem = () => {
|
|
3
|
+
if (/windows nt/i.test(userAgent))
|
|
4
|
+
return "Windows";
|
|
5
|
+
if (/iphone|ipad|ipod/i.test(userAgent))
|
|
6
|
+
return "iOS";
|
|
7
|
+
if (/mac/i.test(userAgent))
|
|
8
|
+
return "macOS";
|
|
9
|
+
if (/linux/i.test(userAgent))
|
|
10
|
+
return "Linux";
|
|
11
|
+
if (/android/i.test(userAgent))
|
|
12
|
+
return "Android";
|
|
13
|
+
return "Unknown";
|
|
14
|
+
};
|
|
15
|
+
const getBrowser = () => {
|
|
16
|
+
if (/chrome/i.test(userAgent) && !/edge/i.test(userAgent))
|
|
17
|
+
return "Chrome";
|
|
18
|
+
if (/firefox/i.test(userAgent))
|
|
19
|
+
return "Firefox";
|
|
20
|
+
if (/safari/i.test(userAgent) && !/chrome/i.test(userAgent))
|
|
21
|
+
return "Safari";
|
|
22
|
+
if (/edg/i.test(userAgent))
|
|
23
|
+
return "Edge";
|
|
24
|
+
return "Unknown";
|
|
25
|
+
};
|
|
26
|
+
export const systemInfo = { os: getOperatingSystem(), browser: getBrowser() };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { systemInfo } from "./getSystemInfo";
|
|
2
|
+
export { timeAgo, timeAgoFromStart } from "./timeAgo";
|
|
3
|
+
export { displayGreeting } from "./displayGreeting";
|
|
4
|
+
export { getDayIdentifier } from "./getDayIdentifier";
|
|
5
|
+
export { useResponsiveDisplay } from "./useResponsiveDisplay";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { systemInfo } from "./getSystemInfo";
|
|
2
|
+
export { timeAgo, timeAgoFromStart } from "./timeAgo";
|
|
3
|
+
export { displayGreeting } from "./displayGreeting";
|
|
4
|
+
export { getDayIdentifier } from "./getDayIdentifier";
|
|
5
|
+
export { useResponsiveDisplay } from "./useResponsiveDisplay";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a given date to a human-readable relative time string.
|
|
3
|
+
*
|
|
4
|
+
* @param {Date} date - The date to be converted.
|
|
5
|
+
* @param lang
|
|
6
|
+
* @returns {string} A string representing the relative time using `Intl` format (e.g., "2 days ago").
|
|
7
|
+
*/
|
|
8
|
+
export declare const timeAgo: (date: Date, lang?: string) => string;
|
|
9
|
+
export declare const timeAgoFromStart: (date: Date, lang?: string) => string;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a given date to a human-readable relative time string.
|
|
3
|
+
*
|
|
4
|
+
* @param {Date} date - The date to be converted.
|
|
5
|
+
* @param lang
|
|
6
|
+
* @returns {string} A string representing the relative time using `Intl` format (e.g., "2 days ago").
|
|
7
|
+
*/
|
|
8
|
+
export const timeAgo = (date, lang = navigator.language || 'en-US') => {
|
|
9
|
+
// Get the current date and time
|
|
10
|
+
const now = new Date();
|
|
11
|
+
date = new Date(date);
|
|
12
|
+
// Calculate the time difference in seconds
|
|
13
|
+
const diffInSeconds = Math.floor((now.getTime() - date.getTime()) / 1000);
|
|
14
|
+
// Create an Intl.RelativeTimeFormat instance with the user's language
|
|
15
|
+
const rtf = new Intl.RelativeTimeFormat(lang, { numeric: 'auto' });
|
|
16
|
+
// Determine the appropriate unit and format the result
|
|
17
|
+
if (diffInSeconds < 60) {
|
|
18
|
+
return rtf.format(-diffInSeconds, 'second');
|
|
19
|
+
}
|
|
20
|
+
if (diffInSeconds < 3600) {
|
|
21
|
+
const minutes = Math.floor(diffInSeconds / 60);
|
|
22
|
+
return rtf.format(-minutes, 'minute');
|
|
23
|
+
}
|
|
24
|
+
if (diffInSeconds < 86_400) {
|
|
25
|
+
const hours = Math.floor(diffInSeconds / 3600);
|
|
26
|
+
return rtf.format(-hours, 'hour');
|
|
27
|
+
}
|
|
28
|
+
const days = Math.floor(diffInSeconds / 86_400);
|
|
29
|
+
return rtf.format(-days, 'day');
|
|
30
|
+
};
|
|
31
|
+
export const timeAgoFromStart = (date, lang = navigator.language || 'en-US') => {
|
|
32
|
+
const now = new Date();
|
|
33
|
+
date = new Date(date);
|
|
34
|
+
const difference = (date.getTime() - now.getTime()) / 1000;
|
|
35
|
+
const differenceHours = Math.floor(difference / (60 * 60));
|
|
36
|
+
const differenceMinutes = Math.floor((difference - 60 * 60 * differenceHours) / 60);
|
|
37
|
+
const diffInSeconds = Math.floor(difference - 60 * 60 * differenceHours - 60 * differenceMinutes);
|
|
38
|
+
const rtf = new Intl.RelativeTimeFormat(lang, { numeric: 'auto' });
|
|
39
|
+
if (differenceMinutes === 0 && diffInSeconds < 60) {
|
|
40
|
+
return rtf.format(diffInSeconds, 'second');
|
|
41
|
+
}
|
|
42
|
+
if (differenceHours === 0 && differenceMinutes < 60) {
|
|
43
|
+
return rtf.format(differenceMinutes, 'minute');
|
|
44
|
+
}
|
|
45
|
+
if (differenceHours < 24) {
|
|
46
|
+
const hours = `${new Intl.RelativeTimeFormat(lang, { numeric: 'auto' }).format(differenceHours, 'hour')}`;
|
|
47
|
+
const minutes = ` ${new Intl.RelativeTimeFormat(lang, {
|
|
48
|
+
localeMatcher: 'lookup',
|
|
49
|
+
numeric: 'always',
|
|
50
|
+
style: 'long',
|
|
51
|
+
}).format(differenceMinutes, 'minute')}`.replace(/^\D+/, '');
|
|
52
|
+
return `${hours} ${minutes}`;
|
|
53
|
+
}
|
|
54
|
+
const days = Math.floor(diffInSeconds / 86_400);
|
|
55
|
+
return rtf.format(days, 'day');
|
|
56
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A custom React hook to determine if the current device is a smaller device
|
|
3
|
+
* based on the screen width.
|
|
4
|
+
* @param [breakpoint=768] - The breakpoint in pixels at which a device is considered "smaller".
|
|
5
|
+
* @returns {boolean} - A boolean value indicating whether the current device is a smaller device.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useResponsiveDisplay: (breakpoint?: number) => boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A custom React hook to determine if the current device is a smaller device
|
|
4
|
+
* based on the screen width.
|
|
5
|
+
* @param [breakpoint=768] - The breakpoint in pixels at which a device is considered "smaller".
|
|
6
|
+
* @returns {boolean} - A boolean value indicating whether the current device is a smaller device.
|
|
7
|
+
*/
|
|
8
|
+
export const useResponsiveDisplay = (breakpoint = 768) => {
|
|
9
|
+
const [isSmallerDevice, setIsSmallerDevice] = useState(false);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const checkScreenSize = () => {
|
|
12
|
+
setIsSmallerDevice(window.innerWidth < breakpoint);
|
|
13
|
+
};
|
|
14
|
+
checkScreenSize();
|
|
15
|
+
const handleResize = () => checkScreenSize();
|
|
16
|
+
window.addEventListener("resize", handleResize);
|
|
17
|
+
return () => {
|
|
18
|
+
window.removeEventListener("resize", handleResize);
|
|
19
|
+
};
|
|
20
|
+
}, [breakpoint]);
|
|
21
|
+
return isSmallerDevice;
|
|
22
|
+
};
|
package/package.json
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomazing-org/design-system",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
|
+
"main": "build/index.js",
|
|
5
6
|
"type": "module",
|
|
7
|
+
"types": "build/types/index.d.ts",
|
|
6
8
|
"files": [
|
|
7
|
-
"
|
|
9
|
+
"build",
|
|
10
|
+
"README.MD"
|
|
8
11
|
],
|
|
9
12
|
"scripts": {
|
|
10
|
-
"build": "npx tsc"
|
|
11
|
-
"format": "npm run format:eslint && npm run format:prettier",
|
|
12
|
-
"format:eslint": "npm run lint:eslint -- --fix",
|
|
13
|
-
"format:prettier": "npm run lint:prettier -- --write",
|
|
14
|
-
"lint": "npm run lint:eslint && npm run lint:prettier && npm run lint:ts",
|
|
15
|
-
"lint:eslint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
16
|
-
"lint:prettier": "prettier \"**/*.{json,js,ts,tsx}\" --check",
|
|
17
|
-
"lint:ts": "tsc --noEmit",
|
|
18
|
-
"clean": "rimraf node_modules"
|
|
13
|
+
"build": "npx tsc"
|
|
19
14
|
},
|
|
20
15
|
"homepage": "https://github.com/atomazing/design-system",
|
|
21
16
|
"keywords": [
|
|
@@ -32,18 +27,12 @@
|
|
|
32
27
|
"license": "MIT",
|
|
33
28
|
"description": "A library providing a set of useful utils, mui style extensions and components to build your application.",
|
|
34
29
|
"devDependencies": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"@types/react": "18.3.3"
|
|
30
|
+
"typescript": "^5.7.3",
|
|
31
|
+
"@types/react": "^18.3.3"
|
|
38
32
|
},
|
|
39
33
|
"peerDependencies": {
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"@
|
|
43
|
-
"@mui/icons-material": "5.15.11",
|
|
44
|
-
"@emotion/css": "11.11.2",
|
|
45
|
-
"@emotion/styled": "11.11.0",
|
|
46
|
-
"@emotion/react": "11.11.4",
|
|
47
|
-
"prettier": "3.3.2"
|
|
34
|
+
"@mui/material": "^5.15.21",
|
|
35
|
+
"@mui/icons-material": "^5.15.11",
|
|
36
|
+
"@emotion/css": "^11.11.2"
|
|
48
37
|
}
|
|
49
38
|
}
|