diff --git a/templates/devtest/icon-gallery.tmpl b/templates/devtest/icon-gallery.tmpl index fd24bf7b34..77607f9370 100644 --- a/templates/devtest/icon-gallery.tmpl +++ b/templates/devtest/icon-gallery.tmpl @@ -3,39 +3,19 @@

Icon Gallery

All {{.IconCount}} SVG icons available in templates.

- +

- - {{range $prefix := .IconGroupOrder}} {{$icons := index $.IconGroups $prefix}} {{if $icons}}

{{$prefix}} {{len $icons}}

{{range $name := $icons}} -
-
{{svg $name 16}}
- {{$name}} + {{end}}
diff --git a/web_src/css/devtest.css b/web_src/css/devtest.css index c344d99058..18424681f9 100644 --- a/web_src/css/devtest.css +++ b/web_src/css/devtest.css @@ -18,3 +18,20 @@ h1, h2 { .fetch-action-demo-forms .form-fetch-action { border: 1px red dashed; /* show the border for demo purpose */ } + +.icon-gallery-search { + width: 300px; +} + +.icon-gallery-card { + width: 120px; +} + +.icon-gallery-preview { + height: 32px; +} + +.icon-gallery-name { + max-width: 108px; + font-size: 10px; +} diff --git a/web_src/js/modules/devtest.ts b/web_src/js/modules/devtest.ts index 7886ff9748..8aa7a9364f 100644 --- a/web_src/js/modules/devtest.ts +++ b/web_src/js/modules/devtest.ts @@ -8,6 +8,25 @@ import {html} from '../utils/html.ts'; type LevelMap = Record Toast | null>; function initDevtestPage() { + const iconSearch = document.querySelector('#icon-search'); + const iconSizeToggle = document.querySelector('#icon-size-toggle'); + if (iconSearch && iconSizeToggle) { + iconSearch.addEventListener('input', () => { + const query = iconSearch.value.toLowerCase(); + for (const card of document.querySelectorAll('.icon-card')) { + card.style.display = card.getAttribute('data-name')!.includes(query) ? '' : 'none'; + } + }); + + iconSizeToggle.addEventListener('change', () => { + const size = iconSizeToggle.checked ? '24' : '16'; + for (const icon of document.querySelectorAll('.icon-card svg')) { + icon.setAttribute('width', size); + icon.setAttribute('height', size); + } + }); + } + const toastButtons = document.querySelectorAll('.toast-test-button'); if (toastButtons.length) { const levelMap: LevelMap = {info: showInfoToast, warning: showWarningToast, error: showErrorToast};