From f37d0564416260f8b836ef80aee7c6fb4bf0ba5b Mon Sep 17 00:00:00 2001 From: Cheerwhy <73086438+Cheerwhy@users.noreply.github.com> Date: Mon, 27 Nov 2023 15:26:48 +0800 Subject: [PATCH] feat(components): [select] add header and footer slot (#14876) * feat(components): [select] add header and footer slot * fix(docs): [select] incorrect word * fix(theme-chalk): [select-dropdown] incorrect padding * Update docs/en-US/component/select.md Co-authored-by: btea <2356281422@qq.com> * Apply suggestions from code review Co-authored-by: btea <2356281422@qq.com> --------- Co-authored-by: qinzz Co-authored-by: btea <2356281422@qq.com> --- docs/en-US/component/select.md | 32 ++++++- docs/examples/select/custom-footer.vue | 89 ++++++++++++++++++ docs/examples/select/custom-header.vue | 93 +++++++++++++++++++ .../components/select/src/select-dropdown.vue | 6 ++ packages/components/select/src/select.vue | 6 ++ packages/theme-chalk/src/common/var.scss | 2 + packages/theme-chalk/src/select-dropdown.scss | 10 ++ 7 files changed, 233 insertions(+), 5 deletions(-) create mode 100644 docs/examples/select/custom-footer.vue create mode 100644 docs/examples/select/custom-header.vue diff --git a/docs/en-US/component/select.md b/docs/en-US/component/select.md index 25b70847ca..acbc54c0d5 100644 --- a/docs/en-US/component/select.md +++ b/docs/en-US/component/select.md @@ -69,6 +69,26 @@ select/custom-template ::: +## Header of the dropdown ^(2.4.3) + +You can customize the header of the dropdown. + +::: demo Use slot to customize the content. + +select/custom-header + +::: + +## Footer of the dropdown ^(2.4.3) + +You can customize the footer of the dropdown. + +::: demo Use slot to customize the content. + +select/custom-footer + +::: + ## Grouping Display options in groups. @@ -184,11 +204,13 @@ select/value-key ### Select Slots -| Name | Description | Subtags | -| ------- | -------------------------------- | --------------------- | -| default | option component list | Option Group / Option | -| prefix | content as Select prefix | — | -| empty | content when there is no options | — | +| Name | Description | Subtags | +| ------- | ------------------------------------- | --------------------- | +| default | option component list | Option Group / Option | +| header ^(2.4.3) | content at the top of the dropdown | — | +| footer ^(2.4.3) | content at the bottom of the dropdown | — | +| prefix | content as Select prefix | — | +| empty | content when there is no options | — | ### Select Exposes diff --git a/docs/examples/select/custom-footer.vue b/docs/examples/select/custom-footer.vue new file mode 100644 index 0000000000..7833a8907b --- /dev/null +++ b/docs/examples/select/custom-footer.vue @@ -0,0 +1,89 @@ + + + + + diff --git a/docs/examples/select/custom-header.vue b/docs/examples/select/custom-header.vue new file mode 100644 index 0000000000..91b7774e50 --- /dev/null +++ b/docs/examples/select/custom-header.vue @@ -0,0 +1,93 @@ + + + + + diff --git a/packages/components/select/src/select-dropdown.vue b/packages/components/select/src/select-dropdown.vue index 2b46a7b64b..83609a3f4c 100644 --- a/packages/components/select/src/select-dropdown.vue +++ b/packages/components/select/src/select-dropdown.vue @@ -3,7 +3,13 @@ :class="[ns.b('dropdown'), ns.is('multiple', isMultiple), popperClass]" :style="{ [isFitInputWidth ? 'width' : 'minWidth']: minWidth }" > +
+ +
+
+ +
diff --git a/packages/components/select/src/select.vue b/packages/components/select/src/select.vue index e13fd4ef56..7794a72a10 100644 --- a/packages/components/select/src/select.vue +++ b/packages/components/select/src/select.vue @@ -249,6 +249,9 @@ + diff --git a/packages/theme-chalk/src/common/var.scss b/packages/theme-chalk/src/common/var.scss index 441ead6389..3d5c9370ed 100644 --- a/packages/theme-chalk/src/common/var.scss +++ b/packages/theme-chalk/src/common/var.scss @@ -442,6 +442,8 @@ $select-dropdown: map.merge( 'max-height': 274px, 'padding': 6px 0, 'empty-padding': 10px 0, + 'header-padding': 10px, + 'footer-padding': 10px, 'border': 1px solid getCssVar('border-color-light'), ), $select-dropdown diff --git a/packages/theme-chalk/src/select-dropdown.scss b/packages/theme-chalk/src/select-dropdown.scss index e439ab3024..9baf1f1fba 100644 --- a/packages/theme-chalk/src/select-dropdown.scss +++ b/packages/theme-chalk/src/select-dropdown.scss @@ -89,3 +89,13 @@ $checked-icon: "data:image/svg+xml;utf8,%3Csvg class='icon' width='200' height=' margin: 0; box-sizing: border-box; } + +@include b(select-dropdown__header) { + padding: map.get($select-dropdown, 'header-padding'); + border-bottom: map.get($select-dropdown, 'border'); +} + +@include b(select-dropdown__footer) { + padding: map.get($select-dropdown, 'footer-padding'); + border-top: map.get($select-dropdown, 'border'); +}