From 7532d1be9893cdae9f194b413c91b346fb05bbce Mon Sep 17 00:00:00 2001 From: Matthias Lindinger Date: Tue, 30 Jul 2024 08:53:04 +0200 Subject: [PATCH] Revert some unwanted changes --- __tests__/components/OverlaySettings.test.js | 32 +++++++++----------- __tests__/lib/ocrFormats.test.js | 2 +- src/components/settings/ButtonContainer.js | 2 +- src/components/settings/ColorInput.js | 2 +- src/components/settings/ColorWidget.js | 2 +- src/components/settings/OverlaySettings.js | 4 +-- src/lib/color.js | 2 +- 7 files changed, 21 insertions(+), 25 deletions(-) diff --git a/__tests__/components/OverlaySettings.test.js b/__tests__/components/OverlaySettings.test.js index ec3d010..df038c5 100644 --- a/__tests__/components/OverlaySettings.test.js +++ b/__tests__/components/OverlaySettings.test.js @@ -22,24 +22,20 @@ const mockTheme = { // Mocked MUI slider for easier testing, taken from // https://stackoverflow.com/a/61628815 (CC BY-SA 4.0) -jest.mock( - '@material-ui/core/Slider', - () => - function (props) { - const { id, name, min, max, onChange } = props; - return ( - onChange(event, event.target.value)} - /> - ); - }, -); +jest.mock('@material-ui/core/Slider', () => (props) => { + const { id, name, min, max, onChange } = props; + return ( + onChange(event, event.target.value)} + /> + ); +}); /** Render a bubble to the testing screen */ function renderSettings(props = {}, renderFn = render) { diff --git a/__tests__/lib/ocrFormats.test.js b/__tests__/lib/ocrFormats.test.js index a347c07..9a97d90 100644 --- a/__tests__/lib/ocrFormats.test.js +++ b/__tests__/lib/ocrFormats.test.js @@ -11,7 +11,7 @@ import contentAsTextAnnos from '../../__fixtures__/anno_iifv2.json'; * https://stackoverflow.com/a/53464807 (CC-BY-SA) */ const closeTo = (expected, precision = 1) => ({ - asymmetricMatch: (actual) => Math.abs(expected - actual) < 10 ** -precision / 2, + asymmetricMatch: (actual) => Math.abs(expected - actual) < Math.pow(10, -precision) -precision / 2, }); describe('parsing ALTO', () => { diff --git a/src/components/settings/ButtonContainer.js b/src/components/settings/ButtonContainer.js index 557d2cb..d6cd741 100644 --- a/src/components/settings/ButtonContainer.js +++ b/src/components/settings/ButtonContainer.js @@ -34,7 +34,7 @@ const useStyles = makeStyles(({ palette, breakpoints }) => { }); /** Container for a settings button */ -function ButtonContainer({ children, withBorder, paddingPrev, paddingNext }) { +const ButtonContainer = ({ children, withBorder, paddingPrev, paddingNext }) => { const classes = useStyles({ withBorder, paddingPrev, paddingNext }); return
{children}
; } diff --git a/src/components/settings/ColorInput.js b/src/components/settings/ColorInput.js index b25104c..4c77cf1 100644 --- a/src/components/settings/ColorInput.js +++ b/src/components/settings/ColorInput.js @@ -37,7 +37,7 @@ const useStyles = makeStyles({ }); /** Input to select a color */ -function ColorInput({ color, onChange, title, autoColors, className }) { +const ColorInput = ({ color, onChange, title, autoColors, className }) => { const classes = useStyles({ color, autoColors }); // We rely on the browser behavior that clicking on an input's label is equivalent // to clicking the input to show a custom color picker button. diff --git a/src/components/settings/ColorWidget.js b/src/components/settings/ColorWidget.js index b011271..ee35f9e 100644 --- a/src/components/settings/ColorWidget.js +++ b/src/components/settings/ColorWidget.js @@ -57,7 +57,7 @@ const useStyles = makeStyles(({ palette, breakpoints }) => { }); /** Widget to update text and background color */ -function ColorWidget({ textColor, bgColor, onChange, t, pageColors, useAutoColors, containerId }) { +const ColorWidget = ({ textColor, bgColor, onChange, t, pageColors, useAutoColors, containerId }) => { const showResetButton = !useAutoColors && pageColors && pageColors.some((c) => c && (c.textColor || c.bgColor)); const classes = useStyles({ showResetButton }); diff --git a/src/components/settings/OverlaySettings.js b/src/components/settings/OverlaySettings.js index ec634e6..5329b91 100644 --- a/src/components/settings/OverlaySettings.js +++ b/src/components/settings/OverlaySettings.js @@ -46,7 +46,7 @@ const useStyles = makeStyles(({ palette, breakpoints }) => { }); /** Control text overlay settings */ -function OverlaySettings({ +const OverlaySettings = ({ windowTextOverlayOptions, imageToolsEnabled, textsAvailable, @@ -55,7 +55,7 @@ function OverlaySettings({ t, pageColors, containerId, -}) { +}) => { const { enabled, visible, diff --git a/src/lib/color.js b/src/lib/color.js index c08418c..7e09e61 100644 --- a/src/lib/color.js +++ b/src/lib/color.js @@ -35,7 +35,7 @@ function luminance([r, g, b]) { if (vSrgb <= 0.03928) { return vSrgb / 12.92; } - return ((vSrgb + 0.055) / 1.055) ** 2.4; + return Math.pow((vSrgb + 0.055) / 1.055, 2.4); }); return colors[0] * 0.2126 + colors[1] * 0.7152 + colors[2] * 0.0722; }