Skip to content

Commit 45d8c1e

Browse files
author
Mirko Brombin
authored
Merge pull request #73 from GabsEdits/appstore/random-placeholder-search
feat: random app name at the placeholder
2 parents 75c5517 + bb71461 commit 45d8c1e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/pages/appstore.astro

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Icon } from 'astro-icon/components';
1414
</div>
1515
<div class="flex justify-center mb-8">
1616
<div class="relative w-full max-w-md">
17-
<input type="search" id="storeSearch" autocomplete="off" placeholder="Epic Games Store" class="w-full py-2 pl-10 pr-4 border rounded-lg shadow-sm focus:ring focus:outline-none dark:bg-gray-800 dark:text-gray-200 dark:placeholder-gray-400 dark:border-gray-700" />
17+
<input type="search" id="storeSearch" autocomplete="off" placeholder="" class="w-full py-2 pl-10 pr-4 border rounded-lg shadow-sm focus:ring focus:outline-none dark:bg-gray-800 dark:text-gray-200 dark:placeholder-gray-400 dark:border-gray-700" />
1818
<Icon name="material-symbols:search" class="absolute top-2 left-2 w-6 h-6 text-gray-400 dark:text-gray-300" />
1919
</div>
2020
</div>
@@ -73,7 +73,7 @@ class AppStore {
7373

7474
initSearch(): void {
7575
if (this.searchInput) {
76-
this.searchInput.addEventListener('keyup', (e) => {
76+
this.searchInput.addEventListener('keyup', () => {
7777
const search = this.searchInput?.value.toLowerCase() || '';
7878
const cards = document.querySelectorAll('#storeResults .card');
7979
cards.forEach((card) => {
@@ -120,6 +120,12 @@ class AppStore {
120120
const installers: { [key: string]: Installer } = jsyaml.load(data) as { [key: string]: Installer };
121121

122122
if (typeof installers === 'object' && this.storeResults) {
123+
const installerNames = Object.keys(installers);
124+
const randomInstallerName = installerNames[Math.floor(Math.random() * installerNames.length)];
125+
if (this.searchInput) {
126+
this.searchInput.placeholder = installers[randomInstallerName].Name;
127+
}
128+
123129
for (const item in installers) {
124130
const installer = installers[item];
125131
const icon = `https://github.com/bottlesdevs/programs/blob/main/data/${item}/${installer.Icon}?raw=true`;

0 commit comments

Comments
 (0)