1111 <legend >{{ parameter.label }}</legend >
1212 <label v-if =" parameter.unselectLabel !== undefined" :for =" `parameter_none_${parameter.id}`" >
1313 <input
14- type =" radio"
15- :id =" `parameter_none_${parameter.id}`"
16- :name =" parameter.id"
17- value =" "
18- v-model =" element.parameters[parameter.id]"
14+ type =" radio"
15+ :id =" `parameter_none_${parameter.id}`"
16+ :name =" parameter.id"
17+ value =" "
18+ v-model =" element.parameters[parameter.id]"
1919 />
2020 {{ parameter.unselectLabel }}<br />
2121 </label >
5151 v-model =" element.parameters[parameter.id]"
5252 />
5353 </template >
54+ <template v-if =" element .type .name === ' Nerd Font Glyph' " >
55+ <ul class =" nerd-font-glyph-suggestions" >
56+ <li
57+ v-for =" glyph in nerdFontGlyphSuggestions"
58+ :key =" glyph.name"
59+ :class =" { selected: element.parameters.glyph === glyph.name }"
60+ >
61+ <button type =" button" :title =" glyph.name" @click =" setTextParameter(parameter.id, glyph.name)" >
62+ <i :class =" `nf ${glyph.name}`" ></i >
63+ </button >
64+ </li >
65+ </ul >
66+ </template >
5467 </label >
5568 </div >
5669 <div class =" properties_color" v-if =" element.type.visible" >
@@ -152,6 +165,8 @@ import prompt from '@/lib/prompt';
152165import { Color } from ' @/lib/enum/color' ;
153166import { PromptElement } from ' @/lib/promptElement' ;
154167import darkMode from ' @/lib/darkMode' ;
168+ import { fuzzySearchNerdFontGlyphs , NerdFontGlyph } from ' @/lib/enum/nerdfontglyph' ;
169+ import debounce from ' lodash.debounce' ;
155170import EmptyState from ' ../base/EmptyState.vue' ;
156171import ColorPicker from ' ../ui/ColorPicker.vue' ;
157172import IconButton from ' ../ui/IconButton.vue' ;
@@ -180,6 +195,10 @@ export default defineComponent({
180195 * Setting any of the properties will modify this (and only this) element.
181196 */
182197 element: prompt .refs ().selectedElement ,
198+ /**
199+ * Nerd Font glyph suggestions based on the current parameter input value.
200+ */
201+ nerdFontGlyphSuggestions: [] as NerdFontGlyph [],
183202 };
184203 },
185204 computed: {
@@ -200,6 +219,17 @@ export default defineComponent({
200219 },
201220 },
202221 methods: {
222+ /**
223+ * Sets the value of a text parameter for the currently selected element.
224+ *
225+ * @param parameterId the ID of the parameter to set
226+ * @param value the value to set for the parameter
227+ */
228+ setTextParameter(parameterId : string , value : string ) {
229+ if (this .element && this .element .parameters ) {
230+ this .element .parameters [parameterId ] = value ;
231+ }
232+ },
203233 /**
204234 * Sets the foreground color of the currently selected element.
205235 *
@@ -233,12 +263,38 @@ export default defineComponent({
233263 prompt .state ().push (element );
234264 }
235265 },
266+ /**
267+ * Updates the list of Nerd Font glyph suggestions based on the provided name.
268+ *
269+ * @param name the name of the Nerd Font glyph to search for
270+ */
271+ updateNerdFontGlyphSuggestions(name : string ) {
272+ this .nerdFontGlyphSuggestions = fuzzySearchNerdFontGlyphs (name );
273+ },
274+ /**
275+ * Debounced version of `updateNerdFontGlyphSuggestions` to avoid excessive calls while typing.
276+ */
277+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
278+ updateNerdFontGlyphSuggestionsDebounced(name : string ) {
279+ // This will be replaced in `created()`
280+ },
281+ },
282+ created() {
283+ this .updateNerdFontGlyphSuggestionsDebounced = debounce (this .updateNerdFontGlyphSuggestions , 50 );
284+ },
285+ watch: {
286+ ' element.parameters.glyph' : function watchGlyphParameter(newVal : string ) {
287+ if (this .element && this .element .type .name === ' Nerd Font Glyph' ) {
288+ this .updateNerdFontGlyphSuggestionsDebounced (newVal || ' ' );
289+ }
290+ },
236291 },
237292});
238293 </script >
239294
240295<style lang="sass" scoped>
241296@import " @/assets/sass/_variables.sass"
297+ @import " https://www.nerdfonts.com/assets/css/webfont.css"
242298
243299.properties-wrapper
244300 text-align : left
@@ -278,6 +334,7 @@ input[type="text"]
278334 width : 20em
279335 padding : 0.2em 0.4em
280336 margin-top : 0.2em
337+ font-family : ' NerdFontsSymbols Nerd Font' , monospace
281338
282339input .color-picker-btn
283340 vertical-align : middle
@@ -290,4 +347,27 @@ input.color-picker-btn
290347
291348input [disabled]
292349 opacity : 0.7
350+
351+ .nerd-font-glyph-suggestions
352+ list-style : none
353+ padding : 0
354+ margin : 1em 0 0
355+
356+ li
357+ display : inline-block
358+ margin : 0.1em
359+
360+ & .selected
361+ color : $color-accent
362+
363+ button
364+ font-size : 1.5em
365+ padding : 0.2em
366+ background : none
367+ border : none
368+ color : inherit
369+ cursor : pointer
370+
371+ i
372+ vertical-align : middle
293373 </style >
0 commit comments