1+ <script >
2+ import { onMount } from ' svelte' ;
3+ import { selectedIcon , isModalOpen , closeIconModal } from ' $lib/stores/iconStore' ;
4+
5+ let selectedVersion = ' ' ;
6+ let versions = [];
7+
8+ $: if ($selectedIcon && $selectedIcon .versions && $selectedIcon .versions .svg ) {
9+ versions = $selectedIcon .versions .svg ;
10+ selectedVersion = versions .includes (' original' ) ? ' original' : versions[0 ];
11+ }
12+
13+ function getIconUrl (icon , version ) {
14+ return ` https://cdn.jsdelivr.net/gh/devicons/devicon/icons/${ icon .name } /${ icon .name } -${ version} .svg` ;
15+ }
16+
17+ function handleKeydown (e ) {
18+ if (e .key === ' Escape' ) {
19+ closeIconModal ();
20+ }
21+ }
22+
23+ onMount (() => {
24+ document .addEventListener (' keydown' , handleKeydown);
25+ return () => {
26+ document .removeEventListener (' keydown' , handleKeydown);
27+ };
28+ });
29+ </script >
30+
31+ <div class ="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4" on:click |self ={closeIconModal }>
32+ <div
33+ class =" bg-white dark:bg-gray-800 p-6 rounded-lg shadow-xl max-w-lg w-full max-h-[90vh] overflow-y-auto"
34+ role =" dialog"
35+ aria-modal =" true"
36+ aria-labelledby =" modal-title"
37+ >
38+ {#if $selectedIcon }
39+ <div class =" flex justify-between items-start mb-4" >
40+ <h2 id ="modal-title" class ="text-xl font-bold dark:text-white" >{$selectedIcon .name }</h2 >
41+ <button
42+ class =" text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"
43+ on:click ={closeIconModal }
44+ aria-label =" Close modal"
45+ >
46+ <svg xmlns =" http://www.w3.org/2000/svg" class =" h-6 w-6" fill =" none" viewBox =" 0 0 24 24" stroke =" currentColor" >
47+ <path stroke-linecap =" round" stroke-linejoin =" round" stroke-width =" 2" d =" M6 18L18 6M6 6l12 12" />
48+ </svg >
49+ </button >
50+ </div >
51+
52+ <div class =" flex flex-col items-center mb-6" >
53+ {#if versions .length > 0 }
54+ <div class =" bg-gray-100 dark:bg-gray-700 p-8 rounded-lg mb-4 w-full flex justify-center" >
55+ <img
56+ src ={getIconUrl ($selectedIcon , selectedVersion )}
57+ alt ={` ${$selectedIcon .name } (${selectedVersion }) ` }
58+ class =" h-24"
59+ />
60+ </div >
61+
62+ <div class =" w-full" >
63+ <label for =" version-select" class =" block text-sm font-medium mb-2 dark:text-gray-200" >Select version:</label >
64+ <select
65+ id =" version-select"
66+ bind:value ={selectedVersion }
67+ class =" w-full p-2 border rounded-md dark:bg-gray-700 dark:border-gray-600 dark:text-white"
68+ >
69+ {#each versions as version }
70+ <option value ={version }>{version }</option >
71+ {/each }
72+ </select >
73+ </div >
74+ {:else }
75+ <p class =" text-gray-500 dark:text-gray-400" >No SVG versions available</p >
76+ {/if }
77+ </div >
78+
79+ {#if $selectedIcon .tags && $selectedIcon .tags .length > 0 }
80+ <div class =" mb-4" >
81+ <h3 class =" font-medium mb-2 dark:text-white" >Tags:</h3 >
82+ <div class =" flex flex-wrap gap-1" >
83+ {#each $selectedIcon .tags as tag }
84+ <span class ="px-2 py-1 bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300 rounded text-sm" >{tag }</span >
85+ {/each }
86+ </div >
87+ </div >
88+ {/if }
89+
90+ <div class =" pt-4 border-t border-gray-200 dark:border-gray-700" >
91+ <button
92+ class =" px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors"
93+ on:click ={closeIconModal }
94+ >
95+ Close
96+ </button >
97+ </div >
98+ {/if }
99+ </div >
100+ </div >
0 commit comments