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

dd-theme-selector

v1.0.3

Published

[![npm version](https://badge.fury.io/js/dd-theme-selector.svg)](https://badge.fury.io/js/dd-theme-selector)

Downloads

9

Readme

dd-theme-selector

npm version

Sample standalone component from Chapter 16-17 from the book (Important: this sample is not licensed and cannot be re-distributed)

The book can be found here:

See Large Scale Apps with Vue 3 and TypeScript.

Description:

The component allows to change the theme of your app/website. You can see a working example here: largescaleapps.com It does not come with styles so you have to provide them (see code sample below). Also uses material-icons, so you will have to include a reference to that somewhere in your app.For example, you could include this in your public/index.html:

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons&lang=en&display=swap"/>

The component uses an internal custom store to manage its state, and also write and reads the selection to localStorage so it remembers the user selection.

How to use:

Create a Vue 3 app (TypeScript) Then install a reference to this package with the command:

npm install --save dd-theme-selector

Add this sample code in your App.vue or other view where you want to try it out. Note that you have to feed it an array of themes (of type ThemeInfoInterface), and also add somewhere the CSS styles, as the dd-theme-selector does not come with any styles. In the code sample below, we are adding them in the <style lang="scss"> section of our view:

<template>
  <h1>Consuming dd-theme-selector from another Vue 3 app:</h1>
  <ThemeSelector :availableThemes="availableThemes" />
</template>

<script lang="ts">
  import { defineComponent } from 'vue'

  import {
    ThemeSelector,
    ThemeInfoInterface
  } from 'dd-theme-selector'
  console.log('hc', ThemeSelector)

  export default defineComponent({
    name: 'App',
    components: {
      ThemeSelector
    },
    setup() {
      const availableThemes = [
        {
          id: 'light-theme',
          name: 'Light',
          icon: 'color_lens',
          selected: false
        },
        {
          id: 'dark-theme',
          name: 'Dark',
          icon: 'color_lens',
          selected: true
        },
        {
          id: 'navy-theme',
          name: 'Navy Dark',
          icon: 'color_lens',
          selected: false
        }
      ]

      return {
        availableThemes
      }
    }
  })
</script>

<style lang="scss">
  body {
    font-family: Avenir, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding: 20px;
    color: #2c3e50;

    h1 {
      font-size: 16px;
    }
  }

  .theme-selector {
    .theme-radio-group {
      display: inline-flex;
      justify-content: center;

      label.theme-radio {
        cursor: pointer;
        display: block;

        &.selected {
          border-bottom: solid 2px #42b983;
        }

        &:hover {
          background: red;
        }

        > i {
          font-size: 32px;
          display: block;
        }
      }

      input {
        display: none;
      }
    }
  }

  body.light-theme {
    .theme-selector .theme-radio-group label.theme-radio {
      &.light-theme > i {
        color: lightgray;
      }
      &.dark-theme > i {
        color: black;
      }
      &.navy-theme > i {
        color: lighten(navy, 20%);
      }
    }
  }

  body.dark-theme {
    background-color: black;
    color: lighten(#2c3e50, 50%);

    .theme-selector .theme-radio-group label.theme-radio {
      &.light-theme > i {
        color: white;
      }
      &.dark-theme > i {
        color: lighten(#000, 40%);
      }
      &.navy-theme > i {
        color: lighten(navy, 40%);
      }
    }
  }

  body.navy-theme {
    background-color: navy;
    color: lighten(#2c3e50, 50%);

    .theme-selector .theme-radio-group label.theme-radio {
      &.light-theme > i {
        color: white;
      }
      &.dark-theme > i {
        color: lighten(#000, 40%);
      }
      &.navy-theme > i {
        color: lighten(navy, 40%);
      }
    }
  }
</style>