-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: react router breadcrumbs (#777)
Signed-off-by: hxtree <[email protected]>
- Loading branch information
Showing
99 changed files
with
520 additions
and
358 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { FC } from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { useBreadcrumbs } from "./useBreadcrumbs"; | ||
|
||
type TBreadCrumbs = { | ||
title?: string; | ||
}; | ||
|
||
export const BreadCrumbs: FC<TBreadCrumbs> = ({ title }) => { | ||
const crumbs = useBreadcrumbs(); | ||
|
||
const lastCrumb = crumbs[crumbs.length - 1]; | ||
if(lastCrumb.url === "/"){ | ||
return; | ||
} | ||
|
||
return ( | ||
<nav className="container mt-2 mb-2" aria-label="breadcrumb"> | ||
<ol className="breadcrumb"> | ||
{crumbs.map((crumb, index) => | ||
index !== crumbs.length - 1 ? ( | ||
<li className="breadcrumb-item active" aria-current="page" key={index}> | ||
<Link to={crumb.url}> | ||
{crumb.title} | ||
</Link> | ||
</li> | ||
) : ( | ||
<li className="breadcrumb-item active" aria-current="page" key={index}> | ||
<span > | ||
{title ? title : crumb.title} | ||
</span> | ||
</li> | ||
) | ||
)} | ||
</ol> | ||
</nav> | ||
); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useMatches } from "react-router-dom"; | ||
|
||
type TCrumb = { | ||
url: string; | ||
title: string; | ||
}; | ||
|
||
const isCrumb = (obj: unknown): obj is TCrumb => { | ||
if (typeof obj === "object" && obj !== null) { | ||
return "url" in obj && "title" in obj; | ||
} | ||
return false; | ||
}; | ||
|
||
export const useBreadcrumbs = () => { | ||
const matches = useMatches(); | ||
|
||
let crumbs: TCrumb[] = []; | ||
|
||
if (matches) { | ||
matches.map((match) => { | ||
if (isCrumb(match.handle)) { | ||
crumbs = [...crumbs, match.handle] | ||
} | ||
}); | ||
} | ||
|
||
return crumbs; | ||
}; |
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,7 +1,18 @@ | ||
import { Button, Link } from '@cats-cradle/design-system/dist/main'; | ||
|
||
export default function HomePage() { | ||
return ( | ||
<main className="container"> | ||
<h1>Game Master Portal</h1> | ||
<h1>Cats Cradle</h1> | ||
<h2>Latest</h2> | ||
<h3>Archetypes</h3> | ||
<p> | ||
Attention, game masters! Introducing our latest tool designed exclusively for you. | ||
Dive into the world of character archetypes with ease. | ||
Uncover diverse options, check out base stats, and seamlessly explore backstories—all in one place. | ||
No-frills, just a straightforward way to look at the data. Raise a <Link href='https://github.com/hxtree/cats-cradle/pulls'>pull request</Link> to suggest changes. | ||
</p> | ||
<Button href="/archetypes" color="secondary">Try It!</Button> | ||
</main> | ||
); | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion
1
...ponents/SocialMediaBar/SocialMediaBar.tsx → ...ponents/SocialMediaBar/SocialMediaBar.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
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...system/src/components/Spinner/Spinner.tsx → ...system/src/components/Spinner/Spinner.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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.