Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactor login buttons to use dropdown #14

Merged
merged 4 commits into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 61 additions & 72 deletions playground/app.vue
Original file line number Diff line number Diff line change
@@ -1,80 +1,69 @@
<script setup>
const { loggedIn, session, clear } = useUserSession()
<script setup lang="ts">
const { loggedIn, user, session, clear } = useUserSession()

const providers = computed(() => [
{
label: session.value.user?.github?.login || 'GitHub',
to: '/auth/github',
disabled: Boolean(user.value?.github),
icon: 'i-simple-icons-github',
},
{
label: session.value.user?.spotify?.display_name || 'Spotify',
to: '/auth/spotify',
disabled: Boolean(user.value?.spotify),
icon: 'i-simple-icons-spotify',
},
{
label: session.value.user?.google?.email || 'Google',
to: '/auth/google',
disabled: Boolean(user.value?.google),
icon: 'i-simple-icons-google',
},
{
label: session.value.user?.twitch?.login || 'Twitch',
to: '/auth/twitch',
disabled: Boolean(user.value?.twitch),
icon: 'i-simple-icons-twitch',
},
{
label: user.value?.auth0?.email || 'Auth0',
to: '/auth/auth0',
disabled: Boolean(user.value?.auth0),
icon: 'i-simple-icons-auth0',
},
{
label: user.value?.discord?.username || 'Discord',
to: '/auth/discord',
disabled: Boolean(user.value?.discord),
icon: 'i-simple-icons-discord',
},
{
label: user.value?.battledotnet?.battletag || 'Battle.net',
to: '/auth/battledotnet',
disabled: Boolean(user.value?.battledotnet),
icon: 'i-simple-icons-battledotnet',
},
].map(p => ({
...p,
prefetch: false,
external: true,
})))
</script>

<template>
<UHeader>
<template #right>
<UButton
v-if="!loggedIn || !session.user.github"
to="/auth/github"
icon="i-simple-icons-github"
external
color="gray"
size="xs"
>
Login with GitHub
</UButton>
<UButton
v-if="!loggedIn || !session.user.spotify"
to="/auth/spotify"
icon="i-simple-icons-spotify"
external
color="gray"
size="xs"
>
Login with Spotify
</UButton>
<UButton
v-if="!loggedIn || !session.user.google"
to="/auth/google"
icon="i-simple-icons-google"
external
color="gray"
size="xs"
>
Login with Google
</UButton>
<UButton
v-if="!loggedIn || !session.user.twitch"
to="/auth/twitch"
icon="i-simple-icons-twitch"
external
color="gray"
size="xs"
>
Login with Twitch
</UButton>
<UButton
v-if="!loggedIn || !session.user.auth0"
to="/auth/auth0"
icon="i-simple-icons-auth0"
external
color="gray"
size="xs"
>
Login with Auth0
</UButton>
<UButton
v-if="!loggedIn || !session.user.discord"
to="/auth/discord"
icon="i-simple-icons-discord"
external
color="gray"
size="xs"
>
Login with Discord
</UButton>
<UButton
v-if="!loggedIn || !session.user.auth0"
to="/auth/battledotnet"
icon="i-simple-icons-battledotnet"
external
color="gray"
size="xs"
>
Login with Battle.net
</UButton>
<UDropdown :items="[providers]">
<UButton
icon="i-heroicons-chevron-down"
trailing
color="gray"
size="xs"
>
Login with
</UButton>
</UDropdown>
<UButton
v-if="loggedIn"
color="gray"
Expand Down