npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ad-sun-moon-switch

v1.0.3

Published

基于 Vue 3 的优雅主题切换组件:iOS 风格开关 + 太阳/月亮交替过渡层(参考 liuyuyang.net)

Readme

ad-sun-moon-switch

基于 Vue 3 的优雅主题切换组件:iOS 风格开关 + 点击时全屏播放太阳/月亮交替过渡层(天空渐变、日月沿抛物线滑落/升起、夜晚浮现星星),效果参考 liuyuyang.net。

vue 3 license

特性

  • ☀️ 点击开关 → 全屏过渡层:太阳滑落、月亮升起(反之亦然),天空在白天/夜晚色间渐变
  • 🌙 支持 prefers-reduced-motion:用户偏好减少动效时直接切换
  • 🧊 主题通过 html.dark 类 + CSS 变量驱动,颜色 0.3s 平滑过渡
  • 💾 主题选择持久化到 localStorage
  • 🧩 零依赖(仅 peer 依赖 vue)

安装

npm install ad-sun-moon-switch

使用

全局注册(推荐)

// main.js
import { createApp } from 'vue'
import VueSunMoonSwitch from 'ad-sun-moon-switch'
import 'ad-sun-moon-switch/style.css' // 主题变量样式(必引)

createApp(App).use(VueSunMoonSwitch).mount('#app')
<template>
  <VueSunMoonSwitch position="top-right" />
</template>

按需引入

<script setup>
import VueSunMoonSwitch from 'ad-sun-moon-switch'
import 'ad-sun-moon-switch/style.css'
</script>

<template>
  <VueSunMoonSwitch position="top-left" />
</template>

Props

| 名称 | 类型 | 默认值 | 说明 | |---|---|---|---| | position | string \| object | 'top-right' | 开关位置:top-right / top-left / bottom-right / bottom-left,或传入 CSS 定位对象如 { top: '20px', left: '20px' } |

自定义主题色

页面主题色由 CSS 变量控制,可在自己的样式中覆盖:

:root {
  --vsm-bg: #f5f7fb;            /* 白天背景 */
  --vsm-text: #1f2937;          /* 白天文字 */
  --vsm-text-secondary: #6b7280;
}

html.dark {
  --vsm-bg: #0b1120;            /* 夜晚背景 */
  --vsm-text: #f1f5f9;
  --vsm-text-secondary: #94a3b8;
}

发布到 npm(作者自用)

npm run build          # 构建库产物(dist/)与 demo
npm login              # 登录 npm 账号(仅首次)
npm publish            # 发布

发布后即可在其他项目安装使用:

npm install ad-sun-moon-switch

License

MIT