Skip to content

Commit 8616190

Browse files
committed
chore(platform): dropdown's dTrigger should be click when in header
1 parent 53bfbfb commit 8616190

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

packages/platform/src/app/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export { AppDetailView } from './detail-view';
66

77
export { AppFCPLoader } from './fcp-loader';
88

9+
export type { AppLanguageProps } from './language';
910
export { AppLanguage } from './language';
1011

1112
export type { AppListProps } from './list';

packages/platform/src/app/components/language/Language.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@ import { DDropdown } from '@react-devui/ui';
1010

1111
import { STORAGE_KEY } from '../../config/storage';
1212

13-
export function AppLanguage(props: React.ButtonHTMLAttributes<HTMLButtonElement>): JSX.Element | null {
13+
export interface AppLanguageProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {
14+
aTrigger?: 'click' | 'hover';
15+
}
16+
17+
export function AppLanguage(props: AppLanguageProps): JSX.Element | null {
18+
const {
19+
aTrigger,
20+
21+
...restProps
22+
} = props;
23+
1424
const languageStorage = useStorage<DLang>(...STORAGE_KEY.language);
1525
const { t, i18n } = useTranslation();
1626

@@ -31,12 +41,13 @@ export function AppLanguage(props: React.ButtonHTMLAttributes<HTMLButtonElement>
3141
),
3242
type: 'item',
3343
}))}
44+
dTrigger={aTrigger}
3445
onItemClick={(id) => {
3546
languageStorage.set(id);
3647
i18n.changeLanguage(id);
3748
}}
3849
>
39-
<button {...props} aria-label={t('components.language.Change language')}>
50+
<button {...restProps} aria-label={t('components.language.Change language')}>
4051
<DCustomIcon viewBox="0 0 24 24">
4152
<path d="M0 0h24v24H0z" fill="none"></path>
4253
<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>

packages/platform/src/app/routes/layout/header/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function AppHeader(props: AppHeaderProps): JSX.Element | null {
9595
</button>
9696
<AppNotification className={styles['app-header__button']} />
9797
<AppUser className={styles['app-header__button']} style={{ gap: '0 8px' }} />
98-
<AppLanguage className={styles['app-header__button']} />
98+
<AppLanguage className={styles['app-header__button']} aTrigger="click" />
9999
</header>
100100
);
101101
}

packages/platform/src/app/routes/layout/header/user/User.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export function AppUser(props: React.ButtonHTMLAttributes<HTMLButtonElement>): J
2121
{ id: 'setting', label: t('routes.layout.Account Settings'), type: 'item', icon: <SettingOutlined />, separator: true },
2222
{ id: 'logout', label: t('routes.layout.Logout'), type: 'item', icon: <LogoutOutlined /> },
2323
]}
24+
dTrigger="click"
2425
onItemClick={(id) => {
2526
switch (id) {
2627
case 'logout':

0 commit comments

Comments
 (0)