-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds breadcrumbs to global navigation
- Loading branch information
1 parent
9006ea5
commit 2c84c07
Showing
8 changed files
with
148 additions
and
21 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,63 @@ | ||
<script lang="ts"> | ||
import { TriangleRight16 } from "svelte-octicons"; | ||
import Logo from "./Logo.svelte"; | ||
import Flex from "./Flex.svelte"; | ||
interface Breadcrumb { | ||
title: string; | ||
href?: string; | ||
} | ||
export let trail: Breadcrumb[] = []; | ||
</script> | ||
|
||
<div class="breadcrumbs"> | ||
<Flex gap={0.375} align="center"> | ||
<slot name="root"> | ||
<a href="/" class="logo crumb"><Logo /></a> | ||
</slot> | ||
{#each trail as { href, title }} | ||
<TriangleRight16 fill="var(--gray-3)" /> | ||
{#if href} | ||
<a class="crumb" {href} {title}>{title}</a> | ||
{:else} | ||
<span {title} class="crumb">{title}</span> | ||
{/if} | ||
{/each} | ||
</Flex> | ||
</div> | ||
|
||
<style> | ||
.breadcrumbs { | ||
flex: 1 0 0; | ||
max-width: 100%; | ||
} | ||
.crumb { | ||
flex: 0 1 auto; | ||
font-size: var(--font-l); | ||
text-decoration: none; | ||
color: var(--gray-4); | ||
padding: 0.25rem 0.5rem; | ||
border-radius: 0.5rem; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} | ||
.crumb:last-child { | ||
color: inherit; | ||
flex: 0 0 auto; | ||
} | ||
a.crumb:hover { | ||
background: var(--gray-1); | ||
} | ||
.logo { | ||
flex: 0 0 auto; | ||
height: 1.5rem; | ||
width: auto; | ||
box-sizing: content-box; | ||
} | ||
</style> |
64 changes: 64 additions & 0 deletions
64
src/lib/components/common/stories/Breadcrumbs.stories.svelte
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,64 @@ | ||
<script context="module" lang="ts"> | ||
import { Story } from "@storybook/addon-svelte-csf"; | ||
import Breadcrumbs from "../Breadcrumbs.svelte"; | ||
export const meta = { | ||
title: "Components / Common / Breadcrumbs", | ||
component: Breadcrumbs, | ||
parameters: { layout: "centered" }, | ||
}; | ||
</script> | ||
|
||
<Story name="Root"> | ||
<Breadcrumbs /> | ||
</Story> | ||
|
||
<Story name="One Crumb"> | ||
<Breadcrumbs trail={[{ href: "/documents", title: "Documents" }]} /> | ||
</Story> | ||
|
||
<Story name="Two Crumbs"> | ||
<Breadcrumbs | ||
trail={[ | ||
{ href: "/documents", title: "Documents" }, | ||
{ href: "/documents/[id]", title: "The Santa Anas" }, | ||
]} | ||
/> | ||
</Story> | ||
|
||
<Story name="Three Crumbs"> | ||
<Breadcrumbs | ||
trail={[ | ||
{ title: "Documents" }, | ||
{ href: "/documents/[id]", title: "The Santa Anas" }, | ||
{ href: "/documents/[id]/organize", title: "Organize" }, | ||
]} | ||
/> | ||
</Story> | ||
|
||
<Story name="Long Crumb"> | ||
<div style="width: 48rem;"> | ||
<Breadcrumbs | ||
trail={[ | ||
{ title: "Documents" }, | ||
{ | ||
href: "/documents/[id]", | ||
title: "BADFILENAME__TOOLONG__FINAL FINAL DRAFT 2.pdf", | ||
}, | ||
{ href: "/documents/[id]/organize", title: "Organize" }, | ||
]} | ||
/> | ||
</div> | ||
</Story> | ||
|
||
<Story name="Custom Root"> | ||
<Breadcrumbs | ||
trail={[ | ||
{ href: "/documents", title: "Documents" }, | ||
{ href: "/documents/[id]", title: "The Santa Anas" }, | ||
{ href: "/documents/[id]/organize", title: "Organize" }, | ||
]} | ||
> | ||
<p slot="root">DocumentCloud</p> | ||
</Breadcrumbs> | ||
</Story> |
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,7 @@ | ||
<script lang="ts"> | ||
import { setContext } from "svelte"; | ||
setContext("breadcrumbs", [{ href: "/app/add-ons", label: "Add-Ons" }]); | ||
</script> | ||
|
||
<slot /> |
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