Skip to content

Commit

Permalink
Merge pull request #163 from US-CBP/ActionBar
Browse files Browse the repository at this point in the history
Action Bar
  • Loading branch information
bagrub authored Jul 19, 2024
2 parents 60f03ad + fd07b6d commit 4a1f4c4
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 43 deletions.
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);
}
}
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
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.`,
};
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>
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,15 @@
}

cbp-structured-list {
display: block;
display: block;
background-color: var(--cbp-structured-list-color-background);
color: var(--cbp-structured-list-color);

[slot] {
[slot=cbp-structured-list-header] {
color: var(--cbp-structured-list-header-color);
background-color: var(--cbp-structured-list-header-color-background);
font-style: italic;

display: flex;
align-items: center;
padding: var(--cbp-space-3x);
Expand All @@ -80,19 +84,6 @@ cbp-structured-list {
flex-basis: 100%;
}
}

[slot=cbp-structured-list-header] {
color: var(--cbp-structured-list-header-color);
background-color: var(--cbp-structured-list-header-color-background);
font-style: italic;
}



[slot=cbp-structured-list-footer] {
color: var(--cbp-structured-list-footer-color);
background-color: var(--cbp-structured-list-footer-color-background);
}

&[striped] [role=list] > *:nth-child(even) {
background-color: var(--cbp-structured-list-color-striped-background);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,13 @@ const StructuredListTemplate = ({ listItems, striped, selectable, showHeader, he
${generateLIs(listItems)}
${showFooter
? `
<div slot="cbp-structured-list-footer">
<cbp-flex align-items="center" justify-content="space-between">
<div>0 items selected.</div>
<div>
<cbp-button fill="ghost" context="dark-inverts" accessibility-text="Delete selected items">Delete</cbp-button>
<cbp-button fill="ghost" context="dark-inverts" accessibility-text="Compare selected items">Compare</cbp-button>
</div>
${showFooter
? ` <div slot="cbp-structured-list-footer">
<cbp-action-bar variant='inline' context="dark-inverts">
<div slot='cbp-action-bar-info'>0 items selected.</div>
<cbp-button fill="ghost" context="dark-inverts" accessibility-text="Delete selected items">Delete</cbp-button>
<cbp-button fill="ghost" context="dark-inverts" accessibility-text="Compare selected items">Compare</cbp-button>
</cbp-action-bar>
</div>
`
: ''}
Expand Down Expand Up @@ -124,14 +122,13 @@ const StructuredListItemsTemplate = ({ listItems, striped, selectable, showHeade
${showFooter
? `
<div slot="cbp-structured-list-footer">
<cbp-flex align-items="center" justify-content="space-between">
<div>0 items selected.</div>
<div>
<cbp-button fill="ghost" context="dark-inverts" accessibility-text="Delete selected items">Delete</cbp-button>
<cbp-button fill="ghost" context="dark-inverts" accessibility-text="Compare selected items">Compare</cbp-button>
</div>
</div>
<div slot="cbp-structured-list-footer">
<cbp-action-bar variant='inline' context="dark-inverts">
<div slot='cbp-action-bar-info'>0 items selected.</div>
<cbp-button fill="ghost" context="dark-inverts" accessibility-text="Delete selected items">Delete</cbp-button>
<cbp-button fill="ghost" context="dark-inverts" accessibility-text="Compare selected items">Compare</cbp-button>
</cbp-action-bar>
</div>
`
: ''}
</cbp-structured-list>
Expand Down Expand Up @@ -248,14 +245,13 @@ const StructuredListWithGridTemplate = ({ striped, selectable, showHeader, heade
${showFooter
? `
<div slot="cbp-structured-list-footer">
<cbp-flex align-items="center" justify-content="space-between">
<div>0 items selected.</div>
<div>
<cbp-button fill="ghost" context="dark-inverts" accessibility-text="Delete selected items">Delete</cbp-button>
<cbp-button fill="ghost" context="dark-inverts" accessibility-text="Compare selected items">Compare</cbp-button>
</div>
</div>
<div slot="cbp-structured-list-footer">
<cbp-action-bar variant='inline' context="dark-inverts">
<div slot='cbp-action-bar-info'>0 items selected.</div>
<cbp-button fill="ghost" context="dark-inverts" accessibility-text="Delete selected items">Delete</cbp-button>
<cbp-button fill="ghost" context="dark-inverts" accessibility-text="Compare selected items">Compare</cbp-button>
</cbp-action-bar>
</div>
`
: ''}
</cbp-structured-list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,16 @@ export class CbpStructuredList {
render() {
return (
<Host>
<slot name="cbp-structured-list-header" />
<slot name="cbp-structured-list-header" />

<div role="list"
aria-label={this.accessibilityText}
aria-describedby={this.headerId}
>
<slot />
</div>

<slot name="cbp-structured-list-footer" />
</Host>
</Host>
);
}

Expand Down

0 comments on commit 4a1f4c4

Please sign in to comment.