Refactor #3832 Refactor #3833 - For Sidebar

pull/3853/head
Bahadır Sofuoğlu 2023-04-07 23:36:13 +03:00
parent ea2c8f878d
commit 82fb1e1c65
4 changed files with 22 additions and 5 deletions

View File

@ -52,6 +52,12 @@ const SidebarProps = [
type: 'boolean', type: 'boolean',
default: 'false', default: 'false',
description: 'Whether background scroll should be blocked when sidebar is visible.' description: 'Whether background scroll should be blocked when sidebar is visible.'
},
{
name: 'closeIcon',
type: 'string',
default: 'undefined',
description: 'Icon to display in the sidebar close button.'
} }
]; ];
@ -63,6 +69,10 @@ const SidebarEvents = [
{ {
name: 'show', name: 'show',
description: 'Callback to invoke when sidebar gets shown.' description: 'Callback to invoke when sidebar gets shown.'
},
{
name: 'closeicon',
description: 'Custom close icon template.'
} }
]; ];

View File

@ -66,7 +66,7 @@ export interface OverlayPanelProps {
*/ */
breakpoints?: OverlayPanelBreakpoints; breakpoints?: OverlayPanelBreakpoints;
/** /**
* Icon to display in the message close button. * Icon to display in the overlaypanel close button.
*/ */
closeIcon?: string | undefined; closeIcon?: string | undefined;
} }

View File

@ -46,7 +46,6 @@ export interface SidebarProps {
showCloseIcon?: boolean | undefined; showCloseIcon?: boolean | undefined;
/** /**
* Icon to display in the sidebar close button. * Icon to display in the sidebar close button.
* @defaultValue pi pi-times
*/ */
closeIcon?: string | undefined; closeIcon?: string | undefined;
/** /**
@ -73,6 +72,10 @@ export interface SidebarSlots {
* Custom header template. * Custom header template.
*/ */
header(): VNode[]; header(): VNode[];
/**
* Custom close icon template.
*/
closeicon(): VNode[];
} }
/** /**

View File

@ -8,7 +8,9 @@
<slot name="header"></slot> <slot name="header"></slot>
</div> </div>
<button v-if="showCloseIcon" :ref="closeButtonRef" v-ripple autofocus type="button" class="p-sidebar-close p-sidebar-icon p-link" :aria-label="closeAriaLabel" @click="hide"> <button v-if="showCloseIcon" :ref="closeButtonRef" v-ripple autofocus type="button" class="p-sidebar-close p-sidebar-icon p-link" :aria-label="closeAriaLabel" @click="hide">
<span :class="['p-sidebar-close-icon', closeIcon]" /> <slot name="closeicon">
<component :is="closeIcon ? 'span' : 'TimesIcon'" :class="['p-sidebar-close-icon ', closeIcon]"></component>
</slot>
</button> </button>
</div> </div>
<div :ref="contentRef" class="p-sidebar-content"> <div :ref="contentRef" class="p-sidebar-content">
@ -25,6 +27,7 @@ import FocusTrap from 'primevue/focustrap';
import Portal from 'primevue/portal'; import Portal from 'primevue/portal';
import Ripple from 'primevue/ripple'; import Ripple from 'primevue/ripple';
import { DomHandler, ZIndexUtils } from 'primevue/utils'; import { DomHandler, ZIndexUtils } from 'primevue/utils';
import TimesIcon from 'primevue/icon/times';
export default { export default {
name: 'Sidebar', name: 'Sidebar',
@ -57,7 +60,7 @@ export default {
}, },
closeIcon: { closeIcon: {
type: String, type: String,
default: 'pi pi-times' default: undefined
}, },
modal: { modal: {
type: Boolean, type: Boolean,
@ -246,7 +249,8 @@ export default {
ripple: Ripple ripple: Ripple
}, },
components: { components: {
Portal: Portal Portal: Portal,
TimesIcon
} }
}; };
</script> </script>