mirror of
https://github.com/ShayManor/github-readme-stats.git
synced 2026-12-02 11:53:48 +05:30
feat(frontend): AuthButton — GitHub sign-in / avatar chip
This commit is contained in:
@@ -3,6 +3,7 @@ import './index.css'
|
||||
import { SearchScreen } from './screens/SearchScreen'
|
||||
import { WorkshopScreen } from './screens/WorkshopScreen'
|
||||
import { ResultScreen } from './screens/ResultScreen'
|
||||
import { AuthButton } from './components/AuthButton'
|
||||
import type { WidgetData } from './lib/renderWidgets'
|
||||
import { DEMO_WIDGET_DATA } from './lib/demoData'
|
||||
import { fetchMe, type Me } from './lib/auth'
|
||||
@@ -200,6 +201,9 @@ export default function App() {
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50">
|
||||
<div className="header-bar">
|
||||
<AuthButton me={me} onChange={setMe} />
|
||||
</div>
|
||||
{step === 'search' && (
|
||||
<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>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user