elismasilva commited on
Commit
d06a21e
·
verified ·
1 Parent(s): faf1294

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +152 -19
index.html CHANGED
@@ -1,19 +1,152 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Gradio Icon Gallery</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <style>
9
+ /* A nicer scrollbar for dark mode */
10
+ ::-webkit-scrollbar { width: 8px; }
11
+ ::-webkit-scrollbar-track { background: #1f2937; } /* gray-800 */
12
+ ::-webkit-scrollbar-thumb { background: #4b5563; border-radius: 4px; } /* gray-600 */
13
+ ::-webkit-scrollbar-thumb:hover { background: #6b7280; } /* gray-500 */
14
+
15
+ .icon-container > svg {
16
+ animation: none !important;
17
+ }
18
+ </style>
19
+ </head>
20
+ <body class="bg-gray-900 text-gray-200 font-sans">
21
+
22
+ <div id="app" class="container mx-auto p-4 md:p-8">
23
+ <header class="text-center mb-8">
24
+ <h1 class="text-4xl font-bold text-white">Gradio Icon Gallery</h1>
25
+ <p class="text-gray-400 mt-2">Browse and search all available icons from <code class="bg-gray-700 text-orange-400 px-2 py-1 rounded">@gradio/icons</code>.</p>
26
+ </header>
27
+
28
+ <div class="sticky top-4 z-10 mb-8">
29
+ <input
30
+ type="text"
31
+ id="search-input"
32
+ placeholder="Search for an icon (e.g., 'Check', 'Download')..."
33
+ class="w-full p-3 bg-gray-800 border border-gray-700 rounded-lg text-white focus:ring-2 focus:ring-orange-500 focus:outline-none transition"
34
+ >
35
+ </div>
36
+
37
+ <div id="icon-grid" class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-4">
38
+ <!-- Icon cards will be inserted here by JavaScript -->
39
+ <div id="loading-message" class="col-span-full text-center py-10">
40
+ <p class="text-lg">Fetching icons from CDN...</p>
41
+ <p class="text-sm text-gray-500">This may take a moment.</p>
42
+ </div>
43
+ </div>
44
+ </div>
45
+
46
+ <script type="module">
47
+ // The definitive, corrected list of icon names.
48
+ const ICON_NAMES = [
49
+ "ArrowDown", "ArrowUp", "Back", "Backward", "Brush", "BrushSize", "Calendar",
50
+ "Camera", "Chart", "Chat", "Check", "Circle", "Clear", "Code", "Color",
51
+ "ColorPickerSolid", "Community", "Copy", "Crop", "Download", "DropdownArrow",
52
+ "DropdownCircularArrow", "Edit", "Erase", "Error", "Eyedropper", "File",
53
+ "Forward", "Image", "ImagePaste", "ImageResize", "Info", "JSON", "Layers",
54
+ "LineChart", "Maximise", "Maximize", "Microphone", "Minimize", "Music",
55
+ "Palette", "Pan", "Paperclip", "Pause", "Play", "Plot", "Plus", "Redo",
56
+ "Remove", "Resize", "Retry", "Rotate", "ScrollDownArrow", "Send", "Settings",
57
+ "Sketch", "Spinner", "Square", "Success", "Table", "TextHighlight", "Trash",
58
+ "Tree", "Trim", "Undo", "Upload", "Video", "Visibility", "VisibilityOff",
59
+ "VolumeHigh", "VolumeLow", "VolumeMuted", "Warning", "Webcam", "ZoomIn", "ZoomOut"
60
+ ].sort(); // Sort the list alphabetically for a clean display.
61
+
62
+ const iconGrid = document.getElementById('icon-grid');
63
+ const searchInput = document.getElementById('search-input');
64
+ const loadingMessage = document.getElementById('loading-message');
65
+
66
+ let allIconData = [];
67
+
68
+ function renderIcons(filter = '') {
69
+ iconGrid.innerHTML = ''; // Clear the current grid
70
+ const lowerCaseFilter = filter.toLowerCase();
71
+
72
+ const filteredIcons = allIconData.filter(icon =>
73
+ icon.name.toLowerCase().includes(lowerCaseFilter)
74
+ );
75
+
76
+ if (filteredIcons.length === 0) {
77
+ iconGrid.innerHTML = `<div class="col-span-full text-center py-10"><p class="text-lg">No icons found for "${filter}"</p></div>`;
78
+ }
79
+
80
+ filteredIcons.forEach(iconData => {
81
+ const card = document.createElement('div');
82
+ card.className = "flex flex-col items-center justify-center p-4 bg-gray-800 rounded-lg border border-gray-700 hover:bg-gray-700 hover:border-orange-500 transition cursor-pointer";
83
+
84
+ const iconContainer = document.createElement('div');
85
+ iconContainer.className = "w-10 h-10 mb-3 text-white icon-container"; // Added 'icon-container' class
86
+
87
+ iconContainer.innerHTML = iconData.svgString;
88
+
89
+ const nameLabel = document.createElement('p');
90
+ nameLabel.className = "text-sm text-center font-mono break-all";
91
+ nameLabel.textContent = iconData.name;
92
+
93
+ card.appendChild(iconContainer);
94
+ card.appendChild(nameLabel);
95
+
96
+ card.addEventListener('click', () => {
97
+ const textToCopy = `<${iconData.name} />`;
98
+ navigator.clipboard.writeText(textToCopy).then(() => {
99
+ const originalText = nameLabel.textContent;
100
+ nameLabel.textContent = "Copied!";
101
+ nameLabel.classList.add('text-green-400');
102
+ setTimeout(() => {
103
+ nameLabel.textContent = originalText;
104
+ nameLabel.classList.remove('text-green-400');
105
+ }, 1500);
106
+ });
107
+ });
108
+
109
+ iconGrid.appendChild(card);
110
+ });
111
+ }
112
+
113
+ async function init() {
114
+ try {
115
+ // Fetch the raw text content of each .svelte file.
116
+ const fetchPromises = ICON_NAMES.map(name =>
117
+ fetch(`https://cdn.jsdelivr.net/npm/@gradio/[email protected]/src/${name}.svelte`)
118
+ .then(response => {
119
+ if (!response.ok) {
120
+ throw new Error(`HTTP error! status: ${response.status} for ${name}`);
121
+ }
122
+ return response.text();
123
+ })
124
+ );
125
+
126
+ const loadedSvgStrings = await Promise.all(fetchPromises);
127
+
128
+ allIconData = ICON_NAMES.map((name, index) => ({
129
+ name: name,
130
+ svgString: loadedSvgStrings[index]
131
+ }));
132
+
133
+ } catch (error) {
134
+ loadingMessage.innerHTML = `<p class="text-red-400">Failed to load icons. Check the browser console for details.</p>`;
135
+ console.error("Error fetching Gradio icons:", error);
136
+ return;
137
+ }
138
+
139
+ loadingMessage.style.display = 'none';
140
+ renderIcons();
141
+
142
+ searchInput.addEventListener('input', (e) => {
143
+ renderIcons(e.target.value);
144
+ });
145
+ }
146
+
147
+ // Start the application
148
+ init();
149
+
150
+ </script>
151
+ </body>
152
+ </html>