mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Cleanup formatting and change model to presenter
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
ac92299778
commit
fc42120549
@ -7,11 +7,11 @@ import { SubTitle } from "../../../../../../renderer/components/layout/sub-title
|
|||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { Select } from "../../../../../../renderer/components/select";
|
import { Select } from "../../../../../../renderer/components/select";
|
||||||
import type { TerminalFontPreferenceModel } from "./terminal-font-options.injectable";
|
import type { TerminalFontPreferencePresenter } from "./terminal-font-options.injectable";
|
||||||
import terminalFontPreferenceModelInjectable from "./terminal-font-options.injectable";
|
import terminalFontPreferencePresenterInjectable from "./terminal-font-options.injectable";
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
model: TerminalFontPreferenceModel;
|
model: TerminalFontPreferencePresenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NonInjectedTerminalFontFamily = observer(({ model }: Dependencies) => (
|
const NonInjectedTerminalFontFamily = observer(({ model }: Dependencies) => (
|
||||||
@ -22,14 +22,13 @@ const NonInjectedTerminalFontFamily = observer(({ model }: Dependencies) => (
|
|||||||
controlShouldRenderValue
|
controlShouldRenderValue
|
||||||
value={model.current.get()}
|
value={model.current.get()}
|
||||||
options={model.options.get()}
|
options={model.options.get()}
|
||||||
onChange={model.set}
|
onChange={model.onSelection}
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
),
|
));
|
||||||
);
|
|
||||||
|
|
||||||
export const TerminalFontFamily = withInjectables<Dependencies>(NonInjectedTerminalFontFamily, {
|
export const TerminalFontFamily = withInjectables<Dependencies>(NonInjectedTerminalFontFamily, {
|
||||||
getProps: (di) => ({
|
getProps: (di) => ({
|
||||||
model: di.inject(terminalFontPreferenceModelInjectable),
|
model: di.inject(terminalFontPreferencePresenterInjectable),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -12,22 +12,27 @@ import { defaultTerminalFontFamily } from "../../../../../../common/vars";
|
|||||||
import type { SelectOption } from "../../../../../../renderer/components/select";
|
import type { SelectOption } from "../../../../../../renderer/components/select";
|
||||||
import { terminalFontInjectionToken } from "../../../../../terminal/renderer/fonts/token";
|
import { terminalFontInjectionToken } from "../../../../../terminal/renderer/fonts/token";
|
||||||
|
|
||||||
export interface TerminalFontPreferenceModel {
|
export interface TerminalFontPreferencePresenter {
|
||||||
readonly options: IComputedValue<SelectOption<string>[]>;
|
readonly options: IComputedValue<SelectOption<string>[]>;
|
||||||
readonly current: IComputedValue<string>;
|
readonly current: IComputedValue<string>;
|
||||||
set: (selection: SingleValue<SelectOption<string>>) => void;
|
onSelection: (selection: SingleValue<SelectOption<string>>) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const terminalFontPreferenceModelInjectable = getInjectable({
|
const terminalFontPreferencePresenterInjectable = getInjectable({
|
||||||
id: "terminal-font-preference-model",
|
id: "terminal-font-preference-presenter",
|
||||||
instantiate: (di): TerminalFontPreferenceModel => {
|
instantiate: (di): TerminalFontPreferencePresenter => {
|
||||||
const userStore = di.inject(userStoreInjectable);
|
const userStore = di.inject(userStoreInjectable);
|
||||||
const terminalFonts = di.injectMany(terminalFontInjectionToken);
|
const terminalFonts = di.injectMany(terminalFontInjectionToken);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
options: computed(() => terminalFonts.map(font => ({
|
options: computed(() => terminalFonts.map(font => ({
|
||||||
label: (
|
label: (
|
||||||
<span style={{ fontFamily: `${font.name}, var(--font-terminal)`, fontSize: userStore.terminalConfig.fontSize }}>
|
<span
|
||||||
|
style={{
|
||||||
|
fontFamily: `${font.name}, var(--font-terminal)`,
|
||||||
|
fontSize: userStore.terminalConfig.fontSize,
|
||||||
|
}}
|
||||||
|
>
|
||||||
{font.name}
|
{font.name}
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
@ -35,11 +40,11 @@ const terminalFontPreferenceModelInjectable = getInjectable({
|
|||||||
isSelected: userStore.terminalConfig.fontFamily === font.name,
|
isSelected: userStore.terminalConfig.fontFamily === font.name,
|
||||||
}))),
|
}))),
|
||||||
current: computed(() => userStore.terminalConfig.fontFamily),
|
current: computed(() => userStore.terminalConfig.fontFamily),
|
||||||
set: action(selection => {
|
onSelection: action(selection => {
|
||||||
userStore.terminalConfig.fontFamily = selection?.value ?? defaultTerminalFontFamily;
|
userStore.terminalConfig.fontFamily = selection?.value ?? defaultTerminalFontFamily;
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default terminalFontPreferenceModelInjectable;
|
export default terminalFontPreferencePresenterInjectable;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user