-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(design): create DaffTabsComponent (#3134)
This adds a new tab component! You can use it like: ```html <daff-tabs aria-label="List of tabs"> <daff-tab> <daff-tab-label>Tab 1</daff-tab-label> <daff-tab-panel> Tab 1 Panel </daff-tab-panel> </daff-tab> </daff-tabs> ``` --------- Co-authored-by: Damien Retzinger <[email protected]>
- Loading branch information
1 parent
d1c71af
commit ffe6c19
Showing
35 changed files
with
1,495 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
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,19 @@ | ||
# Tabs | ||
Tabs provide a way to navigate between panels that display related content. | ||
|
||
## Overview | ||
Tabs allow for users to navigate between related content without having to leave the page. They can be used within components like modals or cards. | ||
|
||
## Accessbility | ||
Tabs follow the [ARIA Tabs design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/). Tabs compose of `tablist`, `tab`, and `tabpanel` elements, each with its appropriate role and integrated keyboard interactions. | ||
|
||
### Label | ||
A meaningful `aria-label` should be set on `<daff-tabs>` by using the `aria-label` property. This will set the `aria-label` on the `tablist` element. | ||
|
||
### Keyboard Interactions | ||
| Key | Action | | ||
| --- | ------ | | ||
| Left Arrow | Moves focus and activates previous tab. If focus is on the first tab, moves focus to the last tab. | | ||
| Right Arrow | Moves focus and activates next tab. If focus is on the last tab, moves focus to the first tab. | | ||
| Home | Moves focus and activates first tab. | | ||
| End | Moves focus and activates last tab. | |
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,7 @@ | ||
{ | ||
"$schema": "../../../../node_modules/ng-packagr/ng-entrypoint.schema.json", | ||
"lib": { | ||
"entryFile": "src/index.ts", | ||
"styleIncludePaths": ["../../scss"] | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
libs/design/tabs/examples/src/basic-tabs/basic-tabs.component.html
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,52 @@ | ||
<daff-tabs aria-label="List of tabs"> | ||
<daff-tab> | ||
<daff-tab-label> | ||
<fa-icon [icon]="faInfoCircle" daffPrefix></fa-icon> | ||
Tab 1 | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 1 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
<daff-tab> | ||
<daff-tab-label> | ||
Tab 2 | ||
<fa-icon [icon]="faInfoCircle" daffSuffix></fa-icon> | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 2 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
<daff-tab> | ||
<daff-tab-label> | ||
<fa-icon [icon]="faInfoCircle" daffPrefix></fa-icon> | ||
Tab 3 | ||
<fa-icon [icon]="faInfoCircle" daffSuffix></fa-icon> | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 3 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
<daff-tab> | ||
<daff-tab-label> | ||
Tab 4 | ||
<fa-icon [icon]="faInfoCircle" daffSuffix></fa-icon> | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 4 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
<daff-tab> | ||
<daff-tab-label> | ||
Tab 5 | ||
<fa-icon [icon]="faInfoCircle" daffSuffix></fa-icon> | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 5 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
</daff-tabs> |
23 changes: 23 additions & 0 deletions
23
libs/design/tabs/examples/src/basic-tabs/basic-tabs.component.ts
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,23 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
} from '@angular/core'; | ||
import { FaIconComponent } from '@fortawesome/angular-fontawesome'; | ||
import { faInfoCircle } from '@fortawesome/free-solid-svg-icons'; | ||
|
||
import { DAFF_TABS_COMPONENTS } from '@daffodil/design/tabs'; | ||
|
||
@Component({ | ||
// eslint-disable-next-line @angular-eslint/component-selector | ||
selector: 'basic-tabs', | ||
templateUrl: './basic-tabs.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [ | ||
DAFF_TABS_COMPONENTS, | ||
FaIconComponent, | ||
], | ||
}) | ||
export class BasicTabsComponent { | ||
faInfoCircle = faInfoCircle; | ||
} |
63 changes: 63 additions & 0 deletions
63
libs/design/tabs/examples/src/custom-select-tabs/custom-select-tabs.component.html
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,63 @@ | ||
<div class="custom-select-tabs__buttons"> | ||
<button daff-button size="sm" (click)="selectTabThree()"> | ||
Select Tab 3 | ||
</button> | ||
|
||
<button daff-button size="sm" (click)="selectTabFive()"> | ||
Select Tab 5 | ||
</button> | ||
</div> | ||
|
||
<daff-tabs aria-label="List of tabs"> | ||
<daff-tab> | ||
<daff-tab-label> | ||
<fa-icon [icon]="faInfoCircle" daffPrefix></fa-icon> | ||
Tab 1 | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 1 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
<daff-tab> | ||
<daff-tab-label> | ||
Tab 2 | ||
<fa-icon [icon]="faInfoCircle" daffSuffix></fa-icon> | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 2 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
<daff-tab id="tab-3"> | ||
<daff-tab-label> | ||
<fa-icon [icon]="faInfoCircle" daffPrefix></fa-icon> | ||
Tab 3 | ||
<fa-icon [icon]="faInfoCircle" daffSuffix></fa-icon> | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 3 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
<daff-tab> | ||
<daff-tab-label> | ||
Tab 4 | ||
<fa-icon [icon]="faInfoCircle" daffSuffix></fa-icon> | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 4 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
<daff-tab id="tab-5"> | ||
<daff-tab-label> | ||
Tab 5 | ||
<fa-icon [icon]="faInfoCircle" daffSuffix></fa-icon> | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 5 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
</daff-tabs> |
7 changes: 7 additions & 0 deletions
7
libs/design/tabs/examples/src/custom-select-tabs/custom-select-tabs.component.scss
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,7 @@ | ||
.custom-select-tabs { | ||
&__buttons { | ||
display: flex; | ||
gap: 8px; | ||
margin: 0 0 16px; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
libs/design/tabs/examples/src/custom-select-tabs/custom-select-tabs.component.ts
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,42 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
ViewChild, | ||
} from '@angular/core'; | ||
import { FaIconComponent } from '@fortawesome/angular-fontawesome'; | ||
import { faInfoCircle } from '@fortawesome/free-solid-svg-icons'; | ||
|
||
import { DAFF_BUTTON_COMPONENTS } from '@daffodil/design/button'; | ||
import { | ||
DAFF_TABS_COMPONENTS, | ||
DaffTabsComponent, | ||
} from '@daffodil/design/tabs'; | ||
|
||
@Component({ | ||
// eslint-disable-next-line @angular-eslint/component-selector | ||
selector: 'custom-select-tabs', | ||
templateUrl: './custom-select-tabs.component.html', | ||
styleUrl: './custom-select-tabs.component.scss', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [ | ||
DAFF_TABS_COMPONENTS, | ||
DAFF_BUTTON_COMPONENTS, | ||
FaIconComponent, | ||
], | ||
}) | ||
export class CustomSelectTabsComponent { | ||
faInfoCircle = faInfoCircle; | ||
|
||
selectedTab = 'tab-3'; | ||
|
||
@ViewChild(DaffTabsComponent) _tab: DaffTabsComponent; | ||
|
||
selectTabThree() { | ||
this._tab.select('tab-3'); | ||
} | ||
|
||
selectTabFive() { | ||
this._tab.select('tab-5'); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
libs/design/tabs/examples/src/disabled-tabs/disabled-tabs.component.html
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,53 @@ | ||
<daff-tabs aria-label="List of tabs"> | ||
<daff-tab> | ||
<daff-tab-label> | ||
<fa-icon [icon]="faInfoCircle" daffPrefix></fa-icon> | ||
Tab 1 | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 1 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
<daff-tab> | ||
<daff-tab-label> | ||
Tab 2 | ||
<fa-icon [icon]="faInfoCircle" daffSuffix></fa-icon> | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 2 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
<daff-tab> | ||
<daff-tab-label> | ||
<fa-icon [icon]="faInfoCircle" daffPrefix></fa-icon> | ||
Tab 3 | ||
<fa-icon [icon]="faInfoCircle" daffSuffix></fa-icon> | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 3 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
<daff-tab> | ||
<daff-tab-label> | ||
Tab 4 | ||
<fa-icon [icon]="faInfoCircle" daffSuffix></fa-icon> | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 4 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
<daff-tab [disabled]="true"> | ||
<daff-tab-label> | ||
Tab 5 | ||
<fa-icon [icon]="faInfoCircle" daffSuffix></fa-icon> | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 5 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
</daff-tabs> |
23 changes: 23 additions & 0 deletions
23
libs/design/tabs/examples/src/disabled-tabs/disabled-tabs.component.ts
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,23 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
} from '@angular/core'; | ||
import { FaIconComponent } from '@fortawesome/angular-fontawesome'; | ||
import { faInfoCircle } from '@fortawesome/free-solid-svg-icons'; | ||
|
||
import { DAFF_TABS_COMPONENTS } from '@daffodil/design/tabs'; | ||
|
||
@Component({ | ||
// eslint-disable-next-line @angular-eslint/component-selector | ||
selector: 'disabled-tabs', | ||
templateUrl: './disabled-tabs.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [ | ||
DAFF_TABS_COMPONENTS, | ||
FaIconComponent, | ||
], | ||
}) | ||
export class DisabledTabsComponent { | ||
faInfoCircle = faInfoCircle; | ||
} |
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 @@ | ||
export * from './public_api'; |
53 changes: 53 additions & 0 deletions
53
libs/design/tabs/examples/src/initially-select-tab/initially-select-tab.component.html
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,53 @@ | ||
<daff-tabs aria-label="List of tabs" [initiallySelected]="'tab-4'"> | ||
<daff-tab> | ||
<daff-tab-label> | ||
<fa-icon [icon]="faInfoCircle" daffPrefix></fa-icon> | ||
Tab 1 | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 1 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
<daff-tab> | ||
<daff-tab-label> | ||
Tab 2 | ||
<fa-icon [icon]="faInfoCircle" daffSuffix></fa-icon> | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 2 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
<daff-tab> | ||
<daff-tab-label> | ||
<fa-icon [icon]="faInfoCircle" daffPrefix></fa-icon> | ||
Tab 3 | ||
<fa-icon [icon]="faInfoCircle" daffSuffix></fa-icon> | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 3 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
<daff-tab id="tab-4"> | ||
<daff-tab-label> | ||
Tab 4 | ||
<fa-icon [icon]="faInfoCircle" daffSuffix></fa-icon> | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 4 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
<daff-tab> | ||
<daff-tab-label> | ||
Tab 5 | ||
<fa-icon [icon]="faInfoCircle" daffSuffix></fa-icon> | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
Tab 5 Panel | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
</daff-tabs> |
Oops, something went wrong.