🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@byelabel/react

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@byelabel/react - npm Package Compare versions

Comparing version
0.0.2
to
0.0.3
+4
build/utils/color.d.ts
export declare function stringToColor(str: string): string;
export declare function hexToRGBA(hexCode: string, opacity: number): string;
export declare function shader(color: string, percent?: number): string;
//# sourceMappingURL=color.d.ts.map
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/utils/color.ts"],"names":[],"mappings":"AAkBA,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAYlE;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,SAAI,GAAG,MAAM,CAsBzD"}
function hashCode(str) {
let hash = 0;
if (!str || !str.length)
return hash;
for (let i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
return hash;
}
function intToRGB(i) {
const c = (i & 0x00FFFFFF).toString(16).toUpperCase();
return '00000'.substring(0, 6 - c.length) + c;
}
export function stringToColor(str) {
return `#${intToRGB(hashCode(str))}`;
}
export function hexToRGBA(hexCode, opacity) {
let hex = hexCode.replace('#', '');
if (hex.length === 3) {
hex = `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`;
}
const r = parseInt(hex.substring(0, 2), 16);
const g = parseInt(hex.substring(2, 4), 16);
const b = parseInt(hex.substring(4, 6), 16);
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
}
export function shader(color, percent = 0) {
let R = parseInt(color.substring(1, 3), 16);
let G = parseInt(color.substring(3, 5), 16);
let B = parseInt(color.substring(5, 7), 16);
R = Math.trunc(R * (100 + percent) / 100);
G = Math.trunc(G * (100 + percent) / 100);
B = Math.trunc(B * (100 + percent) / 100);
R = (R < 255) ? R : 255;
G = (G < 255) ? G : 255;
B = (B < 255) ? B : 255;
R = Math.round(R);
G = Math.round(G);
B = Math.round(B);
const RR = `${(R.toString(16).length === 1) ? '0' : ''}${R.toString(16)}`;
const GG = `${(G.toString(16).length === 1) ? '0' : ''}${G.toString(16)}`;
const BB = `${(B.toString(16).length === 1) ? '0' : ''}${B.toString(16)}`;
return '#' + RR + GG + BB;
}
export * from './color';
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
export * from './color';
+1
-0
export * from './hooks';
export * from './contexts';
export * from './utils';
//# sourceMappingURL=index.d.ts.map
+1
-1

@@ -1,1 +0,1 @@

{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
export * from './hooks';
export * from './contexts';
export * from './utils';
{
"name": "@byelabel/react",
"version": "0.0.2",
"version": "0.0.3",
"description": "ByeLabel React utilities (hooks, contexts)",

@@ -21,2 +21,6 @@ "type": "module",

},
"./utils": {
"types": "./build/utils/index.d.ts",
"default": "./build/utils/index.js"
},
"./package.json": "./package.json"

@@ -23,0 +27,0 @@ },

@@ -162,3 +162,3 @@ # @byelabel/react

[github.com/morsaken/web-im-helpers](https://github.com/morsaken/web-im-helpers) — see the workspace README for the companion `@byelabel/utils` package.
[github.com/byelabel/helpers](https://github.com/byelabel/helpers) — see the workspace README for the companion `@byelabel/utils` package.

@@ -165,0 +165,0 @@ ## License