Skip to content

Commit eaea58b

Browse files
authored
Some ui improvements (#1716)
1 parent c67983c commit eaea58b

12 files changed

Lines changed: 843 additions & 666 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
.root {
2+
--bg-color: white;
3+
--height: var(--layout-nav-height, 54px);
4+
5+
width: 100%;
6+
height: var(--height);
7+
position: fixed;
8+
padding: 0;
9+
padding-inline: var(--spacing-base);
10+
z-index: 999;
11+
background-color: var(--bg-color);
12+
transition: none;
13+
14+
:global {
15+
.ant-switch-handle {
16+
top: 1px !important;
17+
}
18+
}
19+
}
20+
21+
.rootDark {
22+
--bg-color: #141414;
23+
}
24+
25+
.innerRoot {
26+
display: flex;
27+
justify-content: space-between;
28+
align-items: center;
29+
flex-wrap: nowrap;
30+
height: var(--height);
31+
}
32+
33+
.leftCol {
34+
height: var(--height);
35+
line-height: calc(var(--height) + 2px);
36+
}
37+
38+
.leftColInner {
39+
display: flex;
40+
justify-content: space-between;
41+
align-items: center;
42+
height: 100%;
43+
}
44+
45+
.rightCol {
46+
flex: 1;
47+
}
48+
49+
.rightColInner {
50+
display: flex;
51+
align-items: center;
52+
justify-content: flex-end;
53+
flex-wrap: nowrap;
54+
column-gap: calc(var(--spacing-base) / 3);
55+
height: var(--height);
56+
}
57+
58+
.rsdoctorLogo {
59+
width: auto;
60+
height: 30px;
61+
cursor: pointer;
62+
63+
&:active {
64+
opacity: 0.8;
65+
}
66+
}
67+
68+
.translationsIcon {
69+
--color-active: #40a9ff;
70+
--color-hover: #1668dc;
71+
72+
display: inline-block;
73+
font-size: 20px;
74+
text-align: center;
75+
vertical-align: middle;
76+
cursor: pointer;
77+
width: 30px;
78+
transition: all 0.3s ease;
79+
user-select: none;
80+
81+
&:hover {
82+
color: var(--color-hover);
83+
}
84+
85+
&:active {
86+
color: var(--color-active);
87+
}
88+
}

packages/components/src/components/Layout/header.scss

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

packages/components/src/components/Layout/header.tsx

Lines changed: 14 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { TranslationOutlined } from '@ant-design/icons';
22
import { Col, Dropdown, Layout, Row } from 'antd';
33
import React from 'react';
4-
import { Language, Size } from '../../constants';
4+
import { Language } from '../../constants';
55
import { useI18n, useTheme } from '../../utils';
66
import { OverlayAlertsWithButton } from '../Alerts';
77
import { BuilderSelect } from './builder-select';
88
import { Menus } from './menus';
9-
import './header.sass';
109
import { Client } from '@rsdoctor/types';
1110
import { useNavigate } from 'react-router-dom';
11+
import styles from './header.module.scss';
12+
import clsx from 'clsx';
1213

1314
export interface HeaderProps {
1415
enableRoutes?: string[];
@@ -18,58 +19,22 @@ export const Header: React.FC<HeaderProps> = ({ enableRoutes }) => {
1819
const { i18n } = useI18n();
1920

2021
const navigate = useNavigate();
21-
const { isLight } = useTheme();
22-
const iconStyle: React.CSSProperties = {
23-
display: 'inline-block',
24-
fontSize: 20,
25-
textAlign: 'center',
26-
verticalAlign: 'middle',
27-
cursor: 'pointer',
28-
width: 30,
29-
transition: 'all 0.3s ease',
30-
};
22+
const { isDark } = useTheme();
3123
const languages = [
3224
{ value: Language.Cn, label: '中文' },
3325
{ value: Language.En, label: 'English' },
3426
];
3527

3628
return (
37-
<Layout.Header
38-
style={{
39-
height: Size.NavBarHeight,
40-
padding: 0,
41-
paddingLeft: Size.BasePadding,
42-
paddingRight: Size.BasePadding,
43-
position: 'fixed',
44-
zIndex: 999,
45-
width: '100%',
46-
backgroundColor: isLight ? '#fff' : '#141414',
47-
transition: 'none',
48-
}}
49-
>
50-
<Row
51-
justify="space-between"
52-
align="middle"
53-
style={{ height: Size.NavBarHeight }}
54-
wrap={false}
55-
>
56-
<Col
57-
style={{
58-
height: Size.NavBarHeight,
59-
lineHeight: `${Size.NavBarHeight + 2}px`,
60-
}}
61-
>
62-
<div
63-
style={{
64-
display: 'flex',
65-
justifyContent: 'space-between',
66-
alignItems: 'center',
67-
height: '100%',
68-
}}
69-
>
29+
<Layout.Header className={clsx(styles.root, isDark && styles.rootDark)}>
30+
<Row className={styles.innerRoot}>
31+
<Col className={styles.leftCol}>
32+
<div className={styles.leftColInner}>
7033
<img
34+
width="1604"
35+
height="380"
7136
src="https://assets.rspack.rs/rsdoctor/rsdoctor-title-logo.png"
72-
className="rsdoctor-logo"
37+
className={styles.rsdoctorLogo}
7338
alt="logo"
7439
onClick={() => {
7540
if (
@@ -92,14 +57,8 @@ export const Header: React.FC<HeaderProps> = ({ enableRoutes }) => {
9257
style={{ transition: 'none' }}
9358
/>
9459

95-
<Col flex={1}>
96-
<Row
97-
align="middle"
98-
justify="end"
99-
style={{ height: Size.NavBarHeight }}
100-
wrap={false}
101-
gutter={[Size.BasePadding / 3, 0]}
102-
>
60+
<Col className={styles.rightCol}>
61+
<Row className={styles.rightColInner}>
10362
<Col>
10463
<OverlayAlertsWithButton />
10564
</Col>
@@ -130,10 +89,7 @@ export const Header: React.FC<HeaderProps> = ({ enableRoutes }) => {
13089
selectedKeys: [i18n.language],
13190
}}
13291
>
133-
<TranslationOutlined
134-
className="header-icon"
135-
style={iconStyle}
136-
/>
92+
<TranslationOutlined className={styles.translationsIcon} />
13793
</Dropdown>
13894
</Col>
13995
</Row>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.content {
2+
display: flex;
3+
flex-direction: column;
4+
min-height: calc(100dvh - var(--layout-nav-height));
5+
/* this is overridden with !important in pages/Overall/index.module.scss for whatever reason */
6+
padding: var(--spacing-base);
7+
margin-top: var(--layout-nav-height);
8+
background: var(--color-bg-main, initial);
9+
}

packages/components/src/components/Layout/index.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { ConfigContext } from '../../config';
1616
import { SDK } from '@rsdoctor/types';
1717
import { ServerAPIProvider } from '../Manifest';
1818
import { ProjectInfoContext } from './project-info-context';
19+
import styles from './index.module.scss';
1920

2021
export interface LayoutProps {
2122
children: React.JSX.Element;
@@ -72,6 +73,13 @@ export const Layout = (
7273
}, [query]);
7374

7475
const ctx = useContext(ConfigContext);
76+
const showHeader = !ctx.embedded;
77+
78+
const globalCssVars = {
79+
'--spacing-base': Size.BasePadding + 'px',
80+
'--layout-nav-height': showHeader ? Size.NavBarHeight + 'px' : '0px',
81+
'--color-bg-main': MAIN_BG,
82+
} as React.CSSProperties;
7583

7684
return (
7785
<ServerAPIProvider
@@ -80,19 +88,11 @@ export const Layout = (
8088
>
8189
{(project) => (
8290
<ProjectInfoContext.Provider value={{ project }}>
83-
<L>
91+
<L style={globalCssVars}>
8492
<TitleUpdater name={project?.name} />
85-
{!ctx.embedded ? <Header enableRoutes={enableRoutes} /> : null}
93+
{showHeader && <Header enableRoutes={enableRoutes} />}
8694
<Progress />
87-
<L.Content
88-
style={{
89-
height: '100%',
90-
minHeight: '100vh',
91-
padding: Size.BasePadding,
92-
marginTop: !ctx.embedded ? Size.NavBarHeight : 0,
93-
background: MAIN_BG,
94-
}}
95-
>
95+
<L.Content className={styles.content}>
9696
{children}
9797
<FloatButton.BackTop />
9898
</L.Content>

packages/components/src/pages/BundleSize/components/asset.module.scss

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
.bundle {
2-
display: flex;
3-
flex-direction: column;
4-
52
:global {
63
.rc-tree-node-content-wrapper {
74
// width: 100%;
@@ -26,23 +23,37 @@
2623
}
2724
}
2825

26+
.bundleBody {
27+
justify-content: flex-start;
28+
min-height: var(--body-min-height, initial);
29+
}
30+
31+
.bundle,
2932
.bundleBody {
3033
display: flex;
3134
flex-direction: column;
32-
justify-content: flex-start;
33-
min-height: var(--body-min-height, 600px);
35+
flex: 1;
3436
}
3537

3638
.bundleTree {
39+
--tree-min-height: 300px;
3740
--x-pad: 20px;
3841
--y-pad: 14px;
3942
--scrollbar-width: 10px;
4043
--x-pad-minus-scrollbar: calc(var(--x-pad) - var(--scrollbar-width));
44+
4145
display: flex;
4246
flex: 1;
47+
min-height: var(--tree-min-height);
4348
padding: var(--y-pad) var(--x-pad-minus-scrollbar) var(--y-pad) var(--x-pad);
4449
border: 1px solid rgba(235, 237, 241);
4550
border-radius: 8px;
51+
resize: vertical;
52+
53+
/* on smaller devices stop trying to keep the whole tree in viewport: let's expand it a little bit */
54+
@media (max-height: 900px) {
55+
--tree-min-height: 450px;
56+
}
4657
}
4758

4859
.bundleTreeViewport {

packages/components/src/pages/BundleSize/components/asset.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,11 @@ export const AssetDetail: React.FC<{
505505
className={styles.bundle}
506506
title={`Modules of "${asset.path}"`}
507507
style={
508-
{
509-
'--body-min-height': height + 'px',
510-
} as React.CSSProperties
508+
height
509+
? ({
510+
'--body-min-height': height + 'px',
511+
} as React.CSSProperties)
512+
: undefined
511513
}
512514
classNames={{
513515
body: styles.bundleBody,
@@ -590,6 +592,7 @@ const AssetDetailTree = memo(
590592
const ITEM_HEIGHT = 30;
591593
const PERMANENT_PERF_MODE = false;
592594
const DISABLE_PERF_MODE_SCROLL_DELAY = 150;
595+
const ENABLE_ANIMATIONS = false;
593596

594597
// disable all the tooltips and popovers inside the tree?
595598
const [performanceMode, setPerformanceMode] = useState(PERMANENT_PERF_MODE);
@@ -725,6 +728,7 @@ const AssetDetailTree = memo(
725728
: []
726729
}
727730
treeData={treeData as AntdDataNode[]}
731+
motion={ENABLE_ANIMATIONS ? undefined : false}
728732
/>
729733
) : (
730734
<Empty

0 commit comments

Comments
 (0)