Skip to content

Commit 146f2c3

Browse files
committed
Remove unused helper function
1 parent 937a3d0 commit 146f2c3

2 files changed

Lines changed: 1 addition & 17 deletions

File tree

src/utils/helpers/color.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,11 @@ export function buildRandomColor(): string {
88
return `#${rangeOf(HEX_COLOR_LENGTH, () => HEX_DIGITS[Math.floor(Math.random() * HEX_DIGITS.length)]).join('')}`;
99
}
1010

11-
/**
12-
* Returns the perceived lightness of an RGB color, as a number from 0 to 256.
13-
* The lower the number, the darker is the color perceived.
14-
*
15-
* HSP by Darel Rex Finley https://alienryderflex.com/hsp.html
16-
*/
1711
function perceivedLightness (r: number, g: number, b: number): number {
1812
return Math.round(Math.sqrt(0.299 * r ** 2 + 0.587 * g ** 2 + 0.114 * b ** 2));
1913
}
2014

15+
/** @deprecated. Use same symbol from @shlinkio/shlink-frontend-kit */
2116
export function isLightColor(colorHex: string): boolean {
2217
const [r, g, b] = (colorHex.match(/../g) ?? []).map((hex) => parseInt(hex, 16) || 0);
2318
return perceivedLightness(r, g, b) >= LIGHTNESS_BREAKPOINT;

src/utils/helpers/index.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
import { range } from '@shlinkio/data-manipulation';
2-
import type { SyntheticEvent } from 'react';
3-
import { useCallback } from 'react';
42

53
export type OptionalString = string | null | undefined;
64

7-
/**
8-
* Wraps an event handler so that it calls e.preventDefault() before invoking the event handler
9-
*/
10-
export const usePreventDefault = <Event extends SyntheticEvent = SyntheticEvent>(handler: (e: Event) => void) =>
11-
useCallback((e: Event) => {
12-
e.preventDefault();
13-
handler(e);
14-
}, [handler]);
15-
165
export const rangeOf = <T>(size: number, mappingFn: (value: number) => T, startAt = 1): T[] =>
176
range(startAt, size + 1).map(mappingFn);
187

0 commit comments

Comments
 (0)