|
| 1 | +<script setup lang="ts"> |
| 2 | +const open = defineModel<boolean>('open', { default: false }) |
| 3 | +const { loggedIn, user, session, fetch, clear, openInPopup } = useUserSession() |
| 4 | +
|
| 5 | +const handleInput = ref('') |
| 6 | +
|
| 7 | +async function handleLogin() { |
| 8 | + navigateTo( |
| 9 | + { |
| 10 | + path: '/api/auth/atproto', |
| 11 | + query: { handle: handleInput.value }, |
| 12 | + }, |
| 13 | + { external: true }, |
| 14 | + ) |
| 15 | +} |
| 16 | +</script> |
| 17 | + |
| 18 | +<template> |
| 19 | + <Teleport to="body"> |
| 20 | + <Transition |
| 21 | + enter-active-class="transition-opacity duration-200" |
| 22 | + leave-active-class="transition-opacity duration-200" |
| 23 | + enter-from-class="opacity-0" |
| 24 | + leave-to-class="opacity-0" |
| 25 | + > |
| 26 | + <div v-if="open" class="fixed inset-0 z-50 flex items-center justify-center p-4"> |
| 27 | + <!-- Backdrop --> |
| 28 | + <button |
| 29 | + type="button" |
| 30 | + class="absolute inset-0 bg-black/60 cursor-default" |
| 31 | + aria-label="Close modal" |
| 32 | + @click="open = false" |
| 33 | + /> |
| 34 | + |
| 35 | + <!-- Modal --> |
| 36 | + <div |
| 37 | + class="relative w-full bg-bg border border-border rounded-lg shadow-xl max-h-[90vh] overflow-y-auto overscroll-contain" |
| 38 | + role="dialog" |
| 39 | + aria-modal="true" |
| 40 | + aria-labelledby="connector-modal-title" |
| 41 | + > |
| 42 | + <div class="p-6"> |
| 43 | + <div class="flex items-center justify-between mb-6"> |
| 44 | + <h2 id="connector-modal-title" class="font-mono text-lg font-medium"> |
| 45 | + Account Settings |
| 46 | + </h2> |
| 47 | + <button |
| 48 | + type="button" |
| 49 | + class="text-fg-subtle hover:text-fg transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50 rounded" |
| 50 | + aria-label="Close" |
| 51 | + @click="open = false" |
| 52 | + > |
| 53 | + <span class="i-carbon-close block w-5 h-5" aria-hidden="true" /> |
| 54 | + </button> |
| 55 | + </div> |
| 56 | + |
| 57 | + <!-- Connected state --> |
| 58 | + <div v-if="loggedIn" class="space-y-4"> |
| 59 | + <div class="flex items-center gap-3 p-4 bg-bg-subtle border border-border rounded-lg"> |
| 60 | + <span class="w-3 h-3 rounded-full bg-green-500" aria-hidden="true" /> |
| 61 | + <div> |
| 62 | + <p v-if="user" class="font-mono text-xs text-fg-muted"> |
| 63 | + Logged in as @{{ user.bluesky }} |
| 64 | + </p> |
| 65 | + </div> |
| 66 | + </div> |
| 67 | + |
| 68 | + <button |
| 69 | + type="button" |
| 70 | + class="w-full px-4 py-2 font-mono text-sm text-fg-muted bg-bg-subtle border border-border rounded-md transition-colors duration-200 hover:text-fg hover:border-border-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50" |
| 71 | + @click="clear" |
| 72 | + > |
| 73 | + Logout |
| 74 | + </button> |
| 75 | + </div> |
| 76 | + |
| 77 | + <!-- Disconnected state --> |
| 78 | + <form v-else class="space-y-4" @submit.prevent="handleLogin"> |
| 79 | + <p class="text-sm text-fg-muted">Login with your Atmosphere handle:</p> |
| 80 | + |
| 81 | + <div class="space-y-3"> |
| 82 | + <div> |
| 83 | + <label |
| 84 | + for="atproto-handle" |
| 85 | + class="block text-xs text-fg-subtle uppercase tracking-wider mb-1.5" |
| 86 | + > |
| 87 | + Handle |
| 88 | + </label> |
| 89 | + <input |
| 90 | + id="atproto-handle" |
| 91 | + v-model="handleInput" |
| 92 | + type="text" |
| 93 | + name="atproto-handle" |
| 94 | + placeholder="alice.bsky.social" |
| 95 | + autocomplete="off" |
| 96 | + spellcheck="false" |
| 97 | + class="w-full px-3 py-2 font-mono text-sm bg-bg-subtle border border-border rounded-md text-fg placeholder:text-fg-subtle transition-colors duration-200 focus:border-border-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50" |
| 98 | + /> |
| 99 | + </div> |
| 100 | + |
| 101 | + <details class="text-sm"> |
| 102 | + <summary |
| 103 | + class="text-fg-subtle cursor-pointer hover:text-fg-muted transition-colors duration-200" |
| 104 | + > |
| 105 | + What is an Atmosphere handle? |
| 106 | + </summary> |
| 107 | + <div class="mt-3">TODO</div> |
| 108 | + </details> |
| 109 | + </div> |
| 110 | + |
| 111 | + <button |
| 112 | + type="submit" |
| 113 | + :disabled="!handleInput.trim()" |
| 114 | + class="w-full px-4 py-2 font-mono text-sm text-bg bg-fg rounded-md transition-all duration-200 hover:bg-fg/90 disabled:opacity-50 disabled:cursor-not-allowed focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50 focus-visible:ring-offset-2 focus-visible:ring-offset-bg" |
| 115 | + > |
| 116 | + Login |
| 117 | + </button> |
| 118 | + </form> |
| 119 | + </div> |
| 120 | + </div> |
| 121 | + </div> |
| 122 | + </Transition> |
| 123 | + </Teleport> |
| 124 | +</template> |
0 commit comments