mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
refactor: hold the search hint in one attribute
Two empty kbd elements with a data-key each added 24 bytes to every page and put RomM over its weight budget in test_site_platform_density. The hint is one data-key on the outer kbd, 50 bytes lighter than the text it replaced.
This commit is contained in:
1 parent
9760c2fadd
commit
b2ec1969e0
2 files changed
+8
-7
No files matched your search
@@ -1019,7 +1019,7 @@ class SearchButtonShowsOnlyItsName(unittest.TestCase):
|
||||
text = re.sub(r"<[^>]*>", "", button[button.index(">", button.index("aria-keyshortcuts")) + 1:])
|
||||
self.assertEqual(text.split(), ["{Astro.locals.t('search.label')}"])
|
||||
self.assertIn("kbd[data-key]::before", search)
|
||||
self.assertIn("platformKey.dataset.key = '⌘';", search)
|
||||
self.assertIn("shortcut.dataset.key = '⌘ K';", search)
|
||||
|
||||
|
||||
class LogosAtTheirWeight(unittest.TestCase):
|
||||
|
||||
@@ -32,9 +32,11 @@ if (project.trailingSlash === 'never') dataAttributes['data-strip-trailing-slash
|
||||
>
|
||||
<Icon name="magnifier" />
|
||||
<span class="sl-hidden md:sl-block" aria-hidden="true">{Astro.locals.t('search.label')}</span>
|
||||
<kbd class="sl-hidden md:sl-flex" style="display: none;">
|
||||
<kbd data-key={Astro.locals.t('search.ctrlKey')}></kbd><kbd data-key="K"></kbd>
|
||||
</kbd>
|
||||
<kbd
|
||||
class="sl-hidden md:sl-flex"
|
||||
style="display: none;"
|
||||
data-key={`${Astro.locals.t('search.ctrlKey')} K`}
|
||||
></kbd>
|
||||
</button>
|
||||
|
||||
<dialog style="padding:0" aria-label={Astro.locals.t('search.label')}>
|
||||
@@ -69,9 +71,8 @@ if (project.trailingSlash === 'never') dataAttributes['data-strip-trailing-slash
|
||||
const openBtn = document.querySelector('button[data-open-modal]');
|
||||
const shortcut = openBtn?.querySelector('kbd');
|
||||
if (!openBtn || !(shortcut instanceof HTMLElement)) return;
|
||||
const platformKey = shortcut.querySelector('kbd');
|
||||
if (platformKey && /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)) {
|
||||
platformKey.dataset.key = '⌘';
|
||||
if (/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)) {
|
||||
shortcut.dataset.key = '⌘ K';
|
||||
openBtn.setAttribute('aria-keyshortcuts', 'Meta+K');
|
||||
}
|
||||
shortcut.style.display = '';
|
||||
|
||||
Reference in new issue
Block a user