Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into guids
Browse files Browse the repository at this point in the history
  • Loading branch information
astuanax committed Nov 14, 2023
2 parents 91415d5 + 598892e commit ead0c03
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { Icon } from '@iconify/react';
import cx from 'classnames';
import { useCallback, useEffect, useState } from 'react';
import { DropDown } from 'renderer/components/DropDown';
import { COLOR_BLINDNESS_CHANNEL } from 'renderer/components/ToolBar/ColorBlindnessControls';
import {
BLUE_YELLOW,
FULL,
RED_GREEN,
SIMULATIONS,
SUNLIGHT,
VisionSimulationDropDown,
VISUAL_IMPAIRMENTS,
VisionSimulationDropDown,
} from 'renderer/components/VisionSimulationDropDown';
import { webViewPubSub } from 'renderer/lib/pubsub';

Expand Down Expand Up @@ -49,14 +53,14 @@ export const ColorBlindnessTools = ({ webview }: Props) => {
}

if (injectCss !== undefined) {
if (js !== null) {
if (injectCss.name === debugType) {
return;
}
if (injectCss.js !== null) {
webview.reload();
}
await webview.removeInsertedCSS(injectCss.key);
setInjectCss(undefined);
if (injectCss.css === css) {
return;
}
}

try {
Expand Down Expand Up @@ -130,11 +134,11 @@ export const ColorBlindnessTools = ({ webview }: Props) => {
'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pgo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPgo8c3ZnIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8ZGVmcz4KICAgICAgICA8ZmlsdGVyIGlkPSJnYXVzc2lhbl9ibHVyIj4KICAgICAgICAgICAgPGZlR2F1c3NpYW5CbHVyIGluPSJTb3VyY2VHcmFwaGljIiBzdGREZXZpYXRpb249IjEwIiAvPgogICAgICAgIDwvZmlsdGVyPgogICAgPC9kZWZzPgo8L3N2Zz4=';

const impairments: { [key: string]: string } = {
cataract: `body {
[SIMULATIONS.CATARACT]: `body {
-webkit-filter: url('${blur}#gaussian_blur');
filter: url('${blur}#gaussian_blur');
}`,
glaucoma: `#bigoverlay {
[SIMULATIONS.GLAUCOME]: `#bigoverlay {
position: fixed;
top: 0;
left: 0;
Expand All @@ -154,11 +158,11 @@ export const ColorBlindnessTools = ({ webview }: Props) => {
left: -75vmax;
top: -75vmax;
}`,
farsightedness: `body { filter: blur(2px); }`,
[SIMULATIONS.FAR]: `body { filter: blur(2px); }`,
};
const css = impairments[visualImpairment.toLowerCase()];
let js = null;
if (visualImpairment.toLowerCase() === 'glaucoma') {
if (visualImpairment.toLowerCase() === SIMULATIONS.GLAUCOME) {
js = String(`var div = document.createElement('div');
div.innerHTML ='<div class="bigoverlay" id="bigoverlay"><div class="spotlight" id="spotlight"></div></div>';
var body = document.body;
Expand Down

0 comments on commit ead0c03

Please sign in to comment.