-
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.
* First cut of panel component * Remove letter spacing and update line heights with token values in general heading SCSS * Address PR feedback
- Loading branch information
1 parent
b0771b5
commit 7c4b642
Showing
5 changed files
with
160 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Panel | ||
|
||
## Purpose | ||
|
||
A panel is a styled container for displaying information within the main page content area or to either side. | ||
|
||
## Functional Requirements | ||
|
||
* In addition to providing visual styles, panels may provide semantic meaning to the content areas they define. | ||
* Panels shall contain a heading tag (`h2-h6`) appropriate to the document outline. | ||
* The panel heading shall be styled in a consistent manner regardless of heading level. | ||
|
||
## Technical Specifications | ||
|
||
### User Interactions | ||
|
||
* All user interactions are governed by the content placed within the panel. | ||
|
||
### Responsiveness | ||
|
||
* Panels should not be given a fixed width larger than the smallest supported screen size. | ||
* In most cases, a panel's size is defined by its parent and/or a parent-level CSS Grid or Flexbox structure. | ||
|
||
### Accessibility | ||
|
||
* Panels should use appropriate HTML5 landmark tags for better accessibility rather than generic `div` tags. E.g., `aside` or `section`. | ||
* A `section` remains generic unless given an `aria-label` or `aria-labelledby`, which then reads the section as a document landmark. | ||
* Panels shall contain a heading tag (`h2-h6`) appropriate to the document outline, which may be used to label the landmark. | ||
* Alternatively, if the visible text of the heading is not sufficiently descriptive or unique, an `aria-label` may be used directly on the landmark tag. | ||
|
||
### Usage Notes and Additional Considerations | ||
|
||
* Panels should not be confused with cards. If an interface uses multiple similarly formatted items, consider cards. |
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,85 @@ | ||
export default { | ||
title: 'Patterns/Panel', | ||
argTypes: { | ||
tag: { | ||
name: 'Semantic Tag', | ||
description: 'The semantic tag defining the panel', | ||
control: 'radio', | ||
options: ['section', 'aside'], | ||
}, | ||
headingLevel: { | ||
name: 'Heading Level', | ||
description: | ||
'The heading level used as the panel header (e.g., `h2`-`h6`) as appropriate for the document structure.', | ||
control: 'select', | ||
options: ['h2', 'h3', 'h4', 'h5', 'h6'], | ||
}, | ||
header: { | ||
name: 'Heading Text', | ||
description: 'Text used as the panel header.', | ||
control: 'text', | ||
}, | ||
headerId: { | ||
name: 'Heading ID', | ||
description: | ||
'The `id` of the heading tag used to label the wrapping landmark element via `aria-labelledby`. Specifying this `id` will override any `aria-label` on the landmark tag.', | ||
control: 'text', | ||
}, | ||
content: { | ||
name: 'Panel Content', | ||
description: | ||
'Placeholder text representing the panel contents, which can include HTML markup not supported in this story.', | ||
control: 'text', | ||
}, | ||
ariaLabel: { | ||
name: 'ARIA Label', | ||
description: | ||
'An accessible label may be provided if the text within the header is not sufficiently descriptive or unique. In such a case, omit the heading `id`.', | ||
control: 'text', | ||
}, | ||
showIcon: { | ||
name: 'Show Header Icon', | ||
description: | ||
'Show an icon in the panel header as an example. This icon could be swapped out for any other.', | ||
control: 'boolean', | ||
}, | ||
}, | ||
}; | ||
|
||
const PanelTemplate = ({tag, headingLevel, header, headerId, content, ariaLabel, showIcon}) => | ||
` | ||
<${tag} class="cbp-panel" | ||
${headerId ? 'aria-labelledby="' + headerId + '"' : ''} | ||
${ariaLabel ? 'aria-label="' + ariaLabel + '"' : ''} | ||
> | ||
<div class="cbp-panel__header"> | ||
<${headingLevel} | ||
${headerId ? 'id="' + headerId + '"' : ''} | ||
>${showIcon ? '<i class="fas fa-address-book cbp-margin-right-4x"></i>': ''}${header} | ||
</${headingLevel}> | ||
</div> | ||
<div class="cbp-panel__content"> | ||
<p>${content}</p> | ||
</div> | ||
</${tag}> | ||
`; | ||
|
||
export const Default = PanelTemplate.bind({}); | ||
Default.args = { | ||
tag: 'section', | ||
headingLevel: 'h3', | ||
header: 'Panel Header', | ||
headerId: 'panelheader', | ||
content: 'Panel Content', | ||
}; | ||
Default.storyName = 'Default'; | ||
|
||
export const Sidebar = PanelTemplate.bind({}); | ||
Sidebar.args = { | ||
tag: 'aside', | ||
headingLevel: 'h3', | ||
header: 'Sidebar Header', | ||
headerId: 'panelheader', | ||
content: 'Sidebar Content', | ||
}; | ||
Sidebar.storyName = 'Sidebar'; |
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,32 @@ | ||
.cbp-panel { | ||
|
||
.cbp-panel__header { | ||
color: var(--cbp-color-text-lighter); | ||
background-color: var(--cbp-color-gray-cool-50); | ||
padding: var(--cbp-space-5x); | ||
border-bottom: solid var(--cbp-border-size-xl) var(--cbp-color-gray-cool-60); | ||
border-radius: var(--cbp-border-radius-soft) var(--cbp-border-radius-soft) 0 0; | ||
|
||
& :where(h1,h2,h3,h4,h5,h6) { | ||
color: inherit; | ||
font-size: var(--cbp-font-size-heading-lg); | ||
font-weight: normal; | ||
line-height: var(--cbp-space-7x); | ||
} | ||
} | ||
|
||
.cbp-panel__content { | ||
background-color: var(--cbp-color-white); | ||
padding: var(--cbp-space-5x); | ||
border-style: solid; | ||
border-color: var(--cbp-color-gray-cool-10); | ||
border-width: var(--cbp-border-size-md); | ||
border-top-style: none; | ||
border-radius: 0 0 var(--cbp-border-radius-soft) var(--cbp-border-radius-soft); | ||
|
||
> :last-child { | ||
margin-bottom: 0; | ||
padding-bottom: 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