Skip to content

Commit 9aa3446

Browse files
authored
Merge pull request #3593 from Shopify/icon-viewer-hidden
Icon Explorer Improvements
2 parents 4abb1aa + 26a357d commit 9aa3446

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

packages/ui-extensions/docs/surfaces/admin/templates/icon-renderer/dark-mode-listener.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,13 @@
2626
window.addEventListener('theme-mode-changed', () => {
2727
sendThemeToIframe();
2828
});
29+
30+
// Re-send theme when page is restored from cache
31+
window.addEventListener('pageshow', (event) => {
32+
if (event.persisted) {
33+
sendThemeToIframe();
34+
}
35+
});
36+
37+
sendThemeToIframe();
2938
})();

packages/ui-extensions/docs/surfaces/admin/templates/icon-renderer/icon-preview.jsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
const icons = "__ICON_LIST__";
22

33
const styles = `
4+
@keyframes reveal-fallback {
5+
0% { visibility: hidden; }
6+
99% { visibility: hidden; }
7+
100% { visibility: visible; }
8+
}
9+
410
html:not([data-theme]) body {
511
visibility: hidden;
12+
animation: reveal-fallback 300ms forwards;
613
}
714
815
html {
@@ -77,7 +84,6 @@ const styles = `
7784
color: var(--text-primary);
7885
font-size: 14px;
7986
outline: none;
80-
transition: border-color 0.2s;
8187
box-sizing: border-box;
8288
}
8389
@@ -106,9 +112,7 @@ const styles = `
106112
border: 1px solid var(--border-icon-item);
107113
border-radius: 8px;
108114
box-shadow: 0 2px 0px var(--shadow-icon-item);
109-
transition: background-color 0.2s linear, border-color 0.2s linear;
110115
font-family: "JetBrains Mono", Monaco, Consolas, "Lucida Console", monospace
111-
112116
}
113117
114118
.icon-item:hover {
@@ -148,7 +152,6 @@ const styles = `
148152
color: var(--text-primary);
149153
font-size: 14px;
150154
cursor: pointer;
151-
transition: background 0.2s;
152155
}
153156
154157
.pagination-button:hover:not(:disabled) {
@@ -179,10 +182,23 @@ const [isMobile, setIsMobile] = useState(window.innerWidth <= 480);
179182

180183
const pageSize = isMobile ? 6 : 10;
181184

185+
// Simple fuzzy search - checks if all query chars appear in order
186+
const fuzzyMatch = (query, text) => {
187+
let queryIndex = 0;
188+
const lowerQuery = query.toLowerCase();
189+
const lowerText = text.toLowerCase();
190+
191+
for (let i = 0; i < lowerText.length && queryIndex < lowerQuery.length; i++) {
192+
if (lowerText[i] === lowerQuery[queryIndex]) {
193+
queryIndex++;
194+
}
195+
}
196+
197+
return queryIndex === lowerQuery.length;
198+
};
199+
182200
const filteredIcons = searchQuery
183-
? icons.filter((icon) =>
184-
icon.toLowerCase().includes(searchQuery.toLowerCase())
185-
)
201+
? icons.filter(icon => fuzzyMatch(searchQuery, icon))
186202
: icons;
187203

188204
const totalPages = Math.ceil(filteredIcons.length / pageSize);

0 commit comments

Comments
 (0)