parent
07ca49f983
commit
e3c0ee65ec
|
@ -14,7 +14,7 @@ const ScrollTopProps = [
|
||||||
{
|
{
|
||||||
name: 'icon',
|
name: 'icon',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: 'pi pi-chevron-up',
|
default: 'undefined',
|
||||||
description: 'Icon to display.'
|
description: 'Icon to display.'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -25,10 +25,18 @@ const ScrollTopProps = [
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const ScrollTopSlots = [
|
||||||
|
{
|
||||||
|
name: 'icon',
|
||||||
|
description: 'Custom scrolltop icon template.'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
scrolltop: {
|
scrolltop: {
|
||||||
name: 'ScrollTop',
|
name: 'ScrollTop',
|
||||||
description: 'ScrollTop gets displayed after a certain scroll position and used to navigates to the top of the page quickly.',
|
description: 'ScrollTop gets displayed after a certain scroll position and used to navigates to the top of the page quickly.',
|
||||||
props: ScrollTopProps
|
props: ScrollTopProps,
|
||||||
|
slots: ScrollTopSlots
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* @module scrolltop
|
* @module scrolltop
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
import { VNode } from 'vue';
|
||||||
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +26,6 @@ export interface ScrollTopProps {
|
||||||
threshold?: number | undefined;
|
threshold?: number | undefined;
|
||||||
/**
|
/**
|
||||||
* Icon to display.
|
* Icon to display.
|
||||||
* @defaultValue pi pi-chevron-up
|
|
||||||
*/
|
*/
|
||||||
icon?: string | undefined;
|
icon?: string | undefined;
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +38,12 @@ export interface ScrollTopProps {
|
||||||
/**
|
/**
|
||||||
* Defines valid slots in ScrollTop component.
|
* Defines valid slots in ScrollTop component.
|
||||||
*/
|
*/
|
||||||
export interface ScrollTopSlots {}
|
export interface ScrollTopSlots {
|
||||||
|
/**
|
||||||
|
* Custom scrolltop icon template.
|
||||||
|
*/
|
||||||
|
icon(): VNode[];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines valid emits in ScrollTop component.
|
* Defines valid emits in ScrollTop component.
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
<template>
|
<template>
|
||||||
<transition name="p-scrolltop" appear @enter="onEnter" @after-leave="onAfterLeave">
|
<transition name="p-scrolltop" appear @enter="onEnter" @after-leave="onAfterLeave">
|
||||||
<button v-if="visible" :ref="containerRef" :class="containerClass" @click="onClick" type="button" :aria-label="scrollTopAriaLabel">
|
<button v-if="visible" :ref="containerRef" :class="containerClass" @click="onClick" type="button" :aria-label="scrollTopAriaLabel">
|
||||||
<span :class="iconClass"></span>
|
<slot name="icon">
|
||||||
|
<component :is="icon ? 'span' : 'ChevronUpIcon'" :class="['p-scrolltop-icon', icon]"></component>
|
||||||
|
</slot>
|
||||||
</button>
|
</button>
|
||||||
</transition>
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { DomHandler, ZIndexUtils } from 'primevue/utils';
|
import { DomHandler, ZIndexUtils } from 'primevue/utils';
|
||||||
|
import ChevronUpIcon from 'primevue/icon/chevronup';
|
||||||
export default {
|
export default {
|
||||||
name: 'ScrollTop',
|
name: 'ScrollTop',
|
||||||
scrollListener: null,
|
scrollListener: null,
|
||||||
|
@ -24,7 +26,7 @@ export default {
|
||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'pi pi-chevron-up'
|
default: undefined
|
||||||
},
|
},
|
||||||
behavior: {
|
behavior: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -102,12 +104,12 @@ export default {
|
||||||
containerClass() {
|
containerClass() {
|
||||||
return ['p-scrolltop p-link p-component', { 'p-scrolltop-sticky': this.target !== 'window' }];
|
return ['p-scrolltop p-link p-component', { 'p-scrolltop-sticky': this.target !== 'window' }];
|
||||||
},
|
},
|
||||||
iconClass() {
|
|
||||||
return ['p-scrolltop-icon', this.icon];
|
|
||||||
},
|
|
||||||
scrollTopAriaLabel() {
|
scrollTopAriaLabel() {
|
||||||
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.scrollTop : undefined;
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.scrollTop : undefined;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
ChevronUpIcon
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue