1.0.3 • Published 4 years ago

themy v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Themy

Lightwaighy library to create, test and toggle themes and color palettes

Installation

Use the npm to install themy.

npm i themy

Usage

import

/* es6 */
import themy from 'themy';

/* es5 */
const themy = require('themy');

Create themes

const coolTheme = {
  primary: '#f00',
  secondary: 'rgb(23, 176, 235)',
};

const awesomeTheme = {
  primary: '#66cc99',
  secondary: '#cc9966',
};

Initialize

const themes = { coolTheme, awesomeTheme };

const theme = new themy(themes);

// Change theme
theme.setTheme('awesomeTheme');

Change the theme

theme.setTheme('awesomeTheme');

Add a new theme

const themeName = {
  primary: '#9c1de7',
  secodary: '#9c1de7',
};

theme.addTheme({ themeName });

// Set the theme as active theme
theme.setTheme('themeName');

Methods

// get acitve theme
theme.getTheme(); // themeName

// get an array of themes
theme.getThemes(); // ['coolTheme', 'awesomeTheme', 'themeName']

Options

Create and add options like this:

const options = {
  acitve: 'theme1', // Active theme at the start of app
  prefix: 'site', // Classname prefix for classes
  showPanel: true, // Wether show a box to change theme or not
  utils: true, // To add utility classes or not
};

// Then add options as second argument
const theme = new themy(themes, options);

Valid options:

option namevalid valuesdescriptiondefault
activename of your themesactive theme at the start of appfirst theme
debugbooleanto show errors in the consolefalse
utilsbooleanadd utility classes like: 'm-1' = margin: 1emfalse
transitionboolean or numberadd transition time to make color changes soft0.3 (s)
showPanelbooleanto show a panel of buttons to change tehemesfalse
prefixstringany name to add before calssnamesnone
shadesarray of numbersyou can choose just the shades you want1-9
panelOptionsobjectcofigure panel settings{}
panelOptions.position'top-right' and ...position of panel on the screen'top-right'
panelOptions.backgroundstring ( color )background color of panel on the screen'#ccc'
panelOptions.direction'row', 'column'direction of buttons in panel'column'

Your HTML

You just need to add classes

<div class="text-primary">Some text with primary color</div>

<div class="bg-primary">Some text with primary background</div>

Add shades of colors

Descripition is not ready

Table of classes

classnameexampledescription
text-primary<div class='text-primary'>text color primary
text-primary-dark<div class='text-primary-dark'>30% darker primary
text-primary-light<div class='text-primary-light'>30% lighter primary
text-primary-d(1-9)<div class='text-primary-d4'>40% darker primary
text-primary-l(1-9)<div class='text-primary-l6'>60% lighter primary
bg-primary<div class='bg-primary'>background color of primary
border-primary<div class='border-primary'>border color of primary

Licens

MIT

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago