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

vue-daisyui-theme-manager

v0.0.29

Published

A plugin that allows you to change DaisyUI themes during runtime. As well as, setting default light and dark themes, and matching the system theme.

Downloads

187

Readme

Vue Daisy UI Theme Manager Plugin

This plugin allows you to change the theme of your application at runtime. It also allows you to watch for system theme changes and update the theme accordingly.

live-demo

Install:

npm i vue-daisyui-theme-manager

Setup

As you install theme-manager.config.ts will be automatically created and added to the root folder of your project. You can set up the available themes in this file. It will be also used as type definition. But don't forget to specify the list of themes in tailwind.config.js as well. More information about setting up the themes at DaisyUI Themes Setup.

API

Initial Setup

As you insts

Plugin Setup: createThemeManager

Initiate the plugin with the default theme and the dark theme. Theme options are from Daisiy UI themes as well as some custom added themes. Check all the built-in DaisyUI Themes. Create your own custom daisy ui theme here and add it to the tailwind.config.js file!

type DaisyThemes = "light" | "default" | "dark" | "cupcake" |
 "bumblebee" | "emerald" | "corporate" | "synthwave" | "retro" | "cyberpunk" |
  "valentine" | "halloween" | "garden" |  'forest' | 'aqua' | 'lofi' | 'pastel' |
  'fantasy' | 'wireframe' | 'black' | 'luxury' | 'dracula' | 'cmyk' | 'autumn' |
  'business' | 'acid' | 'lemonade' | 'night' | 'coffee' | | "winter"

Type definition

export type ThemeOptions = {
  light: DaisyThemes
  dark: DaisyThemes
  watchSystemTheme: boolean
}

createThemeManager(options?: ThemeOptions): (app: App) => void

Usage in main.ts

The light and dark options are the default themes that will be used when "toggleDark()" is called. Or when "set({theme:'default'})" is being called.

// main.ts
import { createApp } from 'vue'
import App from './App.vue'
import { createThemeManager } from '@/plugins/themeManager'

const app = createApp(App)
app.use(
  createThemeManager({
    light: 'aqua',
    dark: 'coffee',
    watchSystemTheme: true,
  })
)

app.mount('#app')

Usage in the component: useThemeManager()

Type definition

const themeManagerInstance = {
  set,
  get,
  toggleDark,
  setDefaults,
  getDefaults,
  watchSystemTheme,
  isDark,
}

Installation

import { useThemeManager } from '@/plugins/themeManager'
const $theme = useThemeManager()

Methods

  • set - Set a theme from the daisy theme options defined in the tailwind.config.js Type definition:
    set({theme: DaisyThemes}): void
    usage example:
    $theme.set({theme:'light'})
  • get - Get the current active theme Type definition:
    get(): DaisyThemes
    Usage example:
    $theme.get() // ie: 'coffee'
  • toggleDark - Toggle between the default light and dark themes that were defined in the plugin setup Type definition:
    toggleDark(): void
    Usage example:
    $theme.toggleDark()
  • setDefaults - Set the default light and dark themes after the plugin has been initiated. Type definition:
    setDefaults(themes: { light?: DaisyThemes; dark?: DaisyThemes }): void
    Usage example:
    $theme.setDefaults({ light: 'aqua', dark: 'business' })
  • getDefaults - Get the default light and dark themes Type definition:
    getDefaults(): { light: DaisyThemes; dark: DaisyThemes }
    Usage example:
    $theme.getDefaults() // ie: { light: 'aqua', dark: 'business' }
  • watchSystemTheme - Watch for system theme changes, and set if you want it to update the theme immediately to the default theme that corresponds to the system mode (light/dark). updateTheme is set to true by default. Type definition:
    watchSystemTheme(bool?: boolean, updateTheme: boolean = true): boolean
    Usage example:
    /* Returns if the theme manager watching the active system theme */
    $theme.watchSystemTheme() // ie: true
    /*
      Theme will change to the default theme that corresponds
      to the system mode (light/dark)
    */
    $theme.watchSystemTheme(true)
    /* theme will remain the same even if the system theme changes */
    $theme.watchSystemTheme(false)
    /* theme will not change immidiatly to the default theme that corresponds to the system mode (light/dark)
       it will change if the theme of the system changes again
    */
    $theme.watchSystemTheme(true, false)
  • isDark - Get the current system theme Type definition:
    isDark(): boolean
    Usage example:
    $theme.isDark() // ie: true

Contributing

Contributions to the project is highly appreciated. If you have any suggestions/questions/requests please consider opening an issue. If you want to contribute to the project, fixing an open issue is greatly recommended and appreciated. To see the all contribution rules please check the contribution rules.

License

This project is licensed under MIT License if you want to see more, please check LICENSE for more information.

Credits

This project is created and actively maintained by kaandesu