feat(frontend): AuthButton — GitHub sign-in / avatar chip

This commit is contained in:
shay
2026-04-19 19:14:06 -04:00
parent 8ccc0af1cf
commit cd927e686f
2 changed files with 25 additions and 0 deletions
+4
View File
@@ -3,6 +3,7 @@ import './index.css'
import { SearchScreen } from './screens/SearchScreen' import { SearchScreen } from './screens/SearchScreen'
import { WorkshopScreen } from './screens/WorkshopScreen' import { WorkshopScreen } from './screens/WorkshopScreen'
import { ResultScreen } from './screens/ResultScreen' import { ResultScreen } from './screens/ResultScreen'
import { AuthButton } from './components/AuthButton'
import type { WidgetData } from './lib/renderWidgets' import type { WidgetData } from './lib/renderWidgets'
import { DEMO_WIDGET_DATA } from './lib/demoData' import { DEMO_WIDGET_DATA } from './lib/demoData'
import { fetchMe, type Me } from './lib/auth' import { fetchMe, type Me } from './lib/auth'
@@ -200,6 +201,9 @@ export default function App() {
return ( return (
<div className="min-h-screen bg-gray-50"> <div className="min-h-screen bg-gray-50">
<div className="header-bar">
<AuthButton me={me} onChange={setMe} />
</div>
{step === 'search' && ( {step === 'search' && (
<SearchScreen onSearch={handleSearch} /> <SearchScreen onSearch={handleSearch} />
)} )}
@@ -0,0 +1,21 @@
import type { Me } from '../lib/auth'
import { signInUrl, signOut } from '../lib/auth'
export function AuthButton({ me, onChange }: { me: Me; onChange: (m: Me) => void }) {
if (!me.login) {
return (
<a className="auth-btn" href={signInUrl()}>
Sign in with GitHub
</a>
)
}
return (
<div className="auth-chip">
{me.avatar_url && <img src={me.avatar_url} alt="" className="auth-avatar" />}
<span>{me.login}</span>
<button onClick={async () => { await signOut(); onChange({ login: null }) }}>
Sign out
</button>
</div>
)
}