-
Notifications
You must be signed in to change notification settings - Fork 271
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
feat(dropdown): [dropdown] add right side expansion function for dropdown #2608
Changes from all commits
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<template> | ||
<tiny-dropdown> | ||
<template #dropdown> | ||
<tiny-dropdown-menu placement="bottom-start"> | ||
<tiny-dropdown-item label="老友粉"></tiny-dropdown-item> | ||
<tiny-dropdown-item>黄金糕</tiny-dropdown-item> | ||
<tiny-dropdown-item>狮子头</tiny-dropdown-item> | ||
<tiny-dropdown-item>螺蛳粉</tiny-dropdown-item> | ||
<tiny-dropdown-item disabled>双皮奶</tiny-dropdown-item> | ||
<tiny-dropdown-item>蚵仔煎</tiny-dropdown-item> | ||
</tiny-dropdown-menu> | ||
</template> | ||
</tiny-dropdown> | ||
<br /> | ||
<br /> | ||
<tiny-dropdown> | ||
<template #dropdown> | ||
<tiny-dropdown-menu :options="options" placement="bottom-start"> </tiny-dropdown-menu> | ||
</template> | ||
</tiny-dropdown> | ||
</template> | ||
Comment on lines
+1
to
+21
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. Demo should demonstrate right-side expansion functionality The template only shows Suggested additions: <tiny-dropdown>
<template #dropdown>
- <tiny-dropdown-menu placement="bottom-start">
+ <tiny-dropdown-menu placement="bottom-end">
<tiny-dropdown-item label="老友粉"></tiny-dropdown-item>
<!-- ... -->
</tiny-dropdown-menu>
</template>
</tiny-dropdown>
+<!-- Add documentation comment explaining the different placement options -->
+<tiny-dropdown>
+ <template #dropdown>
+ <tiny-dropdown-menu placement="bottom-start" expand="right">
+ <!-- Add example with right expansion -->
+ </tiny-dropdown-menu>
+ </template>
+</tiny-dropdown>
|
||
|
||
<script setup> | ||
import { reactive } from 'vue' | ||
import { iconStarDisable } from '@opentiny/vue-icon' | ||
import { TinyDropdown, TinyDropdownMenu, TinyDropdownItem } from '@opentiny/vue' | ||
const options = reactive([ | ||
{ | ||
label: '老友粉1', | ||
icon: iconStarDisable(), | ||
children: [ | ||
{ | ||
label: '老友粉2.1', | ||
children: [{ label: '狮子头3.1' }] | ||
}, | ||
{ label: '老友粉2.2' }, | ||
{ label: '老友粉2.3', disabled: true } | ||
] | ||
}, | ||
{ | ||
label: '狮子头', | ||
disabled: true | ||
}, | ||
{ | ||
label: '黄金糕', | ||
icon: iconStarDisable() | ||
} | ||
]) | ||
</script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<template> | ||
<tiny-dropdown> | ||
<template #dropdown> | ||
<tiny-dropdown-menu placement="bottom-start"> | ||
<tiny-dropdown-item label="老友粉"></tiny-dropdown-item> | ||
<tiny-dropdown-item>黄金糕</tiny-dropdown-item> | ||
<tiny-dropdown-item>狮子头</tiny-dropdown-item> | ||
<tiny-dropdown-item>螺蛳粉</tiny-dropdown-item> | ||
<tiny-dropdown-item disabled>双皮奶</tiny-dropdown-item> | ||
<tiny-dropdown-item>蚵仔煎</tiny-dropdown-item> | ||
</tiny-dropdown-menu> | ||
</template> | ||
</tiny-dropdown> | ||
<br /> | ||
<br /> | ||
<tiny-dropdown> | ||
<template #dropdown> | ||
<tiny-dropdown-menu :options="options" placement="bottom-start"> </tiny-dropdown-menu> | ||
</template> | ||
</tiny-dropdown> | ||
</template> | ||
|
||
<script> | ||
import { iconStarDisable } from '@opentiny/vue-icon' | ||
import { TinyDropdown, TinyDropdownMenu, TinyDropdownItem } from '@opentiny/vue' | ||
export default { | ||
components: { | ||
TinyDropdown, | ||
TinyDropdownMenu, | ||
TinyDropdownItem | ||
}, | ||
data() { | ||
return { | ||
options: [ | ||
{ | ||
label: '老友粉1', | ||
icon: iconStarDisable(), | ||
children: [ | ||
{ | ||
label: '老友粉2.1', | ||
children: [{ label: '狮子头3.1' }] | ||
}, | ||
{ label: '老友粉2.2' }, | ||
{ label: '老友粉2.3', disabled: true } | ||
] | ||
}, | ||
{ | ||
label: '狮子头', | ||
disabled: true | ||
}, | ||
{ | ||
label: '黄金糕', | ||
icon: iconStarDisable() | ||
} | ||
] | ||
} | ||
} | ||
} | ||
</script> |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -35,17 +35,17 @@ | |||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// 菜单项内边距 | ||||||||||||||||||||||||||
--tv-DropdownItem-padding: 0px var(--tv-space-xl, 16px); | ||||||||||||||||||||||||||
// 展开图标的右侧外边距 | ||||||||||||||||||||||||||
--tv-DropdownItem-expand-margin-right: var(--tv-space-md, 8px); | ||||||||||||||||||||||||||
// 前置图标的右侧外边距 | ||||||||||||||||||||||||||
--tv-DropdownItem-pre-icon-margin-right: var(--tv-space-sm, 4px); | ||||||||||||||||||||||||||
// 展开图标的水平外边距 | ||||||||||||||||||||||||||
--tv-DropdownItem-expand-margin-x: var(--tv-space-md, 8px); | ||||||||||||||||||||||||||
// 自定义图标的水平外边距 | ||||||||||||||||||||||||||
--tv-DropdownItem-pre-icon-margin-x: var(--tv-space-sm, 4px); | ||||||||||||||||||||||||||
Comment on lines
+38
to
+41
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. Add variables to support right-side expansion While renaming margin variables to be more generic is good, additional variables are needed to fully support right-side expansion functionality. Consider adding: // 展开图标的水平外边距
--tv-DropdownItem-expand-margin-x: var(--tv-space-md, 8px);
// 自定义图标的水平外边距
--tv-DropdownItem-pre-icon-margin-x: var(--tv-space-sm, 4px);
+// 右侧展开时的位置调整
+--tv-DropdownItem-expand-right-offset: var(--tv-space-xl, 16px);
+// 右侧展开时的图标旋转
+--tv-DropdownItem-expand-right-rotation: 270deg; 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
// 菜单项内容区的左侧外边距 | ||||||||||||||||||||||||||
--tv-DropdownItem-content-margin-left: calc( | ||||||||||||||||||||||||||
var(--tv-DropdownItem-icon-size) + var(--tv-DropdownItem-expand-margin-right) | ||||||||||||||||||||||||||
var(--tv-DropdownItem-icon-size) + var(--tv-DropdownItem-expand-margin-x) | ||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||
// 菜单项文本的左侧外边距 | ||||||||||||||||||||||||||
--tv-DropdownItem-label-margin-left: calc( | ||||||||||||||||||||||||||
var(--tv-DropdownItem-icon-size) + var(--tv-DropdownItem-pre-icon-margin-right) | ||||||||||||||||||||||||||
var(--tv-DropdownItem-icon-size) + var(--tv-DropdownItem-pre-icon-margin-x) | ||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||
Comment on lines
+44
to
49
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. 🛠️ Refactor suggestion Update margin calculations for right-side expansion The current margin calculations need to be updated to handle both left and right expansion scenarios. Consider updating the calculations: --tv-DropdownItem-content-margin-left: calc(
- var(--tv-DropdownItem-icon-size) + var(--tv-DropdownItem-expand-margin-x)
+ var(--tv-expand-direction) * (var(--tv-DropdownItem-icon-size) + var(--tv-DropdownItem-expand-margin-x))
);
--tv-DropdownItem-label-margin-left: calc(
- var(--tv-DropdownItem-icon-size) + var(--tv-DropdownItem-pre-icon-margin-x)
+ var(--tv-expand-direction) * (var(--tv-DropdownItem-icon-size) + var(--tv-DropdownItem-pre-icon-margin-x))
);
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// 菜单项高度(默认) | ||||||||||||||||||||||||||
|
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.
💡 Codebase verification
Breaking Change Confirmed: IPlacementType restriction impacts existing code
The verification shows extensive usage of 'top' related placement values across the codebase, particularly in:
The removal of these options from
IPlacementType
will break existing implementations. Specific impacts:Recommendations:
🔗 Analysis chain
Breaking Change: IPlacementType restriction.
The removal of 'top', 'top-start', and 'top-end' options from
IPlacementType
is a breaking change that could affect existing implementations.Let's verify the impact:
Consider:
Let me gather more information to verify the impact comprehensively.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 242
Script:
Length of output: 41346