Browse Source

style: add dropdown group title rtl style (#23404)

* style: add dropdown group title rtl style

* fix margin

* fix lint
pull/23426/head
xrkffgg 5 years ago
committed by GitHub
parent
commit
3d76859bbc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      components/dropdown/demo/sub-menu.md
  2. 7
      components/dropdown/style/rtl.less
  3. 5
      site/theme/template/Layout/Header/More.tsx
  4. 9
      site/theme/template/Layout/Header/Navigation.tsx
  5. 3
      site/theme/template/Layout/Header/index.tsx
  6. 1
      site/theme/template/Layout/Header/interface.tsx

2
components/dropdown/demo/sub-menu.md

@ -21,8 +21,10 @@ const { SubMenu } = Menu;
const menu = ( const menu = (
<Menu> <Menu>
<Menu.ItemGroup title="Group title">
<Menu.Item>1st menu item</Menu.Item> <Menu.Item>1st menu item</Menu.Item>
<Menu.Item>2nd menu item</Menu.Item> <Menu.Item>2nd menu item</Menu.Item>
</Menu.ItemGroup>
<SubMenu title="sub menu"> <SubMenu title="sub menu">
<Menu.Item>3rd menu item</Menu.Item> <Menu.Item>3rd menu item</Menu.Item>
<Menu.Item>4th menu item</Menu.Item> <Menu.Item>4th menu item</Menu.Item>

7
components/dropdown/style/rtl.less

@ -16,6 +16,13 @@
} }
&-menu { &-menu {
&-item-group-title {
.@{dropdown-prefix-cls}-rtl & {
direction: rtl;
text-align: right;
}
}
&-submenu-popup { &-submenu-popup {
ul, ul,
li { li {

5
site/theme/template/Layout/Header/More.tsx

@ -55,7 +55,7 @@ export function getEcosystemGroup({ isZhCN }: SharedProps): React.ReactElement {
export default (props: SharedProps) => { export default (props: SharedProps) => {
const menu = <Menu>{getEcosystemGroup(props)}</Menu>; const menu = <Menu>{getEcosystemGroup(props)}</Menu>;
const DownStyle = props.isRTL ? '-1px 2px 0 0' : '-1px 0 0 2px';
return ( return (
<Dropdown overlay={menu} placement="bottomRight"> <Dropdown overlay={menu} placement="bottomRight">
<Button size="small" className="header-button"> <Button size="small" className="header-button">
@ -63,9 +63,8 @@ export default (props: SharedProps) => {
<DownOutlined <DownOutlined
style={{ style={{
fontSize: '9px', fontSize: '9px',
marginLeft: 2, margin: DownStyle,
verticalAlign: 'middle', verticalAlign: 'middle',
marginTop: -1,
}} }}
/> />
</Button> </Button>

9
site/theme/template/Layout/Header/Navigation.tsx

@ -12,6 +12,7 @@ import './Navigation.less';
export interface NavigationProps extends SharedProps { export interface NavigationProps extends SharedProps {
isMobile: boolean; isMobile: boolean;
isRTL: boolean;
pathname: string; pathname: string;
responsive: null | 'narrow' | 'crowded'; responsive: null | 'narrow' | 'crowded';
location: { pathname: string }; location: { pathname: string };
@ -22,6 +23,7 @@ export interface NavigationProps extends SharedProps {
export default ({ export default ({
isZhCN, isZhCN,
isRTL,
isMobile, isMobile,
pathname, pathname,
responsive, responsive,
@ -32,10 +34,7 @@ export default ({
}: NavigationProps) => { }: NavigationProps) => {
const menuMode = isMobile ? 'inline' : 'horizontal'; const menuMode = isMobile ? 'inline' : 'horizontal';
const module = pathname const module = pathname.split('/').slice(0, -1).join('/');
.split('/')
.slice(0, -1)
.join('/');
let activeMenuItem = module || 'home'; let activeMenuItem = module || 'home';
if (location.pathname === 'changelog' || location.pathname === 'changelog-cn') { if (location.pathname === 'changelog' || location.pathname === 'changelog-cn') {
activeMenuItem = 'docs/react'; activeMenuItem = 'docs/react';
@ -56,7 +55,7 @@ export default ({
<Menu.Item key="switch-direction" onClick={onDirectionChange}> <Menu.Item key="switch-direction" onClick={onDirectionChange}>
{directionText} {directionText}
</Menu.Item>, </Menu.Item>,
getEcosystemGroup({ isZhCN }), getEcosystemGroup({ isZhCN, isRTL }),
]; ];
if (isMobile) { if (isMobile) {

3
site/theme/template/Layout/Header/index.tsx

@ -180,6 +180,7 @@ class Header extends React.Component<HeaderProps, HeaderState> {
<SiteContext.Consumer> <SiteContext.Consumer>
{({ isMobile }) => { {({ isMobile }) => {
const { menuVisible, windowWidth, searching } = this.state; const { menuVisible, windowWidth, searching } = this.state;
const { direction } = this.context;
const { const {
location, location,
themeConfig, themeConfig,
@ -197,6 +198,7 @@ class Header extends React.Component<HeaderProps, HeaderState> {
const isHome = ['', 'index', 'index-cn'].includes(pathname); const isHome = ['', 'index', 'index-cn'].includes(pathname);
const isZhCN = locale === 'zh-CN'; const isZhCN = locale === 'zh-CN';
const isRTL = direction === 'rtl';
let responsive: null | 'narrow' | 'crowded' = null; let responsive: null | 'narrow' | 'crowded' = null;
if (windowWidth < RESPONSIVE_XS) { if (windowWidth < RESPONSIVE_XS) {
responsive = 'crowded'; responsive = 'crowded';
@ -211,6 +213,7 @@ class Header extends React.Component<HeaderProps, HeaderState> {
const sharedProps = { const sharedProps = {
isZhCN, isZhCN,
isRTL,
}; };
const searchBox = ( const searchBox = (

1
site/theme/template/Layout/Header/interface.tsx

@ -1,3 +1,4 @@
export interface SharedProps { export interface SharedProps {
isZhCN: boolean; isZhCN: boolean;
isRTL: boolean;
} }

Loading…
Cancel
Save