Coder Social home page Coder Social logo

theme-switcher-tool's Introduction

Theme Switcher Tool

NPM version NPM downloads

theme switcher tool. these are examples with theme-generator-webpack-plugin

Install

Browser Environment

<script src="//unpkg.com/theme-switcher-tool"></script>

ES Module Environment

yarn add theme-switcher-tool

or

npm install theme-switcher-tool

Usage

import ThemeSwitcherTool from 'theme-switcher-tool';

const themeSwitcherTool = ThemeSwitcherTool({
    // Your theme list
    themeList: [
                { themeName: "theme-default", themePath: "https://unpkg.com/vue-easytable/libs/theme-default/index.css" },
                { themeName: "theme-dark", themePath: "https://unpkg.com/vue-easytable/libs/theme-dark/index.css" },
            ],
    // Your actual style id
    styleLinkId: "theme_creator_cli_style_id",
    useStorage: true,
    storageKey: "theme_switcher_tool_theme"
});

const historyTheme = themeSwitcherTool.getCurrentTheme() || "theme-dark";

/*
switcher theme
1、you can show your loading message
*/
themeSwitcherTool.switcher({
    themeName: historyTheme
}).then(()=>{

    // somthing to do. such as close your loading message
})

API

config

参数 说明 类型 可选值 默认值 参考值
themeList 需要切换的主题列表 {Array<Object>} [{"themeName":"theme-black","themePath":"./themes/theme-black.css"},{"themeName":"theme-blue","themePath":"./themes/theme-blue.css"}]
styleLinkId htmllink标签id {String} theme_creator_cli_style_id
useStorage 是否使用 localStorage记录当前主题名称 {Bool} false
storageKey localStorage key 值 {String}

methods

名称 说明 参数 返回值类型
getCurrentTheme 返回当前主题名称(当设置了 localStorage 存储) {String}
switcher 切换主题 themeName {String}

License

This project is licensed under MIT

theme-switcher-tool's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.