-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tabs): add actions section (#1620)
Please check if your PR fulfills the following requirements: - [ ] Tests for the changes have been added (for bug fixes / features) - [ ] Docs have been added / updated (for bug fixes / features) - [ ] If applicable, have a visual design approval What kind of change does this PR introduce? 1: Slot which is being projected inside the header so basically `<clr-tabs-actions>Whatever content you put here</clr-tabs-actions>`. 2: Directive `clrTabsAction` which you put on the element you want to be interactable and part of the navigation of tabs ( arrows ). <!-- Please check the one that applies to this PR using "x". --> - [ ] Bugfix - [X] Feature - [ ] Code style update (formatting, local variables) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] CI related changes - [ ] Documentation content changes - [ ] Other... Please describe: <!-- Please describe the current behavior that you are modifying, or link to a relevant issue. --> Issue Number: CDE-2391 - [ ] Yes - [X] No <!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. --> --------- Co-authored-by: GitHub <[email protected]>
- Loading branch information
Showing
31 changed files
with
529 additions
and
93 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,99 @@ | ||
/* | ||
* Copyright (c) 2016-2024 Broadcom. All Rights Reserved. | ||
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. | ||
* This software is released under MIT license. | ||
* The full license information can be found in LICENSE in the root directory of this project. | ||
*/ | ||
|
||
import { ClrTabs, ClrTabsModule } from '@clr/angular'; | ||
import { moduleMetadata, StoryFn, StoryObj } from '@storybook/angular'; | ||
|
||
import { TabsLayout } from '../../../projects/angular/src/layout/tabs/enums/tabs-layout.enum'; | ||
|
||
export default { | ||
title: 'Tabs/Tabs Actions', | ||
decorators: [ | ||
moduleMetadata({ | ||
imports: [ClrTabsModule], | ||
}), | ||
], | ||
component: ClrTabs, | ||
argTypes: { | ||
// inputs | ||
clrLayout: { control: 'inline-radio', options: TabsLayout }, | ||
tabsActionsPosition: { control: 'inline-radio', options: ['left', 'right'] }, | ||
// methods | ||
closeOnEscapeKey: { control: { disable: true }, table: { disable: true } }, | ||
closeOnFocusOut: { control: { disable: true }, table: { disable: true } }, | ||
closeOnOutsideClick: { control: { disable: true }, table: { disable: true } }, | ||
openOverflowOnFocus: { control: { disable: true }, table: { disable: true } }, | ||
resetKeyFocusCurrentToActive: { control: { disable: true }, table: { disable: true } }, | ||
toggleOverflowOnClick: { control: { disable: true }, table: { disable: true } }, | ||
toggleOverflowOnPosition: { control: { disable: true }, table: { disable: true } }, | ||
// story helpers | ||
createArray: { control: { disable: true }, table: { disable: true } }, | ||
clickTabAction: { control: { disable: true }, table: { disable: true } }, | ||
tabCount: { control: { type: 'number', min: 1, max: 100 } }, | ||
activeTab: { control: { type: 'number', min: 1, max: 100 } }, | ||
}, | ||
args: { | ||
// inputs | ||
clrLayout: TabsLayout.HORIZONTAL, | ||
tabsActionsPosition: 'right', | ||
// story helpers | ||
createArray: n => new Array(n), | ||
clickTabAction: () => alert('Tab action clicked!'), | ||
tabCount: 4, | ||
activeTab: 1, | ||
title: 'Tab', | ||
content: 'Tab Content', | ||
}, | ||
}; | ||
|
||
const tabsTemplate: StoryFn = args => ({ | ||
template: ` | ||
<clr-tabs [clrLayout]="clrLayout"> | ||
<clr-tabs-actions [position]="tabsActionsPosition"> | ||
<button class="btn btn-icon btn-link" (click)="clickTabAction()" clrTabAction> | ||
<cds-icon shape="plus"></cds-icon> | ||
Tab Action | ||
</button> | ||
</clr-tabs-actions> | ||
<clr-tab *ngFor="let _ of createArray(tabCount); let i = index"> | ||
<button clrTabLink>{{ title }} {{ i + 1 }}</button> | ||
<clr-tab-content *clrIfActive="activeTab === i + 1"> | ||
<p>{{ content }} {{ i + 1 }}</p> | ||
</clr-tab-content> | ||
</clr-tab> | ||
</clr-tabs> | ||
`, | ||
props: { ...args }, | ||
}); | ||
|
||
export const Tabs: StoryObj = { | ||
render: tabsTemplate, | ||
}; | ||
|
||
export const VerticalTabs: StoryObj = { | ||
render: tabsTemplate, | ||
args: { | ||
tabsActionsPosition: 'left', | ||
clrLayout: TabsLayout.VERTICAL, | ||
}, | ||
}; | ||
|
||
export const TabsResponsive: StoryObj = { | ||
render: tabsTemplate, | ||
parameters: { | ||
viewport: { | ||
defaultViewport: 'large', | ||
}, | ||
}, | ||
}; | ||
|
||
export const TabsActionsLeft: StoryObj = { | ||
render: tabsTemplate, | ||
args: { | ||
tabsActionsPosition: 'left', | ||
}, | ||
}; |
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
Oops, something went wrong.