-
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(ld-breadcrumbs): add ld-breadcrumbs component
- Loading branch information
1 parent
1249040
commit 199b445
Showing
38 changed files
with
871 additions
and
127 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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
src/docs/components/docs-breadcrumbs/assets/chevron-light.svg
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,15 @@ | ||
:host, | ||
.ld-breadcrumbs { | ||
--ld-crumb-icon-gap: 0.5em; | ||
--ld-crumb-gap: 0.6em; | ||
|
||
line-height: 1.5; | ||
} | ||
|
||
.ld-breadcrumbs > ol { | ||
display: flex; | ||
flex-wrap: wrap; | ||
list-style: none; | ||
padding: 0; | ||
margin: 0; | ||
} |
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,52 @@ | ||
import '../../components' // type definitions for type checks and intelliSense | ||
import { Component, h, Element } from '@stencil/core' | ||
|
||
/** | ||
* @part list - Breadcrumbs list | ||
* @virtualProp ref - reference to component | ||
* @virtualProp {string | number} key - for tracking the node's identity when working with lists | ||
*/ | ||
|
||
@Component({ | ||
tag: 'ld-breadcrumbs', | ||
styleUrl: 'ld-breadcrumbs.css', | ||
shadow: true, | ||
}) | ||
export class LdBreadcrumbs { | ||
@Element() el: HTMLElement | ||
|
||
private observer: MutationObserver | ||
|
||
private updateCurrent = () => { | ||
const crumbs = this.el.querySelectorAll('ld-crumb') | ||
crumbs.forEach((crumb) => { | ||
crumb.current = undefined | ||
}) | ||
crumbs[crumbs.length - 1].current = true | ||
} | ||
|
||
componentDidLoad() { | ||
this.observer = new MutationObserver(this.updateCurrent) | ||
this.observer.observe(this.el, { | ||
subtree: true, | ||
childList: true, | ||
attributes: false, | ||
}) | ||
|
||
this.updateCurrent() | ||
} | ||
|
||
disconnectedCallback() { | ||
if (this.observer) this.observer.disconnect() | ||
} | ||
|
||
render() { | ||
return ( | ||
<nav aria-label="Breadcrumbs" class="ld-breadcrumbs"> | ||
<ol class="ld-breadcrumbs__list" part="list"> | ||
<slot></slot> | ||
</ol> | ||
</nav> | ||
) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/liquid/components/ld-breadcrumbs/ld-crumb/ld-crumb.css
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,32 @@ | ||
.ld-breadcrumbs .ld-link, | ||
.ld-crumb__link::part(anchor) { | ||
--ld-link-gap: var(--ld-crumb-icon-gap); | ||
--ld-link-chevron-gap: var(--ld-crumb-gap); | ||
display: inline-flex; | ||
} | ||
|
||
.ld-breadcrumbs li:not(:last-of-type) .ld-link, | ||
.ld-crumb__link:not(.ld-crumb__link--current)::part(anchor) { | ||
--ld-link-col: var(--ld-col-neutral-600); | ||
|
||
font-weight: normal; | ||
margin-right: calc(var(--ld-crumb-gap) + 0.5em); | ||
|
||
&:hover { | ||
--ld-link-col: var(--ld-thm-primary-hover); | ||
} | ||
|
||
&:focus:focus-visible { | ||
--ld-link-col: var(--ld-thm-primary-focus); | ||
} | ||
|
||
&:active { | ||
--ld-link-col: var(--ld-thm-primary-active); | ||
} | ||
} | ||
|
||
.ld-breadcrumbs li:last-of-type .ld-link, | ||
.ld-crumb__link--current { | ||
cursor: default; | ||
pointer-events: none; | ||
} |
40 changes: 40 additions & 0 deletions
40
src/liquid/components/ld-breadcrumbs/ld-crumb/ld-crumb.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import '../../../components' // type definitions for type checks and intelliSense | ||
import { Component, h, Prop } from '@stencil/core' | ||
import { getClassNames } from '../../../utils/getClassNames' | ||
|
||
/** | ||
* @part link - Breadcrumb link | ||
* @virtualProp ref - reference to component | ||
* @virtualProp {string | number} key - for tracking the node's identity when working with lists | ||
*/ | ||
@Component({ | ||
tag: 'ld-crumb', | ||
styleUrl: 'ld-crumb.css', | ||
shadow: true, | ||
}) | ||
export class LdCrumb { | ||
/** @internal */ | ||
@Prop() current?: boolean | ||
|
||
/** The URL that the hyperlink points to. */ | ||
@Prop() href?: string | ||
|
||
render() { | ||
return ( | ||
<li class="ld-crumb"> | ||
<ld-link | ||
href={this.href} | ||
class={getClassNames([ | ||
'ld-crumb__link', | ||
this.current && 'ld-crumb__link--current', | ||
])} | ||
part="link" | ||
aria-current={this.current ? 'page' : undefined} | ||
chevron={this.current ? undefined : 'end'} | ||
> | ||
<slot></slot> | ||
</ld-link> | ||
</li> | ||
) | ||
} | ||
} |
Oops, something went wrong.