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): Implementation #138

Merged
merged 26 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
024d385
feat(tabs): Initial commit
Vignesh-Manogar-E3433 Feb 26, 2020
feac2a3
feat(tabs): Implemented {{nucleus-tabs}}
Vignesh-Manogar-E3433 Feb 27, 2020
5a84fa7
refactor(tabs): calling component attributes through get call
Vignesh-Manogar-E3433 Mar 3, 2020
6df0f48
fix(tabs): Background variant border radius issue
Vignesh-Manogar-E3433 Mar 3, 2020
f590917
refractor(tabs): current selected name change
Vignesh-Manogar-E3433 Mar 3, 2020
17dcb82
fix(tabs): no focus on disabled button
Vignesh-Manogar-E3433 Mar 4, 2020
907fda0
fix(tabs): no focus on disabled button & safari text rendering issue
Vignesh-Manogar-E3433 Mar 4, 2020
d6015a8
feat(tabs): 'beforeChange' handler implementation
Vignesh-Manogar-E3433 Mar 5, 2020
0d3c03d
feat(tabs): Adding customClasses prop to tabs
Vignesh-Manogar-E3433 Mar 6, 2020
8167111
refractor(tabs): class names changed to follow existing conventions
Vignesh-Manogar-E3433 Mar 6, 2020
a177a2d
refractor(tabs): Added missing empty lines at the end of files
Vignesh-Manogar-E3433 Mar 6, 2020
68555b1
Merge branch 'master' into feature/nucleus-tabs
shibulijack-fd Mar 9, 2020
d4b5ade
fix(tabs): documentation issues
Vignesh-Manogar-E3433 Mar 9, 2020
37470bf
Merge branch 'master' into feature/nucleus-tabs
Vignesh-Manogar-E3433 Mar 9, 2020
a4f3033
fix(tabs): safari font color on active element
Vignesh-Manogar-E3433 Mar 10, 2020
ad5af24
refractor(tabs): Removed sending attributes in single props object
Vignesh-Manogar-E3433 Mar 11, 2020
0606c98
feat(tabs): select prop optional
Vignesh-Manogar-E3433 Mar 12, 2020
21b017e
feat(tabs): disabled as boolean or string
Vignesh-Manogar-E3433 Mar 16, 2020
4aafed1
Merge branch 'master' into feature/nucleus-tabs
shibulijack-fd Mar 18, 2020
d358915
fix(tabs): focus styling not appearing on click
Vignesh-Manogar-E3433 Mar 18, 2020
b3867bb
fix(tabs): removed vendor prefixes
Vignesh-Manogar-E3433 Mar 18, 2020
678ebfa
fix(tabs): pressed and active hover state styling
Vignesh-Manogar-E3433 Mar 18, 2020
c4d7676
refactor(tabs): Combined attribute bindings, class bindings. Single l…
Vignesh-Manogar-E3433 Mar 19, 2020
f9086e2
refactor(tabs): changeFocusTab function
Vignesh-Manogar-E3433 Mar 19, 2020
fcce8cc
Merge branch 'master' into feature/nucleus-tabs
shibulijack-fd Mar 19, 2020
dba6afd
Merge branch 'master' into feature/nucleus-tabs
shibulijack-fd Mar 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@nucleus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@freshworks/inline-banner": "^0.5.4",
"@freshworks/modal": "^0.5.4",
"@freshworks/toast-message": "^0.6.4",
"@freshworks/tabs": "^0.1.0",
"ember-cli-autoprefixer": "^0.8.1",
"ember-cli-babel": "^7.11.1",
"ember-cli-htmlbars": "^4.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// BEGIN-SNIPPET nucleus-tabs-2.js
import Component from '@ember/component';
import { inject } from '@ember/service';
import { get } from '@ember/object';

export default Component.extend({
flashMessages: inject(),
actions: {
onChange(changedTo) { // changedTo, ChangedFrom, event params accepted
const flashMessages = get(this, 'flashMessages');
flashMessages.info(`Custom action invoked. '${changedTo}' tab selected!`, {
timeout: 1500
});
}
}
});
// END-SNIPPET
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// BEGIN-SNIPPET nucleus-tabs-3.js
import Component from '@ember/component';
import { inject } from '@ember/service';
import RSVP from 'rsvp';
import { get } from '@ember/object';

export default Component.extend({
flashMessages: inject(),
actions: {
beforeChange() { // changedTo, changedFrom, event params accepted
const flashMessages = get(this, 'flashMessages');
flashMessages.info(`Performing asyncronous operation..`, {
timeout: 1500
});
return new RSVP.Promise(function(resolve) {
setTimeout(function () {
resolve();
}, 2000);
});
},
onChange() { // changedTo, ChangedFrom, event params accepted
const flashMessages = get(this, 'flashMessages');
flashMessages.info(`Tab changed.`, {
timeout: 1500
});
}
}
});
// END-SNIPPET
1 change: 1 addition & 0 deletions packages/@nucleus/tests/dummy/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Router.map(function() {
this.route("nucleus-modal");
this.route("nucleus-toast-message");
this.route("nucleus-banner");
this.route("nucleus-tabs");
});

this.route('not-found', { path: '/*path' });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{#docs-demo as |demo|}}
{{#demo.example name="nucleus-tabs-2.hbs" }}
{{#nucleus-tabs
description="site-navigation"
onChange=(action "onChange") as |tabs| }}
{{#tabs.panel name="I want apples" }}
<div>This is apples section</div>
{{/tabs.panel}}
{{#tabs.panel name="I want oranges" }}
<div>This is oranges section</div>
{{/tabs.panel}}
{{#tabs.panel name="I want grapes" }}
<div>This is grapes section</div>
{{/tabs.panel}}
{{/nucleus-tabs}}
{{/demo.example}}

{{demo.snippet "nucleus-tabs-2.hbs"}}
{{demo.snippet "nucleus-tabs-2.js" label="component.js"}}
{{/docs-demo}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{#docs-demo as |demo|}}
{{#demo.example name="nucleus-tabs-3.hbs" }}
{{#nucleus-tabs
description="site-navigation"
select="I want apples"
beforeChange=(action "beforeChange")
onChange=(action "onChange") as |tabs| }}
{{#tabs.panel name="I want apples" }}
<div>This is apples section</div>
{{/tabs.panel}}
{{#tabs.panel name="I want oranges" }}
<div>This is oranges section</div>
{{/tabs.panel}}
{{#tabs.panel name="I want grapes" }}
<div>This is grapes section</div>
{{/tabs.panel}}
{{/nucleus-tabs}}
{{/demo.example}}

{{demo.snippet "nucleus-tabs-3.hbs"}}
{{demo.snippet "nucleus-tabs-3.js" label="component.js"}}
{{/docs-demo}}
1 change: 1 addition & 0 deletions packages/@nucleus/tests/dummy/app/templates/docs.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{{nav.item "Inline Banner" "docs.components.nucleus-inline-banner"}}
{{nav.item "Modal" "docs.components.nucleus-modal"}}
{{nav.item "Toast message" "docs.components.nucleus-toast-message"}}
{{nav.item "Tabs" "docs.components.nucleus-tabs"}}
{{/viewer.nav}}

{{#viewer.main}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# Tabs

```sh
yarn add @freshworks/tabs
```

Tabs are used to organise content under each section. Tabs are most helpful when there is a lot of content to show in a page. Tabs can help in showing content which are under the same level of hierarchy, under each section inside the same page.

## Usage

#### 1. Categorisation

It's easy for the user to quickly distinguish which tab belongs to which content.

{{#docs-demo as |demo|}}
{{#demo.example name="nucleus-tabs.hbs"}}
{{#nucleus-tabs
customClasses="sample-tab sample-tab-simple"
description="site-navigation"
select="I want apples"
variant="line" as |tabs| }}
{{#tabs.panel name="I want apples" }}
<div>This is apples section</div>
{{/tabs.panel}}
{{#tabs.panel name="I want oranges" }}
<div>This is oranges section</div>
{{/tabs.panel}}
{{#tabs.panel name="I want grapes" }}
<div>This is grapes section</div>
{{/tabs.panel}}
{{/nucleus-tabs}}
{{/demo.example}}
{{demo.snippet 'nucleus-tabs.hbs'}}
{{/docs-demo}}

#### 2. Custom action 'on' changing tab

{{nucleus-tabs/demo-1}}

#### 3. Custom action 'before' changing tab

{{nucleus-tabs/demo-2}}

#### 4. Disabled tab

{{#docs-demo as |demo|}}
{{#demo.example name="nucleus-tabs-4.hbs"}}
{{#nucleus-tabs
description="site-navigation"
variant="line" as |tabs| }}
{{#tabs.panel name="I want apples" }}
<div>This is apples section</div>
{{/tabs.panel}}
{{#tabs.panel name="I want oranges" }}
<div>This is oranges section</div>
{{/tabs.panel}}
{{#tabs.panel name="I want grapes" disabled=true }}
<div>This is grapes section</div>
{{/tabs.panel}}
{{/nucleus-tabs}}
{{/demo.example}}
{{demo.snippet 'nucleus-tabs-4.hbs'}}
{{/docs-demo}}

## Styles

#### 1. Default

{{#docs-demo as |demo|}}
{{#demo.example name="nucleus-tabs-variant1.hbs"}}
{{#nucleus-tabs
description="site-navigation"
select="I want apples"
variant="line" as |tabs| }}
{{#tabs.panel name="I want apples" }}
<div>This is apples section</div>
{{/tabs.panel}}
{{#tabs.panel name="I want oranges" }}
<div>This is oranges section</div>
{{/tabs.panel}}
{{#tabs.panel name="I want grapes" }}
<div>This is grapes section</div>
{{/tabs.panel}}
{{/nucleus-tabs}}
{{/demo.example}}
{{demo.snippet 'nucleus-tabs-variant1.hbs'}}
{{/docs-demo}}



#### 2. With Background
Pass 'variant' property as 'background'.

{{#docs-demo as |demo|}}
{{#demo.example name="nucleus-tabs-variant2.hbs"}}
{{#nucleus-tabs
description="site-navigation"
select="I want apples"
variant="background" as |tabs| }}
{{#tabs.panel name="I want apples" }}
<div>This is apples section</div>
{{/tabs.panel}}
{{#tabs.panel name="I want oranges" }}
<div>This is oranges section</div>
{{/tabs.panel}}
{{#tabs.panel name="I want grapes" }}
<div>This is grapes section</div>
{{/tabs.panel}}
{{/nucleus-tabs}}
{{/demo.example}}
{{demo.snippet 'nucleus-tabs-variant2.hbs'}}
{{/docs-demo}}


## Guidelines

✅ **Do's**

1. Tabs should be placed in a single row over the content

2. Include all interactive states for the tabs


🚫 **Dont's**

1. Dont use tabs for sequential content. Users can navigate to any tab at any time and cannot be expected to do it sequentially.

2. Dont use tabs for content in different levels of hierarchy.

## Accessibility

__role=tablist__

Indicates that the element serves as a container for a set of tabs.

__aria-label=Entertainment__

Provides a label that describes the purpose of the set of tabs.


__role=tab__

Indicates the element serves as a tab control.

__aria-select=true__

Indicates the tab control is activated and its associated panel is displayed.

__aria-select=false__

Indicates the tab control is not active and its associated panel is NOT displayed.

__aria-controls=IDREF__

Refers to the tabpanel element associated with the tab.


__role=tabpanel__

Indicates the element serves as a container for tab panel content.

__aria-labelledby=IDREF__

Refers to the tab element that controls the panel.

{{docs-note}}
8 changes: 8 additions & 0 deletions packages/tabs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.1.0] - 2019-03-06
### Added
- {{nucleus-tabs}} Initial imlpementation.
9 changes: 9 additions & 0 deletions packages/tabs/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2019

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 changes: 22 additions & 0 deletions packages/tabs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@freshworks/tabs
==============================================================================

```
yarn add @freshworks/tabs
```

Tabs are used to organise content under each section.

Scenario
------------------------------------------------------------------------------
Tabs are most helpful when there is a lot of content to show in a page. Tabs can help in showing content which are under the same level of hierarchy, under each section inside the same page.

Guidelines
------------------------------------------------------------------------------
**Do's**
1. Tabs should be placed in a single row over the content
2. Include all interactive states for the tabs


**Dont's**
1. Dont use tabs for sequential content. Users can navigate to any tab at any time and cannot be expected to do it sequentially.
Loading