Skip to content

Commit 11c2777

Browse files
committed
Update snapshots
1 parent d9a3fae commit 11c2777

5 files changed

Lines changed: 7 additions & 17 deletions

File tree

src/utils/components/ColorPicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { faPalette as colorIcon } from '@fortawesome/free-solid-svg-icons';
22
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3+
import { isLightColor } from '@shlinkio/shlink-frontend-kit';
34
import { Input } from '@shlinkio/shlink-frontend-kit/tailwind';
45
import { clsx } from 'clsx';
56
import { forwardRef } from 'react';
6-
import { isLightColor } from '../helpers/color';
77

88
export type ColorPickerProps = {
99
name: string;

src/utils/helpers/color.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,7 @@ import { rangeOf } from './index';
22

33
const HEX_COLOR_LENGTH = 6;
44
const HEX_DIGITS = '0123456789ABCDEF';
5-
const LIGHTNESS_BREAKPOINT = 128;
65

76
export function buildRandomColor(): string {
87
return `#${rangeOf(HEX_COLOR_LENGTH, () => HEX_DIGITS[Math.floor(Math.random() * HEX_DIGITS.length)]).join('')}`;
98
}
10-
11-
function perceivedLightness (r: number, g: number, b: number): number {
12-
return Math.round(Math.sqrt(0.299 * r ** 2 + 0.587 * g ** 2 + 0.114 * b ** 2));
13-
}
14-
15-
/** @deprecated. Use same symbol from @shlinkio/shlink-frontend-kit */
16-
export function isLightColor(colorHex: string): boolean {
17-
const [r, g, b] = (colorHex.match(/../g) ?? []).map((hex) => parseInt(hex, 16) || 0);
18-
return perceivedLightness(r, g, b) >= LIGHTNESS_BREAKPOINT;
19-
}

src/utils/services/ColorGenerator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { isLightColor } from '@shlinkio/shlink-frontend-kit';
12
import type { CSSProperties } from 'react';
2-
import { buildRandomColor, isLightColor } from '../helpers/color';
3+
import { buildRandomColor } from '../helpers/color';
34
import type { TagColorsStorage } from './TagColorsStorage';
45

56
const normalizeKey = (key: string) => key.toLowerCase().trim();

test/utils/components/__snapshots__/IconInput.test.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ exports[`<IconInput /> > displays provided icon 1`] = `
66
class="tw:relative"
77
>
88
<input
9-
class="tw:w-full tw:focus-ring tw:px-3 tw:py-1.5 tw:rounded-md tw:border tw:border-lm-input-border tw:dark:border-dm-input-border tw:bg-lm-primary tw:dark:bg-dm-primary tw:group-[&]/card:bg-lm-input tw:group-[&]/card:dark:bg-dm-input tw:pr-11"
9+
class="tw:outline-none tw:w-full tw:focus-ring tw:px-3 tw:py-1.5 tw:rounded-md tw:border tw:border-lm-input-border tw:dark:border-dm-input-border tw:bg-lm-primary tw:dark:bg-dm-primary tw:group-[&]/card:bg-lm-input tw:group-[&]/card:dark:bg-dm-input tw:pr-11"
1010
/>
1111
<svg
1212
aria-hidden="true"
@@ -33,7 +33,7 @@ exports[`<IconInput /> > displays provided icon 2`] = `
3333
class="tw:relative"
3434
>
3535
<input
36-
class="tw:w-full tw:focus-ring tw:px-3 tw:py-1.5 tw:rounded-md tw:border tw:border-lm-input-border tw:dark:border-dm-input-border tw:bg-lm-primary tw:dark:bg-dm-primary tw:group-[&]/card:bg-lm-input tw:group-[&]/card:dark:bg-dm-input tw:pr-11"
36+
class="tw:outline-none tw:w-full tw:focus-ring tw:px-3 tw:py-1.5 tw:rounded-md tw:border tw:border-lm-input-border tw:dark:border-dm-input-border tw:bg-lm-primary tw:dark:bg-dm-primary tw:group-[&]/card:bg-lm-input tw:group-[&]/card:dark:bg-dm-input tw:pr-11"
3737
/>
3838
<svg
3939
aria-hidden="true"
@@ -60,7 +60,7 @@ exports[`<IconInput /> > displays provided icon 3`] = `
6060
class="tw:relative"
6161
>
6262
<input
63-
class="tw:w-full tw:focus-ring tw:px-3 tw:py-1.5 tw:rounded-md tw:border tw:border-lm-input-border tw:dark:border-dm-input-border tw:bg-lm-primary tw:dark:bg-dm-primary tw:group-[&]/card:bg-lm-input tw:group-[&]/card:dark:bg-dm-input tw:pr-11"
63+
class="tw:outline-none tw:w-full tw:focus-ring tw:px-3 tw:py-1.5 tw:rounded-md tw:border tw:border-lm-input-border tw:dark:border-dm-input-border tw:bg-lm-primary tw:dark:bg-dm-primary tw:group-[&]/card:bg-lm-input tw:group-[&]/card:dark:bg-dm-input tw:pr-11"
6464
/>
6565
<svg
6666
aria-hidden="true"

test/visits/helpers/__snapshots__/MapModal.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ exports[`<MapModal /> > renders expected map 1`] = `
2121
</h5>
2222
<button
2323
aria-label="Close dialog"
24-
class="tw:opacity-50 tw:highlight:opacity-80 tw:transition-opacity tw:rounded-md tw:focus-ring tw:cursor-pointer"
24+
class="tw:rounded-md tw:focus-ring tw:cursor-pointer tw:opacity-50 tw:highlight:opacity-80 tw:transition-opacity"
2525
type="button"
2626
>
2727
<svg

0 commit comments

Comments
 (0)