-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #228 from US-CBP/breadcrumb
initial creation of Breadcrumb component
- Loading branch information
Showing
6 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
packages/web-components/src/components/cbp-breadcrumb/cbp-breadcrumb.scss
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,25 @@ | ||
/** | ||
* @Prop --cbp-breadcrumb-color: var(--cbp-color-text-darkest); | ||
* @Prop --cbp-breadcrumb-color-dark: var(--cbp-color-text-lightest); | ||
*/ | ||
|
||
:root{ | ||
--cbp-breadcrumb-color: var(--cbp-color-text-darkest); | ||
--cbp-breadcrumb-color-dark: var(--cbp-color-text-lightest); | ||
} | ||
|
||
[data-cbp-theme=light] cbp-breadcrumb[context*=dark]:not([context=light-always]), | ||
[data-cbp-theme=dark] cbp-breadcrumb:not([context=dark-inverts]):not([context=light-always]) { | ||
--cbp-breadcrumb-color: var(--cbp-breadcrumb-color-dark); | ||
} | ||
|
||
cbp-breadcrumb { | ||
color: var(--cbp-breadcrumb-color); | ||
|
||
nav { | ||
display: flex; | ||
flex-wrap: wrap; | ||
align-items: center; | ||
gap: var(--cbp-space-2x); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
packages/web-components/src/components/cbp-breadcrumb/cbp-breadcrumb.specs.mdx
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,31 @@ | ||
import { Meta } from '@storybook/addon-docs'; | ||
|
||
<Meta title="Components/Breadcrumb/Specifications" /> | ||
|
||
# cbp-breadcrumb | ||
|
||
## Purpose | ||
|
||
* Breadcrumb component exist to give users a key indicator of where they are within an application when the user happens to be deeper within the site’s architecture. the Breadcrumb is primarily made using the cbp-button & cbp-link, as such please also review the documentation for those components as well. | ||
|
||
## Functional Requirements | ||
|
||
* The Breadcrumb component acts as a wrapper for navigation links. | ||
|
||
## Technical Specifications | ||
|
||
### User Interactions | ||
|
||
* The Breadcrumb is a composite component constructed of cbp-links & cbp-button, please see those components documentation for details on User Interactions | ||
|
||
### Responsiveness | ||
|
||
* TODO: update to come for overflow button responsiveness | ||
|
||
### Accessibility | ||
|
||
* The Breadcrumb is a composite component constructed of cbp-links & cbp-button, please see those components documentation for details on Accessibility. | ||
|
||
### Additional Notes and Considerations | ||
|
||
* |
64 changes: 64 additions & 0 deletions
64
packages/web-components/src/components/cbp-breadcrumb/cbp-breadcrumb.stories.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,64 @@ | ||
export default { | ||
title: 'Components/Breadcrumb', | ||
//tags: ['autodocs'], | ||
argTypes: { | ||
context : { | ||
control: 'select', | ||
options: [ "light-inverts", "light-always", "dark-inverts", "dark-always"] | ||
}, | ||
sx: { | ||
description: 'Supports adding inline styles as an object of key-value pairs comprised of CSS properties and values. Values should reference design tokens when possible.', | ||
control: 'object', | ||
}, | ||
}, | ||
args: { | ||
}, | ||
}; | ||
|
||
function generateBreadcrumbs(breadcrumbs, context){ | ||
const html = breadcrumbs.map(({text, href}) => { | ||
return ` / <cbp-link href=${href} context=${context}> ${text}</cbp-link> ` | ||
} | ||
); | ||
return html.join(''); | ||
} | ||
|
||
const Template = ({ breadcrumbs, home, context, sx}) => { | ||
return ` | ||
<cbp-breadcrumb | ||
${context && context != 'light-inverts' ? `context=${context}` : ''} | ||
${sx ? `sx=${JSON.stringify(sx)}` : ''} | ||
> | ||
<cbp-button | ||
tag="a" | ||
fill="ghost" | ||
color="primary" | ||
variant="square" | ||
context=${context} | ||
href=${home} | ||
accessibility-text="Home" | ||
> | ||
<cbp-icon | ||
name="home" | ||
> | ||
</cbp-icon> | ||
</cbp-button> | ||
${generateBreadcrumbs(breadcrumbs, context)} | ||
</cbp-breadcrumb> | ||
`; | ||
}; | ||
|
||
export const Breadcrumb = Template.bind({}); | ||
Breadcrumb.args = { | ||
breadcrumbs: [ | ||
{ | ||
text: 'Test', | ||
href: '#' | ||
}, | ||
{ | ||
text: 'Test 2', | ||
href: '#' | ||
}, | ||
], | ||
home: '#' | ||
}; |
36 changes: 36 additions & 0 deletions
36
packages/web-components/src/components/cbp-breadcrumb/cbp-breadcrumb.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,36 @@ | ||
import { Component, Prop, Element, Host, h } from '@stencil/core'; | ||
import { setCSSProps } from '../../utils/utils'; | ||
|
||
@Component({ | ||
tag: 'cbp-breadcrumb', | ||
styleUrl: 'cbp-breadcrumb.scss', | ||
}) | ||
export class CbpBreadcrumb { | ||
|
||
@Element() host: HTMLElement; | ||
|
||
/** Specifies the context of the component as it applies to the visual design and whether it inverts when light/dark mode is toggled. Default behavior is "light-inverts" and does not have to be specified. */ | ||
@Prop({ reflect: true }) context: "light-inverts" | "light-always" | "dark-inverts" | "dark-always"; | ||
|
||
/** Supports adding inline styles as an object */ | ||
@Prop() sx: any = {}; | ||
|
||
componentWillLoad() { | ||
if (typeof this.sx == 'string') { | ||
this.sx = JSON.parse(this.sx) || {}; | ||
} | ||
setCSSProps(this.host, { | ||
...this.sx, | ||
}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<Host> | ||
<nav aria-label='Breadcrumb'> | ||
<slot></slot> | ||
</nav> | ||
</Host> | ||
); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -25,6 +25,7 @@ export default { | |
'eye-slash', | ||
'filter', | ||
'globe', | ||
'home', | ||
'landmark', | ||
'lock', | ||
'magnifying-glass', | ||
|
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