1.1.5 • Published 9 months ago

dynamic-colors v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

npm.io

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

npm (scoped) npm bundle size (scoped) npm jsDelivr hits (npm scoped)

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/dynamic-colors@1.1.5/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 ESMcreate()
in IIFEDynamicColors.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 ESMremove()
in IIFEDynamicColors.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 ESMsetAutoTheme()
in IIFEDynamicColors.setAutoTheme()

setDarkTheme()

The setDarkTheme() function changes all instances of the DynamicColors class to a dark theme.

Available as
in ESMsetDarkTheme()
in IIFEDynamicColors.setDarkTheme()

setLightTheme()

The setLightTheme() function changes all instances of the DynamicColors class to a light theme.

Available as
in ESMsetLightTheme()
in IIFEDynamicColors.setLightTheme()

themeCycle()

The themeCycle() function cycles through different themes based on the current theme:

Available as
in ESMthemeCycle()
in IIFEDynamicColors.themeCycle()
  • If the current theme is Auto, the next theme will be Light.
  • If the current theme is Light, the next theme will be Dark.
  • If the current theme is Dark, the next theme will be Auto.

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

NPM

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.