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 🙏

© 2024 – Pkg Stats / Ryan Hefner

v-toggle-theme

v3.0.7

Published

A Vue 3 and Vuetify 3 compatible component that automatically switches between light and dark themes based on sunrise and sunset times. Includes manual override capabilities and full support for SSR and geolocation.

Downloads

385

Readme

VToggleTheme: Theme Switcher Component

This Vue component automatically switches themes based on the sunrise and sunset times of the user's location, utilizing Vuetify's theming system. Users can also manually toggle the theme, which disables the automatic switching.

Features

  • Automatic Theme Switching: Updates the theme based on real-time sunrise/sunset times.
  • Manual Override: Allows users to manually switch themes, disabling automatic switching.
  • Vuetify Integration: Seamlessly integrates with Vuetify's theming system.
  • Geo-location Support: Uses the browser's geolocation API to determine the user's current coordinates.
  • SSR Compatibility: Ensures correct operation in both client and server-side environments.

Requirements

  • Vue 3.x
  • Vuetify 3.x
  • @mdi/js: Required for icon support.

Installation

Install the component via npm:

npm install v-toggle-theme sunrise-sunset-js @mdi/js --save

Ensure Vue 3.x, Vuetify 3.x, and @mdi/js are set up in your project:

npm install vue@next vuetify@next @mdi/js

Usage

Props

  • themeNameLight (String): Name of the light theme. Default: 'light'.
    • Example: :themeNameLight="'myLightTheme'"
  • themeNameDark (String): Name of the dark theme. Default: 'dark'.
    • Example: :themeNameDark="'myDarkTheme'"
  • fallbackLocation (Object): Default coordinates if geolocation fails. Default: { lat: 47.36667, lng: 8.55 } (Zurich).
    • Example: :fallbackLocation="{ lat: 40.7128, lng: -74.0060 }" (New York)
  • renderAs (String): Renders as 'button' or 'switch'. Default: 'button'.
    • Example: :renderAs="'switch'"
  • switchIconColor (String): Sets the switch color, utilizing Vuetify's color utilities.
    • Example: :switchIconColor="'green'"
  • tooltip (Boolean): Enables tooltips. Default: false.
    • Example: :tooltip="true"
  • tipDark (String): Tooltip text for dark mode. Default: 'Dark mode'.
    • Example: :tipDark="'Activate dark mode'"
  • tipLight (String): Tooltip text for light mode. Default: 'Light mode'.
    • Example: :tipLight="'Activate light mode'"
  • automatic (Boolean): Enables automatic theme switching. Default: true.
    • Example: :automatic="false"

Integration

Options API

<template>
  <v-toggle-theme color="primary" :tooltip="true" />
</template>

<script>
import VToggleTheme from 'v-toggle-theme';

export default {
  components: {
    VToggleTheme
  }
}
</script>

Composition API

<template>
  <v-toggle-theme color="primary" :tooltip="true" />
</template>

<script setup>
import VToggleTheme from 'v-toggle-theme';
</script>

Events

  • switchManually: Toggles the theme manually and stops automatic switching.

Customization

Customize the switch appearance using Vuetify's button or switch properties. Modify themeNameLight and themeNameDark according to your Vuetify theme settings for deeper integration.

License

Licensed under the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version.

Acknowledgements

Thanks to Matt Kane (@ascorbic) for creating the sunrise-sunset-js package, a crucial tool for this project.