Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tabs): Introduce Tabs component #868

Merged
merged 60 commits into from Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
cee6b91
feat(tabs): Introduce tabs component
andybraren Oct 1, 2018
4d5e941
Fixed active color and border color
andybraren Oct 30, 2018
0aa5c56
Added active tab to scroll example
andybraren Oct 30, 2018
b1d705d
Fixed bottom border of active tabs with secondary
andybraren Oct 30, 2018
13b2918
Updated variables
andybraren Oct 30, 2018
ee9460f
Fix active tab overlapping scroll buttons
andybraren Oct 30, 2018
b3abd59
Changed button modifiers: pf-m-start and pf-m-end
andybraren Oct 30, 2018
a5155ee
Add pf-m-start-current modifier
andybraren Oct 30, 2018
6f2b6d5
Design review updates
andybraren Oct 30, 2018
6e6ec07
Reordered scroll buttons to match visual order
andybraren Nov 6, 2018
22a1317
Remove focus styling on scroll buttons
andybraren Nov 6, 2018
7c36d25
Removed role attributes
andybraren Nov 6, 2018
1fe875f
Removed custom focus states
andybraren Nov 6, 2018
5234a6e
Fixed scroll button bg color variable
andybraren Nov 7, 2018
d1fde88
Add hidden attribute to non-visible scroll buttons
andybraren Nov 7, 2018
9077938
Clarified reference to the Nav component
andybraren Nov 7, 2018
4afde97
Moved pf-m-current to first secondary tab
andybraren Nov 7, 2018
cc204ab
BoxShadow variable tweaks
andybraren Nov 7, 2018
9a69f6b
Changed current color variable
andybraren Nov 7, 2018
70f8d20
First tab is now the current tab in all examples
andybraren Nov 7, 2018
21438ce
Added tabs-section.hbs
andybraren Nov 7, 2018
9d66084
Updated handlebars indentation
andybraren Nov 7, 2018
1450cb7
Re-enabled stylelint around variables
andybraren Nov 7, 2018
0791894
Fixed scroll button background color in dark theme
andybraren Nov 7, 2018
5762393
Fixed incorrect section modifier handlebars
andybraren Nov 8, 2018
85aa280
Added handlebars block for tabs--attribute
andybraren Nov 8, 2018
122e3be
Fixed border and box shadow color variables
andybraren Nov 8, 2018
e50b440
Removed unnecessary box shadow declaration
andybraren Nov 8, 2018
e4f4a56
Removed unnecessary width declaration
andybraren Nov 8, 2018
3c75c3c
Switched to new Handlebars contains utility
andybraren Nov 9, 2018
db9c770
Updated example titles
andybraren Nov 9, 2018
6768c6b
Condensed scroll button display CSS
andybraren Nov 9, 2018
f26fb3c
Set borders to variables and adjusted syntax
andybraren Nov 9, 2018
7ddd8b2
Fix contains Handlebars utility
andybraren Nov 9, 2018
124d4a0
Z index tweaks
andybraren Nov 9, 2018
b5f640d
Added base classes to tabs-primary documentation
andybraren Nov 9, 2018
8e35819
Update current variable name
andybraren Nov 9, 2018
eecdd0f
Removed global variable from box shadow color
andybraren Nov 9, 2018
6f77bf1
Testing putting box-shadow within ::before
andybraren Nov 12, 2018
db1b15f
Added tabs-button.hbs and aria-controls
andybraren Nov 12, 2018
1eb7a37
Testing using borders within ::before
andybraren Nov 12, 2018
4d65727
Added tabs-list.hbs
andybraren Nov 12, 2018
87d9e6e
Replace box-shadows with fancy borders
andybraren Nov 12, 2018
9883512
Switched to hiding scroll buttons solely via CSS
andybraren Nov 13, 2018
1a30741
Updated documentation
andybraren Nov 13, 2018
b620c82
Removed unneeded flex
andybraren Nov 13, 2018
5e726a8
Fixed filled style
andybraren Nov 13, 2018
1ed743b
Added newline to two docs
andybraren Nov 13, 2018
5f15dc8
Removed aria-controls from non-primary examples
andybraren Nov 13, 2018
1af7cde
Changed secondary tabs doc heading
andybraren Nov 13, 2018
4256c78
Moving scroll buttons around
andybraren Nov 13, 2018
dd669c9
More scroll button movements
andybraren Nov 13, 2018
87579b0
Updated secondary tabs styling and docs
andybraren Nov 14, 2018
834db89
Updated primary tabs docs
andybraren Nov 14, 2018
0e4084b
Fixed scrollbar style within secondary tabs
andybraren Nov 14, 2018
bf43bf0
Added more tabs to scrolling example
andybraren Nov 14, 2018
a945c54
Updated flex implementation
andybraren Nov 14, 2018
7785fb5
Removed extraneous quotation mark
andybraren Nov 15, 2018
b47ec47
Clarified secondary tabs title
andybraren Nov 15, 2018
39e1586
Made secondary tab selector more robust
andybraren Nov 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/helpers/contains.js
@@ -1,6 +1,6 @@
const util = require('handlebars-utils');

module.exports = (collection, value, options) => {
const hasIt = collection.indexOf(value) >= 0;
const hasIt = collection && collection.indexOf(value) >= 0;
return util.value(hasIt, this, options);
};
3 changes: 3 additions & 0 deletions src/patternfly/components/Tabs/docs/code.md
@@ -0,0 +1,3 @@
## Overview

`Tabs` should only be used to change content views within a page. The similar-looking but semantically different [Horizontal Nav component](https://pf-next.com/components/Nav/examples/) is available for general navigation use cases.
34 changes: 34 additions & 0 deletions src/patternfly/components/Tabs/docs/design.md
@@ -0,0 +1,34 @@
# Component Name
_Include a short (1-2 sentence) description of the component here and fill out the following sections as needed_

## Usage
_(Required)
Inform readers about when and how this component or pattern should be used, including any variations or related best practices._
* What problem does this solve?
* When to use
* When not to use
* Alternative solutions
* How to use it in context (in my design)
* Layout or sizing considerations
* Using with other components or patterns
* Examples

## Behavior
_(Optional)
You can include behavioral specifications to help readers understand any complex aspects of behavior that might not be obvious from the implementation examples.
This will aid readers in understanding aspects of behavior that may not be
obvious from looking at implementation examples._
* Include mockups (can be low or mid-fi) with enumerated callouts to describe intended interactions.
* Mockups can be low or mid-fi.

## Styling
_(Optional)
If there are styling considerations that may not be obvious from looking at the implementation examples, they should be explained here._

## Content
_(optional)
Provide content standards and writing suggestions for this component or pattern to help designers and developers deliver consistent and thoughtful content. You can include guidelines, messaging standards, or similar best practices specific to this component or pattern.This will extend
any general terminology and wording best practices to provide component specific guidance._
* Editorial guidelines for labeling and message text
* Length restrictions and/or what to do if text overflows
* Localization considerations
5 changes: 5 additions & 0 deletions src/patternfly/components/Tabs/docs/tabs-filled.md
@@ -0,0 +1,5 @@
## Modifiers

| Class | Applied To | Outcome |
| -- | -- | -- |
| `.pf-m-fill` | `.pf-c-tabs` | Enables the filled tab list layout. **Required** |
24 changes: 24 additions & 0 deletions src/patternfly/components/Tabs/docs/tabs-primary.md
@@ -0,0 +1,24 @@
### Accessibility

| Attribute | Applied To | Outcome |
| -- | -- | -- |
| `aria-controls="tabsection1"` | `.pf-c-tabs__button` | Identifies the section controlled by the tab. **Required** |
| `aria-labelledby="tab1"` | `section` | Identifies the tab associated with the section. **Required** |
| `hidden` | `section` | Indicates that a tab panel is not currently active. **Required** |

### Usage

| Attribute | Applied To | Outcome |
| -- | -- | -- |
| `.pf-c-tabs` | `<div>` | Creates a tab component. **Required** |
| `.pf-c-tabs__scroll-button` | `<button>` | Creates a scroll button. **Required** |
| `.pf-c-tabs__list` | `<ul>` | Creates a tab list. **Required** |
| `.pf-c-tabs__item` | `<li>` | Creates a tab item. **Required** |
| `.pf-c-tabs__button` | `<button>` | Creates a tab button. **Required** |
| `id="tab1"` | `.pf-c-tabs__button` | Uniquely identifies the tab. **Required** |

### Modifiers

| Class | Applied To | Outcome |
| -- | -- | -- |
| `.pf-m-current`| `.pf-c-tabs__item` | Highlights the current tab. |
12 changes: 12 additions & 0 deletions src/patternfly/components/Tabs/docs/tabs-scroll.md
@@ -0,0 +1,12 @@
### Note

Whenever a `.pf-m-current` tab is scrolled beyond the width of the container, the appropriate scroll button should be highlighted using `.pf-m-start-current` or `.pf-m-end-current` to indicate that the current tab exists in that direction.

## Modifiers

| Class | Applied To | Outcome |
| -- | -- | -- |
| `.pf-m-start` | `.pf-c-tabs` | Enables the first directional scroll button. |
| `.pf-m-start-current` | `.pf-c-tabs` | Highlights the first directional scroll button. |
| `.pf-m-end` | `.pf-c-tabs` | Enables the second directional scroll button. |
| `.pf-m-end-current` | `.pf-c-tabs` | Highlights the second directional scroll button. |
9 changes: 9 additions & 0 deletions src/patternfly/components/Tabs/docs/tabs-secondary.md
@@ -0,0 +1,9 @@
### Note

Secondary tabs can be placed as an independent component anywhere within an interface. If placed directly adjacent to a set of Primary tabs, they adopt a small amount of styling to properly align and separate the two tab sets.

### Modifiers

| Class | Applied To | Outcome |
| -- | -- | -- |
| `.pf-m-tabs-secondary` | `.pf-c-tabs` | Creates a secondary tabs component. **Required** |
55 changes: 55 additions & 0 deletions src/patternfly/components/Tabs/examples/index.js
@@ -0,0 +1,55 @@
import React from 'react';
import Documentation from '@siteComponents/Documentation';
import Example from '@siteComponents/Example';

// Raw
import tabsExamplePrimaryRaw from '!raw!./tabs-primary.hbs';
import tabsExampleSecondaryRaw from '!raw!./tabs-secondary.hbs';
import tabsExampleFilledRaw from '!raw!./tabs-filled.hbs';
import tabsExampleScrollRaw from '!raw!./tabs-scroll.hbs';

// Primary tabs
import TabsExamplePrimary from './tabs-primary.hbs';
import tabsPrimaryDocs from '../docs/tabs-primary.md';

// Secondary tabs
import TabsExampleSecondary from './tabs-secondary.hbs';
import tabsSecondaryDocs from '../docs/tabs-secondary.md';

// Filled tabs
import TabsExampleFilled from './tabs-filled.hbs';
import tabsFilledDocs from '../docs/tabs-filled.md';

// Scroll buttons
import TabsExampleScroll from './tabs-scroll.hbs';
import tabsScrollDocs from '../docs/tabs-scroll.md';

import docs from '../docs/code.md';
import '../tabs.scss';

export const headingText = 'Tabs';
export const Docs = docs;

export default () => {
const tabsExamplePrimary = TabsExamplePrimary();
const tabsExampleSecondary = TabsExampleSecondary();
const tabsExampleFilled = TabsExampleFilled();
const tabsExampleScroll = TabsExampleScroll();

return (
<Documentation docs={Docs} heading={headingText}>
<Example heading="Primary tabs with sections" handlebars={tabsExamplePrimaryRaw} docs={tabsPrimaryDocs}>
{tabsExamplePrimary}
</Example>
<Example heading="Scroll buttons" handlebars={tabsExampleScrollRaw} docs={tabsScrollDocs}>
{tabsExampleScroll}
</Example>
<Example heading="Secondary tabs" handlebars={tabsExampleSecondaryRaw} docs={tabsSecondaryDocs}>
{tabsExampleSecondary}
</Example>
<Example heading="Filled tabs" handlebars={tabsExampleFilledRaw} docs={tabsFilledDocs}>
{tabsExampleFilled}
</Example>
</Documentation>
);
};
19 changes: 19 additions & 0 deletions src/patternfly/components/Tabs/examples/tabs-filled.hbs
@@ -0,0 +1,19 @@
{{#> tabs tabs--modifier="pf-m-fill" tabs--attribute='aria-label="Filled tabs example"'}}
{{#> tabs-list}}
{{#> tabs-item tabs-item--current="true"}}
{{#> tabs-button tabs-button--attribute='id="ex4-tab1"'}}
Tab item 1
{{/tabs-button}}
{{/tabs-item}}
{{#> tabs-item}}
{{#> tabs-button tabs-button--attribute='id="ex4-tab2"'}}
Tab item 2
{{/tabs-button}}
{{/tabs-item}}
{{#> tabs-item}}
{{#> tabs-button tabs-button--attribute='id="ex4-tab3"'}}
Tab item 3
{{/tabs-button}}
{{/tabs-item}}
{{/tabs-list}}
{{/tabs}}
29 changes: 29 additions & 0 deletions src/patternfly/components/Tabs/examples/tabs-primary.hbs
@@ -0,0 +1,29 @@
{{#> tabs tabs--attribute='aria-label="Primary tabs with sections example"'}}
{{#> tabs-list}}
{{#> tabs-item tabs-item--attribute='' tabs-item--current="true"}}
{{#> tabs-button tabs-button--attribute='id="ex1-tab1" aria-controls="ex1-section1"'}}
Tab item 1
{{/tabs-button}}
{{/tabs-item}}
{{#> tabs-item}}
{{#> tabs-button tabs-button--attribute='id="ex1-tab2" aria-controls="ex1-section2"'}}
Tab item 2
{{/tabs-button}}
{{/tabs-item}}
{{#> tabs-item}}
{{#> tabs-button tabs-button--attribute='id="ex1-tab3" aria-controls="ex1-section3"'}}
Tab item 3
{{/tabs-button}}
{{/tabs-item}}
{{/tabs-list}}
{{/tabs}}

{{#> tabs-section tabs-section--attribute='id="ex1-section1" aria-labelledby="ex1-tab1"'}}
Tab 1 section
{{/tabs-section}}
{{#> tabs-section tabs-section--attribute='id="ex1-section2" aria-labelledby="ex1-tab2" hidden'}}
Tab 2 section
{{/tabs-section}}
{{#> tabs-section tabs-section--attribute='id="ex1-section3" aria-labelledby="ex1-tab3" hidden'}}
Tab 3 section
{{/tabs-section}}
34 changes: 34 additions & 0 deletions src/patternfly/components/Tabs/examples/tabs-scroll.hbs
@@ -0,0 +1,34 @@
{{#> tabs tabs--modifier="pf-m-start pf-m-start-current pf-m-end" tabs--attribute='aria-label="Scroll buttons example"'}}
{{#> tabs-list}}
{{#> tabs-item tabs-item--current="true"}}
{{#> tabs-button tabs-button--attribute='id="ex2-tab1"'}}
Tab item 1
{{/tabs-button}}
{{/tabs-item}}
{{#> tabs-item}}
{{#> tabs-button tabs-button--attribute='id="ex2-tab2"'}}
Tab item 2
{{/tabs-button}}
{{/tabs-item}}
{{#> tabs-item}}
{{#> tabs-button tabs-button--attribute='id="ex2-tab3"'}}
Tab item 3
{{/tabs-button}}
{{/tabs-item}}
{{#> tabs-item}}
{{#> tabs-button tabs-button--attribute='id="ex2-tab4"'}}
Tab item 4
{{/tabs-button}}
{{/tabs-item}}
{{#> tabs-item}}
{{#> tabs-button tabs-button--attribute='id="ex2-tab5"'}}
Tab item 5
{{/tabs-button}}
{{/tabs-item}}
{{#> tabs-item}}
{{#> tabs-button tabs-button--attribute='id="ex2-tab6"'}}
Tab item 6
{{/tabs-button}}
{{/tabs-item}}
{{/tabs-list}}
{{/tabs}}
39 changes: 39 additions & 0 deletions src/patternfly/components/Tabs/examples/tabs-secondary.hbs
@@ -0,0 +1,39 @@
{{#> tabs tabs--attribute='aria-label="Primary tabs with secondary example"'}}
{{#> tabs-list}}
{{#> tabs-item tabs-item--current="true"}}
{{#> tabs-button tabs-button--attribute='id="ex3-tab1"'}}
Tab item 1
{{/tabs-button}}
{{/tabs-item}}
{{#> tabs-item}}
{{#> tabs-button tabs-button--attribute='id="ex3-tab2""'}}
Tab item 2
{{/tabs-button}}
{{/tabs-item}}
{{#> tabs-item}}
{{#> tabs-button tabs-button--attribute='id="ex3-tab3"'}}
Tab item 3
{{/tabs-button}}
{{/tabs-item}}
{{/tabs-list}}
andybraren marked this conversation as resolved.
Show resolved Hide resolved
{{/tabs}}

{{#> tabs tabs--modifier="pf-m-tabs-secondary" tabs--attribute='aria-label="Secondary tabs example"'}}
{{#> tabs-list}}
{{#> tabs-item tabs-item--current="true"}}
{{#> tabs-button tabs-button--attribute='id="ex3-secondary-tab1"'}}
Secondary tab item 1
{{/tabs-button}}
{{/tabs-item}}
{{#> tabs-item}}
{{#> tabs-button tabs-button--attribute='id="ex3-secondary-tab2"'}}
Secondary tab item 2
{{/tabs-button}}
{{/tabs-item}}
{{#> tabs-item}}
{{#> tabs-button tabs-button--attribute='id="ex3-secondary-tab3"'}}
Secondary tab item 3
{{/tabs-button}}
{{/tabs-item}}
{{/tabs-list}}
{{/tabs}}
6 changes: 6 additions & 0 deletions src/patternfly/components/Tabs/tabs-button.hbs
@@ -0,0 +1,6 @@
<button class="pf-c-tabs__button{{#if tab-button--modifier}} {{tab-button--modifier}}{{/if}}"
{{#if tabs-button--attribute}}
{{{tabs-button--attribute}}}
{{/if}}>
{{> @partial-block}}
</button>
6 changes: 6 additions & 0 deletions src/patternfly/components/Tabs/tabs-item.hbs
@@ -0,0 +1,6 @@
<li class="pf-c-tabs__item{{#if tabs-item--current}} pf-m-current{{/if}}{{#if tabs-item--modifier}} {{tabs-item--modifier}}{{/if}}"
{{#if tabs-item--attribute}}
{{{tabs-item--attribute}}}
{{/if}}>
{{> @partial-block}}
</li>
18 changes: 18 additions & 0 deletions src/patternfly/components/Tabs/tabs-list.hbs
@@ -0,0 +1,18 @@
<button class="pf-c-tabs__scroll-button" aria-label="Scroll left"
{{#if tabs-scroll-buttons--attribute}}
{{{tabs-scroll-buttons--attribute}}}
{{/if}}>
<i class="fas fa-angle-left" hidden></i>
</button>
<ul class="pf-c-tabs__list{{#if tabs-list--modifier}} {{tabs-list--modifier}}{{/if}}"
{{#if tabs-list--attribute}}
{{{tabs-list--attribute}}}
{{/if}}>
{{> @partial-block}}
</ul>
<button class="pf-c-tabs__scroll-button" aria-label="Scroll right"
{{#if tabs-scroll-buttons--attribute}}
{{{tabs-scroll-buttons--attribute}}}
{{/if}}>
<i class="fas fa-angle-right" hidden></i>
</button>
6 changes: 6 additions & 0 deletions src/patternfly/components/Tabs/tabs-section.hbs
@@ -0,0 +1,6 @@
<section class="pf-c-tabs__section"{{#if tabs-section--modifier}} {{tabs-section--modifier}}{{/if}}
{{#if tabs-section--attribute}}
{{{tabs-section--attribute}}}
{{/if}}>
{{> @partial-block}}
</section>
6 changes: 6 additions & 0 deletions src/patternfly/components/Tabs/tabs.hbs
@@ -0,0 +1,6 @@
<div class="pf-c-tabs{{#if tabs--modifier}} {{tabs--modifier}}{{/if}}"
{{#if tabs--attribute}}
{{{tabs--attribute}}}
{{/if}}>
{{> @partial-block}}
</div>