Skip to content

Commit 70a234c

Browse files
committed
v1.1.5
1 parent 1bf8d21 commit 70a234c

File tree

9 files changed

+25
-16
lines changed

9 files changed

+25
-16
lines changed

DynamicColors.js

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
## Installation
88

99
[![npm (scoped)](https://img.shields.io/npm/v/dynamic-colors)](https://www.npmjs.com/package/dynamic-colors)
10-
[![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/dynamic-colors)](https://bundlephobia.com/package/[email protected].4)
10+
[![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/dynamic-colors)](https://bundlephobia.com/package/[email protected].5)
1111
[![npm](https://img.shields.io/npm/dy/dynamic-colors)](https://www.npmjs.com/package/dynamic-colors)
12-
[![jsDelivr hits (npm scoped)](https://img.shields.io/jsdelivr/gh/hy/patelka2211/dynamic-colors)](https://cdn.jsdelivr.net/gh/patelka2211/[email protected].4/)
12+
[![jsDelivr hits (npm scoped)](https://img.shields.io/jsdelivr/gh/hy/patelka2211/dynamic-colors)](https://cdn.jsdelivr.net/gh/patelka2211/[email protected].5/)
1313

1414
To install Dynamic Colors using npm, run the following command:
1515

1616
```sh
1717
npm i dynamic-colors
1818
```
1919

20-
Alternatively, you can include [Dynnamic Colors's IIFE file](https://cdn.jsdelivr.net/gh/patelka2211/[email protected].4/DynamicColors.js) in your website using a `<script>` tag:
20+
Alternatively, you can include [Dynnamic Colors's IIFE file](https://cdn.jsdelivr.net/gh/patelka2211/[email protected].5/DynamicColors.js) in your website using a `<script>` tag:
2121

2222
```html
23-
<script src="https://cdn.jsdelivr.net/gh/patelka2211/[email protected].4/DynamicColors.js"></script>
23+
<script src="https://cdn.jsdelivr.net/gh/patelka2211/[email protected].5/DynamicColors.js"></script>
2424
```
2525

2626
## Available APIs

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dynamic-colors",
3-
"version": "1.1.4",
3+
"version": "1.1.5",
44
"description": "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.",
55
"main": "index.js",
66
"module": "index.js",
@@ -11,6 +11,7 @@
1111
"rollup-iife": "rollup -c --environment format:iife",
1212
"terser-esm": "terser ./index.js -c -m --toplevel -o ./index.js",
1313
"terser-iife": "terser ./DynamicColors.js -c -m -o ./DynamicColors.js",
14+
"prerelease-build": "npm run tsc-build && npm run rollup-esm && npm run rollup-iife && rm -rf ./lib/",
1415
"build": "npm run tsc-build && npm run rollup-esm && npm run rollup-iife && npm run terser-esm && npm run terser-iife && rm -rf ./lib/",
1516
"test-build": "npm run tsc-build && npm run rollup-esm && tsc ./test/index.ts -t es6 && rollup ./test/index.js -o ./test/out.js && rm -rf ./lib/"
1617
},
@@ -44,7 +45,7 @@
4445
"bugs": {
4546
"url": "https://github.com/patelka2211/dynamic-colors/issues"
4647
},
47-
"homepage": "https://github.com/patelka2211/dynamic-colors#readme",
48+
"homepage": "https://kpverse.in/dynamic-colors/",
4849
"devDependencies": {
4950
"rollup": "^3.25.1",
5051
"rollup-plugin-dts": "^5.3.0",

rollup.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const currentDate = new Date(),
66
banner = `/**
77
* **Dynamic Colors** from KPVERSE
88
*
9+
* v1.1.5
10+
*
911
* Updated on ${formattedDate}.
1012
*
1113
* Copyright © 2023-present, Kartavya Patel. All rights reserved.

src/dynamicColors/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ export class DynamicColors {
4141
public setColor(HEXColor: string) {
4242
let color = validateHEX(HEXColor);
4343

44-
if (color === false)
45-
throw Error(`"${HEXColor}" is not valid HEX color.`);
44+
if (!color)
45+
throw Error(
46+
`"${HEXColor}" is not valid HEX color. Only 7 length HEX color is accepted. For example: "#2596D1" or "#ffffff".`
47+
);
4648

4749
if (this.id === undefined) return;
4850

src/helper/validateHEX.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
22
* Validates a HEX color value.
33
* @param {string} color The color value to validate.
4-
* @returns {string | false} The validated color value if it is a valid HEX color, or otherwise `false`.
4+
* @returns {string | undefined} The validated color value if it is a valid HEX color, or otherwise `undefined`.
55
*/
6-
export function validateHEX(color: string): string | false {
7-
if (/^#([0-9A-Fa-f]{3}){1,2}$/i.test(color)) return color.toLowerCase();
8-
return false;
6+
export function validateHEX(color: string): string | undefined {
7+
if (/^#[0-9A-Fa-f]{6}$/i.test(color)) return color.toLowerCase();
8+
return;
99
}

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export { remove } from "./dynamicColors/remove";
33
export { DynamicColorsType } from "./dynamicColors/types";
44
export { getInstanceByName } from "./instances/getInstanceByName";
55
export { isInstance } from "./instances/isInstance";
6+
export { VERSION } from "./metadata";
67
export { getCurrentOSTheme } from "./theme/getCurrentOSTheme";
78
export { getCurrentUITheme } from "./theme/getCurrentUITheme";
89
export { setAutoTheme } from "./theme/setAutoTheme";

src/metadata.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const VERSION = "1.1.5";

0 commit comments

Comments
 (0)