-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dependabot/npm_and_yarn/eslint-plugin-reac…
…t-7.32.1 Signed-off-by: Sebastian Malton <sebastian@malton.name>
- Loading branch information
Showing
27 changed files
with
305 additions
and
147 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
50 changes: 50 additions & 0 deletions
50
...derer/preference-items/terminal/terminal-font-family/terminal-font-options.injectable.tsx
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,50 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { getInjectable } from "@ogre-tools/injectable"; | ||
import type { IComputedValue } from "mobx"; | ||
import { action, computed } from "mobx"; | ||
import React from "react"; | ||
import type { SingleValue } from "react-select"; | ||
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable"; | ||
import { defaultTerminalFontFamily } from "../../../../../../common/vars"; | ||
import type { SelectOption } from "../../../../../../renderer/components/select"; | ||
import { terminalFontInjectionToken } from "../../../../../terminal/renderer/fonts/token"; | ||
|
||
export interface TerminalFontPreferencePresenter { | ||
readonly options: IComputedValue<SelectOption<string>[]>; | ||
readonly current: IComputedValue<string>; | ||
onSelection: (selection: SingleValue<SelectOption<string>>) => void; | ||
} | ||
|
||
const terminalFontPreferencePresenterInjectable = getInjectable({ | ||
id: "terminal-font-preference-presenter", | ||
instantiate: (di): TerminalFontPreferencePresenter => { | ||
const userStore = di.inject(userStoreInjectable); | ||
const terminalFonts = di.injectMany(terminalFontInjectionToken); | ||
|
||
return { | ||
options: computed(() => terminalFonts.map(font => ({ | ||
label: ( | ||
<span | ||
style={{ | ||
fontFamily: `${font.name}, var(--font-terminal)`, | ||
fontSize: userStore.terminalConfig.fontSize, | ||
}} | ||
> | ||
{font.name} | ||
</span> | ||
), | ||
value: font.name, | ||
isSelected: userStore.terminalConfig.fontFamily === font.name, | ||
}))), | ||
current: computed(() => userStore.terminalConfig.fontFamily), | ||
onSelection: action(selection => { | ||
userStore.terminalConfig.fontFamily = selection?.value ?? defaultTerminalFontFamily; | ||
}), | ||
}; | ||
}, | ||
}); | ||
|
||
export default terminalFontPreferencePresenterInjectable; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions
18
src/features/terminal/renderer/fonts/anonymous-pro.injectable.ts
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,18 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { getInjectable } from "@ogre-tools/injectable"; | ||
import { terminalFontInjectionToken } from "./token"; | ||
import AnonymousPro from "./AnonymousPro-Regular.ttf"; | ||
|
||
const anonymousProTerminalFontInjectable = getInjectable({ | ||
id: "anonymous-pro-terminal-font", | ||
instantiate: () => ({ | ||
name:"Anonymous Pro", | ||
url: AnonymousPro, | ||
}), | ||
injectionToken: terminalFontInjectionToken, | ||
}); | ||
|
||
export default anonymousProTerminalFontInjectable; |
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,13 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { getInjectable } from "@ogre-tools/injectable"; | ||
import { terminalFontInjectionToken } from "./token"; | ||
|
||
const terminalFontsInjectable = getInjectable({ | ||
id: "terminal-fonts", | ||
instantiate: (di) => di.injectMany(terminalFontInjectionToken), | ||
}); | ||
|
||
export default terminalFontsInjectable; |
18 changes: 18 additions & 0 deletions
18
src/features/terminal/renderer/fonts/ibm-plex-mono.injectable.ts
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,18 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { getInjectable } from "@ogre-tools/injectable"; | ||
import { terminalFontInjectionToken } from "./token"; | ||
import IBMPlexMono from "./IBMPlexMono-Regular.ttf"; | ||
|
||
const ibmPlexMonoTerminalFontInjectable = getInjectable({ | ||
id: "ibm-plex-mono-terminal-font", | ||
instantiate: () => ({ | ||
name: "IBM Plex Mono", | ||
url: IBMPlexMono, | ||
}), | ||
injectionToken: terminalFontInjectionToken, | ||
}); | ||
|
||
export default ibmPlexMonoTerminalFontInjectable; |
18 changes: 18 additions & 0 deletions
18
src/features/terminal/renderer/fonts/jetbrains-mono.injectable.ts
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,18 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { getInjectable } from "@ogre-tools/injectable"; | ||
import { terminalFontInjectionToken } from "./token"; | ||
import JetBrainsMono from "./JetBrainsMono-Regular.ttf"; | ||
|
||
const jetbrainsMonoTerminalFontInjectable = getInjectable({ | ||
id: "jetbrains-mono-terminal-font", | ||
instantiate: () => ({ | ||
name: "JetBrains Mono", | ||
url: JetBrainsMono, | ||
}), | ||
injectionToken: terminalFontInjectionToken, | ||
}); | ||
|
||
export default jetbrainsMonoTerminalFontInjectable; |
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
27 changes: 27 additions & 0 deletions
27
src/features/terminal/renderer/fonts/load-font.injectable.ts
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,27 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { getInjectable } from "@ogre-tools/injectable"; | ||
import type { TerminalFont } from "./token"; | ||
|
||
export type LoadTerminalFont = (font: TerminalFont) => Promise<void>; | ||
|
||
const loadTerminalFontInjectable = getInjectable({ | ||
id: "load-terminal-font", | ||
instantiate: (): LoadTerminalFont => async (font) => { | ||
const fontLoaded = document.fonts.check(`10px ${font.name}`); | ||
|
||
if (fontLoaded) { | ||
return; | ||
} | ||
|
||
const fontFace = new FontFace(font.name, `url(${font.url})`); | ||
|
||
document.fonts.add(fontFace); | ||
await fontFace.load(); | ||
}, | ||
causesSideEffects: true, | ||
}); | ||
|
||
export default loadTerminalFontInjectable; |
24 changes: 24 additions & 0 deletions
24
src/features/terminal/renderer/fonts/preload-fonts.injectable.ts
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,24 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { getInjectable } from "@ogre-tools/injectable"; | ||
import { beforeFrameStartsFirstInjectionToken } from "../../../../renderer/before-frame-starts/tokens"; | ||
import terminalFontsInjectable from "./fonts.injectable"; | ||
import loadTerminalFontInjectable from "./load-font.injectable"; | ||
|
||
const preloadTerminalFontsInjectable = getInjectable({ | ||
id: "preload-terminal-fonts", | ||
instantiate: (di) => ({ | ||
id: "preload-terminal-fonts", | ||
run: async () => { | ||
const terminalFonts = di.inject(terminalFontsInjectable); | ||
const loadTerminalFont = di.inject(loadTerminalFontInjectable); | ||
|
||
await Promise.allSettled(terminalFonts.map(loadTerminalFont)); | ||
}, | ||
}), | ||
injectionToken: beforeFrameStartsFirstInjectionToken, | ||
}); | ||
|
||
export default preloadTerminalFontsInjectable; |
18 changes: 18 additions & 0 deletions
18
src/features/terminal/renderer/fonts/red-hat-mono.injectable.ts
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,18 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { getInjectable } from "@ogre-tools/injectable"; | ||
import { terminalFontInjectionToken } from "./token"; | ||
import RedHatMono from "./RedHatMono-Regular.ttf"; | ||
|
||
const redHatMonoTerminalFontInjectable = getInjectable({ | ||
id: "red-hat-mono-terminal-font", | ||
instantiate: () => ({ | ||
name: "Red Hat Mono", | ||
url: RedHatMono, | ||
}), | ||
injectionToken: terminalFontInjectionToken, | ||
}); | ||
|
||
export default redHatMonoTerminalFontInjectable; |
18 changes: 18 additions & 0 deletions
18
src/features/terminal/renderer/fonts/roboto-mono.injectable.ts
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,18 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { getInjectable } from "@ogre-tools/injectable"; | ||
import { terminalFontInjectionToken } from "./token"; | ||
import RobotoMono from "./Roboto-Mono.ttf"; // patched font with icons | ||
|
||
const robotoMonoTerminalFontInjectable = getInjectable({ | ||
id: "roboto-mono-terminal-font", | ||
instantiate: () => ({ | ||
name: "RobotoMono", | ||
url: RobotoMono, | ||
}), | ||
injectionToken: terminalFontInjectionToken, | ||
}); | ||
|
||
export default robotoMonoTerminalFontInjectable; |
18 changes: 18 additions & 0 deletions
18
src/features/terminal/renderer/fonts/source-code-pro.injectable.ts
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,18 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { getInjectable } from "@ogre-tools/injectable"; | ||
import { terminalFontInjectionToken } from "./token"; | ||
import SourceCodePro from "./SourceCodePro-Regular.ttf"; | ||
|
||
const sourceCodeProTerminalFontInjectable = getInjectable({ | ||
id: "source-code-pro-terminal-font", | ||
instantiate: () => ({ | ||
name: "Source Code Pro", | ||
url: SourceCodePro, | ||
}), | ||
injectionToken: terminalFontInjectionToken, | ||
}); | ||
|
||
export default sourceCodeProTerminalFontInjectable; |
18 changes: 18 additions & 0 deletions
18
src/features/terminal/renderer/fonts/space-mono.injectable.ts
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,18 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { getInjectable } from "@ogre-tools/injectable"; | ||
import { terminalFontInjectionToken } from "./token"; | ||
import SpaceMono from "./SpaceMono-Regular.ttf"; | ||
|
||
const spaceMonoTerminalFontInjectable = getInjectable({ | ||
id: "space-mono-terminal-font", | ||
instantiate: () => ({ | ||
name: "Space Mono", | ||
url: SpaceMono, | ||
}), | ||
injectionToken: terminalFontInjectionToken, | ||
}); | ||
|
||
export default spaceMonoTerminalFontInjectable; |
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,15 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
|
||
import { getInjectionToken } from "@ogre-tools/injectable"; | ||
|
||
export interface TerminalFont { | ||
name: string; | ||
url: string; | ||
} | ||
|
||
export const terminalFontInjectionToken = getInjectionToken<TerminalFont>({ | ||
id: "terminal-font-token", | ||
}); |
18 changes: 18 additions & 0 deletions
18
src/features/terminal/renderer/fonts/ubuntu-mono.injectable.ts
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,18 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { getInjectable } from "@ogre-tools/injectable"; | ||
import { terminalFontInjectionToken } from "./token"; | ||
import UbuntuMono from "./UbuntuMono-Regular.ttf"; | ||
|
||
const ubunutuMonoTerminalFontInjectable = getInjectable({ | ||
id: "ubunutu-mono-terminal-font", | ||
instantiate: () => ({ | ||
name: "Ubuntu Mono", | ||
url: UbuntuMono, | ||
}), | ||
injectionToken: terminalFontInjectionToken, | ||
}); | ||
|
||
export default ubunutuMonoTerminalFontInjectable; |
Oops, something went wrong.