dynamic-colors
v1.1.5
Published
Dynamic Colors is a JavaScript library that can dynamically generate color palettes from a single HEX color and it provides a range of useful APIs for creating, managing, and manipulating color palettes.
Downloads
15
Maintainers
Readme
Dynamic Colors
Dynamic Colors is a JavaScript library that can dynamically generate color palette from a single HEX color and it provides a range of useful APIs for creating, managing, and manipulating color palettes such as create(), remove(), setAutoTheme(), setDarkTheme(), setLightTheme(), themeCycle(), isInstance().
Installation
To install Dynamic Colors using npm, run the following command:
npm i dynamic-colors
Alternatively, you can include Dynnamic Colors's IIFE file in your website using a <script>
tag:
<script src="https://cdn.jsdelivr.net/gh/patelka2211/[email protected]/DynamicColors.js"></script>
Available APIs
create()
The create() function creates a new instance of the DynamicColors class, which is used to manage color palettes.
| | Available as | | :------ | :--------------------- | | in ESM | create() | | in IIFE | DynamicColors.create() |
remove()
The remove() function is used to unsubscribe an instance of the DynamicColors class from all available DynamicColors instances. By calling this function with the desired instance as an argument, you can effectively remove the instance's association with the color palettes managed by Dynamic Colors.
| | Available as | | :------ | :--------------------- | | in ESM | remove() | | in IIFE | DynamicColors.remove() |
setAutoTheme()
The setAutoTheme() function subscribes all instances of the DynamicColors class to automatically change the theme based on the user's operating system theme.
| | Available as | | :------ | :--------------------------- | | in ESM | setAutoTheme() | | in IIFE | DynamicColors.setAutoTheme() |
setDarkTheme()
The setDarkTheme() function changes all instances of the DynamicColors class to a dark theme.
| | Available as | | :------ | :--------------------------- | | in ESM | setDarkTheme() | | in IIFE | DynamicColors.setDarkTheme() |
setLightTheme()
The setLightTheme() function changes all instances of the DynamicColors class to a light theme.
| | Available as | | :------ | :---------------------------- | | in ESM | setLightTheme() | | in IIFE | DynamicColors.setLightTheme() |
themeCycle()
The themeCycle() function cycles through different themes based on the current theme:
| | Available as | | :------ | :------------------------- | | in ESM | themeCycle() | | in IIFE | DynamicColors.themeCycle() |
- If the current theme is
Auto
, the next theme will beLight
. - If the current theme is
Light
, the next theme will beDark
. - If the current theme is
Dark
, the next theme will beAuto
.
isInstance()
Determines whether the given object is an instance of DynamicColors
. Returns true
if the object is an instance of DynamicColors
, otherwise false
.
Internally used functionalities
DynamicColors class
The DynamicColors class is used internally by Dynamic Colors to manage the color palettes it generates. It has the following characteristics:
The DynamicColors class is created using the create() function and can only be removed using the remove() function.
Material Dynamic Colors
Dynamic Colors leverages the power of Material Dynamic Colors internally to generate color palettes. It builds upon the functionality provided by Material Dynamic Colors and offers additional features. With Dynamic Colors, you can go beyond the basic color generation and enjoy advanced functionalities tailored to your specific needs, enabling you to create dynamic visual experiences for your web applications.
License
This project is licensed under the MIT License, which permits you to use, copy, modify, merge, publish, distribute, and sublicense the software, subject to the conditions stated in the LICENSE file.