-
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 all 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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -88,7 +88,7 @@ function layoutNavCssVars(surface: 'sider' | 'header'): Record<string, string> { | |||||||
| [navVar.itemRadius]: '6px', | ||||||||
| [navVar.itemGap]: '8px', | ||||||||
| [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]: '400', | ||||||||
| [navVar.itemFontWeight]: '500', | ||||||||
| [navVar.itemPadBlock]: '6px', | ||||||||
| [navVar.itemPadInline]: `${padInline}px`, | ||||||||
| [navVar.stackGap]: `${stackGap}px`, | ||||||||
|
|
@@ -305,10 +305,13 @@ const genProLayoutBaseMenuStyle: GenerateStyle<ProLayoutBaseMenuToken> = ( | |||||||
| whiteSpace: 'nowrap', | ||||||||
| }, | ||||||||
| '&-collapsed': { | ||||||||
| minWidth: v('itemHeight'), | ||||||||
| height: v('itemHeight'), | ||||||||
| width: 'fit-content', | ||||||||
| maxWidth: '100%', | ||||||||
| minWidth: v('iconBox'), | ||||||||
| height: 'auto', | ||||||||
| flexDirection: 'column', | ||||||||
| justifyContent: 'center', | ||||||||
| justifyContent: 'flex-start', | ||||||||
| alignItems: 'flex-start', | ||||||||
| [`${c}-item-icon`]: { | ||||||||
| width: v('iconBox'), | ||||||||
| height: v('iconBox'), | ||||||||
|
|
@@ -317,7 +320,7 @@ const genProLayoutBaseMenuStyle: GenerateStyle<ProLayoutBaseMenuToken> = ( | |||||||
| }, | ||||||||
| '&-collapsed-level-0': { | ||||||||
| flexDirection: 'column', | ||||||||
| justifyContent: 'center', | ||||||||
| justifyContent: 'flex-start', | ||||||||
| }, | ||||||||
| [`&${c}-group-item-title`]: { | ||||||||
| gap: v('itemGap'), | ||||||||
|
|
@@ -330,10 +333,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', | ||||||||
|
|
@@ -410,21 +413,22 @@ 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', | ||||||||
| }, | ||||||||
| [`${c}-submenu${c}-submenu-open > ${c}-submenu-title`]: { | ||||||||
| backgroundColor: v('colorBgSelected'), | ||||||||
| borderRadius: v('itemRadius'), | ||||||||
| }, | ||||||||
| /** 侧栏收起:不展示分组标题,仅保留图标型菜单项 */ | ||||||||
| [`${c}-group ${c}-group-title`]: { | ||||||||
| display: 'none', | ||||||||
| }, | ||||||||
| }, | ||||||||
| }, | ||||||||
|
|
||||||||
| /** 侧栏收起:不展示分组标题(完整选择器,避免嵌套编译差异) */ | ||||||||
| [`${c}--collapsed ${c}-group ${c}-group-title`]: { | ||||||||
| display: 'none', | ||||||||
| }, | ||||||||
|
|
||||||||
| [`${c}:not(${c}--horizontal)`]: { | ||||||||
| display: 'flex', | ||||||||
| flexDirection: 'column', | ||||||||
|
|
@@ -433,19 +437,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', | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,14 +9,9 @@ import type { | |
| } from './navMenuTypes'; | ||
|
|
||
| /** | ||
| * 主导航渲染模式(与历史 antd Menu `mode` 命名对齐)。 | ||
| * 主导航渲染模式:顶栏 `horizontal`,侧栏 `vertical`(展开与收起均如此,收起时子菜单为弹出层)。 | ||
| */ | ||
| export type MenuMode = | ||
| | 'vertical' | ||
| | 'vertical-left' | ||
| | 'vertical-right' | ||
| | 'horizontal' | ||
| | 'inline'; | ||
| export type MenuMode = 'vertical' | 'horizontal'; | ||
|
Comment on lines
11
to
+14
|
||
|
|
||
| /** | ||
| * 可合并到 `ProLayoutNavMenu` 根节点 `<nav>` 上的 DOM 属性。 | ||
|
|
||
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.