Skip to content

Commit

Permalink
fix(kit): InputRange case with very long placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
nsbarsukov committed Apr 11, 2022
1 parent 459eaae commit 67b735a
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,37 @@ describe('InputRange', () => {
});
});
});

describe('Very long placeholder', () => {
it('basic case', () => {
cy.viewport('macbook-11');
cy.tuiVisit(`${INPUT_RANGE_PAGE_URL}/API`);

cy.get('#demoContent')
.should('be.visible')
.matchImageSnapshot('01-long-placeholder_basic');
});

it('with `leftValueContent` and `rightValueContent`', () => {
cy.viewport('iphone-x');
cy.tuiVisit(
`${INPUT_RANGE_PAGE_URL}/API?rightValueContent=TOP%20SECRET&leftValueContent=I%20am%20a%20leftValueContent`,
);

cy.get('#demoContent')
.should('be.visible')
.matchImageSnapshot('02-long-placeholder_value-content');
});

it('with `pluralize`', () => {
cy.viewport('iphone-8');
cy.tuiVisit(`${INPUT_RANGE_PAGE_URL}/API?pluralize$=1`);

cy.get('#demoContent')
.should('be.visible')
.matchImageSnapshot('03-long-placeholder_pluralize');
});
});
});

function initializeAliases(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@

.control {
flex: 1;
min-width: 0;
margin-right: 1.5rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@
[maxLabel]="maxLabel"
[segmentsPluralize]="segmentsPluralize"
>
Range
Just a very long label. Don't afraid it does not overflow
the wrapper, the label is just cut off with ellipsis when it
does not fit the wrapper.
</tui-input-range>
</ng-template>
</tui-doc-demo>
Expand Down
24 changes: 19 additions & 5 deletions projects/kit/components/input-range/input-range.style.less
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
.t-wrapper {
display: flex;
position: relative;
}

.t-text-input {
flex: 1;
.t-left {
width: 100%;
}

.t-right {
position: absolute;
right: 0;
top: 0;
display: flex;
width: 50%;
height: 100%;
text-align: right;

&:last-of-type {
text-align: right;
& .t-text-input {
flex: 1;
}
}

.t-text-input {
text-align: inherit;
}

.t-pluralize-right {
display: flex;
align-items: center;
Expand Down
68 changes: 35 additions & 33 deletions projects/kit/components/input-range/input-range.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
>
<tui-input-number
tuiTextfieldAppearance="none"
class="t-text-input"
class="t-left t-text-input"
[min]="min"
[max]="value[1]"
[precision]="precision"
Expand All @@ -35,39 +35,41 @@
></div>
</tui-input-number>

<tui-input-number
tuiTextfieldAppearance="none"
class="t-text-input"
[min]="value[0]"
[max]="max"
[precision]="precision"
[decimal]="decimal"
[disabled]="computedDisabled"
[readOnly]="readOnly"
[tuiTextfieldSize]="computedSize"
[tuiTextfieldLabelOutside]="legacyLabelOutside"
[ngModel]="value[1]"
(ngModelChange)="onInputRight($event)"
(focusedChange)="onTextInputFocused($event, true)"
(keydown.arrowUp)="changeByStep($event, [0, 1])"
(keydown.arrowDown)="changeByStep($event, [0, -1])"
>
<div
*ngIf="showRightValueContent"
polymorpheus-outlet
[content]="maxLabel ? legacyMaxLabel : rightValueContent"
[context]="{$implicit: value[1]}"
></div>
</tui-input-number>
<div class="t-right">
<tui-input-number
tuiTextfieldAppearance="none"
class="t-text-input"
[min]="value[0]"
[max]="max"
[precision]="precision"
[decimal]="decimal"
[disabled]="computedDisabled"
[readOnly]="readOnly"
[tuiTextfieldSize]="computedSize"
[tuiTextfieldLabelOutside]="legacyLabelOutside"
[ngModel]="value[1]"
(ngModelChange)="onInputRight($event)"
(focusedChange)="onTextInputFocused($event, true)"
(keydown.arrowUp)="changeByStep($event, [0, 1])"
(keydown.arrowDown)="changeByStep($event, [0, -1])"
>
<div
*ngIf="showRightValueContent"
polymorpheus-outlet
[content]="maxLabel ? legacyMaxLabel : rightValueContent"
[context]="{$implicit: value[1]}"
></div>
</tui-input-number>

<!-- TODO replace by postfix of the right InputNumber (after fix https://github.com/Tinkoff/taiga-ui/issues/1193) -->
<span
*ngIf="!showRightValueContent && pluralizeMap"
automation-id="tui-input-range__pluralize-right"
class="t-pluralize-right"
>
&nbsp;{{value[1] | i18nPlural: pluralizeMap}}
</span>
<!-- TODO replace by postfix of the right InputNumber (after fix https://github.com/Tinkoff/taiga-ui/issues/1193) -->
<span
*ngIf="!showRightValueContent && pluralizeMap"
automation-id="tui-input-range__pluralize-right"
class="t-pluralize-right"
>
&nbsp;{{value[1] | i18nPlural: pluralizeMap}}
</span>
</div>

<tui-range
class="t-slider"
Expand Down

0 comments on commit 67b735a

Please sign in to comment.