-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add help modal and fix saved snippet state bug
- Loading branch information
1 parent
0209fec
commit f1e2532
Showing
4 changed files
with
144 additions
and
92 deletions.
There are no files selected for viewing
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,113 +1,158 @@ | ||
import { A } from '@solidjs/router' | ||
import { Button } from './ui/button' | ||
import { OcMarkgithub2 } from 'solid-icons/oc' | ||
import { OcMarkgithub2, OcQuestion2 } from 'solid-icons/oc' | ||
import { FaSolidSun, FaSolidMoon } from 'solid-icons/fa' | ||
import { createThemeSwitcher } from '~/components/theme-switcher' | ||
import { authToken } from '~/lib/store' | ||
import { Show } from 'solid-js' | ||
import { createSignal, Show } from 'solid-js' | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuTrigger, | ||
} from '~/components/ui/dropdown-menu' | ||
import { user } from '~/lib/store' | ||
import { TbCode, TbDoorExit } from 'solid-icons/tb' | ||
import { TbCode, TbDoorExit, TbQuestionMark } from 'solid-icons/tb' | ||
import { linkStyles } from '~/lib/styles' | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogDescription, | ||
DialogFooter, | ||
DialogHeader, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from '~/components/ui/dialog' | ||
import { makePersisted } from '@solid-primitives/storage' | ||
|
||
export default function Header() { | ||
const [isShowingHelpDialog, setIsShowingHelpDialog] = makePersisted(createSignal(true), { | ||
name: 'isShowingHelpDialog', | ||
}) | ||
const [isDarkMode, toggleDarkMode] = createThemeSwitcher() | ||
|
||
const handleToggle = () => { | ||
toggleDarkMode() // Call without arguments | ||
} | ||
|
||
return ( | ||
<header class="flex flex-col"> | ||
<nav class="flex flex-row gap-2 justify-between p-4"> | ||
<div class="flex flex-row items-center gap-8"> | ||
<div class="flex flex-col items-center justify-center"> | ||
<a href="/"> | ||
<h1 class="text-3xl font-title text-sky-500">Giffium</h1> | ||
</a> | ||
<p class="text-left mt-[-10px]"> | ||
by{' '} | ||
<a href="https://cmgriffing.com" rel="dofollow" target="_blank" class={linkStyles}> | ||
cmgriffing | ||
<> | ||
<header class="flex flex-col"> | ||
<nav class="flex flex-row gap-2 justify-between p-4"> | ||
<div class="flex flex-row items-center gap-8"> | ||
<div class="flex flex-col items-center justify-center"> | ||
<a href="/"> | ||
<h1 class="text-3xl font-title text-sky-500">Giffium</h1> | ||
</a> | ||
</p> | ||
</div> | ||
<p class="text-left mt-[-10px]"> | ||
by{' '} | ||
<a href="https://cmgriffing.com" rel="dofollow" target="_blank" class={linkStyles}> | ||
cmgriffing | ||
</a> | ||
</p> | ||
</div> | ||
|
||
<ul class="flex flex-row gap-4"> | ||
<li class=""> | ||
<A href="/about" class={linkStyles}> | ||
About | ||
</A> | ||
</li> | ||
<li class=""> | ||
<a | ||
href="https://github.com/cmgriffing/giffium" | ||
target="_blank" | ||
rel="noreferrer" | ||
class={linkStyles} | ||
> | ||
Source | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
<div class="flex flex-row items-center gap-2"> | ||
<button | ||
onClick={handleToggle} | ||
class="flex items-center justify-center cursor-pointer w-10 h-10 bg-neutral-100 hover:bg-neutral-200 dark:bg-neutral-600 dark:hover:bg-neutral-600/80 rounded transition" | ||
aria-label="Toggle dark mode" | ||
> | ||
{isDarkMode() ? ( | ||
<FaSolidMoon class="w-4 h-4 text-neutral-200" /> | ||
) : ( | ||
<FaSolidSun class="w-4 h-4 text-neutral-500" /> | ||
)} | ||
</button> | ||
<Show when={!authToken()}> | ||
<ul class="flex flex-row gap-4"> | ||
<li class=""> | ||
<A href="/about" class={linkStyles}> | ||
About | ||
</A> | ||
</li> | ||
<li class=""> | ||
<a | ||
href="https://github.com/cmgriffing/giffium" | ||
target="_blank" | ||
rel="noreferrer" | ||
class={linkStyles} | ||
> | ||
Source | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
<div class="flex flex-row items-center gap-2"> | ||
<Button | ||
as="a" | ||
href={`https://github.com/login/oauth/authorize?client_id=${ | ||
import.meta.env.VITE_GITHUB_CLIENT_ID | ||
}&redirect_uri=${window.location.origin}/oauth`} | ||
variant={'ghost'} | ||
class="flex flex-row items-center px-2" | ||
onClick={() => setIsShowingHelpDialog(true)} | ||
> | ||
<OcMarkgithub2 size={24} class="mr-4" /> | ||
Login/Signup | ||
<OcQuestion2 size={24} /> | ||
</Button> | ||
</Show> | ||
<Show when={Boolean(authToken())}> | ||
<DropdownMenu> | ||
<DropdownMenuTrigger> | ||
<Button class="flex flex-row items-center gap-2"> | ||
<img | ||
src={user()?.githubAvatarUrl} | ||
alt={user()?.githubUsername} | ||
class="w-6 h-6 rounded-full" | ||
/> | ||
{user()?.githubUsername} | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuItem> | ||
<A href="/snippets" class="flex flex-row items-center gap-2"> | ||
<TbCode /> Snippets | ||
</A> | ||
</DropdownMenuItem> | ||
<DropdownMenuItem> | ||
<A href="/logged-out" class="flex flex-row items-center gap-2"> | ||
<TbDoorExit /> | ||
Log out | ||
</A> | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
</Show> | ||
</div> | ||
</nav> | ||
</header> | ||
<Button | ||
variant={'ghost'} | ||
class="flex flex-row items-center px-2" | ||
onClick={handleToggle} | ||
aria-label="Toggle dark mode" | ||
> | ||
{isDarkMode() ? ( | ||
<FaSolidMoon size={24} class="text-white" /> | ||
) : ( | ||
<FaSolidSun size={24} class="text-black" /> | ||
)} | ||
</Button> | ||
<Show when={!authToken()}> | ||
<Button | ||
as="a" | ||
class="ml-4" | ||
href={`https://github.com/login/oauth/authorize?client_id=${ | ||
import.meta.env.VITE_GITHUB_CLIENT_ID | ||
}&redirect_uri=${window.location.origin}/oauth`} | ||
> | ||
<OcMarkgithub2 size={24} class="mr-4" /> | ||
Login/Signup | ||
</Button> | ||
</Show> | ||
<Show when={Boolean(authToken())}> | ||
<DropdownMenu> | ||
<DropdownMenuTrigger> | ||
<Button class="flex flex-row items-center gap-2 ml-4"> | ||
<img | ||
src={user()?.githubAvatarUrl} | ||
alt={user()?.githubUsername} | ||
class="w-6 h-6 rounded-full" | ||
/> | ||
{user()?.githubUsername} | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuItem> | ||
<A href="/snippets" class="flex flex-row items-center gap-2"> | ||
<TbCode /> Snippets | ||
</A> | ||
</DropdownMenuItem> | ||
<DropdownMenuItem> | ||
<A href="/logged-out" class="flex flex-row items-center gap-2"> | ||
<TbDoorExit /> | ||
Log out | ||
</A> | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
</Show> | ||
</div> | ||
</nav> | ||
</header> | ||
<Dialog open={isShowingHelpDialog()} onOpenChange={setIsShowingHelpDialog} modal> | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle>Welcome to Giffium</DialogTitle> | ||
<DialogDescription> | ||
<p class="mb-8 text-center font-bold text-lg text-white"> | ||
Create and share beautiful gifs of your source code diffs. | ||
</p> | ||
<p class="text-white">Get started by following these steps.</p> | ||
<ol class="list-disc list-inside pl-8 text-white"> | ||
<li>Enter your start and end code snippets.</li> | ||
<li>Select the theme and language.</li> | ||
<li>Click the Next button to preview your snippet animation.</li> | ||
<li>Click the Generate button to generate a gif.</li> | ||
</ol> | ||
|
||
<p class="text-white mt-8">You can also log in with GitHub to save your snippets.</p> | ||
</DialogDescription> | ||
</DialogHeader> | ||
</DialogContent> | ||
</Dialog> | ||
</> | ||
) | ||
} |
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