chore: fix lint and refactor some site code (#40185)

* chore: refactor header code style

* fix lint
This commit is contained in:
afc163 2023-01-12 11:57:54 +08:00 committed by GitHub
parent 716e56b3ae
commit fdc6709977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 15 deletions

View File

@ -61,15 +61,15 @@ export function getEcosystemGroup(): Exclude<MenuProps['items'], undefined> {
}
export default (props: SharedProps) => {
const downstyle = props.isRTL ? '-1px 2px 0 0' : '-1px 0 0 2px';
const downStyle = props.isRTL ? '-1px 2px 0 0' : '-1px 0 0 2px';
return (
<Dropdown menu={{ items: getEcosystemGroup() }} placement="bottomRight">
<Button size="small" className="header-button">
<Button size="small">
<FormattedMessage id="app.header.menu.more" />
<DownOutlined
style={{
fontSize: '9px',
margin: downstyle,
margin: downStyle,
verticalAlign: 'middle',
}}
/>

View File

@ -20,8 +20,6 @@ import SwitchBtn from './SwitchBtn';
const RESPONSIVE_XS = 1120;
const RESPONSIVE_SM = 1200;
const { Option } = Select;
const antdVersion: string = packageJson.version;
const useStyle = () => {
@ -244,14 +242,12 @@ const Header: React.FC = () => {
[antdVersion]: antdVersion,
...themeConfig?.docVersions,
};
const versionOptions = Object.keys(docVersions).map((version) => (
<Option value={docVersions[version]} key={version}>
{version}
</Option>
));
const versionOptions = Object.keys(docVersions).map((version) => ({
value: docVersions[version],
label: version,
}));
const isHome = ['', 'index', 'index-cn'].includes(pathname);
const isZhCN = lang === 'cn';
const isRTL = direction === 'rtl';
let responsive: null | 'narrow' | 'crowded' = null;
@ -284,7 +280,7 @@ const Header: React.FC = () => {
/>
);
let menu: React.ReactNode[] = [
let menu = [
navigationNode,
<Select
key="version"
@ -295,9 +291,8 @@ const Header: React.FC = () => {
dropdownStyle={getDropdownStyle}
dropdownMatchSelectWidth={false}
getPopupContainer={(trigger) => trigger.parentNode}
>
{versionOptions}
</Select>,
options={versionOptions}
/>,
<More key="more" {...sharedProps} />,
<SwitchBtn
key="lang"