-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(tabs): Initial commit * feat(tabs): Implemented {{nucleus-tabs}} Basic functionality working Refractoring some code * refactor(tabs): calling component attributes through get call * fix(tabs): Background variant border radius issue * refractor(tabs): current selected name change * fix(tabs): no focus on disabled button * fix(tabs): no focus on disabled button & safari text rendering issue * feat(tabs): 'beforeChange' handler implementation * feat(tabs): Adding customClasses prop to tabs * refractor(tabs): class names changed to follow existing conventions * refractor(tabs): Added missing empty lines at the end of files * fix(tabs): documentation issues * fix(tabs): safari font color on active element * refractor(tabs): Removed sending attributes in single props object * feat(tabs): select prop optional * feat(tabs): disabled as boolean or string * fix(tabs): focus styling not appearing on click * fix(tabs): removed vendor prefixes * fix(tabs): pressed and active hover state styling * refactor(tabs): Combined attribute bindings, class bindings. Single line if statements wrapped * refactor(tabs): changeFocusTab function Co-authored-by: Shibu Lijack <[email protected]>
- Loading branch information
1 parent
46c07ba
commit 598e3e6
Showing
62 changed files
with
1,769 additions
and
0 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
17 changes: 17 additions & 0 deletions
17
packages/@nucleus/tests/dummy/app/components/nucleus-tabs/demo-1.js
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,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 |
29 changes: 29 additions & 0 deletions
29
packages/@nucleus/tests/dummy/app/components/nucleus-tabs/demo-2.js
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,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 |
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
20 changes: 20 additions & 0 deletions
20
packages/@nucleus/tests/dummy/app/templates/components/nucleus-tabs/demo-1.hbs
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,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}} |
22 changes: 22 additions & 0 deletions
22
packages/@nucleus/tests/dummy/app/templates/components/nucleus-tabs/demo-2.hbs
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,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}} |
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
166 changes: 166 additions & 0 deletions
166
packages/@nucleus/tests/dummy/app/templates/docs/components/nucleus-tabs.md
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,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}} |
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,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. |
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,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. |
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,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. |
Oops, something went wrong.