Skip to content

Commit 1cdbc77

Browse files
committed
chore(site): update styles
1 parent 2503338 commit 1cdbc77

File tree

4 files changed

+50
-44
lines changed

4 files changed

+50
-44
lines changed

packages/site/executors/build-base/files/resources.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"Close main navigation": "Close main navigation",
1515
"Open anchor navigation": "Open anchor navigation",
1616
"Close anchor navigation": "Close anchor navigation",
17+
"Change language": "Change language",
1718
"Light theme": "Light theme",
1819
"Dark theme": "Dark theme",
1920
"GitHub repository": "GitHub repository",
@@ -54,6 +55,7 @@
5455
"Close main navigation": "关闭主导航栏",
5556
"Open anchor navigation": "打开锚点导航栏",
5657
"Close anchor navigation": "关闭锚点导航栏",
58+
"Change language": "改变语言",
5759
"Light theme": "浅色主题",
5860
"Dark theme": "深色主题",
5961
"GitHub repository": "GitHub 存储库",

packages/site/src/app/routes/layout/Header.tsx

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import type { AppTheme } from '../../App';
2+
import type { DDropdownItem } from '@react-devui/ui/components/dropdown';
23
import type { DLang } from '@react-devui/ui/utils/types';
34

45
import { useTranslation } from 'react-i18next';
56
import { Link, useLocation } from 'react-router-dom';
67

78
import { useStorage } from '@react-devui/hooks';
89
import { DCustomIcon, GithubOutlined } from '@react-devui/icons';
9-
import { DMenu } from '@react-devui/ui';
10+
import { DDropdown, DMenu, DSeparator } from '@react-devui/ui';
1011
import { getClassName } from '@react-devui/utils';
1112

1213
export interface AppHeaderProps {
@@ -24,17 +25,6 @@ export function AppHeader(props: AppHeaderProps): JSX.Element | null {
2425
const location = useLocation();
2526
const activeId = location.pathname.startsWith('/docs') ? 'docs' : location.pathname.startsWith('/components') ? 'components' : null;
2627

27-
const switchLang =
28-
languageStorage.value === 'en-US'
29-
? {
30-
label: '切换语言为中文',
31-
text: '中 文',
32-
}
33-
: {
34-
label: 'Switch language to English',
35-
text: 'English',
36-
};
37-
3828
return (
3929
<header className="app-layout-header">
4030
<Link className="d-none d-md-inline-flex app-layout-header__logo-container" to="/">
@@ -81,18 +71,44 @@ export function AppHeader(props: AppHeaderProps): JSX.Element | null {
8171
dMode="horizontal"
8272
dActive={activeId}
8373
></DMenu>
74+
<DSeparator className="d-none d-md-inline-flex" style={{ margin: '16px 12px' }} dVertical />
8475
<div className="app-layout-header__button-container">
85-
<button
86-
className="app-layout-header__button app-layout-header__button--text"
87-
aria-label={switchLang.label}
88-
onClick={() => {
89-
const val = languageStorage.value === 'en-US' ? 'zh-CN' : 'en-US';
90-
languageStorage.set(val);
91-
i18n.changeLanguage(val);
76+
<DDropdown
77+
dList={(
78+
[
79+
['🇨🇳', '简体中文', 'zh-CN'],
80+
['🇺🇸', 'English', 'en-US'],
81+
] as [string, string, DLang][]
82+
).map<DDropdownItem<DLang>>((item) => ({
83+
id: item[2],
84+
label: (
85+
<>
86+
<div className="app-layout-header__language-item-region">{item[0]}</div>
87+
<span className="app-layout-header__language-item-lng">{item[1]}</span>
88+
</>
89+
),
90+
type: 'item',
91+
}))}
92+
onItemClick={(id) => {
93+
languageStorage.set(id);
94+
i18n.changeLanguage(id);
9295
}}
9396
>
94-
{switchLang.text}
95-
</button>
97+
<button
98+
className="app-layout-header__button"
99+
aria-label={t('Change language')}
100+
onClick={() => {
101+
const val = languageStorage.value === 'en-US' ? 'zh-CN' : 'en-US';
102+
languageStorage.set(val);
103+
i18n.changeLanguage(val);
104+
}}
105+
>
106+
<DCustomIcon viewBox="0 0 24 24">
107+
<path d="M0 0h24v24H0z" fill="none"></path>
108+
<path d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z "></path>
109+
</DCustomIcon>
110+
</button>
111+
</DDropdown>
96112
<button
97113
className="app-layout-header__button"
98114
aria-label={t(themeStorage.value === 'light' ? 'Dark theme' : 'Light theme')}

packages/site/src/styles/_app.scss

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ code:not(.hljs) {
7474
margin: 0 1px;
7575
font-family: Consolas, Menlo, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
7676
background-color: var(--app-code-background-color);
77-
/* stylelint-disable-next-line declaration-property-value-allowed-list */
78-
border-radius: 2px;
77+
border-radius: var(--#{$rd-prefix}border-radius);
7978
}
8079

8180
h1 {
@@ -248,8 +247,7 @@ h3 {
248247
margin-bottom: 12px;
249248
text-align: center;
250249
background: var(--#{$rd-prefix}background-color-primary);
251-
/* stylelint-disable-next-line declaration-property-value-allowed-list */
252-
border-radius: 6px;
250+
border-radius: var(--#{$rd-prefix}border-radius);
253251
}
254252
}
255253

packages/site/src/styles/routes/layout.scss

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,39 +40,31 @@
4040
color: var(--#{$rd-prefix}text-color);
4141
text-decoration: none;
4242
background-color: transparent;
43-
border: 1px solid var(--#{$rd-prefix}color-border);
44-
/* stylelint-disable-next-line declaration-property-value-allowed-list */
45-
border-radius: 8px;
46-
transition: border-color var(--#{$rd-prefix}animation-duration-base) linear, color var(--#{$rd-prefix}animation-duration-base) linear,
47-
background-color var(--#{$rd-prefix}animation-duration-base) linear;
43+
border: none;
44+
transition: color var(--#{$rd-prefix}animation-duration-base) linear;
4845

4946
@include font-size(1.2rem);
5047

5148
&:hover,
5249
&:focus {
5350
color: var(--#{$rd-prefix}color-primary-lighter);
54-
background-color: var(--#{$rd-prefix}background-color-primary-hover);
5551
}
5652

5753
&:active {
5854
color: var(--#{$rd-prefix}color-primary-darker);
59-
background-color: var(--#{$rd-prefix}background-color-primary);
6055
}
6156

6257
@include m(menu) {
6358
padding: 4px;
6459
margin-right: auto;
6560
border: none;
6661
}
62+
}
6763

68-
@include m(text) {
69-
padding: 0 11px;
70-
background-color: transparent !important;
71-
/* stylelint-disable-next-line declaration-property-value-allowed-list */
72-
border-radius: 2px;
73-
74-
@include font-size(1rem);
75-
}
64+
@include e(language-item-region) {
65+
display: inline-block;
66+
margin-right: 8px;
67+
font-size: 1.1em;
7668
}
7769

7870
@include e(hamburger) {
@@ -88,8 +80,7 @@
8880
width: 28px;
8981
height: 2px;
9082
background-color: var(--#{$rd-prefix}text-color);
91-
/* stylelint-disable-next-line declaration-property-value-allowed-list */
92-
border-radius: 2px;
83+
border-radius: 50%;
9384
/* stylelint-disable-next-line declaration-property-value-disallowed-list */
9485
transition: all 300ms linear;
9586
transform-origin: center;
@@ -131,7 +122,6 @@
131122
@include e(menu) {
132123
min-width: unset;
133124
height: 100%;
134-
margin-right: 20px;
135125

136126
&::after {
137127
content: none;
@@ -237,7 +227,7 @@
237227
text-decoration: none;
238228
border: 1px solid var(--#{$rd-prefix}color-border);
239229
/* stylelint-disable-next-line declaration-property-value-allowed-list */
240-
border-radius: 10px;
230+
border-radius: 8px;
241231

242232
svg:last-child {
243233
margin-left: auto;

0 commit comments

Comments
 (0)