Drawer: new footer slot added

pull/5756/head
tugcekucukoglu 2024-05-09 15:42:08 +03:00
parent 0250a5cfdd
commit a2c6b3c5aa
3 changed files with 22 additions and 2 deletions

View File

@ -242,6 +242,10 @@ export interface DrawerSlots {
*/ */
closeCallback: () => void; closeCallback: () => void;
}): VNode[]; }): VNode[];
/**
* Custom footer template.
*/
footer(): VNode[];
} }
/** /**

View File

@ -31,6 +31,9 @@
<div :ref="contentRef" :class="cx('content')" v-bind="ptm('content')"> <div :ref="contentRef" :class="cx('content')" v-bind="ptm('content')">
<slot></slot> <slot></slot>
</div> </div>
<div :ref="footerContainerRef" :class="cx('footer')" v-bind="ptm('footer')">
<slot name="footer"> </slot>
</div>
</template> </template>
</div> </div>
</transition> </transition>
@ -61,6 +64,7 @@ export default {
mask: null, mask: null,
content: null, content: null,
headerContainer: null, headerContainer: null,
footerContainer: null,
closeButton: null, closeButton: null,
outsideClickListener: null, outsideClickListener: null,
documentKeydownListener: null, documentKeydownListener: null,
@ -129,7 +133,11 @@ export default {
focusTarget = this.$slots.default && findFocusableElement(this.container); focusTarget = this.$slots.default && findFocusableElement(this.container);
if (!focusTarget) { if (!focusTarget) {
focusTarget = this.closeButton; focusTarget = this.$slots.footer && findFocusableElement(this.footerContainer);
if (!focusTarget) {
focusTarget = this.closeButton;
}
} }
} }
@ -168,6 +176,9 @@ export default {
headerContainerRef(el) { headerContainerRef(el) {
this.headerContainer = el; this.headerContainer = el;
}, },
footerContainerRef(el) {
this.footerContainer = el;
},
closeButtonRef(el) { closeButtonRef(el) {
this.closeButton = el ? el.$el : undefined; this.closeButton = el ? el.$el : undefined;
}, },

View File

@ -28,6 +28,10 @@ const theme = ({ dt }) => `
padding: ${dt('drawer.header.padding')}; padding: ${dt('drawer.header.padding')};
} }
.p-drawer-footer {
padding: ${dt('drawer.header.padding')};
}
.p-drawer-title { .p-drawer-title {
font-weight: ${dt('drawer.title.font.weight')}; font-weight: ${dt('drawer.title.font.weight')};
font-size: ${dt('drawer.title.font.size')}; font-size: ${dt('drawer.title.font.size')};
@ -148,7 +152,8 @@ const classes = {
header: 'p-drawer-header', header: 'p-drawer-header',
title: 'p-drawer-title', title: 'p-drawer-title',
pcCloseButton: 'p-drawer-close-button', pcCloseButton: 'p-drawer-close-button',
content: 'p-drawer-content' content: 'p-drawer-content',
footer: 'p-drawer-footer'
}; };
export default BaseStyle.extend({ export default BaseStyle.extend({