Skip to content

Commit c8457c2

Browse files
Cb 3960 migrate core blocks components to css modules (#2578)
* CB-3960 removes unused SlideBox styles * CB-3960 makes menu panel reshadowless * CB-3960 makes menu bar small item reshadowless * CB-3960 removes reshadow from loaders * fix: loader styles are the same as was * fix: CB-3960 fix hidden actions in table footer * fix: menu trigger --------- Co-authored-by: mr-anton-t <[email protected]>
1 parent 1f3ae6a commit c8457c2

File tree

18 files changed

+534
-567
lines changed

18 files changed

+534
-567
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*
2+
* CloudBeaver - Cloud Database Manager
3+
* Copyright (C) 2020-2024 DBeaver Corp and others
4+
*
5+
* Licensed under the Apache License, Version 2.0.
6+
* you may not use this file except in compliance with the License.
7+
*/
8+
9+
.loader {
10+
margin: auto;
11+
display: flex;
12+
flex-direction: column;
13+
justify-content: center;
14+
align-items: center;
15+
opacity: 0;
16+
transition: opacity cubic-bezier(0.4, 0, 0.2, 1) 0.3s;
17+
&:global(.animate) {
18+
opacity: 1;
19+
}
20+
& .staticImage {
21+
height: 100%;
22+
width: 100%;
23+
display: none;
24+
}
25+
&.secondary,
26+
&.overlay,
27+
&:global(.secondary),
28+
&:global(.overlay) {
29+
&:not(.small):not(:global(.small)) {
30+
& .staticImage.secondaryIcon {
31+
display: block;
32+
}
33+
}
34+
&.small,
35+
&:global(.small) {
36+
& .staticImage.secondarySmallIcon {
37+
display: block;
38+
}
39+
}
40+
}
41+
&:not(.secondary):not(.overlay):not(:global(.secondary)):not(:global(.overlay)) {
42+
&:not(.small):not(:global(.small)) {
43+
& .staticImage.primaryIcon {
44+
display: block;
45+
}
46+
}
47+
&.small,
48+
&:global(.small) {
49+
& .staticImage.primarySmallIcon {
50+
display: block;
51+
}
52+
}
53+
}
54+
}
55+
.icon {
56+
display: flex;
57+
align-items: center;
58+
justify-content: center;
59+
width: 40px;
60+
height: 40px;
61+
animation: rotation 2s infinite linear;
62+
}
63+
.message {
64+
padding: 16px;
65+
}
66+
.actions {
67+
padding-top: 42px;
68+
}
69+
.loader.inline {
70+
height: 38px;
71+
flex-direction: row;
72+
margin: 0;
73+
justify-content: left;
74+
& .icon {
75+
width: 24px;
76+
height: 24px;
77+
}
78+
& .message {
79+
display: block;
80+
padding: 0 16px;
81+
}
82+
& .actions {
83+
padding: 0;
84+
}
85+
}
86+
.loader.small {
87+
& .icon {
88+
width: 16px;
89+
height: 16px;
90+
}
91+
& .message {
92+
display: none;
93+
}
94+
}
95+
.loader.fullSize {
96+
height: 100%;
97+
& .icon {
98+
width: 100%;
99+
height: 100%;
100+
}
101+
}
102+
@keyframes rotation {
103+
from {
104+
transform: rotate(0deg);
105+
}
106+
to {
107+
transform: rotate(359deg);
108+
}
109+
}
110+
111+
.loaderOverlay {
112+
composes: theme-text-on-primary from global;
113+
position: absolute;
114+
top: 0;
115+
left: 0;
116+
width: 100%;
117+
height: 100%;
118+
background-color: rgba(0, 0, 0, 0.4);
119+
}

webapp/packages/core-blocks/src/Loader/Loader.tsx

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,18 @@
88
import { observable } from 'mobx';
99
import { observer } from 'mobx-react-lite';
1010
import { Suspense, useContext, useEffect, useRef, useState } from 'react';
11-
import styled, { use } from 'reshadow';
1211

13-
import type { ComponentStyle } from '@cloudbeaver/core-theming';
1412
import { ILoadableState, uuid } from '@cloudbeaver/core-utils';
1513

1614
import { Button } from '../Button';
1715
import { ErrorBoundary } from '../ErrorBoundary';
1816
import { ExceptionMessage } from '../ExceptionMessage';
1917
import { Translate } from '../localization/Translate';
18+
import { s } from '../s';
2019
import { StaticImage } from '../StaticImage';
21-
import { useStyles } from '../useStyles';
20+
import { useS } from '../useS';
21+
import styles from './Loader.m.css';
2222
import { ILoaderContext, LoaderContext } from './LoaderContext';
23-
import { loaderStyles, overlayStyles } from './loaderStyles';
2423

2524
type LoaderState =
2625
| ILoadableState
@@ -52,7 +51,6 @@ interface Props {
5251
className?: string;
5352
fullSize?: boolean;
5453
state?: LoaderState | LoaderState[];
55-
style?: ComponentStyle;
5654
children?: (() => React.ReactNode) | React.ReactNode;
5755
onCancel?: () => void;
5856
}
@@ -80,7 +78,6 @@ export const Loader = observer<Props>(function Loader({
8078
loading,
8179
inlineException,
8280
state,
83-
style,
8481
children,
8582
onCancel,
8683
}) {
@@ -171,7 +168,7 @@ export const Loader = observer<Props>(function Loader({
171168
loading = false;
172169
}
173170

174-
style = useStyles(loaderStyles, style, overlay && overlayStyles);
171+
const style = useS(styles);
175172
const [isVisible, setVisible] = useState(loading);
176173

177174
const refLoaderDisplayed = { state: false };
@@ -232,7 +229,6 @@ export const Loader = observer<Props>(function Loader({
232229
fullSize={fullSize}
233230
className={className}
234231
inlineException={inlineException}
235-
style={style}
236232
/>
237233
}
238234
>
@@ -251,7 +247,7 @@ export const Loader = observer<Props>(function Loader({
251247
if (hideException) {
252248
return null;
253249
}
254-
return styled(style)(<ExceptionMessage exception={exception} inline={inline || inlineException} className={className} onRetry={reload} />);
250+
return <ExceptionMessage exception={exception} inline={inline || inlineException} className={className} onRetry={reload} />;
255251
}
256252

257253
if (children && (!loader || !loading) && !overlay) {
@@ -274,31 +270,31 @@ export const Loader = observer<Props>(function Loader({
274270

275271
refLoaderDisplayed.state = true;
276272

277-
return styled(style)(
273+
return (
278274
<LoaderContext.Provider value={contextState}>
279275
<>
280276
{overlay && renderWrappedChildren()}
281-
<loader ref={loaderRef} className={className} {...use({ small, fullSize, inline, secondary, overlay })}>
282-
<icon>
283-
<StaticImage icon={spinnerType.primary} {...use({ primaryIcon: true })} />
284-
<StaticImage icon={spinnerType.primarySmall} {...use({ primarySmallIcon: true })} />
285-
<StaticImage icon={spinnerType.secondary} {...use({ secondaryIcon: true })} />
286-
<StaticImage icon={spinnerType.secondarySmall} {...use({ secondarySmallIcon: true })} />
287-
</icon>
277+
<div ref={loaderRef} className={s(style, { loader: true, loaderOverlay: overlay, small, fullSize, inline, secondary, overlay }, className)}>
278+
<div className={s(style, { icon: true })}>
279+
<StaticImage icon={spinnerType.primary} className={s(style, { staticImage: true, primaryIcon: true })} />
280+
<StaticImage icon={spinnerType.primarySmall} className={s(style, { staticImage: true, primarySmallIcon: true })} />
281+
<StaticImage icon={spinnerType.secondary} className={s(style, { staticImage: true, secondaryIcon: true })} />
282+
<StaticImage icon={spinnerType.secondarySmall} className={s(style, { staticImage: true, secondarySmallIcon: true })} />
283+
</div>
288284
{!hideMessage && (
289-
<message>
285+
<div className={s(style, { message: true })}>
290286
<Translate token={message || 'ui_processing_loading'} />
291-
</message>
287+
</div>
292288
)}
293289
{onCancel && (
294-
<actions>
290+
<div className={s(style, { actions: true })}>
295291
<Button type="button" mod={['unelevated']} disabled={cancelDisabled} onClick={onCancel}>
296292
<Translate token="ui_processing_cancel" />
297293
</Button>
298-
</actions>
294+
</div>
299295
)}
300-
</loader>
296+
</div>
301297
</>
302-
</LoaderContext.Provider>,
298+
</LoaderContext.Provider>
303299
);
304300
});

webapp/packages/core-blocks/src/Loader/loaderStyles.ts

Lines changed: 0 additions & 138 deletions
This file was deleted.

webapp/packages/core-blocks/src/Menu/MenuBarSmallItem.m.css

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,25 @@
1111
padding: 0;
1212
margin: 0;
1313
flex-shrink: 0;
14-
}
14+
}
15+
16+
.iconBox {
17+
composes: theme-form-element-radius theme-text-primary theme-ripple from global;
18+
box-sizing: border-box;
19+
overflow: hidden;
20+
padding: 4px !important;
21+
margin: 2px !important;
22+
flex-shrink: 0;
23+
height: 24px !important;
24+
display: flex;
25+
cursor: pointer;
26+
align-items: center;
27+
gap: 2px;
28+
user-select: none;
29+
outline: none;
30+
31+
& .iconLabel {
32+
text-transform: uppercase;
33+
font-weight: 500;
34+
}
35+
}

0 commit comments

Comments
 (0)