Skip to content

Commit

Permalink
Deprecate scroll option
Browse files Browse the repository at this point in the history
  • Loading branch information
wtetsu committed Jan 13, 2024
1 parent e0f89d5 commit 6637ab8
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 39 deletions.
9 changes: 2 additions & 7 deletions src/main/core/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,13 @@
import dom from "../lib/dom";
import template from "../lib/template";

const STYLES_SCROLL = "border-radius: 5px 0px 0px 5px;";
const STYLES_NORMAL = "border-radius: 5px 5px 5px 5px;";

const createDialogElement = (settings) => {
const systemStyles = settings.scroll === "scroll" ? STYLES_SCROLL : STYLES_NORMAL;

const html = template.render(settings.dialogTemplate, {
systemStyles,
systemStyles: "border-radius: 5px 0px 0px 5px;", // For backward compatibility
backgroundColor: settings.backgroundColor,
width: settings.width,
height: settings.height,
scroll: settings.scroll,
scroll: "scroll", // For backward compatibility
});
const dialog = dom.create(html);
dom.applyStyles(dialog, settings.normalDialogStyles);
Expand Down
5 changes: 2 additions & 3 deletions src/main/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export default {
parseWordsLimit: 8,
lookupWithCapitalized: false,
initialPosition: "right",
scroll: "scroll",
skipPdfConfirmation: false,
pdfUrl: "",
backgroundColor: "#ffffff",
Expand Down Expand Up @@ -60,12 +59,12 @@ export default {

dialogTemplate: `<div class="notranslate"
style="all:initial;
{{systemStyles}}
border-radius: 5px 0px 0px 5px;
width: {{width}}px;
height: {{height}}px;
position: fixed;
overflow-x: hidden;
overflow-y: {{scroll}};
overflow-y: scroll;
top: 5px;
background-color: {{backgroundColor}};
z-index: 2147483646;
Expand Down
15 changes: 1 addition & 14 deletions src/options/component/organism/BasicSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { produce } from "immer";
import { res } from "../../logic";
import { env } from "../../extern";
import { Select } from "../atom/Select";
import { MouseDictionaryBasicSettings, UpdateEventHandler, InitialPosition, Scroll } from "../../types";
import { MouseDictionaryBasicSettings, UpdateEventHandler, InitialPosition } from "../../types";

type Props = {
settings: MouseDictionaryBasicSettings;
Expand Down Expand Up @@ -48,11 +48,6 @@ export const BasicSettings: React.FC<Props> = (props) => {
});
}

const scrolls = [
{ name: res.get("scrollOn"), value: "scroll" },
{ name: res.get("scrollOff"), value: "hidden" },
];

const update = (patch: Partial<MouseDictionaryBasicSettings>) => {
const newPatch = produce(patch, (d) => {
for (const name of Object.keys(patch)) {
Expand Down Expand Up @@ -108,14 +103,6 @@ export const BasicSettings: React.FC<Props> = (props) => {
onChange={(value) => update({ initialPosition: value as InitialPosition })}
/>

<label>{res.get("scrollBar")}</label>
<Select
value={settings.scroll}
options={scrolls}
style={{ width: 250 }}
onChange={(value) => update({ scroll: value as Scroll })}
/>

<br />

<h3>{res.get("colorAndFont")}</h3>
Expand Down
2 changes: 1 addition & 1 deletion src/options/page/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const Main: React.FC = () => {
refPreview.current = new Preview(s);
}
refPreview.current?.update(s, state.previewText, true);
}, [s.scroll, s.backgroundColor, s.dialogTemplate, s.contentWrapperTemplate]);
}, [s.backgroundColor, s.dialogTemplate, s.contentWrapperTemplate]);
useEffect(() => {
if (!state.initialized) {
return;
Expand Down
4 changes: 0 additions & 4 deletions src/options/resource/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ const EnglishTextResource: TextResource = {
positionRight: "Right",
positionKeep: "Restore the last position and size",

scrollOff: "Not available",
scrollOn: "Available",

saveSettings: "Save settings",
defaultSettings: "Reset to default",
finishSaving: "Saving has finished",
Expand All @@ -58,7 +55,6 @@ const EnglishTextResource: TextResource = {
width: "Width",
height: "Height",
initialPosition: "Initial position",
scrollBar: "Scroll bar",
dictionaryData: "Dictionary data",
colorAndFont: "Font size and color",
headFont: "Header font",
Expand Down
4 changes: 0 additions & 4 deletions src/options/resource/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ const JapaneseTextResource: TextResource = {
positionRight: "右",
positionKeep: "前回位置とサイズを記憶",

scrollOff: "なし",
scrollOn: "あり",

saveSettings: "設定を保存する",
defaultSettings: "初期状態に戻す",
finishSaving: "保存しました。",
Expand All @@ -53,7 +50,6 @@ const JapaneseTextResource: TextResource = {
width: "幅",
height: "高さ",
initialPosition: "初期表示位置",
scrollBar: "スクロールバー",
dictionaryData: "辞書データ",
colorAndFont: "色と文字サイズ",
background: "背景",
Expand Down
3 changes: 0 additions & 3 deletions src/options/resource/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export type TextResource = {
positionLeft: string;
positionRight: string;
positionKeep: string;
scrollOff: string;
scrollOn: string;
saveSettings: string;
defaultSettings: string;
finishSaving: string;
Expand All @@ -43,7 +41,6 @@ export type TextResource = {
width: string;
height: string;
initialPosition: string;
scrollBar: string;
dictionaryData: string;
colorAndFont: string;
headFont: string;
Expand Down
3 changes: 0 additions & 3 deletions src/options/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@

export type InitialPosition = "left" | "right" | "keep";

export type Scroll = "scroll" | "hidden";

export type MouseDictionaryBasicSettings = {
initialPosition: InitialPosition;
scroll: Scroll;
backgroundColor: string;
headFontColor: string;
descFontColor: string;
Expand Down

0 comments on commit 6637ab8

Please sign in to comment.