@@ -7,14 +7,14 @@ import { DiscourseNode } from "~/types";
77import { ConfirmationModal } from "./ConfirmationModal" ;
88import { getTemplateFiles , getTemplatePluginInfo } from "~/utils/templates" ;
99
10- type EditableFieldKey = keyof Omit < DiscourseNode , "id" | "shortcut" | "color" > ;
10+ type EditableFieldKey = keyof Omit < DiscourseNode , "id" | "shortcut" > ;
1111
1212type BaseFieldConfig = {
1313 key : EditableFieldKey ;
1414 label : string ;
1515 description : string ;
1616 required ?: boolean ;
17- type : "text" | "select" ;
17+ type : "text" | "select" | "color" ;
1818 placeholder ?: string ;
1919 validate ?: (
2020 value : string ,
@@ -68,6 +68,13 @@ const FIELD_CONFIGS: Record<EditableFieldKey, BaseFieldConfig> = {
6868 type : "select" ,
6969 required : false ,
7070 } ,
71+ color : {
72+ key : "color" ,
73+ label : "Color" ,
74+ description : "The color to use for this node type" ,
75+ type : "color" ,
76+ required : false ,
77+ } ,
7178} ;
7279
7380const FIELD_CONFIG_ARRAY = Object . values ( FIELD_CONFIGS ) ;
@@ -92,6 +99,23 @@ const TextField = ({
9299 />
93100) ;
94101
102+ const ColorField = ( {
103+ value,
104+ error,
105+ onChange,
106+ } : {
107+ value : string ;
108+ error ?: string ;
109+ onChange : ( value : string ) => void ;
110+ } ) => (
111+ < input
112+ type = "color"
113+ value = { value || "#000000" }
114+ onChange = { ( e ) => onChange ( e . target . value ) }
115+ className = { `h-8 w-20 ${ error ? "input-error" : "" } ` }
116+ />
117+ ) ;
118+
95119const TemplateField = ( {
96120 value,
97121 error,
@@ -367,6 +391,8 @@ const NodeTypeSettings = () => {
367391 templateConfig = { templateConfig }
368392 templateFiles = { templateFiles }
369393 />
394+ ) : fieldConfig . type === "color" ? (
395+ < ColorField value = { value } error = { error } onChange = { handleChange } />
370396 ) : (
371397 < TextField
372398 fieldConfig = { fieldConfig }
@@ -391,7 +417,15 @@ const NodeTypeSettings = () => {
391417 onClick = { ( ) => startEditing ( index ) }
392418 >
393419 < div className = "flex items-center justify-between" >
394- < span className = "font-medium" > { nodeType . name } </ span >
420+ < div className = "flex items-center gap-2" >
421+ { nodeType . color && (
422+ < div
423+ className = "h-4 w-4 rounded-full"
424+ style = { { backgroundColor : nodeType . color } }
425+ />
426+ ) }
427+ < span > { nodeType . name } </ span >
428+ </ div >
395429 < div className = "flex gap-2" >
396430 < button
397431 className = "icon-button"
0 commit comments