-
Notifications
You must be signed in to change notification settings - Fork 4
fix(filter-bar): preserve pipe label width (#DS-5588) #2064
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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
657e9e7
fix(filter-bar): preserve pipe label width (#DS-5588)
rmnturov 0b91663
test(filter-bar): cover multi-select pipe truncation (#DS-5588)
rmnturov fa37b58
test(filter-bar): update states screenshots (#DS-5588)
rmnturov 56d85e5
chore(filter-bar): resolve main conflicts (#DS-5588)
rmnturov 81dce2f
fix(filter-bar): correct pipe truncation layout (#DS-5588)
rmnturov a753e99
test: updated e2e snapshots
rmnturov ab77ddb
fix(filter-bar): remove unused pipe title refs (#DS-5588)
rmnturov 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
27 changes: 27 additions & 0 deletions
27
packages/components-dev/filter-bar/pipe-truncation-example.html
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,27 @@ | ||
| <section class="dev-filter-bar-pipe-truncation" data-testid="filterBarPipeTruncation"> | ||
| <div> | ||
| <h2 class="kbq-h2">Обрезка названия и значения пайпа</h2> | ||
| <p>Короткий лейбл сохраняет место для себя, даже если значение длинное.</p> | ||
| </div> | ||
|
|
||
| @for (group of groups; track group.type) { | ||
| <section class="dev-filter-bar-pipe-truncation__group" [attr.data-testid]="group.title"> | ||
| <h3 class="kbq-h3">{{ group.title }}</h3> | ||
|
|
||
| <div class="dev-filter-bar-pipe-truncation__grid"> | ||
| @for (item of group.cases; track item.id) { | ||
| <article class="dev-filter-bar-pipe-truncation__case" [attr.data-testid]="item.id"> | ||
| <div class="dev-filter-bar-pipe-truncation__label">{{ item.label }}</div> | ||
| <div class="dev-filter-bar-pipe-truncation__bar"> | ||
| <kbq-filter-bar [filter]="item.filter" [pipeTemplates]="[item.template]"> | ||
| @for (pipe of item.filter.pipes; track pipe) { | ||
| <ng-container *kbqPipe="pipe" /> | ||
| } | ||
| </kbq-filter-bar> | ||
| </div> | ||
| </article> | ||
| } | ||
| </div> | ||
| </section> | ||
| } | ||
| </section> |
36 changes: 36 additions & 0 deletions
36
packages/components-dev/filter-bar/pipe-truncation-example.scss
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,36 @@ | ||
| .dev-filter-bar-pipe-truncation { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: var(--kbq-size-xl); | ||
| } | ||
|
|
||
| .dev-filter-bar-pipe-truncation__group { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: var(--kbq-size-m); | ||
| } | ||
|
|
||
| .dev-filter-bar-pipe-truncation__grid { | ||
| display: grid; | ||
| grid-template-columns: repeat(2, minmax(280px, 360px)); | ||
| gap: var(--kbq-size-l) var(--kbq-size-xl); | ||
| } | ||
|
|
||
| .dev-filter-bar-pipe-truncation__case { | ||
| min-width: 0; | ||
| } | ||
|
|
||
| .dev-filter-bar-pipe-truncation__label { | ||
| margin-bottom: var(--kbq-size-xs); | ||
| } | ||
|
|
||
| .dev-filter-bar-pipe-truncation__bar { | ||
| width: 360px; | ||
| max-width: 100%; | ||
| } | ||
|
|
||
| @media (max-width: 760px) { | ||
| .dev-filter-bar-pipe-truncation__grid { | ||
| grid-template-columns: minmax(280px, 360px); | ||
| } | ||
| } |
220 changes: 220 additions & 0 deletions
220
packages/components-dev/filter-bar/pipe-truncation-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,220 @@ | ||
| import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
| import { | ||
| KbqFilter, | ||
| KbqFilterBarModule, | ||
| KbqPipeTemplate, | ||
| KbqPipeTypes, | ||
| KbqSelectValue | ||
| } from '@koobiq/components/filter-bar'; | ||
|
|
||
| type SelectPipeType = KbqPipeTypes.Select | KbqPipeTypes.MultiSelect; | ||
|
|
||
| type PipeTruncationType = SelectPipeType | KbqPipeTypes.Text; | ||
|
|
||
| interface PipeTruncationCase { | ||
| id: string; | ||
| label: string; | ||
| filter: KbqFilter; | ||
| template: KbqPipeTemplate; | ||
| } | ||
|
|
||
| interface PipeTruncationGroup { | ||
| title: string; | ||
| type: PipeTruncationType; | ||
| cases: PipeTruncationCase[]; | ||
| } | ||
|
|
||
| const SHORT_OPTION: KbqSelectValue = { name: 'Файл', value: 'short', id: 'short' }; | ||
| const MEDIUM_OPTION: KbqSelectValue = { name: 'Отдел безопасности', value: 'medium', id: 'medium' }; | ||
| const LONG_OPTION: KbqSelectValue = { | ||
| name: 'Исходный код и развернутое приложение из внешнего репозитория', | ||
| value: 'long', | ||
| id: 'long' | ||
| }; | ||
| const OTHER_OPTION: KbqSelectValue = { name: 'Прочее', value: 'other', id: 'other' }; | ||
|
|
||
| const SHORT_NAME = 'Тип'; | ||
| const MEDIUM_NAME = 'Ответственный отдел'; | ||
| const LONG_NAME = 'Источник исходного кода и развернутое приложение'; | ||
| const SHORT_TEXT_VALUE = 'Файл'; | ||
| const MEDIUM_TEXT_VALUE = MEDIUM_OPTION.name; | ||
| const LONG_TEXT_VALUE = LONG_OPTION.name; | ||
|
|
||
| function createPipeTruncationCase( | ||
| type: PipeTruncationType, | ||
| id: string, | ||
| label: string, | ||
| name: string, | ||
| selectedValue: KbqSelectValue | KbqSelectValue[] | string | null, | ||
| options: KbqSelectValue[] = [SHORT_OPTION, MEDIUM_OPTION, LONG_OPTION], | ||
| selectedAllEqualsSelectedNothing?: boolean | ||
| ): PipeTruncationCase { | ||
| const value = selectedValue | ||
| ? type === KbqPipeTypes.MultiSelect | ||
| ? Array.isArray(selectedValue) | ||
| ? selectedValue | ||
| : [selectedValue] | ||
| : selectedValue | ||
| : null; | ||
|
|
||
| return { | ||
| id, | ||
| label, | ||
| filter: { | ||
| name: id, | ||
| readonly: false, | ||
| disabled: false, | ||
| changed: false, | ||
| saved: false, | ||
| pipes: [ | ||
| { | ||
| id, | ||
| name, | ||
| type, | ||
| value, | ||
| cleanable: selectedValue !== null, | ||
| removable: false, | ||
| disabled: false, | ||
| selectedAllEqualsSelectedNothing | ||
| } | ||
| ] | ||
| }, | ||
| template: { | ||
| id, | ||
| name, | ||
| type, | ||
| ...(type === KbqPipeTypes.Text ? {} : { values: options }), | ||
| cleanable: true, | ||
| removable: false, | ||
| disabled: false | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| function createPipeTruncationCases(type: PipeTruncationType): PipeTruncationCase[] { | ||
| const typeName = type; | ||
|
|
||
| if (type === KbqPipeTypes.Text) { | ||
| return [ | ||
| createPipeTruncationCase( | ||
| type, | ||
| 'text-short-name-short-value', | ||
| 'Короткое название + короткое значение', | ||
| SHORT_NAME, | ||
| SHORT_TEXT_VALUE | ||
| ), | ||
| createPipeTruncationCase( | ||
| type, | ||
| 'text-medium-name-medium-value', | ||
| 'Название средней длины + значение средней длины', | ||
| MEDIUM_NAME, | ||
| MEDIUM_TEXT_VALUE | ||
| ), | ||
| createPipeTruncationCase( | ||
| type, | ||
| 'text-short-name-long-value', | ||
| 'Короткое название + длинное значение', | ||
| SHORT_NAME, | ||
| LONG_TEXT_VALUE | ||
| ), | ||
| createPipeTruncationCase( | ||
| type, | ||
| 'text-long-name-short-value', | ||
| 'Длинное название + короткое значение', | ||
| LONG_NAME, | ||
| SHORT_TEXT_VALUE | ||
| ), | ||
| createPipeTruncationCase( | ||
| type, | ||
| 'text-long-name-long-value', | ||
| 'Длинное название + длинное значение', | ||
| LONG_NAME, | ||
| LONG_TEXT_VALUE | ||
| ) | ||
| ]; | ||
| } | ||
|
|
||
| return [ | ||
| createPipeTruncationCase( | ||
| type, | ||
| `${typeName}-short-name-short-value`, | ||
| 'Короткое название + короткое значение', | ||
| SHORT_NAME, | ||
| SHORT_OPTION | ||
| ), | ||
| createPipeTruncationCase( | ||
| type, | ||
| `${typeName}-medium-name-medium-value`, | ||
| 'Название средней длины + значение средней длины', | ||
| MEDIUM_NAME, | ||
| MEDIUM_OPTION | ||
| ), | ||
| createPipeTruncationCase( | ||
| type, | ||
| `${typeName}-short-name-long-value`, | ||
| 'Короткое название + длинное значение', | ||
| SHORT_NAME, | ||
| LONG_OPTION | ||
| ), | ||
| createPipeTruncationCase( | ||
| type, | ||
| `${typeName}-long-name-short-value`, | ||
| 'Длинное название + короткое значение', | ||
| LONG_NAME, | ||
| SHORT_OPTION | ||
| ), | ||
| createPipeTruncationCase( | ||
| type, | ||
| `${typeName}-long-name-long-value`, | ||
| 'Длинное название + длинное значение', | ||
| LONG_NAME, | ||
| LONG_OPTION | ||
| ), | ||
| ...(type === KbqPipeTypes.MultiSelect ? [ | ||
| createPipeTruncationCase( | ||
| type, | ||
| `${typeName}-long-name-two-values`, | ||
| 'Длинное название + 2 выбранные опции', | ||
| LONG_NAME, | ||
| [SHORT_OPTION, LONG_OPTION], | ||
| [SHORT_OPTION, LONG_OPTION, OTHER_OPTION], | ||
| false | ||
| ) | ||
| ] : []), | ||
| createPipeTruncationCase( | ||
| type, | ||
| `${typeName}-empty-short-name`, | ||
| 'Пустой пайп + короткое название', | ||
| SHORT_NAME, | ||
| null | ||
| ), | ||
| createPipeTruncationCase(type, `${typeName}-empty-long-name`, 'Пустой пайп + длинное название', LONG_NAME, null) | ||
| ]; | ||
| } | ||
|
|
||
| @Component({ | ||
| selector: 'dev-filter-bar-pipe-truncation-example', | ||
| imports: [KbqFilterBarModule], | ||
| templateUrl: './pipe-truncation-example.html', | ||
| styleUrls: ['./pipe-truncation-example.scss'], | ||
| changeDetection: ChangeDetectionStrategy.OnPush | ||
| }) | ||
| export class DevFilterBarPipeTruncationExample { | ||
| readonly groups: PipeTruncationGroup[] = [ | ||
| { | ||
| title: 'Select', | ||
| type: KbqPipeTypes.Select, | ||
| cases: createPipeTruncationCases(KbqPipeTypes.Select) | ||
| }, | ||
| { | ||
| title: 'MultiSelect', | ||
| type: KbqPipeTypes.MultiSelect, | ||
| cases: createPipeTruncationCases(KbqPipeTypes.MultiSelect) | ||
| }, | ||
| { | ||
| title: 'Text', | ||
| type: KbqPipeTypes.Text, | ||
| cases: createPipeTruncationCases(KbqPipeTypes.Text) | ||
| } | ||
| ]; | ||
| } |
Binary file modified
BIN
+479 Bytes
(100%)
packages/components/filter-bar/__screenshots__/01-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+455 Bytes
(100%)
packages/components/filter-bar/__screenshots__/01-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.