Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 8 additions & 3 deletions frontend/src/ts/commandline/lists/font-family.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Command } from "../types";
import { FontNameSchema } from "@monkeytype/schemas/fonts";
import { Command, withValidation } from "../types";
import { buildCommandForConfigKey } from "../util";
import FileStorage from "../../utils/file-storage";

import { showNoticeNotification } from "../../states/notifications";
import { Config } from "../../config/store";
import { setConfig } from "../../config/setters";
import { applyFontFamily } from "../../ui";

const fromMeta = buildCommandForConfigKey("fontFamily");

if (fromMeta.subgroup) {
Expand All @@ -17,12 +19,15 @@ if (fromMeta.subgroup) {
subgroup: {
title: "Custom font...",
list: [
{
withValidation({
id: "customFontName",
display: "Custom name...",
icon: "fa-font",
alias: "custom font name",
input: true,
validation: {
schema: FontNameSchema,
},
defaultValue: (): string => {
return Config.fontFamily.replace(/_/g, " ");
},
Expand All @@ -31,7 +36,7 @@ if (fromMeta.subgroup) {
const fontName = input.replaceAll(/ /g, "_");
setConfig("fontFamily", fontName);
},
},
}),
{
id: "customLocalFont",
display: "Local font...",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ConfigSchema } from "@monkeytype/schemas/configs";
import { FontNameSchema } from "@monkeytype/schemas/fonts";
import { createResource, For, JSXElement, Show } from "solid-js";
import { z } from "zod";

Expand Down Expand Up @@ -170,7 +171,7 @@ export function FontFamily(): JSXElement {
text: "Make sure you have the font installed on your computer before applying",
buttonText: "apply",
schema: z.object({
fontName: z.string(),
fontName: FontNameSchema,
}),
inputs: {
fontName: {
Expand Down
Loading