-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: collapsed menu DOM and submenu indicators #9585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
ff51853
d154b48
21fb3a0
64ef648
5e988d0
df03f45
bcdf813
e8d0b36
fd8f9c8
f5df8c6
f854814
3dad266
eca9c70
4c2bce8
87c6cfa
58ad339
87259de
f5ad651
85ce0e0
30694d7
50f1421
c2128aa
c3e4f2e
fed4d24
8faaa5f
fc697e3
edee2a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,17 @@ | ||
| import type { PopoverProps, ColorPickerProps } from 'antd'; | ||
| import type { PopoverProps } from 'antd'; | ||
| import React from 'react'; | ||
| import { FieldColorPicker } from '../../../field'; | ||
| import { ProConfigProvider } from '../../../provider'; | ||
| import type { ProFormFieldItemProps } from '../../typing'; | ||
| import ProFromField from '../Field'; | ||
|
|
||
| export type ProFormColorPickerProps = | ||
| ProFormFieldItemProps<ColorPickerProps> & { | ||
| popoverProps?: PopoverProps; | ||
| colors?: string[]; | ||
| }; | ||
| /** 使用宽松字段类型,避免 d.ts 生成时拉入 `@rc-component/color-picker` 导致 TS2742 */ | ||
| export type ProFormColorPickerProps = ProFormFieldItemProps< | ||
| Record<string, unknown> | ||
| > & { | ||
| popoverProps?: PopoverProps; | ||
| colors?: string[]; | ||
| }; | ||
|
Comment on lines
+8
to
+14
|
||
|
|
||
| /** | ||
| * 颜色选择组件 | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,4 @@ | ||||||||
| import type { CSSInterpolation } from '@ant-design/cssinjs'; | ||||||||
| import type { CSSProperties } from 'react'; | ||||||||
| import type { GenerateStyle } from '../../../../provider'; | ||||||||
| import { useStyle as useAntdStyle } from '../../../../provider'; | ||||||||
|
|
@@ -86,7 +87,7 @@ function layoutNavCssVars(surface: 'sider' | 'header'): Record<string, string> { | |||||||
| [navVar.itemHeight]: `${itemH}px`, | ||||||||
| [navVar.itemRadius]: '6px', | ||||||||
| [navVar.itemGap]: '8px', | ||||||||
| [navVar.itemFontSize]: 'calc(var(--ant-font-size) + 1px)', | ||||||||
| [navVar.itemFontSize]: '14px', | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoding
Suggested change
|
||||||||
| [navVar.itemFontWeight]: '500', | ||||||||
| [navVar.itemPadBlock]: '6px', | ||||||||
| [navVar.itemPadInline]: `${padInline}px`, | ||||||||
|
|
@@ -184,8 +185,27 @@ const genProLayoutBaseMenuStyle: GenerateStyle<ProLayoutBaseMenuToken> = ( | |||||||
| [`${c}-item`]: { | ||||||||
| listStyle: 'none', | ||||||||
| ...rowItem, | ||||||||
| /** 标题区(icon+文案)直接作为子节点,省一层 wrapper */ | ||||||||
| [`> *`]: { | ||||||||
| /** 只对标题根节点拉伸,避免 Tooltip 等外包层占满一行导致收起态比图标大 */ | ||||||||
| [`> ${c}-item-title`]: { | ||||||||
| flex: 1, | ||||||||
| minWidth: 0, | ||||||||
| display: 'flex', | ||||||||
| flexDirection: 'row', | ||||||||
| alignItems: 'center', | ||||||||
| gap: v('itemGap'), | ||||||||
| }, | ||||||||
| /** `menuItemRender` 常见为 `<Link><defaultDom/></Link>` */ | ||||||||
| [`> a`]: { | ||||||||
| flex: 1, | ||||||||
| minWidth: 0, | ||||||||
| display: 'flex', | ||||||||
| flexDirection: 'row', | ||||||||
| alignItems: 'center', | ||||||||
| gap: v('itemGap'), | ||||||||
| color: 'inherit', | ||||||||
| textDecoration: 'none', | ||||||||
| }, | ||||||||
| [`> [data-pro-layout-menu-item-title-wrap]`]: { | ||||||||
| flex: 1, | ||||||||
| minWidth: 0, | ||||||||
| display: 'flex', | ||||||||
|
|
@@ -217,15 +237,47 @@ const genProLayoutBaseMenuStyle: GenerateStyle<ProLayoutBaseMenuToken> = ( | |||||||
| [`${c}-submenu-title`]: { | ||||||||
| ...rowItem, | ||||||||
| font: 'inherit', | ||||||||
| /** 子菜单标题内联 DOM(与 leaf 一致) */ | ||||||||
| [`> *`]: { | ||||||||
| /** 文案区(含 icon+文本);右侧为展开指示器 */ | ||||||||
| [`${c}-submenu-title-inner`]: { | ||||||||
| flex: 1, | ||||||||
| minWidth: 0, | ||||||||
| display: 'flex', | ||||||||
| flexDirection: 'row', | ||||||||
| alignItems: 'center', | ||||||||
| gap: v('itemGap'), | ||||||||
| [`> *`]: { | ||||||||
| flex: 1, | ||||||||
| minWidth: 0, | ||||||||
| display: 'flex', | ||||||||
| flexDirection: 'row', | ||||||||
| alignItems: 'center', | ||||||||
| gap: v('itemGap'), | ||||||||
| }, | ||||||||
| }, | ||||||||
| [`${c}-submenu-expand-icon`]: { | ||||||||
| display: 'inline-flex', | ||||||||
| flexShrink: 0, | ||||||||
| alignItems: 'center', | ||||||||
| justifyContent: 'center', | ||||||||
| marginInlineStart: 'auto', | ||||||||
| color: v('colorIcon'), | ||||||||
| fontSize: 10, | ||||||||
| lineHeight: 0, | ||||||||
| transition: 'transform 0.2s ease', | ||||||||
| '& > span': { lineHeight: 0 }, | ||||||||
| }, | ||||||||
| [`${c}-submenu-expand-icon${c}-submenu-expand-icon--popup-horizontal${c}-submenu-expand-icon--open`]: | ||||||||
| { | ||||||||
| transform: 'rotate(180deg)', | ||||||||
| }, | ||||||||
| [`${c}-submenu-expand-icon${c}-submenu-expand-icon--inline${c}-submenu-expand-icon--open`]: | ||||||||
| { | ||||||||
| transform: 'rotate(90deg)', | ||||||||
| }, | ||||||||
| [`${c}-submenu-expand-icon${c}-submenu-expand-icon--popup-vertical${c}-submenu-expand-icon--open`]: | ||||||||
| { | ||||||||
| transform: 'rotate(90deg)', | ||||||||
| }, | ||||||||
| '&:hover': { | ||||||||
| backgroundColor: v('colorBgHover'), | ||||||||
| color: v('colorTextHover'), | ||||||||
|
|
@@ -304,10 +356,13 @@ const genProLayoutBaseMenuStyle: GenerateStyle<ProLayoutBaseMenuToken> = ( | |||||||
| whiteSpace: 'nowrap', | ||||||||
| }, | ||||||||
| '&-collapsed': { | ||||||||
| minWidth: v('itemHeight'), | ||||||||
| width: 'fit-content', | ||||||||
| maxWidth: '100%', | ||||||||
| minWidth: v('iconBox'), | ||||||||
| height: v('itemHeight'), | ||||||||
| flexDirection: 'column', | ||||||||
| justifyContent: 'center', | ||||||||
| justifyContent: 'flex-start', | ||||||||
| alignItems: 'flex-start', | ||||||||
| [`${c}-item-icon`]: { | ||||||||
| width: v('iconBox'), | ||||||||
| height: v('iconBox'), | ||||||||
|
|
@@ -316,7 +371,7 @@ const genProLayoutBaseMenuStyle: GenerateStyle<ProLayoutBaseMenuToken> = ( | |||||||
| }, | ||||||||
| '&-collapsed-level-0': { | ||||||||
| flexDirection: 'column', | ||||||||
| justifyContent: 'center', | ||||||||
| justifyContent: 'flex-start', | ||||||||
| }, | ||||||||
| [`&${c}-group-item-title`]: { | ||||||||
| gap: v('itemGap'), | ||||||||
|
|
@@ -329,10 +384,10 @@ const genProLayoutBaseMenuStyle: GenerateStyle<ProLayoutBaseMenuToken> = ( | |||||||
| [`&${c}-item-title-collapsed`]: { | ||||||||
| display: 'flex', | ||||||||
| flexDirection: 'column', | ||||||||
| alignItems: 'center', | ||||||||
| alignItems: 'flex-start', | ||||||||
| [`${c}-item-text`]: { | ||||||||
| display: 'inline', | ||||||||
| textAlign: 'center', | ||||||||
| textAlign: 'start', | ||||||||
| fontSize: 'calc(var(--ant-font-size, 14px) - 1px)', | ||||||||
| maxHeight: 12, | ||||||||
| lineHeight: '12px', | ||||||||
|
|
@@ -409,7 +464,7 @@ const genProLayoutBaseMenuStyle: GenerateStyle<ProLayoutBaseMenuToken> = ( | |||||||
| paddingInlineEnd: 0, | ||||||||
| }, | ||||||||
| [`${c}-item-title`]: { | ||||||||
| width: '100%', | ||||||||
| width: 'fit-content', | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The PR aims to prevent the
Suggested change
|
||||||||
| maxWidth: '100%', | ||||||||
| overflow: 'visible', | ||||||||
| }, | ||||||||
|
|
@@ -432,19 +487,6 @@ const genProLayoutBaseMenuStyle: GenerateStyle<ProLayoutBaseMenuToken> = ( | |||||||
| gap: v('stackGap'), | ||||||||
| }, | ||||||||
|
|
||||||||
| /** vertical(侧栏收起)下标题区收窄为 20px 宽,便于在窄侧栏内居中 */ | ||||||||
| ...(mode === 'vertical' | ||||||||
| ? { | ||||||||
| [`&--collapsed ${c}-item-title-collapsed`]: { | ||||||||
| width: 20, | ||||||||
| minWidth: 20, | ||||||||
| maxWidth: 20, | ||||||||
| marginInline: 'auto', | ||||||||
| alignSelf: 'center', | ||||||||
| }, | ||||||||
| } | ||||||||
| : {}), | ||||||||
|
|
||||||||
| [`${c}--horizontal`]: { | ||||||||
| display: 'flex', | ||||||||
| flexDirection: 'row', | ||||||||
|
|
@@ -489,7 +531,7 @@ const genProLayoutBaseMenuStyle: GenerateStyle<ProLayoutBaseMenuToken> = ( | |||||||
| }, | ||||||||
|
|
||||||||
| [`${c}-link`]: { display: 'block' }, | ||||||||
| }; | ||||||||
| } as CSSInterpolation; | ||||||||
| }; | ||||||||
|
|
||||||||
| export function useStyle(prefixCls: string, mode: MenuMode | undefined) { | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
Record<string, unknown>forProFormColorPickerPropsremoves type safety for the component'sfieldProps. While this is intended to avoid TS2742 errors during declaration emission, it's a significant trade-off for a library. Consider if a more specific local type or usingimport typemore effectively could resolve the emission issue without losing type safety for consumers.