11import { ComponentProps , For , JSXElement , Show } from "solid-js" ;
22
3+ import { configMetadata } from "../../../config/metadata" ;
34import { setConfig , setQuoteLengthAll } from "../../../config/setters" ;
45import { getConfig } from "../../../config/store" ;
56import { restartTestEvent } from "../../../events/test" ;
@@ -8,7 +9,7 @@ import { useRefWithUtils } from "../../../hooks/useRefWithUtils";
89import { isLoggedIn } from "../../../states/core" ;
910import { showModal } from "../../../states/modals" ;
1011import { getResultVisible , getFocus } from "../../../states/test" ;
11- import { FaSolidIcon } from "../../../types/font-awesome" ;
12+ import { FaObject } from "../../../types/font-awesome" ;
1213import { areUnsortedArraysEqual } from "../../../utils/arrays" ;
1314import { cn } from "../../../utils/cn" ;
1415import { Anime , AnimeShow } from "../../common/anime" ;
@@ -59,7 +60,7 @@ export function TestConfig(): JSXElement {
5960}
6061
6162function TCButton ( props : {
62- icon : FaSolidIcon ;
63+ fa : FaObject ;
6364 text : string ;
6465 active ?: boolean ;
6566 disabled ?: boolean ;
@@ -69,7 +70,7 @@ function TCButton(props: {
6970 < Button
7071 variant = "text"
7172 class = { cn ( buttonClass ) }
72- fa = { { icon : props . icon , fixedWidth : true } }
73+ fa = { { ... props . fa , fixedWidth : true } }
7374 text = { props . text }
7475 active = { props . active }
7576 onClick = { props . onClick }
@@ -79,10 +80,7 @@ function TCButton(props: {
7980}
8081
8182function PuncAndNum ( ) : JSXElement {
82- const buttons = [
83- { icon : "fa-at" , configKey : "punctuation" } ,
84- { icon : "fa-hashtag" , configKey : "numbers" } ,
85- ] as const ;
83+ const buttons = [ "punctuation" , "numbers" ] as const ;
8684
8785 return (
8886 < Anime
@@ -96,10 +94,10 @@ function PuncAndNum(): JSXElement {
9694 < AnimeShow when = { getConfig . mode !== "zen" } duration = { durationMs } >
9795 < div class = { cardClass } >
9896 < For each = { buttons } >
99- { ( { icon , configKey } ) => (
97+ { ( configKey ) => (
10098 < TCButton
101- icon = { icon }
102- text = { configKey }
99+ fa = { configMetadata [ configKey ] . fa }
100+ text = { configMetadata [ configKey ] . displayString ?? configKey }
103101 active = { getConfig [ configKey ] }
104102 disabled = {
105103 getConfig . mode === "zen" || getConfig . mode === "quote"
@@ -118,24 +116,24 @@ function PuncAndNum(): JSXElement {
118116}
119117
120118function Mode ( ) : JSXElement {
121- const modes = [
122- { icon : "fa-clock" , mode : "time" } ,
123- { icon : "fa-font" , mode : "words" } ,
124- { icon : "fa-quote-left" , mode : "quote" } ,
125- { icon : "fa-mountain" , mode : "zen" } ,
126- { icon : "fa-wrench" , mode : "custom" } ,
127- ] as const ;
119+ const modeOptions = [ "time" , "words" , "quote" , "zen" , "custom" ] as const ;
128120
129121 return (
130122 < div class = { cn ( "z-2" , cardClass ) } >
131- < For each = { modes } >
132- { ( { icon , mode } ) => (
123+ < For each = { modeOptions } >
124+ { ( modeOption ) => (
133125 < TCButton
134- icon = { icon }
135- text = { mode }
136- active = { getConfig . mode === mode }
126+ fa = {
127+ configMetadata . mode . optionsMetadata ?. [ modeOption ] ?. fa ??
128+ configMetadata . mode . fa
129+ }
130+ text = {
131+ configMetadata . mode . optionsMetadata ?. [ modeOption ]
132+ ?. displayString ?? modeOption
133+ }
134+ active = { getConfig . mode === modeOption }
137135 onClick = { ( ) => {
138- setConfig ( "mode" , mode ) ;
136+ setConfig ( "mode" , modeOption ) ;
139137 restartTestEvent . dispatch ( ) ;
140138 } }
141139 />
0 commit comments