Skip to content

Commit 96f0ec6

Browse files
li-jia-nanMadCcc
andauthored
site: site style optimization (ant-design#48088)
* site: site style optimization * Update .dumi/theme/slots/Header/index.tsx Co-authored-by: MadCcc <[email protected]> Signed-off-by: lijianan <[email protected]> --------- Signed-off-by: lijianan <[email protected]> Co-authored-by: MadCcc <[email protected]>
1 parent 7c09fc0 commit 96f0ec6

File tree

4 files changed

+27
-35
lines changed

4 files changed

+27
-35
lines changed

.dumi/theme/slots/Header/Logo.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import * as React from 'react';
12
import { createStyles } from 'antd-style';
23
import { Link, useLocation } from 'dumi';
3-
import * as React from 'react';
4+
45
import * as utils from '../../utils';
56

67
const useStyle = createStyles(({ token, css }) => {

.dumi/theme/slots/Header/Navigation.tsx

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import * as React from 'react';
2-
import { FormattedMessage, useFullSidebarData, useLocation } from 'dumi';
32
import { MenuOutlined } from '@ant-design/icons';
4-
import { createStyles, css } from 'antd-style';
53
import type { MenuProps } from 'antd';
64
import { Menu } from 'antd';
7-
import * as utils from '../../utils';
8-
import type { SharedProps } from './interface';
5+
import { createStyles, css } from 'antd-style';
6+
import { FormattedMessage, useFullSidebarData, useLocation } from 'dumi';
7+
98
import useLocale from '../../../hooks/useLocale';
109
import Link from '../../common/Link';
10+
import * as utils from '../../utils';
11+
import type { SharedProps } from './interface';
1112

1213
// ============================= Theme =============================
1314
const locales = {
@@ -65,7 +66,7 @@ const useStyle = createStyles(({ token }) => {
6566
position: absolute;
6667
inset: 0;
6768
background-color: transparent;
68-
content: "";
69+
content: '';
6970
}
7071
}
7172
@@ -114,14 +115,8 @@ export interface NavigationProps extends SharedProps {
114115
onDirectionChange: () => void;
115116
}
116117

117-
export default ({
118-
isZhCN,
119-
isMobile,
120-
responsive,
121-
directionText,
122-
onLangChange,
123-
onDirectionChange,
124-
}: NavigationProps) => {
118+
const HeaderNavigation: React.FC<NavigationProps> = (props) => {
119+
const { isZhCN, isMobile, responsive, directionText, onLangChange, onDirectionChange } = props;
125120
const { pathname, search } = useLocation();
126121
const [locale] = useLocale(locales);
127122

@@ -132,11 +127,7 @@ export default ({
132127

133128
const menuMode = isMobile ? 'inline' : 'horizontal';
134129

135-
const module = pathname
136-
.split('/')
137-
.filter((path) => path)
138-
.slice(0, -1)
139-
.join('/');
130+
const module = pathname.split('/').filter(Boolean).slice(0, -1).join('/');
140131
let activeMenuItem = module || 'home';
141132
if (pathname.startsWith('/changelog')) {
142133
activeMenuItem = 'docs/react';
@@ -287,7 +278,8 @@ export default ({
287278
className={styles.nav}
288279
disabledOverflow
289280
items={items}
290-
style={{ borderRight: 0 }}
291281
/>
292282
);
293283
};
284+
285+
export default HeaderNavigation;

.dumi/theme/slots/Header/SwitchBtn.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { createStyles } from 'antd-style';
21
import React from 'react';
3-
import classNames from 'classnames';
42
import { Tooltip } from 'antd';
3+
import { createStyles } from 'antd-style';
4+
import classNames from 'classnames';
55

66
export interface LangBtnProps {
77
label1: React.ReactNode;

.dumi/theme/slots/Header/index.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ const locales = {
3939

4040
const useStyle = createStyles(({ token, css }) => {
4141
const searchIconColor = '#ced4d9';
42-
4342
return {
4443
header: css`
4544
position: sticky;
@@ -102,12 +101,10 @@ const useStyle = createStyles(({ token, css }) => {
102101
display: flex;
103102
align-items: center;
104103
margin: 0;
105-
104+
column-gap: 12px;
106105
> * {
107106
flex: none;
108107
margin: 0;
109-
margin-inline-end: 12px;
110-
111108
&:last-child {
112109
margin-inline-end: 40px;
113110
}
@@ -118,7 +115,6 @@ const useStyle = createStyles(({ token, css }) => {
118115
`,
119116
popoverMenu: {
120117
width: 300,
121-
122118
[`${token.antCls}-popover-inner-content`]: {
123119
padding: 0,
124120
},
@@ -130,16 +126,19 @@ const useStyle = createStyles(({ token, css }) => {
130126
user-select: none;
131127
`,
132128
link: css`
133-
margin-left: 10px;
134-
129+
margin-inline-start: 10px;
135130
@media only screen and (max-width: ${token.mobileMaxWidth}px) {
136-
margin-left: 0;
131+
margin-inline-start: 0;
137132
}
138133
`,
139-
icon: css`
140-
margin-right: 10px;
141-
width: 22px;
142-
height: 22px;
134+
versionSelect: css`
135+
min-width: 90px;
136+
.rc-virtual-list {
137+
.rc-virtual-list-holder {
138+
scrollbar-width: thin;
139+
scrollbar-color: unset;
140+
}
141+
}
143142
`,
144143
};
145144
});
@@ -299,8 +298,8 @@ const Header: React.FC = () => {
299298
navigationNode,
300299
<Select
301300
key="version"
302-
className="version"
303301
size="small"
302+
className={styles.versionSelect}
304303
defaultValue={pkg.version}
305304
onChange={handleVersionChange}
306305
dropdownStyle={getDropdownStyle}

0 commit comments

Comments
 (0)