-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6030099
commit f1ee8cb
Showing
7 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,8 @@ | |
"jsx-quotes": [ | ||
"error", | ||
"prefer-double" | ||
] | ||
], | ||
"unicorn/prevent-abbreviations": "off" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
import {Icon} from 'astro-iconify'; | ||
export type OverflowItemProps = { | ||
title: string; | ||
url: string; | ||
}; | ||
export type OverflowMenuProps = { | ||
overflowItems?: readonly OverflowItemProps[]; | ||
}; | ||
const {overflowItems} = Astro.props; | ||
--- | ||
|
||
<div class="relative flex items-center" style="padding-top:2px"> | ||
<select class="overflow-menu-component absolute inset-0 w-full h-full opacity-0 cursor-pointer" style="font-weight: initial; font-family: system-ui;"> | ||
<option value="" disabled selected>…</option> | ||
{overflowItems?.map(item => ( | ||
<option value={item.url}>{item.title}</option> | ||
))} | ||
<slot /> | ||
</select> | ||
<Icon name="tabler:dots-circle-horizontal" class="w-5 h-5 text-primary-600 dark:text-primary-400 pointer-events-none"/> | ||
</div> | ||
|
||
<script is:inline> | ||
document.addEventListener('change', event => { | ||
if (event.target?.matches('.overflow-menu-component')) { | ||
const selectedValue = event.target.value; | ||
if (selectedValue) { | ||
event.target.value = ''; // Clear selection | ||
window.location.href = selectedValue; | ||
} | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
import Layout from '~/layouts/SimplePageLayout.astro'; | ||
import {fetchApps} from '~/utils/apps.js'; | ||
const apps = await fetchApps(); | ||
const appSlugs = apps | ||
.filter(app => !app.unlisted) | ||
.map(app => app.slug); | ||
--- | ||
|
||
<Layout> | ||
<script type="module" define:vars={{appSlugs}}> | ||
const randomItem = items => items[Math.floor(Math.random() * items.length)]; | ||
window.location.href = `/${randomItem(appSlugs)}?from-random`; | ||
</script> | ||
<div class="flex items-center justify-center min-h-[50vh] text-center"> | ||
<noscript> | ||
<p class="text-center">JavaScript is required show a random app. You can always browse the <a href="/apps">app list</a> manually.</p> | ||
</noscript> | ||
</div> | ||
</Layout> |