Skip to content

Commit

Permalink
adds anchor reusable component
Browse files Browse the repository at this point in the history
  • Loading branch information
wmalarski committed Oct 29, 2023
1 parent 7a9f579 commit 8c05798
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/components/anon-navbar/index.marko
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { buildPath } from "../../utils/paths";
<app-navbar>
<@start>
<a href=buildPath({ path: "/" })>
<app-anchor variant="ghost" size="lg" href=buildPath({ path: "/" })>
Home
</a>
</app-anchor>
</@start>
<@end>
<a href=buildPath({ path: "/sign-in" })>
<app-anchor variant="ghost" href=buildPath({ path: "/sign-in" })>
Sign In
</a>
<a href=buildPath({ path: "/sign-up" })>
</app-anchor>
<app-anchor variant="ghost" href=buildPath({ path: "/sign-up" })>
Sign Up
</a>
</app-anchor>
</@end>
</app-navbar>
25 changes: 25 additions & 0 deletions src/components/app-anchor/index.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { buttonClass, type ButtonClassProps } from "../app-button/recipes";
export type Input = Marko.Input<"a"> & ButtonClassProps;

<const/{
color,
isLoading,
shape,
size,
variant,
class: className,
...rest
}=input/>

<const/recipeResult=buttonClass({
className,
color,
isLoading,
shape,
size,
variant,
})/>

<a ...rest class=recipeResult>
<${input.renderBody}/>
</a>
1 change: 1 addition & 0 deletions src/routes/todos/(active,finished,)/+page.marko
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<protected-navbar />
<main class="flex flex-col gap-8 max-w-md justify-center w-full mx-auto">
<pre>
${" "}${JSON.stringify(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
import { buildPath } from "../../../../utils/paths";
<app-navbar>
<@start>
<a href=buildPath({ path: "/" })>
<app-anchor variant="ghost" size="lg" href=buildPath({ path: "/" })>
Home
</a>
</app-anchor>
</@start>

<@center>
<app-anchor variant="ghost" href=buildPath({ path: "/todos" })>
All
</app-anchor>
<app-anchor variant="ghost" href=buildPath({ path: "/todos/active" })>
Active
</app-anchor>
<app-anchor variant="ghost" href=buildPath({ path: "/todos/finished" })>
Finished
</app-anchor>
</@center>

<@end>
<a href=buildPath({ path: "/api/auth/sign-out" })>
<app-anchor variant="ghost" href=buildPath({ path: "/api/auth/sign-out" })>
Sign Out
</a>
</app-anchor>
</@end>
</app-navbar>

0 comments on commit 8c05798

Please sign in to comment.