Skip to content

Commit

Permalink
Move back to signals-based implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-collinsworth committed Apr 18, 2024
1 parent 189ab6d commit 7935dfd
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
13 changes: 12 additions & 1 deletion frontend/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import { FullUser } from "../utils/api_types.ts";
import { GlobalSearch } from "../islands/GlobalSearch.tsx";
import { UserMenu } from "../islands/UserMenu.tsx";
import { Logo } from "./Logo.tsx";
import { GitHub } from "./icons/GitHub.tsx";
import { SearchKind } from "../util.ts";
import { HeaderLogo } from "../islands/HeaderLogo.tsx";

export function Header({
user,
Expand Down Expand Up @@ -61,6 +61,17 @@ export function Header({
<Logo size="medium" class="flex-none hover:animate-flip-rotate" />
</a>
)}
<div>
{!isHomepage && (
<a
href="/"
class="outline-none focus-visible:ring-2 ring-cyan-700"
>
<span className="sr-only">JSR home</span>
<HeaderLogo class="h-8 flex-none" />
</a>
)}
</div>
<div class="hidden sm:block grow-1 flex-1">
{!isHomepage && (
<GlobalSearch
Expand Down
2 changes: 2 additions & 0 deletions frontend/fresh.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import * as $DevelopmentLogin from "./islands/DevelopmentLogin.tsx";
import * as $GitHubActionsLink from "./islands/GitHubActionsLink.tsx";
import * as $GithubUserLink from "./islands/GithubUserLink.tsx";
import * as $GlobalSearch from "./islands/GlobalSearch.tsx";
import * as $HeaderLogo from "./islands/HeaderLogo.tsx";
import * as $HomepageHeroParticles from "./islands/HomepageHeroParticles.tsx";
import * as $PublishingTaskRequeue from "./islands/PublishingTaskRequeue.tsx";
import * as $UserManageScopeInvite from "./islands/UserManageScopeInvite.tsx";
Expand Down Expand Up @@ -122,6 +123,7 @@ const manifest = {
"./islands/GitHubActionsLink.tsx": $GitHubActionsLink,
"./islands/GithubUserLink.tsx": $GithubUserLink,
"./islands/GlobalSearch.tsx": $GlobalSearch,
"./islands/HeaderLogo.tsx": $HeaderLogo,
"./islands/HomepageHeroParticles.tsx": $HomepageHeroParticles,
"./islands/PublishingTaskRequeue.tsx": $PublishingTaskRequeue,
"./islands/UserManageScopeInvite.tsx": $UserManageScopeInvite,
Expand Down
38 changes: 38 additions & 0 deletions frontend/islands/HeaderLogo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2024 the JSR authors. All rights reserved. MIT license.
import { signal } from "@preact/signals";

const rotationDegrees = signal(0);
const isAnimating = signal(false);

export function HeaderLogo(props: { class?: string }) {
return (
<div
onMouseEnter={() => {
if (isAnimating.value) return;
isAnimating.value = true;
rotationDegrees.value += 180;
}}
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 638 343"
fill="none"
class={`transition-transform duration-300 ${props.class}`}
style={`transform: rotate(${rotationDegrees.value}deg)`}
aria-hidden="true"
onTransitionEnd={() => isAnimating.value = false}
>
<g fill-rule="evenodd">
<path
fill="#083344"
d="M637.272 49v196h-98v98h-343v-49h-196V98h98V0h343v49h196Z"
/>
<path
fill="#F7DF1E"
d="M100.101 196h47.171V49h49v196H51.102v-98H100.1v49ZM588.272 98v98h-49v-49h-49v147h-49V98h147ZM294.272 98v49h98v147h-147v-49h98v-49h-98V49h147v49h-98Z"
/>
</g>
</svg>
</div>
);
}

0 comments on commit 7935dfd

Please sign in to comment.