Skip to content

Commit

Permalink
feat(DropdownMenuItem): support footer slot (#3309)
Browse files Browse the repository at this point in the history
* feat(DropdownMenuItem): support footer slot

* test: update snapshots
  • Loading branch information
anlyyao authored Nov 28, 2024
1 parent e46ed43 commit 21c9b4e
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 20 deletions.
7 changes: 7 additions & 0 deletions src/dropdown-item/dropdown-item.less
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@
}
}

&__body,
&__footer {
&:empty {
display: none;
}
}

&__radio,
&__checkbox {
width: 100%;
Expand Down
4 changes: 4 additions & 0 deletions src/dropdown-item/dropdown-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const name = `${prefix}-dropdown-item`;
export interface DropdownItemProps extends TdDropdownItemProps {}
@wxComponent()
export default class DropdownMenuItem extends SuperComponent {
options = {
multipleSlots: true,
};

externalClasses = [
`${prefix}-class`,
`${prefix}-class-content`,
Expand Down
53 changes: 33 additions & 20 deletions src/dropdown-item/dropdown-item.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@
t-class="{{classPrefix}}__popup-host"
t-class-content="{{classPrefix}}__content {{prefix}}-class-content"
>
<view wx:if="{{options && options.length > 0}}" class="{{classPrefix}}__body">
<view class="{{classPrefix}}__body">
<!-- 单选列表 -->
<scroll-view wx:if="{{!multiple}}" class="{{classPrefix}}__scroll" scroll-y scroll-into-view="id_{{value}}">
<scroll-view
wx:if="{{!multiple && options && options.length > 0}}"
class="{{classPrefix}}__scroll"
scroll-y
scroll-into-view="id_{{value}}"
>
<t-radio-group
class="{{classPrefix}}__radio {{prefix}}-class-column"
t-class="{{classPrefix}}__radio-group"
Expand All @@ -51,7 +56,12 @@
</t-radio-group>
</scroll-view>
<!-- 多选列表 -->
<scroll-view wx:else class="{{classPrefix}}__scroll" scroll-y scroll-into-view="id_{{firstCheckedValue}}">
<scroll-view
wx:if="{{multiple && options && options.length > 0}}"
class="{{classPrefix}}__scroll"
scroll-y
scroll-into-view="id_{{firstCheckedValue}}"
>
<t-checkbox-group
class="{{classPrefix}}__checkbox {{prefix}}-class-column"
t-class="{{classPrefix}}__checkbox-group"
Expand All @@ -74,23 +84,26 @@

<slot />
</view>
<view class="{{classPrefix}}__footer {{prefix}}-class-footer" wx:if="{{multiple}}">
<t-button
block
class="{{classPrefix}}__footer-btn {{classPrefix}}__reset-btn"
theme="light"
disabled="{{value.length == 0}}"
bindtap="handleReset"
>重置</t-button
>
<t-button
block
class="{{classPrefix}}__footer-btn {{classPrefix}}__confirm-btn"
theme="primary"
disabled="{{value.length == 0}}"
bindtap="handleConfirm"
>确定</t-button
>
<view class="{{classPrefix}}__footer {{prefix}}-class-footer">
<slot name="footer" />
<block wx:if="{{multiple}}">
<t-button
block
class="{{classPrefix}}__footer-btn {{classPrefix}}__reset-btn"
theme="light"
content="重置"
disabled="{{value.length == 0}}"
bindtap="handleReset"
/>
<t-button
block
class="{{classPrefix}}__footer-btn {{classPrefix}}__confirm-btn"
theme="primary"
content="确定"
disabled="{{value.length == 0}}"
bindtap="handleConfirm"
/>
</block>
</view>
</t-popup>
</view>
2 changes: 2 additions & 0 deletions src/dropdown-menu/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ name | params | description
-- | -- | --
close | \- | \-
open | \- | \-

### DropdownMenu External Classes

className | Description
Expand Down Expand Up @@ -55,6 +56,7 @@ change | `(value: DropdownValue)` | \-
close | \- | \-
confirm | `(value: DropdownValue)` | \-
reset | \- | \-

### DropdownItem External Classes

className | Description
Expand Down
2 changes: 2 additions & 0 deletions src/dropdown-menu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ z-index | Number | 11600 | 菜单栏 z-index 层级 | N
-- | -- | --
close | \- | 菜单关闭时触发
open | \- | 菜单展开时触发

### DropdownMenu External Classes

类名 | 描述
Expand Down Expand Up @@ -102,6 +103,7 @@ change | `(value: DropdownValue)` | 值改变时触发
close | \- | 关闭时触发
confirm | `(value: DropdownValue)` | 点击确认时触发
reset | \- | 点击重置时触发

### DropdownItem External Classes

类名 | 描述
Expand Down
3 changes: 3 additions & 0 deletions src/dropdown-menu/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,9 @@ exports[`dropdown-menu :base 1`] = `
</t-radio-group>
</wx-scroll-view>
</wx-view>
<wx-view
class="t-dropdown-item__footer t-class-footer"
/>
<wx-view
class="t-popup__close"
bind:tap="handleClose"
Expand Down

0 comments on commit 21c9b4e

Please sign in to comment.