8000 feat: support multiple terminal fonts by mtojek · Pull Request #17257 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: support multiple terminal fonts #17257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Review fixes
  • Loading branch information
mtojek committed Apr 7, 2025
commit 2a68eebf9fa0d0e0029d563e60c051afa6c0a864
2 changes: 1 addition & 1 deletion cli/testdata/TestProvisioners_Golden/list.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ID CREATED AT LAST SEEN AT NAME VERSION TAGS KEY NAME STATUS CURRENT JOB ID CURRENT JOB STATUS PREVIOUS JOB ID PREVIOUS JOB STATUS ORGANIZATION
ID CREATED AT LAST SEEN AT NAME VERSION TAGS KEY NAME STATUS CURRENT JOB ID CURRENT JOB STATUS PREVIOUS JOB ID PREVIOUS JOB STATUS ORGANIZATION
00000000-0000-0000-aaaa-000000000000 ====[timestamp]===== ====[timestamp]===== default-provisioner v0.0.0-devel map[owner: scope:organization] built-in idle <nil> <nil> 00000000-0000-0000-bbbb-000000000001 succeeded Coder
00000000-0000-0000-aaaa-000000000001 ====[timestamp]===== ====[timestamp]===== provisioner-1 v0.0.0 map[foo:bar owner: scope:organization] built-in busy 00000000-0000-0000-bbbb-000000000002 running <nil> <nil> Coder
00000000-0000-0000-aaaa-000000000002 ====[timestamp]===== ====[timestamp]===== provisioner-2 v0.0.0 map[owner: scope:organization] built-in offline <nil> <nil> 00000000-0000-0000-bbbb-000000000003 succeeded Coder
Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_provisioner_list.golden
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CREATED AT LAST SEEN AT KEY NAME NAME VERSION STATUS TAGS
CREATED AT LAST SEEN AT KEY NAME NAME VERSION STATUS TAGS
====[timestamp]===== ====[timestamp]===== built-in test v0.0.0-devel idle map[owner: scope:organization]
22 changes: 3 additions & 19 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 3 additions & 13 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions coderd/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"net/http"
"slices"

"github.com/go-chi/chi/v5"
"github.com/go-chi/render"
Expand Down Expand Up @@ -1067,12 +1068,7 @@ func (api *API) putUserAppearanceSettings(rw http.ResponseWriter, r *http.Reques
}

func isValidFontName(font codersdk.TerminalFontName) bool {
switch font {
case codersdk.TerminalFontIbmPlexMono, codersdk.TerminalFontFiraCode, "":
return true
default:
return false
}
return slices.Contains(codersdk.TerminalFontNames, font)
}

// @Summary Update user password
Expand Down
8 changes: 5 additions & 3 deletions codersdk/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,22 @@ type ValidateUserPasswordResponse struct {
// TerminalFontName is the name of supported terminal font
type TerminalFontName string

var TerminalFontNames = []TerminalFontName{TerminalFontUnknown, TerminalFontIBMPlexMono, TerminalFontFiraCode}

const (
TerminalFontUnknown TerminalFontName = ""
TerminalFontIbmPlexMono TerminalFontName = "ibm-plex-mono"
TerminalFontIBMPlexMono TerminalFontName = "ibm-plex-mono"
TerminalFontFiraCode TerminalFontName = "fira-code"
)

type UserAppearanceSettings struct {
ThemePreference string `json:"theme_preference"`
TerminalFont TerminalFontName `json:"terminal_font" enums:"ibm-plex-mono,fira-code"`
TerminalFont TerminalFontName `json:"terminal_font"`
}

type UpdateUserAppearanceSettingsRequest struct {
ThemePreference string `json:"theme_preference" validate:"required"`
TerminalFont TerminalFontName `json:"terminal_font" validate:"required" enums:"ibm-plex-mono,fira-code"`
TerminalFont TerminalFontName `json:"terminal_font" validate:"required"`
}

type UpdateUserPasswordRequest struct {
Expand Down
18 changes: 2 additions & 16 deletions docs/reference/api/schemas.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/reference/api/users.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion provisioner/terraform/testdata/resources/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.11.2
1.11.1
25 changes: 13 additions & 12 deletions site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type { FC } from "react";
import themes, {
DEFAULT_TERMINAL_FONT,
DEFAULT_THEME,
fontLabels,
type Theme,
} from "theme";
import { Section } from "../Section";
Expand Down Expand Up @@ -112,18 +113,18 @@ export const AppearanceForm: FC<AppearanceFormProps> = ({
onChangeTerminalFont(toTerminalFontName(value))
}
>
<FormControlLabel
value="ibm-plex-mono"
control={<Radio />}
label={
<div css={{ fontFamily: "IBM Plex Mono" }}>IBM Plex Mono</div>
}
/>
<FormControlLabel
value="fira-code"
control={<Radio />}
label={<div css={{ fontFamily: "Fira Code" }}>Fira Code</div>}
/>
{TerminalFontNames.filter((name) => name !== "").map((name) => (
<FormControlLabel
key={name}
value={name}
control={<Radio />}
label={
<div css={{ fontFamily: fontLabels[name] }}>
IBM Plex Mono
</div>
}
/>
))}
</RadioGroup>
</FormControl>
</Section>
Expand Down
9 changes: 9 additions & 0 deletions site/src/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// biome-ignore lint/nursery/noRestrictedImports: We still use `Theme` as a basis for our actual theme, for now.
import type { Theme as MuiTheme } from "@mui/material/styles";
import type { TerminalFontName } from "api/typesGenerated";
import type * as monaco from "monaco-editor";
import { of } from "rxjs";
import type { Branding } from "./branding";
import { terminalFonts } from "./constants";
import dark from "./dark";
import type { NewTheme } from "./experimental";
import type { ExternalImageModeStyles } from "./externalImages";
Expand Down Expand Up @@ -37,4 +40,10 @@ const theme = {

export default theme;

export const fontLabels: Record<TerminalFontName, string> = {
"fira-code": "Fira Code",
"ibm-plex-mono": "IBM Plex Mono",
"": "", // needed for enum completeness, otherwise fails the build
};

export const DEFAULT_TERMINAL_FONT = "ibm-plex-mono";
0