diff --git a/desktop-app/src/renderer/components/DropDown/index.tsx b/desktop-app/src/renderer/components/DropDown/index.tsx index 3747d8729..466b17a59 100644 --- a/desktop-app/src/renderer/components/DropDown/index.tsx +++ b/desktop-app/src/renderer/components/DropDown/index.tsx @@ -59,7 +59,7 @@ export function DropDown({ label, options, className }: Props) { option.onClick !== null ? ( - - } - options={[ - { - label: ( -
- A11y Tools -
- ), - onClick: null, - }, - { - label: ( -
- Visual deficiency -
- ), - onClick: null, - }, - { - label: ( -
- - Red-green deficiency - -
- ), - onClick: null, - }, - ...redgreen.map((x: string) => { - return { - label: ( -
- {injectCss?.name === x.toLowerCase() ? ( - - ) : ( - <> - )} - - {x} - -
- ), - onClick: () => { - applyColorDeficiency(x.toLowerCase()); - }, - }; - }), - { - label: ( -
- - Blue-yellow deficiency - -
- ), - onClick: null, - }, - ...blueyellow.map((x: string) => { - return { - label: ( -
- {injectCss?.name === x.toLowerCase() ? ( - - ) : ( - <> - )} - - {x} - -
- ), - onClick: () => { - applyColorDeficiency(x.toLowerCase()); - }, - }; - }), - { - label: ( -
- - Full color deficiency - -
- ), - onClick: null, - }, - ...full.map((x: string) => { - return { - label: ( -
- {injectCss?.name === x.toLowerCase() ? ( - - ) : ( - <> - )} - - {x} - -
- ), - onClick: () => { - applyColorDeficiency(x.toLowerCase()); - }, - }; - }), - { - label: ( -
- Visual impairment -
- ), - onClick: null, - }, - ...visualimpairments.map((x: string) => { - return { - label: ( -
- {injectCss?.name === x.toLowerCase() ? ( - - ) : ( - <> - )} - - {x} - -
- ), - onClick: () => { - applyVisualImpairment(x.toLowerCase()); - }, - }; - }), - { - label: ( -
- - Temporary impairment - -
- ), - onClick: null, - }, - ...sunlight.map((x: string) => { - return { - label: ( -
- {injectCss?.name === x.toLowerCase() ? ( - - ) : ( - <> - )} - - {x} - -
- ), - onClick: () => { - applySunlight(x.toLowerCase()); - }, - }; - }), - ]} - /> + + diff --git a/desktop-app/src/renderer/components/VisionSimulationDropDown/index.tsx b/desktop-app/src/renderer/components/VisionSimulationDropDown/index.tsx new file mode 100644 index 000000000..e29b5cb81 --- /dev/null +++ b/desktop-app/src/renderer/components/VisionSimulationDropDown/index.tsx @@ -0,0 +1,193 @@ +import cx from 'classnames'; +import { Icon } from '@iconify/react'; +import { DropDown } from '../DropDown'; + +const MenuItemLabel = ({ + label, + isActive, +}: { + label: string; + isActive: boolean; +}) => { + return ( +
+ + + {label} + +
+ ); +}; + +const MenuItemHeader = ({ label }: { label: string }) => { + return ( +
+ + ); +}; + +export const SIMULATIONS = { + DEUTERANOPIA: 'deuteranopia', + DEUTERANOMALY: 'deuteranomaly', + PROTANOPIA: 'protanopia', + PROTANOMALY: 'protanomaly', + TRITANOPIA: 'tritanopia', + TRITANOMALY: 'tritanomaly', + ACHROMATOMALY: 'achromatomaly', + ACHROMATOPSIA: 'achromatopsia', + CATARACT: 'cataract', + FAR: 'farsightedness', + GLAUCOME: 'glaucoma', + SOLARIZE: 'solarize', +}; + +export const RED_GREEN = [ + SIMULATIONS.DEUTERANOPIA, + SIMULATIONS.DEUTERANOMALY, + SIMULATIONS.PROTANOPIA, + SIMULATIONS.PROTANOMALY, +]; +export const BLUE_YELLOW = [SIMULATIONS.TRITANOPIA, SIMULATIONS.TRITANOMALY]; +export const FULL = [SIMULATIONS.ACHROMATOMALY, SIMULATIONS.ACHROMATOPSIA]; +export const VISUAL_IMPAIRMENTS = [ + SIMULATIONS.CATARACT, + SIMULATIONS.FAR, + SIMULATIONS.GLAUCOME, +]; +export const SUNLIGHT = [SIMULATIONS.SOLARIZE]; + +interface Props { + simulationName: string | undefined; + onChange: (name: string | undefined) => void; +} + +export const VisionSimulationDropDown = ({ + simulationName, + onChange, +}: Props) => { + return ( + } + options={[ + { + label: , + onClick: null, + }, + { + label: ( + + ), + onClick: () => { + onChange(undefined); + }, + }, + { + label: , + onClick: null, + }, + ...RED_GREEN.map((x: string) => { + return { + label: ( + + ), + onClick: () => { + onChange(x.toLowerCase()); + }, + }; + }), + { + label: , + onClick: null, + }, + ...BLUE_YELLOW.map((x: string) => { + return { + label: ( + + ), + onClick: () => { + onChange(x.toLowerCase()); + }, + }; + }), + { + label: , + onClick: null, + }, + ...FULL.map((x: string) => { + return { + label: ( + + ), + onClick: () => { + onChange(x.toLowerCase()); + }, + }; + }), + { + label: , + onClick: null, + }, + ...VISUAL_IMPAIRMENTS.map((x: string) => { + return { + label: ( + + ), + onClick: () => { + onChange(x.toLowerCase()); + }, + }; + }), + { + label: , + onClick: null, + }, + ...SUNLIGHT.map((x: string) => { + return { + label: ( + + ), + onClick: () => { + onChange(x.toLowerCase()); + }, + }; + }), + ]} + /> + ); +};