@@ -17,7 +17,7 @@ import { EditorContainer, EmptyContent } from "pages/common/styledComponent";
17
17
import { useCallback , useEffect , useMemo , useState } from "react" ;
18
18
import styled from "styled-components" ;
19
19
import { isUserViewMode , useAppPathParam } from "util/hooks" ;
20
- import { StringControl , jsonControl } from "comps/controls/codeControl" ;
20
+ import { BoolCodeControl , StringControl , jsonControl } from "comps/controls/codeControl" ;
21
21
import { styleControl } from "comps/controls/styleControl" ;
22
22
import {
23
23
NavLayoutStyle ,
@@ -41,6 +41,8 @@ import {
41
41
menuItemStyleOptions
42
42
} from "./navLayoutConstants" ;
43
43
44
+ const { Header } = Layout ;
45
+
44
46
const DEFAULT_WIDTH = 240 ;
45
47
type MenuItemStyleOptionValue = "normal" | "hover" | "active" ;
46
48
@@ -99,10 +101,12 @@ const StyledMenu = styled(AntdMenu)<{
99
101
.ant-menu-submenu {
100
102
margin: ${ ( props ) => props . $navItemStyle ?. margin } ;
101
103
width: ${ ( props ) => props . $navItemStyle ?. width } ;
104
+ padding: 0;
102
105
103
106
.ant-menu-submenu-title {
104
107
width: 100%;
105
108
height: auto !important;
109
+ max-height: 100%;
106
110
background-color: ${ ( props ) => props . $navItemStyle ?. background } ;
107
111
color: ${ ( props ) => props . $navItemStyle ?. text } ;
108
112
border-radius: ${ ( props ) => props . $navItemStyle ?. radius } !important;
@@ -190,7 +194,8 @@ let NavTmpLayout = (function () {
190
194
width : withDefault ( StringControl , DEFAULT_WIDTH ) ,
191
195
backgroundImage : withDefault ( StringControl , "" ) ,
192
196
mode : dropdownControl ( ModeOptions , "inline" ) ,
193
- navStyle : withDefault ( styleControl ( NavLayoutStyle ) , defaultStyle ) ,
197
+ collapse : BoolCodeControl ,
198
+ navStyle : withDefault ( styleControl ( NavLayoutStyle ) , { ...defaultStyle , padding : '1px' } ) ,
194
199
navItemStyle : withDefault ( styleControl ( NavLayoutItemStyle ) , defaultStyle ) ,
195
200
navItemHoverStyle : withDefault ( styleControl ( NavLayoutItemHoverStyle ) , { } ) ,
196
201
navItemActiveStyle : withDefault ( styleControl ( NavLayoutItemActiveStyle ) , { } ) ,
@@ -226,6 +231,9 @@ let NavTmpLayout = (function () {
226
231
label : trans ( "labelProp.position" ) ,
227
232
radioButton : true
228
233
} ) }
234
+ { children . collapse . propertyView ( {
235
+ label : trans ( "labelProp.collapse" ) ,
236
+ } ) }
229
237
{ children . backgroundImage . propertyView ( {
230
238
label : `Background Image` ,
231
239
placeholder : 'https://temp.im/350x400' ,
@@ -266,6 +274,7 @@ NavTmpLayout = withViewFn(NavTmpLayout, (comp) => {
266
274
const items = comp . children . items . getView ( ) ;
267
275
const navWidth = comp . children . width . getView ( ) ;
268
276
const navMode = comp . children . mode . getView ( ) ;
277
+ const navCollapse = comp . children . collapse . getView ( ) ;
269
278
const navStyle = comp . children . navStyle . getView ( ) ;
270
279
const navItemStyle = comp . children . navItemStyle . getView ( ) ;
271
280
const navItemHoverStyle = comp . children . navItemHoverStyle . getView ( ) ;
@@ -547,32 +556,46 @@ NavTmpLayout = withViewFn(NavTmpLayout, (comp) => {
547
556
backgroundStyle = `center / cover url('${ backgroundImage } ') no-repeat, ${ backgroundStyle } ` ;
548
557
}
549
558
559
+ let navMenu = (
560
+ < StyledMenu
561
+ items = { menuItems }
562
+ mode = { navMode }
563
+ style = { {
564
+ height : `calc(100% - ${ getVerticalMargin ( navStyle . margin . split ( ' ' ) ) } )` ,
565
+ width : `calc(100% - ${ getHorizontalMargin ( navStyle . margin . split ( ' ' ) ) } )` ,
566
+ borderRight : navMode !== 'horizontal' ? `1px solid ${ navStyle . border } ` : 'none' ,
567
+ borderBottom : navMode === 'horizontal' ? `1px solid ${ navStyle . border } ` : 'none' ,
568
+ borderRadius : navStyle . radius ,
569
+ color : navStyle . text ,
570
+ margin : navStyle . margin ,
571
+ padding : navStyle . padding ,
572
+ background : backgroundStyle ,
573
+ flex : 1 ,
574
+ minWidth : 0 ,
575
+ } }
576
+ defaultOpenKeys = { defaultOpenKeys }
577
+ selectedKeys = { [ selectedKey ] }
578
+ $navItemStyle = { {
579
+ // width: `calc(100% - ${getHorizontalMargin(navItemStyle.margin.split(' '))})`,
580
+ width : 'auto' ,
581
+ ...navItemStyle ,
582
+ } }
583
+ $navItemHoverStyle = { navItemHoverStyle }
584
+ $navItemActiveStyle = { navItemActiveStyle }
585
+ />
586
+ ) ;
587
+
550
588
let content = (
551
589
< Layout >
552
- < StyledSide theme = "light" width = { navWidth } >
553
- < StyledMenu
554
- items = { menuItems }
555
- mode = { navMode }
556
- style = { {
557
- height : `calc(100% - ${ getVerticalMargin ( navStyle . margin . split ( ' ' ) ) } )` ,
558
- width : `calc(100% - ${ getHorizontalMargin ( navStyle . margin . split ( ' ' ) ) } )` ,
559
- borderRight : `1px solid ${ navStyle . border } ` ,
560
- borderRadius : navStyle . radius ,
561
- color : navStyle . text ,
562
- margin : navStyle . margin ,
563
- padding : navStyle . padding ,
564
- background : backgroundStyle ,
565
- } }
566
- defaultOpenKeys = { defaultOpenKeys }
567
- selectedKeys = { [ selectedKey ] }
568
- $navItemStyle = { {
569
- width : `calc(100% - ${ getHorizontalMargin ( navItemStyle . margin . split ( ' ' ) ) } )` ,
570
- ...navItemStyle ,
571
- } }
572
- $navItemHoverStyle = { navItemHoverStyle }
573
- $navItemActiveStyle = { navItemActiveStyle }
574
- />
575
- </ StyledSide >
590
+ { navMode === 'horizontal' ? (
591
+ < Header style = { { display : 'flex' , alignItems : 'center' , padding : 0 } } >
592
+ { navMenu }
593
+ </ Header >
594
+ ) : (
595
+ < StyledSide theme = "light" width = { navWidth } collapsed = { navCollapse } >
596
+ { navMenu }
597
+ </ StyledSide >
598
+ ) }
576
599
< MainContent > { pageView } </ MainContent >
577
600
</ Layout >
578
601
) ;
0 commit comments