-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add setting to toggle color correction
- Loading branch information
1 parent
c320ef0
commit c9be556
Showing
27 changed files
with
319 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React, { FC, useCallback, useEffect, useMemo, useState } from "react"; | ||
import { Select, SelectCommonProps } from "ui/form/Select"; | ||
import l10n from "shared/lib/lang/l10n"; | ||
import { SingleValue } from "react-select"; | ||
import { ColorCorrectionSetting } from "shared/lib/resources/types"; | ||
|
||
interface ColorCorrectionSelectProps extends SelectCommonProps { | ||
name: string; | ||
value?: ColorCorrectionSetting; | ||
onChange?: (newId: ColorCorrectionSetting) => void; | ||
} | ||
|
||
export interface ColorCorrectionOption { | ||
value: ColorCorrectionSetting; | ||
label: string; | ||
} | ||
|
||
export const ColorCorrectionSelect: FC<ColorCorrectionSelectProps> = ({ | ||
value, | ||
onChange, | ||
}) => { | ||
const [currentValue, setCurrentValue] = useState<ColorCorrectionOption>(); | ||
|
||
const colorCorrectionOptions: ColorCorrectionOption[] = useMemo( | ||
() => [ | ||
{ | ||
value: "default", | ||
label: l10n("FIELD_COLOR_CORRECTION_ENABLED_DEFAULT"), | ||
}, | ||
{ | ||
value: "none", | ||
label: l10n("FIELD_COLOR_CORRECTION_NONE"), | ||
}, | ||
], | ||
[] | ||
); | ||
|
||
useEffect(() => { | ||
const currentColorCorrection = colorCorrectionOptions.find( | ||
(e) => e.value === value | ||
); | ||
if (currentColorCorrection) { | ||
setCurrentValue(currentColorCorrection); | ||
} | ||
}, [colorCorrectionOptions, value]); | ||
|
||
const onSelectChange = useCallback( | ||
(newValue: SingleValue<ColorCorrectionOption>) => { | ||
if (newValue) { | ||
onChange?.(newValue.value); | ||
} | ||
}, | ||
[onChange] | ||
); | ||
|
||
return ( | ||
<Select | ||
value={currentValue} | ||
options={colorCorrectionOptions} | ||
onChange={onSelectChange} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.