Skip to content

Commit 12d86c5

Browse files
committed
Use substring instead of deprecated substr.
1 parent a85e5b3 commit 12d86c5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/components/HexColorInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const HexColorInput = (props: HexColorInputProps): JSX.Element => {
1919

2020
/** Escapes all non-hexadecimal characters including "#" */
2121
const escape = useCallback(
22-
(value: string) => value.replace(/([^0-9A-F]+)/gi, "").substr(0, alpha ? 8 : 6),
22+
(value: string) => value.replace(/([^0-9A-F]+)/gi, "").substring(0, alpha ? 8 : 6),
2323
[alpha]
2424
);
2525

src/utils/convert.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const angleUnits: Record<string, number> = {
1414
export const hexToHsva = (hex: string): HsvaColor => rgbaToHsva(hexToRgba(hex));
1515

1616
export const hexToRgba = (hex: string): RgbaColor => {
17-
if (hex[0] === "#") hex = hex.substr(1);
17+
if (hex[0] === "#") hex = hex.substring(1);
1818

1919
if (hex.length < 6) {
2020
return {
@@ -26,9 +26,9 @@ export const hexToRgba = (hex: string): RgbaColor => {
2626
}
2727

2828
return {
29-
r: parseInt(hex.substr(0, 2), 16),
30-
g: parseInt(hex.substr(2, 2), 16),
31-
b: parseInt(hex.substr(4, 2), 16),
29+
r: parseInt(hex.substring(0, 2), 16),
30+
g: parseInt(hex.substring(2, 4), 16),
31+
b: parseInt(hex.substring(4, 6), 16),
3232
a: 1,
3333
};
3434
};

0 commit comments

Comments
 (0)