Refactor #3832 Refactor #3833 - For OverlayPanel

pull/3853/head
Bahadır Sofuoğlu 2023-04-07 23:07:42 +03:00
parent 89c797bccd
commit 93e29872e9
4 changed files with 38 additions and 2 deletions

View File

@ -28,6 +28,12 @@ const MessageProps = [
type: 'string', type: 'string',
default: 'undefined', default: 'undefined',
description: 'Display a custom icon for the message.' description: 'Display a custom icon for the message.'
},
{
name: 'closeIcon',
type: 'string',
default: 'undefined',
description: 'Display a custom close icon for the message.'
} }
]; ];

View File

@ -40,6 +40,19 @@ const OverlayPanelProps = [
type: 'object', type: 'object',
default: 'null', default: 'null',
description: 'Object literal to define widths per screen size.' description: 'Object literal to define widths per screen size.'
},
{
name: 'closeIcon',
type: 'string',
default: 'undefined',
description: 'Display a custom close icon for the message.'
}
];
const MessageSlots = [
{
name: 'closeicon',
description: 'Custom close icon template.'
} }
]; ];
@ -59,6 +72,7 @@ module.exports = {
name: 'OverlayPanel', name: 'OverlayPanel',
description: 'OverlayPanel is a container component positioned as connected to its target.', description: 'OverlayPanel is a container component positioned as connected to its target.',
props: OverlayPanelProps, props: OverlayPanelProps,
slots: MessageSlots,
events: OverlayPanelEvents events: OverlayPanelEvents
} }
}; };

View File

@ -65,6 +65,10 @@ export interface OverlayPanelProps {
* Object literal to define widths per screen size. * Object literal to define widths per screen size.
*/ */
breakpoints?: OverlayPanelBreakpoints; breakpoints?: OverlayPanelBreakpoints;
/**
* Icon to display in the message close button.
*/
closeIcon?: string | undefined;
} }
/** /**
@ -75,6 +79,10 @@ export interface OverlayPanelSlots {
* Custom content template. * Custom content template.
*/ */
default(): VNode[]; default(): VNode[];
/**
* Custom close icon template.
*/
closeicon(): VNode[];
} }
/** /**

View File

@ -6,7 +6,9 @@
<slot></slot> <slot></slot>
</div> </div>
<button v-if="showCloseIcon" v-ripple class="p-overlaypanel-close p-link" :aria-label="closeAriaLabel" type="button" autofocus @click="hide" @keydown="onButtonKeydown"> <button v-if="showCloseIcon" v-ripple class="p-overlaypanel-close p-link" :aria-label="closeAriaLabel" type="button" autofocus @click="hide" @keydown="onButtonKeydown">
<span class="p-overlaypanel-close-icon pi pi-times"></span> <slot name="closeicon">
<component :is="closeIcon ? 'span' : 'TimesIcon'" :class="['p-overlaypanel-close-icon ', closeIcon]"></component>
</slot>
</button> </button>
</div> </div>
</transition> </transition>
@ -19,6 +21,7 @@ import OverlayEventBus from 'primevue/overlayeventbus';
import Portal from 'primevue/portal'; import Portal from 'primevue/portal';
import Ripple from 'primevue/ripple'; import Ripple from 'primevue/ripple';
import { ConnectedOverlayScrollHandler, DomHandler, UniqueComponentId, ZIndexUtils } from 'primevue/utils'; import { ConnectedOverlayScrollHandler, DomHandler, UniqueComponentId, ZIndexUtils } from 'primevue/utils';
import TimesIcon from 'primevue/icon/times';
export default { export default {
name: 'OverlayPanel', name: 'OverlayPanel',
@ -48,6 +51,10 @@ export default {
breakpoints: { breakpoints: {
type: Object, type: Object,
default: null default: null
},
closeIcon: {
type: String,
default: undefined
} }
}, },
data() { data() {
@ -315,7 +322,8 @@ export default {
ripple: Ripple ripple: Ripple
}, },
components: { components: {
Portal: Portal Portal: Portal,
TimesIcon
} }
}; };
</script> </script>