11<script setup lang="ts">
2- import type { CustomIcon , FontAwesomePreset } from ' @/model/customIcon'
32import {
43 BrandsKeyword ,
54 DuotoneKeyword ,
@@ -13,14 +12,12 @@ import {
1312import { FontAwesomeIconType } from ' @/model/fontAwesomeIconType'
1413import Icon from ' @/components/utils/IconDisplay.vue'
1514import type { FontAwesomeIcon } from ' @/model/fontAwesomeIcon'
16- import { ref } from ' vue'
1715import { fontAwesomeVersionInfo } from ' @/model/fontAwesomeInfo'
16+ import { useIconsStore } from ' @/stores/icons.ts'
17+ import { storeToRefs } from ' pinia'
1818
19- const props = defineProps <{
20- icon: CustomIcon <FontAwesomePreset >
21- }>()
22-
23- const currentIcon = ref (props .icon ?? ({} as CustomIcon <FontAwesomePreset >))
19+ const iconStore = useIconsStore ()
20+ const { currentIcon } = storeToRefs (iconStore )
2421
2522const relevantFamilies =
2623 fontAwesomeVersionInfo .fontLicense === ' Pro' ? FontAwesomeFamilyKeys : FontAwesomeFreeFamilyKeys
@@ -30,7 +27,7 @@ const relevantStyles =
3027 : FontAwesomeFreeStyleKeys
3128
3229function createFontAwesomeIconDisplayFromStyle(style : FontAwesomeStyle ): FontAwesomeIcon {
33- if (props . icon === undefined ) {
30+ if (currentIcon . value === undefined ) {
3431 const fallBackIcon = FontAwesomeIconType .createFallBackIcon ()
3532 return {
3633 id: fallBackIcon .id ,
@@ -41,19 +38,15 @@ function createFontAwesomeIconDisplayFromStyle(style: FontAwesomeStyle): FontAwe
4138 duotoneAlpha: 0.5 ,
4239 style: style
4340 }
44- } else {
45- const id = props .icon .fontAwesomeIcon .id
46- const label = props .icon .fontAwesomeIcon .label
47- const unicode = props .icon .fontAwesomeIcon .unicode
48- const isBrandsIcon = props .icon .fontAwesomeIcon .isBrandsIcon
49- const family = props .icon .fontAwesomeIcon .family
50- const duotoneAlpha = props .icon .fontAwesomeIcon .duotoneAlpha
51- return { id , label , unicode , isBrandsIcon , family , style , duotoneAlpha }
5241 }
42+
43+ const { id, label, unicode, isBrandsIcon, family, duotoneAlpha } =
44+ currentIcon .value .fontAwesomeIcon
45+ return { id , label , unicode , isBrandsIcon , family , style , duotoneAlpha }
5346}
5447
5548function createFontAwesomeIconDisplayFromFamily(family : FontAwesomeFamily ): FontAwesomeIcon {
56- if (props . icon === undefined ) {
49+ if (currentIcon . value === undefined ) {
5750 const fallBackIcon = FontAwesomeIconType .createFallBackIcon ()
5851 return {
5952 id: fallBackIcon .id ,
@@ -64,15 +57,11 @@ function createFontAwesomeIconDisplayFromFamily(family: FontAwesomeFamily): Font
6457 duotoneAlpha: 0.5 ,
6558 style: fallBackIcon .styles .free [0 ]! .style
6659 }
67- } else {
68- const id = props .icon .fontAwesomeIcon .id
69- const label = props .icon .fontAwesomeIcon .label
70- const unicode = props .icon .fontAwesomeIcon .unicode
71- const isBrandsIcon = props .icon .fontAwesomeIcon .isBrandsIcon
72- const style = props .icon .fontAwesomeIcon .style
73- const duotoneAlpha = props .icon .fontAwesomeIcon .duotoneAlpha
74- return { id , label , unicode , isBrandsIcon , family , style , duotoneAlpha }
7560 }
61+
62+ const { id, label, unicode, isBrandsIcon, style, duotoneAlpha } =
63+ currentIcon .value .fontAwesomeIcon
64+ return { id , label , unicode , isBrandsIcon , family , style , duotoneAlpha }
7665}
7766
7867function updateSize(event : Event ) {
@@ -102,15 +91,15 @@ function updateAlpha(event: Event) {
10291 <input
10392 id =" iconSize"
10493 type =" range"
105- :value =" props.icon? .fontSize ?? 180"
94+ :value =" currentIcon .fontSize ?? 180"
10695 @input =" (event) => updateSize(event)"
10796 min =" 50"
10897 max =" 250"
10998 class =" mb-6 h-2 w-full cursor-pointer appearance-none rounded-lg bg-gray-200 focus:border-blue-500 focus:ring-1 focus:ring-blue-500 focus:outline-none dark:bg-gray-700"
11099 />
111100 </div >
112101
113- <div v-if =" props.icon .fontAwesomeIcon.family.includes(DuotoneKeyword)" >
102+ <div v-if =" currentIcon .fontAwesomeIcon.family.includes(DuotoneKeyword)" >
114103 <label
115104 for =" duotoneAlpha"
116105 class =" mb-[0.5] block text-sm font-medium text-gray-900 dark:text-white"
@@ -119,7 +108,7 @@ function updateAlpha(event: Event) {
119108 <input
120109 id =" duotoneAlpha"
121110 type =" range"
122- :value =" props.icon? .fontAwesomeIcon.duotoneAlpha ?? 0.5"
111+ :value =" currentIcon .fontAwesomeIcon.duotoneAlpha ?? 0.5"
123112 @input =" (event) => updateAlpha(event)"
124113 min =" 0"
125114 max =" 1"
@@ -139,7 +128,7 @@ function updateAlpha(event: Event) {
139128 :value =" family"
140129 class =" peer hidden"
141130 @input =" () => updateFamily(family)"
142- :checked =" family === props.icon? .fontAwesomeIcon.family"
131+ :checked =" family === currentIcon .fontAwesomeIcon.family"
143132 />
144133 <label
145134 :for =" family"
@@ -155,7 +144,7 @@ function updateAlpha(event: Event) {
155144 </div >
156145 </div >
157146
158- <div v-if =" !icon .fontAwesomeIcon.family.includes(DuotoneKeyword)" >
147+ <div v-if =" !currentIcon .fontAwesomeIcon.family.includes(DuotoneKeyword)" >
159148 <label class =" mt-3 block text-sm font-medium text-gray-900 dark:text-white"
160149 >Font Style:
161150 </label >
@@ -168,7 +157,7 @@ function updateAlpha(event: Event) {
168157 :value =" style"
169158 class =" peer hidden"
170159 @input =" () => updateStyle(style)"
171- :checked =" style === props.icon? .fontAwesomeIcon.style"
160+ :checked =" style === currentIcon .fontAwesomeIcon.style"
172161 />
173162 <label
174163 :for =" style"
0 commit comments