Socket
Socket
Sign inDemoInstall

@vuepress/plugin-back-to-top

Package Overview
Dependencies
Maintainers
2
Versions
210
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vuepress/plugin-back-to-top - npm Package Compare versions

Comparing version 2.0.0-rc.8 to 2.0.0-rc.9

lib/node/locales.d.ts

2

lib/client/components/BackToTop.d.ts

@@ -1,2 +0,1 @@

import '../styles/vars.css';
import '../styles/back-to-top.css';

@@ -6,2 +5,1 @@ export declare const BackToTop: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {

}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
export default BackToTop;

@@ -1,24 +0,50 @@

import { debounce } from 'ts-debounce';
import { computed, defineComponent, h, onMounted, ref, Transition } from 'vue';
import { getScrollTop, scrollToTop } from '../utils.js';
import '../styles/vars.css';
import { useLocaleConfig } from '@vuepress/helper/client';
import { useElementSize, useWindowScroll, useWindowSize } from '@vueuse/core';
import { computed, defineComponent, h, onMounted, shallowRef, Transition, } from 'vue';
import { usePageFrontmatter } from 'vuepress/client';
import '../styles/back-to-top.css';
export const BackToTop = defineComponent({
name: 'BackToTop',
setup() {
const scrollTop = ref(0);
const show = computed(() => scrollTop.value > 300);
const onScroll = debounce(() => {
scrollTop.value = getScrollTop();
}, 100);
setup(props) {
const pageFrontmatter = usePageFrontmatter();
const locale = useLocaleConfig(__BACK_TO_TOP_LOCALES__);
const body = shallowRef();
const { height: bodyHeight } = useElementSize(body);
const { height: windowHeight } = useWindowSize();
/** Scroll distance */
const { y } = useWindowScroll();
/** Whether to display button */
const show = computed(() => pageFrontmatter.value.backToTop !== false &&
y.value > __BACK_TO_TOP_THRESHOLD__);
const progress = computed(() => (y.value / (bodyHeight.value - windowHeight.value)) * 100);
onMounted(() => {
scrollTop.value = getScrollTop();
window.addEventListener('scroll', () => onScroll());
body.value = document.body;
});
const backToTopEl = h('div', { class: 'back-to-top', onClick: scrollToTop });
return () => h(Transition, {
name: 'back-to-top',
}, () => (show.value ? backToTopEl : null));
return () => h(Transition, { name: 'back-to-top' }, () => show.value
? h('button', {
'type': 'button',
'class': 'vp-back-to-top-button',
'aria-label': locale.value.backToTop,
'onClick': () => {
window.scrollTo({ top: 0, behavior: 'smooth' });
},
}, [
__BACK_TO_TOP_PROGRESS__
? h('span', {
'class': 'vp-scroll-progress',
'role': 'progressbar',
'aria-labelledby': 'loadinglabel',
'aria-valuenow': progress.value,
}, h('svg', h('circle', {
cx: '50%',
cy: '50%',
style: {
'stroke-dasharray': `calc(${Math.PI * progress.value}% - ${4 * Math.PI}px) calc(${Math.PI * 100}% - ${4 * Math.PI}px)`,
},
})))
: null,
h('div', { class: 'back-to-top-icon' }),
])
: null);
},
});
export default BackToTop;
import type { ClientConfig } from 'vuepress/client';
import './styles/vars.css';
declare const _default: ClientConfig;
export default _default;
import { defineClientConfig } from 'vuepress/client';
import { BackToTop } from './components/index.js';
import './styles/vars.css';
export default defineClientConfig({
rootComponents: [BackToTop],
});
import type { Plugin } from 'vuepress/core';
export declare const backToTopPlugin: () => Plugin;
import type { BackToTopPluginOptions } from './options.js';
export declare const backToTopPlugin: (options?: BackToTopPluginOptions) => Plugin;

@@ -1,6 +0,23 @@

import { getDirname, path } from 'vuepress/utils';
import { getLocaleConfig } from '@vuepress/helper';
import { getDirname, logger, path } from 'vuepress/utils';
import { backToTopLocales } from './locales.js';
import { PLUGIN_NAME } from './logger.js';
const __dirname = getDirname(import.meta.url);
export const backToTopPlugin = () => ({
name: '@vuepress/plugin-back-to-top',
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
});
export const backToTopPlugin = (options = {}) => (app) => {
if (app.env.isDebug)
logger.info('Options', options);
return {
name: PLUGIN_NAME,
define: (app) => ({
__BACK_TO_TOP_LOCALES__: getLocaleConfig({
app,
name: 'back-to-top',
default: backToTopLocales,
config: options.locales,
}),
__BACK_TO_TOP_PROGRESS__: options.progress ?? true,
__BACK_TO_TOP_THRESHOLD__: options.threshold ?? 100,
}),
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
};
};
import { backToTopPlugin } from './backToTopPlugin.js';
export * from './backToTopPlugin.js';
export type * from './options.js';
export type * from '../shared/index.js';
export default backToTopPlugin;
{
"name": "@vuepress/plugin-back-to-top",
"version": "2.0.0-rc.8",
"version": "2.0.0-rc.9",
"description": "VuePress plugin - back to top",

@@ -36,7 +36,8 @@ "keywords": [

"clean": "rimraf --glob ./lib ./*.tsbuildinfo",
"copy": "cpx \"src/**/*.{css,svg}\" lib",
"style": "sass src:lib --style=compressed --no-source-map"
"copy": "cpx \"src/**/*.svg\" lib",
"style": "sass src:lib --no-source-map"
},
"dependencies": {
"ts-debounce": "^4.0.0",
"@vuepress/helper": "2.0.0-rc.9",
"@vueuse/core": "^10.7.2",
"vue": "^3.4.15"

@@ -50,3 +51,3 @@ },

},
"gitHead": "a025fcc27e4de1d71b5b5ae18cbb9eec9e7c2a69"
"gitHead": "12c12dadd0758df4ad5256851fc3cb3c949873e8"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc