Skip to content

Commit 73c2eaa

Browse files
committed
fix: fixed dashboard ui
1 parent e9fa432 commit 73c2eaa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+731
-574
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"scripts": {
1010
"start": "vite",
11-
"start:dev": "vite-live-preview --reload --port=8443",
11+
"start:dev": "vite-live-preview --reload --port=8444",
1212
"build": "vite build",
1313
"preview": "vite preview",
1414
"test:lint": "prettier --log-level silent --write . && eslint \"./src/**/*.?(js|jsx|ts|tsx)\"",

public/ic-bot-builder.svg

+4
Loading

public/ic-cross.svg

+1
Loading

public/ic-delete.svg

+1
Loading

public/ic-google-drive.svg

+1
Loading

public/ic-my-computer.svg

+4
Loading

public/ic-open.svg

+1
Loading

public/ic-quick-strategy.svg

+6
Loading

public/ic-save.svg

+1
Loading

public/ic-user-guide.svg

+1
Loading

src/components/load-modal/load-modal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { tabs_title } from '@/constants/load-modal';
66
import { useStore } from '@/hooks/useStore';
77
import { localize } from '@/utils/tmp/dummy';
88

9-
import GoogleDrive from '../../pages/dashboard/load-bot-preview/google-drive';
9+
import GoogleDrive from '../../pages/dashboard/common/google-drive';
1010
import MobileFullPageModal from '../shared_ui/mobile-full-page-modal';
1111

1212
import Local from './local';
+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
/** @define dc-dialog */
2+
3+
.dc-dialog {
4+
width: 100vw;
5+
height: 100vh;
6+
display: flex;
7+
align-items: center;
8+
justify-content: center;
9+
text-align: center;
10+
flex-direction: column;
11+
z-index: 999;
12+
position: absolute;
13+
top: 0;
14+
left: 0;
15+
right: 0;
16+
bottom: 0;
17+
18+
&__wrapper {
19+
position: fixed;
20+
left: 0;
21+
top: 0;
22+
width: 100%;
23+
height: 100%;
24+
display: flex;
25+
align-items: center;
26+
justify-content: center;
27+
z-index: 999;
28+
transition: opacity 0.25s cubic-bezier(0.25, 0.1, 0.1, 0.25);
29+
background-color: var(--overlay-outside-dialog);
30+
31+
&--enter,
32+
&--exit {
33+
opacity: 0;
34+
35+
.dc-dialog__dialog {
36+
transform: translate3d(0, 50px, 0);
37+
opacity: 0;
38+
}
39+
}
40+
&--enter-done {
41+
opacity: 1;
42+
43+
.dc-dialog__dialog {
44+
transform: translate3d(0, 0, 0);
45+
opacity: 1;
46+
}
47+
}
48+
&--has-portal {
49+
background-color: transparent;
50+
}
51+
}
52+
&__dialog {
53+
max-width: 560px;
54+
max-height: 338px;
55+
min-width: 440px;
56+
min-height: 176px;
57+
margin-top: -#{$HEADER_HEIGHT};
58+
padding: 2.4rem;
59+
border-radius: 8px;
60+
box-sizing: border-box;
61+
display: flex;
62+
justify-content: space-around;
63+
flex-direction: column;
64+
align-items: center;
65+
box-shadow: 0 2px 8px 0 var(--shadow-menu);
66+
background-color: var(--general-main-2);
67+
transition:
68+
transform 0.25s cubic-bezier(0.25, 0.1, 0.1, 0.25),
69+
opacity 0.25s cubic-bezier(0.25, 0.1, 0.1, 0.25);
70+
}
71+
&__header {
72+
&-wrapper {
73+
width: 100%;
74+
display: flex;
75+
justify-content: space-between;
76+
align-items: center;
77+
margin-bottom: 1rem;
78+
&--end {
79+
justify-content: flex-end;
80+
}
81+
}
82+
&--title {
83+
align-self: flex-start;
84+
}
85+
&--close {
86+
cursor: pointer;
87+
}
88+
}
89+
&__content {
90+
align-self: flex-start;
91+
margin-bottom: 2.4rem;
92+
max-width: calc(440px - 4.8rem);
93+
width: 100%;
94+
95+
/* postcss-bem-linter: ignore */
96+
.dc-input__label {
97+
background-color: var(--general-main-2);
98+
}
99+
&--centered {
100+
align-self: center;
101+
}
102+
}
103+
&__footer {
104+
display: flex;
105+
justify-content: flex-end;
106+
align-items: center;
107+
width: 100%;
108+
@include mobile {
109+
flex-wrap: wrap;
110+
align-items: flex-start;
111+
}
112+
}
113+
&__button {
114+
margin-left: 0.8rem;
115+
height: 4rem;
116+
min-width: 6.4rem;
117+
border-width: 2px;
118+
@include mobile {
119+
&:not(:last-child) {
120+
margin-bottom: 1rem;
121+
}
122+
}
123+
}
124+
}
125+
126+
@media screen and (max-width: 560px) {
127+
.dc-dialog {
128+
&__dialog {
129+
min-width: auto;
130+
131+
&--has-margin {
132+
min-width: unset;
133+
width: calc(100vw - 4.8rem);
134+
}
135+
}
136+
}
137+
}
+204
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
import React from 'react';
2+
import classNames from 'classnames';
3+
import ReactDOM from 'react-dom';
4+
import { CSSTransition } from 'react-transition-group';
5+
// import Icon from '../icon/icon';
6+
// import Button from '../button/button';
7+
import Text from '../text';
8+
// import { useOnClickOutside } from '../../hooks';
9+
10+
type TDialog = {
11+
cancel_button_text?: string;
12+
className?: string;
13+
confirm_button_text?: string;
14+
dismissable?: boolean;
15+
disableApp?: () => void;
16+
enableApp?: () => void;
17+
has_close_icon?: boolean;
18+
is_closed_on_cancel?: boolean;
19+
is_closed_on_confirm?: boolean;
20+
is_content_centered?: boolean;
21+
is_loading?: boolean;
22+
is_mobile_full_width?: boolean;
23+
is_visible: boolean;
24+
onCancel?: () => void;
25+
onClose?: () => void;
26+
onConfirm: () => void;
27+
onEscapeButtonCancel?: () => void;
28+
portal_element_id?: string;
29+
title?: React.ReactNode;
30+
};
31+
32+
const Dialog = ({
33+
disableApp,
34+
// dismissable,
35+
enableApp,
36+
is_closed_on_cancel = true,
37+
is_closed_on_confirm = true,
38+
is_visible,
39+
onCancel,
40+
onClose,
41+
onConfirm,
42+
onEscapeButtonCancel,
43+
...other_props
44+
}: React.PropsWithChildren<TDialog>) => {
45+
const {
46+
cancel_button_text,
47+
className,
48+
children,
49+
confirm_button_text,
50+
is_loading,
51+
is_mobile_full_width = true,
52+
is_content_centered,
53+
portal_element_id,
54+
title,
55+
has_close_icon,
56+
} = other_props;
57+
58+
const wrapper_ref = React.useRef() as React.MutableRefObject<HTMLInputElement>;
59+
60+
React.useEffect(() => {
61+
if (is_visible && !!disableApp) {
62+
disableApp();
63+
}
64+
}, [is_visible, disableApp]);
65+
66+
React.useEffect(() => {
67+
const close = (e: { key: string }) => {
68+
if (e.key === 'Escape') {
69+
onEscapeButtonCancel?.();
70+
}
71+
};
72+
window.addEventListener('keydown', close);
73+
return () => window.removeEventListener('keydown', close);
74+
// eslint-disable-next-line react-hooks/exhaustive-deps
75+
}, []);
76+
77+
const handleCancel = () => {
78+
if (is_closed_on_cancel && enableApp) {
79+
enableApp();
80+
}
81+
onCancel?.();
82+
};
83+
84+
const handleConfirm = () => {
85+
if (is_closed_on_confirm && enableApp) {
86+
enableApp();
87+
}
88+
onConfirm();
89+
};
90+
91+
const handleClose = () => {
92+
if (onClose) {
93+
onClose();
94+
} else if (onCancel) {
95+
handleCancel();
96+
} else {
97+
handleConfirm();
98+
}
99+
};
100+
101+
// const validateClickOutside = () => !!dismissable || !!(has_close_icon && is_visible && is_closed_on_cancel);
102+
103+
// useOnClickOutside(wrapper_ref, handleClose, validateClickOutside);
104+
105+
const content_classes = classNames('dc-dialog__content', {
106+
'dc-dialog__content--centered': is_content_centered,
107+
});
108+
//
109+
const is_text =
110+
typeof children === 'string' ||
111+
(React.isValidElement(children) && typeof children?.props?.i18n_default_text === 'string');
112+
const dialog = (
113+
<CSSTransition
114+
appear
115+
in={is_visible && !is_loading}
116+
timeout={50}
117+
classNames={{
118+
appear: 'dc-dialog__wrapper--enter',
119+
enter: 'dc-dialog__wrapper--enter',
120+
enterDone: 'dc-dialog__wrapper--enter-done',
121+
exit: 'dc-dialog__wrapper--exit',
122+
}}
123+
unmountOnExit
124+
>
125+
<div
126+
className={classNames('dc-dialog__wrapper', className, {
127+
'dc-dialog__wrapper--has-portal': !!portal_element_id,
128+
})}
129+
>
130+
<div
131+
className={classNames('dc-dialog__dialog', {
132+
'dc-dialog__dialog--has-margin': !is_mobile_full_width,
133+
})}
134+
role='dialog'
135+
ref={wrapper_ref}
136+
>
137+
{(title || has_close_icon) && (
138+
<div
139+
className={classNames('dc-dialog__header-wrapper', {
140+
'dc-dialog__header-wrapper--end': !title,
141+
})}
142+
>
143+
{!!title && (
144+
<Text as='h1' color='prominent' weight='bold' className='dc-dialog__header--title'>
145+
{title}
146+
</Text>
147+
)}
148+
{has_close_icon && (
149+
<div onClick={handleClose} className='dc-dialog__header--close'>
150+
<img src='/ic-cross.svg'/>
151+
{/* <Icon icon='IcCross' /> */}
152+
</div>
153+
)}
154+
</div>
155+
)}
156+
{is_text ? (
157+
<Text as='p' size='xs' styles={{ lineHeight: '1.43' }} className={content_classes}>
158+
{children}
159+
</Text>
160+
) : (
161+
<div className={content_classes}>{children}</div>
162+
)}
163+
<div className='dc-dialog__footer'>
164+
{!!onCancel && (
165+
// <Button
166+
// className='dc-dialog__button'
167+
// has_effect
168+
// text={cancel_button_text}
169+
// onClick={handleCancel}
170+
// secondary
171+
// large
172+
// />
173+
<button className='dc-dialog__button' onClick={handleCancel}>
174+
{cancel_button_text}
175+
</button>
176+
)}
177+
{!!confirm_button_text && (
178+
// <Button
179+
// className='dc-dialog__button'
180+
// has_effect
181+
// text={confirm_button_text}
182+
// onClick={handleConfirm}
183+
// primary
184+
// large
185+
// />
186+
<button className='dc-dialog__button' onClick={handleConfirm}>
187+
{confirm_button_text}
188+
</button>
189+
)}
190+
</div>
191+
</div>
192+
</div>
193+
</CSSTransition>
194+
);
195+
196+
if (portal_element_id) {
197+
const target_element = document.getElementById(portal_element_id);
198+
if (target_element) return ReactDOM.createPortal(dialog, target_element);
199+
}
200+
201+
return dialog;
202+
};
203+
204+
export default Dialog;

0 commit comments

Comments
 (0)