Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ycjcl868/theme-switcher
a theme switch tool
https://github.com/ycjcl868/theme-switcher
Last synced: 8 days ago
JSON representation
a theme switch tool
- Host: GitHub
- URL: https://github.com/ycjcl868/theme-switcher
- Owner: ycjcl868
- Created: 2020-01-02T03:14:42.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-02T10:18:35.000Z (almost 5 years ago)
- Last Synced: 2024-10-13T11:07:26.547Z (23 days ago)
- Language: TypeScript
- Homepage:
- Size: 12.7 KB
- Stars: 23
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Theme Switcher
[![codecov](https://codecov.io/gh/ycjcl868/theme-switcher/branch/master/graph/badge.svg)](https://codecov.io/gh/ycjcl868/theme-switcher) [![NPM version](https://img.shields.io/npm/v/theme-switcher.svg?style=flat)](https://npmjs.org/package/theme-switcher) [![NPM downloads](http://img.shields.io/npm/dm/theme-switcher.svg?style=flat)](https://npmjs.org/package/theme-switcher) [![CircleCI](https://circleci.com/gh/ycjcl868/theme-switcher/tree/master.svg?style=svg)](https://circleci.com/gh/ycjcl868/theme-switcher/tree/master)
## Usage
Browser
```html
var themeSwitcher = window.ThemeSwitcher({
themeMap: {
dark: '/dark.css',
default: '/default.css',
}
});// => will load <link rel="prefetch" href="dark.css" />
// => will load <link rel="prefetch" href="default.css" />themeSwitcher.switcher({
theme: 'dark',
});
// => will load <link rel="stylesheet" href="dark.css">console.log(themeSwitcher.getTheme()); // => dark
```
ES Module
```js
import themeSwitcher from 'theme-switcher';const { switcher, getTheme } = themeSwitcher({
themeMap: {
dark: '/dark.css',
light: '/default.css',
}
});// => will load
// => will loadthemeSwitcher.switcher({
theme: 'dark',
});
// => will loadconsole.log(themeSwitcher.getTheme()); // => dark
```