-
Notifications
You must be signed in to change notification settings - Fork 4
chore: added add-tab-example's (#DS-5231) #1717
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
Open
artembelik
wants to merge
3
commits into
main
Choose a base branch
from
feat/DS-5231
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
37 changes: 37 additions & 0 deletions
37
...ges/docs-examples/components/tabs/tabs-add-tab-vertical/tabs-add-tab-vertical-example.css
This file contains hidden or 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,37 @@ | ||
| :host { | ||
| display: flex; | ||
| width: 100%; | ||
| max-width: 100%; | ||
| height: 250px; | ||
| --tab-nav-selected: var(--kbq-tabs-tab-item-filled-on-background-states-selected-background); | ||
| } | ||
|
|
||
| .example-tab-nav-bar { | ||
| width: 240px; | ||
| } | ||
|
|
||
| .example-tab-link { | ||
| display: inline-block; | ||
| text-align: left; | ||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| } | ||
|
|
||
| .example-tab-close { | ||
| position: absolute; | ||
| right: calc(var(--kbq-tabs-size-tab-item-padding-horizontal) - var(--kbq-tabs-size-tab-item-focus-outline-width)); | ||
| top: 0; | ||
| bottom: 0; | ||
| width: 32px; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: flex-end; | ||
| background: linear-gradient(var(--tab-nav-selected), var(--tab-nav-selected)), var(--kbq-background-bg); | ||
| mask-image: linear-gradient(to right, transparent 0%, black 50%); | ||
| } | ||
|
|
||
| .example-tabs-add-tab-vertical__content { | ||
| flex: 1; | ||
| padding: var(--kbq-size-m); | ||
| overflow: auto; | ||
| } | ||
61 changes: 61 additions & 0 deletions
61
...ages/docs-examples/components/tabs/tabs-add-tab-vertical/tabs-add-tab-vertical-example.ts
This file contains hidden or 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,61 @@ | ||
| import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
| import { KbqButtonModule } from '@koobiq/components/button'; | ||
| import { KbqIconModule } from '@koobiq/components/icon'; | ||
| import { KbqTabsModule } from '@koobiq/components/tabs'; | ||
|
|
||
| /** | ||
| * @title Tabs add tab vertical | ||
| */ | ||
| @Component({ | ||
| selector: 'tabs-add-tab-vertical-example', | ||
| imports: [KbqTabsModule, KbqButtonModule, KbqIconModule], | ||
| template: ` | ||
| <nav kbqTabNavBar vertical class="example-tab-nav-bar" [tabNavPanel]="tabNavPanel"> | ||
| @for (tab of tabs; track tab) { | ||
| <a kbqTabLink class="example-tab-link" [active]="activeTab === tab" (click)="activeTab = tab"> | ||
| {{ tab }} | ||
| @if (activeTab === tab) { | ||
| <div class="example-tab-close"> | ||
| <i | ||
| kbq-icon-button="kbq-xmark-s_16" | ||
| color="contrast-fade" | ||
| (click)="removeTab(tab, $event)" | ||
| ></i> | ||
| </div> | ||
| } | ||
| </a> | ||
| } | ||
| <button color="contrast-fade" kbq-button (click)="addTab()"> | ||
| <i kbq-icon="kbq-plus_16"></i> | ||
| </button> | ||
| </nav> | ||
|
|
||
| <div #tabNavPanel="kbqTabNavPanel" kbqTabNavPanel class="example-tabs-add-tab-vertical__content"> | ||
| Content for {{ activeTab }} | ||
| </div> | ||
| `, | ||
| styleUrls: ['./tabs-add-tab-vertical-example.css'], | ||
| changeDetection: ChangeDetectionStrategy.OnPush | ||
| }) | ||
| export class TabsAddTabVerticalExample { | ||
| protected tabs = ['BruteForce', 'Complex Attack', 'DDoS', 'HIPS alert']; | ||
| protected activeTab = this.tabs[0]; | ||
|
|
||
| protected addTab(): void { | ||
| const newTab = `Tab ${this.tabs.length + 1}`; | ||
|
|
||
| this.tabs = [...this.tabs, newTab]; | ||
| this.activeTab = newTab; | ||
| } | ||
|
|
||
| protected removeTab(tab: string, event: MouseEvent): void { | ||
| event.stopPropagation(); | ||
| const index = this.tabs.indexOf(tab); | ||
|
|
||
| this.tabs = this.tabs.filter((t) => t !== tab); | ||
|
|
||
| if (this.tabs.length > 0) { | ||
| this.activeTab = this.tabs[Math.max(0, index - 1)]; | ||
| } | ||
|
artembelik marked this conversation as resolved.
|
||
| } | ||
| } | ||
23 changes: 23 additions & 0 deletions
23
packages/docs-examples/components/tabs/tabs-add-tab/tabs-add-tab-example.css
This file contains hidden or 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 @@ | ||
| :host { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: var(--kbq-size-l); | ||
| --tab-nav-selected: var(--kbq-tabs-tab-item-filled-on-background-states-selected-background); | ||
| } | ||
|
|
||
| .example-tab-nav-bar { | ||
| overflow: hidden; | ||
| } | ||
|
|
||
| .example-tab-close { | ||
| position: absolute; | ||
| right: calc(var(--kbq-tabs-size-tab-item-padding-horizontal) - var(--kbq-tabs-size-tab-item-focus-outline-width)); | ||
| top: 0; | ||
| bottom: 0; | ||
| width: 32px; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: flex-end; | ||
| background: linear-gradient(var(--tab-nav-selected), var(--tab-nav-selected)), var(--kbq-background-bg); | ||
| mask-image: linear-gradient(to right, transparent 0%, black 50%); | ||
| } |
57 changes: 57 additions & 0 deletions
57
packages/docs-examples/components/tabs/tabs-add-tab/tabs-add-tab-example.ts
This file contains hidden or 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,57 @@ | ||
| import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
| import { KbqButtonModule } from '@koobiq/components/button'; | ||
| import { KbqIconModule } from '@koobiq/components/icon'; | ||
| import { KbqTabsModule } from '@koobiq/components/tabs'; | ||
|
|
||
| /** | ||
| * @title Tabs add tab | ||
| */ | ||
| @Component({ | ||
| selector: 'tabs-add-tab-example', | ||
| imports: [KbqTabsModule, KbqButtonModule, KbqIconModule], | ||
| template: ` | ||
| <nav kbqTabNavBar class="example-tab-nav-bar"> | ||
| @for (tab of tabs; track tab) { | ||
| <a kbqTabLink [active]="activeTab === tab" (click)="activeTab = tab"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. нажатие по enter/space тоже должно менять activeTab в соответствии со спекой |
||
| {{ tab }} | ||
| @if (activeTab === tab) { | ||
| <div class="example-tab-close"> | ||
| <i | ||
| kbq-icon-button="kbq-xmark-s_16" | ||
| color="contrast-fade" | ||
| (click)="removeTab(tab, $event)" | ||
| ></i> | ||
| </div> | ||
| } | ||
| </a> | ||
| } | ||
| </nav> | ||
| <button color="contrast" kbqStyle="transparent" kbq-button (click)="addTab()"> | ||
| <i kbq-icon="kbq-plus_16"></i> | ||
| </button> | ||
| `, | ||
| styleUrls: ['./tabs-add-tab-example.css'], | ||
| changeDetection: ChangeDetectionStrategy.OnPush | ||
| }) | ||
| export class TabsAddTabExample { | ||
| protected tabs = ['BruteForce', 'Complex Attack', 'DDoS', 'HIPS alert']; | ||
| protected activeTab = this.tabs[0]; | ||
|
|
||
| protected addTab(): void { | ||
| const newTab = `Tab ${this.tabs.length + 1}`; | ||
|
|
||
| this.tabs = [...this.tabs, newTab]; | ||
| this.activeTab = newTab; | ||
| } | ||
|
|
||
| protected removeTab(tab: string, event: MouseEvent): void { | ||
| event.stopPropagation(); | ||
| const index = this.tabs.indexOf(tab); | ||
|
|
||
| this.tabs = this.tabs.filter((t) => t !== tab); | ||
|
|
||
| if (this.tabs.length > 0) { | ||
| this.activeTab = this.tabs[Math.max(0, index - 1)]; | ||
| } | ||
|
artembelik marked this conversation as resolved.
|
||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Может сделать это как один из дефолтных вариантов табов вместо реализации в примере? Стили реализовать внутри компоненты , а обработчики addTab/removeTab оставить пользователям
В #1696 занес стили из примеров под новый тип button-toggle-group, можно сделать аналогично