-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from ostyjs/showcase
Showcase
- Loading branch information
Showing
13 changed files
with
143 additions
and
77 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
templates/react-shadcn/src/features/active-user-widget/index.tsx
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,43 @@ | ||
import { PowerIcon, UserIcon } from 'lucide-react'; | ||
import { useActiveUser, useLogin, useRealtimeProfile } from 'nostr-hooks'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import { Avatar, AvatarFallback, AvatarImage } from '@/shared/components/ui/avatar'; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuSeparator, | ||
DropdownMenuTrigger, | ||
} from '@/shared/components/ui/dropdown-menu'; | ||
|
||
export const ActiveUserWidget = () => { | ||
const { activeUser } = useActiveUser(); | ||
const { profile } = useRealtimeProfile(activeUser?.pubkey); | ||
const { logout } = useLogin(); | ||
|
||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger> | ||
<Avatar> | ||
<AvatarImage src={profile?.image} alt={profile?.name} /> | ||
<AvatarFallback className="bg-muted" /> | ||
</Avatar> | ||
</DropdownMenuTrigger> | ||
|
||
<DropdownMenuContent align="end" sideOffset={8}> | ||
<DropdownMenuItem onClick={() => navigate(`/profile/${activeUser?.npub}`)}> | ||
<UserIcon className="w-4 h-4 mr-2" /> | ||
Profile | ||
</DropdownMenuItem> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuItem onClick={logout}> | ||
<PowerIcon className="w-4 h-4 mr-2" /> | ||
Logout | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
}; |
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
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
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 |
---|---|---|
@@ -1,64 +1,20 @@ | ||
import { GitHubLogoIcon } from '@radix-ui/react-icons'; | ||
import { useActiveUser, useNdk } from 'nostr-hooks'; | ||
import { useActiveUser } from 'nostr-hooks'; | ||
|
||
import { ModeToggle } from '@/shared/components/mode-toggle'; | ||
import { Button } from '@/shared/components/ui/button'; | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardFooter, | ||
CardHeader, | ||
CardTitle, | ||
} from '@/shared/components/ui/card'; | ||
import { Separator } from '@/shared/components/ui/separator'; | ||
|
||
import { LoginWidget } from '@/features/login-widget'; | ||
import { LogoutWidget } from '@/features/logout-widget'; | ||
import { ZapWidget } from '@/features/zap-widget'; | ||
import { NotesFeedWidget } from '@/features/notes-feed-widget'; | ||
|
||
export const HomePage = () => { | ||
const { ndk } = useNdk(); | ||
const { activeUser } = useActiveUser(); | ||
|
||
const zapTarget = ndk?.getUser({ | ||
pubkey: '3e294d2fd339bb16a5403a86e3664947dd408c4d87a0066524f8a573ae53ca8e', // Sep | ||
}); | ||
|
||
return ( | ||
<> | ||
<div className="flex flex-col items-center justify-center w-full h-full"> | ||
<Card> | ||
<CardHeader> | ||
<CardTitle>Osty</CardTitle> | ||
<CardDescription>Start building on Nostr in seconds with Osty</CardDescription> | ||
</CardHeader> | ||
|
||
<Separator /> | ||
|
||
<CardContent className="mt-6 flex gap-4"> | ||
{zapTarget && <ZapWidget target={zapTarget} />} | ||
|
||
{activeUser ? <LogoutWidget /> : <LoginWidget />} | ||
</CardContent> | ||
|
||
<Separator /> | ||
|
||
<CardFooter className="mt-6 flex items-center gap-2"> | ||
<p className="text-xs text-gray-500"> | ||
Made with <span className="text-red-500">💜</span> by Sepehr | ||
</p> | ||
|
||
<Button variant="outline" size="icon" asChild className="ml-auto"> | ||
<a href="https://github.com/ostyjs/create-osty" target="_blank" rel="noreferrer"> | ||
<GitHubLogoIcon /> | ||
</a> | ||
</Button> | ||
|
||
<ModeToggle /> | ||
</CardFooter> | ||
</Card> | ||
</div> | ||
{activeUser ? ( | ||
<NotesFeedWidget /> | ||
) : ( | ||
<div className="flex flex-col h-full w-full items-center justify-center"> | ||
<h3>Welcome to Osty!</h3> | ||
<p>Log-in to view and create notes</p> | ||
</div> | ||
)} | ||
</> | ||
); | ||
}; |
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