mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-03 12:29:24 +08:00
fix: Nav样式问题、性能优化 (#6280)
Co-authored-by: wanglinfang <wanglinfang@baidu.com>
This commit is contained in:
parent
7d4167b7b1
commit
0d218b7b28
@ -40,6 +40,14 @@
|
|||||||
.#{$ns}Nav-Menu-submenu-arrow {
|
.#{$ns}Nav-Menu-submenu-arrow {
|
||||||
color: var(--Menu-dark-fontColor);
|
color: var(--Menu-dark-fontColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
.#{$ns}Nav-Menu-item-label,
|
||||||
|
.#{$ns}Nav-Menu-item-icon,
|
||||||
|
.#{$ns}Nav-Menu-submenu-arrow {
|
||||||
|
color: var(--Menu-dark-fontColor-onHover);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,6 +194,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
height: var(--Nav-Item-height);
|
height: var(--Nav-Item-height);
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-item-divider {
|
&-item-divider {
|
||||||
@ -334,6 +343,9 @@
|
|||||||
&-submenu {
|
&-submenu {
|
||||||
.#{$ns}Badge {
|
.#{$ns}Badge {
|
||||||
position: static;
|
position: static;
|
||||||
|
flex: 1;
|
||||||
|
width: 0;
|
||||||
|
display: flex;
|
||||||
}
|
}
|
||||||
.#{$ns}Nav-Menu-item-wrap {
|
.#{$ns}Nav-Menu-item-wrap {
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -542,7 +554,7 @@
|
|||||||
&-submenu-title {
|
&-submenu-title {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 0 var(--Menu-Submenu-item-paddingX) 0 px2rem(16px);
|
padding: 0 px2rem(16px);
|
||||||
line-height: var(--Nav-Item-height);
|
line-height: var(--Nav-Item-height);
|
||||||
display: block;
|
display: block;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
@ -568,7 +580,8 @@
|
|||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
.#{$ns}Nav-Menu-item-label,
|
.#{$ns}Nav-Menu-item-label,
|
||||||
.#{$ns}Nav-Menu-item-icon {
|
.#{$ns}Nav-Menu-item-icon,
|
||||||
|
.#{$ns}Nav-Menu-submenu-arrow {
|
||||||
color: var(--Menu-dark-fontColor-onHover);
|
color: var(--Menu-dark-fontColor-onHover);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -961,7 +974,8 @@
|
|||||||
color: var(--Menu-dark-ancestor-fontColor-onActive);
|
color: var(--Menu-dark-ancestor-fontColor-onActive);
|
||||||
|
|
||||||
.#{$ns}Nav-Menu-item-label,
|
.#{$ns}Nav-Menu-item-label,
|
||||||
.#{$ns}Nav-Menu-item-icon {
|
.#{$ns}Nav-Menu-item-icon,
|
||||||
|
.#{$ns}Nav-Menu-submenu-arrow {
|
||||||
color: var(--Menu-dark-ancestor-fontColor-onActive);
|
color: var(--Menu-dark-ancestor-fontColor-onActive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ export class Menu extends React.Component<MenuProps, MenuState> {
|
|||||||
mode: 'inline',
|
mode: 'inline',
|
||||||
direction: 'ltr',
|
direction: 'ltr',
|
||||||
prefix: '',
|
prefix: '',
|
||||||
triggerSubMenuAction: 'hover',
|
triggerSubMenuAction: 'click',
|
||||||
inlineIndent: 15,
|
inlineIndent: 15,
|
||||||
popOverContainer: () => document.body,
|
popOverContainer: () => document.body,
|
||||||
renderLink: (link: MenuItemProps) => {
|
renderLink: (link: MenuItemProps) => {
|
||||||
@ -279,13 +279,17 @@ export class Menu extends React.Component<MenuProps, MenuState> {
|
|||||||
componentDidUpdate(prevProps: MenuProps, prevState: MenuState) {
|
componentDidUpdate(prevProps: MenuProps, prevState: MenuState) {
|
||||||
const props = this.props;
|
const props = this.props;
|
||||||
const isOpen = prevProps.isOpen;
|
const isOpen = prevProps.isOpen;
|
||||||
|
let isNavDiff = prevProps.navigations.length !== props.navigations.length;
|
||||||
if (
|
if (!isNavDiff) {
|
||||||
!isEqualWith(prevProps.navigations, props.navigations, (prev, cur) =>
|
// 顺序也要保持一致
|
||||||
isEqual(prev, cur)
|
for (let [index, item] of props.navigations.entries()) {
|
||||||
) ||
|
if (!isEqual(item, prevProps.navigations[index])) {
|
||||||
!isEqual(prevProps.location, props.location)
|
isNavDiff = true;
|
||||||
) {
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isNavDiff || !isEqual(prevProps.location, props.location)) {
|
||||||
const {transformedNav, activeKey, defaultOpenKeys, openKeys} =
|
const {transformedNav, activeKey, defaultOpenKeys, openKeys} =
|
||||||
this.normalizeNavigations({
|
this.normalizeNavigations({
|
||||||
...props,
|
...props,
|
||||||
|
@ -254,6 +254,11 @@ export interface NavSchema extends BaseSchema {
|
|||||||
* 自定义展开图标位置 默认在前面 before after
|
* 自定义展开图标位置 默认在前面 before after
|
||||||
*/
|
*/
|
||||||
expandPosition?: string;
|
expandPosition?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主题配色 默认light
|
||||||
|
*/
|
||||||
|
themeColor?: 'light' | 'dark';
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Link {
|
export interface Link {
|
||||||
@ -637,6 +642,7 @@ export class Navigation extends React.Component<
|
|||||||
indentSize,
|
indentSize,
|
||||||
accordion,
|
accordion,
|
||||||
draggable,
|
draggable,
|
||||||
|
themeColor,
|
||||||
expandPosition,
|
expandPosition,
|
||||||
render
|
render
|
||||||
} = this.props;
|
} = this.props;
|
||||||
@ -681,6 +687,7 @@ export class Navigation extends React.Component<
|
|||||||
isOpen={(item: NavigationItem) => !!item.open}
|
isOpen={(item: NavigationItem) => !!item.open}
|
||||||
stacked={!!stacked}
|
stacked={!!stacked}
|
||||||
mode={mode}
|
mode={mode}
|
||||||
|
themeColor={themeColor}
|
||||||
location={location}
|
location={location}
|
||||||
onSelect={this.handleClick}
|
onSelect={this.handleClick}
|
||||||
onToggle={this.toggleLink}
|
onToggle={this.toggleLink}
|
||||||
@ -1177,7 +1184,6 @@ export class NavigationRenderer extends React.Component<RendererProps> {
|
|||||||
| {
|
| {
|
||||||
loadConfig: (ctx?: any) => Promise<any> | void;
|
loadConfig: (ctx?: any) => Promise<any> | void;
|
||||||
setConfig: (value: any) => void;
|
setConfig: (value: any) => void;
|
||||||
setFilterConfig: (value: any) => void;
|
|
||||||
}
|
}
|
||||||
| undefined = undefined;
|
| undefined = undefined;
|
||||||
|
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
"amis-formula": ["./packages/amis-formula/src/index.ts"],
|
"amis-formula": ["./packages/amis-formula/src/index.ts"],
|
||||||
"amis-ui": ["./packages/amis-ui/src/index.tsx"],
|
"amis-ui": ["./packages/amis-ui/src/index.tsx"],
|
||||||
"amis": ["./packages/amis/src/index.tsx"]
|
"amis": ["./packages/amis/src/index.tsx"]
|
||||||
}
|
},
|
||||||
|
"downlevelIteration": true
|
||||||
},
|
},
|
||||||
"types": ["typePatches"],
|
"types": ["typePatches"],
|
||||||
"references": [],
|
"references": [],
|
||||||
|
Loading…
Reference in New Issue
Block a user