-
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 #163 from US-CBP/ActionBar
Action Bar
- Loading branch information
Showing
7 changed files
with
202 additions
and
43 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
packages/web-components/src/components/cbp-action-bar/cbp-action-bar.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,46 @@ | ||
/** | ||
* @prop --cbp-action-bar-color-background: var(--cbp-color-grey-cool-70); | ||
* @prop--cbp-action-bar-color-background-dark: var(--cbp-color-grey-cool-5); | ||
*/ | ||
//todo: swap light and dark values so context works correctly | ||
:root { | ||
--cbp-action-bar-color-background: var(--cbp-color-gray-cool-5); | ||
--cbp-action-bar-color-background-dark: var(--cbp-color-gray-cool-70); | ||
|
||
--cbp-action-bar-color: var(--cbp-color-text-darkest); | ||
--cbp-action-bar-color-dark: var(--cbp-color-text-lightest); | ||
|
||
} | ||
|
||
[data-cbp-theme=light] cbp-action-bar[context*=dark]:not([context=light-always]), | ||
[data-cbp-theme=dark] cbp-action-bar:not([context=dark-inverts]):not([context=light-always]) { | ||
--cbp-action-bar-color-background: var(--cbp-action-bar-color-background-dark); | ||
--cbp-action-bar-color: var(--cbp-action-bar-color-dark); | ||
|
||
} | ||
|
||
cbp-action-bar { | ||
display: flex; | ||
align-items: center; | ||
justify-content: right; | ||
min-height: var(--cbp-space-14x); | ||
width: 100%; | ||
padding: var(--cbp-space-3x); | ||
color: var(--cbp-action-bar-color); | ||
background-color: var(--cbp-action-bar-color-background); | ||
gap: var(--cbp-space-3x); | ||
|
||
& > *[slot="cbp-action-bar-info"]{ | ||
margin-inline-end: auto; | ||
} | ||
/* | ||
*** Sticky variant position | ||
*/ | ||
&[variant=floating] { | ||
position: fixed; | ||
bottom: 0; | ||
left: 0; | ||
padding-inline: var(--cbp-responsive-spacing-outer); | ||
box-shadow: var(--cbp-shadow-level-3-up); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/web-components/src/components/cbp-action-bar/cbp-action-bar.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,33 @@ | ||
import { Meta } from '@storybook/addon-docs'; | ||
|
||
<Meta title="Components/Action bar/Specifications" /> | ||
|
||
# cbp-action-bar | ||
|
||
## Purpose | ||
|
||
The Action bar serves several purposes, the most common use case is a submission bar in a form page. Alternatively the bar can be used to | ||
contain tools that affect the content of the page the user is on. | ||
|
||
## Functional Requirements | ||
|
||
* The Action bar is a container with slots for a status or text description of the action bar and a slot for the buttons/links to be displayed | ||
* Action bar comes with 2 variants, inline & floating. | ||
*inline: is rendered inplace. Primarily for supporting Forms, strucutred list footer, grids, etc | ||
*floating: is rendered at bottom of viewport, used for containing tools that affect the content of the whole page the user is viewing | ||
|
||
### Responsiveness | ||
|
||
* Since content is slotted into the action bar the end user can alter/add items to hide, alter as needed for Responsiveness | ||
* Inline variant is designed to follow the overall responsiveness of the control/container it is in so that behavior does not conflict | ||
with these other controls | ||
* Sticky variant utilizes responsive padding variables to adjust as per overall design system breakpoints | ||
|
||
### Accessibility | ||
|
||
* Action bar as a container does not recieve focus, it also does not inhibit the native Accessibility of any of the slotted content. | ||
Thus consumers will need to ensure that any slotted content is accessibile (CBP components will come with this natively) | ||
|
||
### Additional Notes and Considerations | ||
|
||
* it is not advised to use both inline and floating action bar on the same page to avoid user confusion |
56 changes: 56 additions & 0 deletions
56
packages/web-components/src/components/cbp-action-bar/cbp-action-bar.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,56 @@ | ||
export default { | ||
title: 'Components/Action Bar', | ||
tags: ['autodocs'], | ||
argTypes: { | ||
|
||
variant: { | ||
control: 'select', | ||
options: ['inline', 'floating'], | ||
}, | ||
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: { | ||
}, | ||
}; | ||
|
||
const Template = ({actionBarInfo, variant, context}) => { | ||
return ` | ||
<cbp-action-bar | ||
${variant ? `variant=${variant}` : ''} | ||
${context && context != 'light-inverts' ? `context=${context}` : ''} | ||
> | ||
<cbp-typography | ||
slot='cbp-action-bar-info' | ||
tag='div' | ||
> | ||
${actionBarInfo} | ||
</cbp-typography> | ||
<cbp-button | ||
${context && context != 'light-inverts' ? `context=${context}` : ''} | ||
fill="ghost" | ||
accessibility-text="Action 1" | ||
> | ||
Action 1 | ||
</cbp-button> | ||
<cbp-button | ||
${context && context != 'light-inverts' ? `context=${context}` : ''} | ||
fill="ghost" | ||
accessibility-text="Action 2" | ||
> | ||
Action 2 | ||
</cbp-button> | ||
</cbp-action-bar> | ||
`; | ||
}; | ||
|
||
export const ActionBar = Template.bind({}); | ||
ActionBar.args = { | ||
actionBarInfo: `0 items selected.`, | ||
}; |
38 changes: 38 additions & 0 deletions
38
packages/web-components/src/components/cbp-action-bar/cbp-action-bar.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,38 @@ | ||
import { Component, Host, Element, Prop, h } from '@stencil/core'; | ||
import { setCSSProps } from '../../utils/utils'; | ||
|
||
@Component({ | ||
tag: 'cbp-action-bar', | ||
styleUrl: 'cbp-action-bar.scss', | ||
}) | ||
export class CbpActionBar { | ||
@Element() host: HTMLElement; | ||
|
||
/** variant for type: floating/inline */ | ||
@Prop({ reflect: true }) variant: 'inline' | 'floating' = 'inline' | ||
|
||
/** 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> | ||
<slot name="cbp-action-bar-info" /> | ||
<slot /> | ||
</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
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