Skip to content
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

feat(kit): Badge add overflow elipsis and title #2806

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions projects/kit/components/badge/badge.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,8 @@ export class TuiBadgeComponent {
get isEmpty(): boolean {
return this.value === ``;
}

titleText({offsetWidth, scrollWidth}: HTMLElement): string {
splincode marked this conversation as resolved.
Show resolved Hide resolved
return offsetWidth < scrollWidth ? this.outputValue : ``;
}
}
3 changes: 2 additions & 1 deletion projects/kit/components/badge/badge.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {TuiResizeModule} from '@taiga-ui/cdk';

import {TuiBadgeComponent} from './badge.component';

@NgModule({
imports: [CommonModule],
imports: [CommonModule, TuiResizeModule],
declarations: [TuiBadgeComponent],
exports: [TuiBadgeComponent],
})
Expand Down
15 changes: 10 additions & 5 deletions projects/kit/components/badge/badge.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
white-space: nowrap;
overflow: hidden;
vertical-align: middle;
max-width: 100%;

&:after {
.transition(background);
Expand Down Expand Up @@ -236,7 +237,7 @@
height: 1rem;
min-width: 1rem;

.left-content:before {
.t-left-content:before {
width: 0.34375rem;
height: 0.34375rem;
}
Expand All @@ -247,7 +248,7 @@
height: 1.25rem;
min-width: 1.25rem;

.left-content:before {
.t-left-content:before {
width: 0.25rem;
height: 0.25rem;
}
Expand All @@ -264,15 +265,15 @@
line-height: var(--tui-height-s);
min-width: var(--tui-height-s);

.left-content:before {
.t-left-content:before {
margin: 0 0.5rem 0 0;
width: 0.5rem;
height: 0.5rem;
}
}

&._empty-value {
.left-content {
.t-left-content {
margin: 0 -0.25rem;

&:before {
Expand All @@ -282,7 +283,7 @@
}
}

.left-content {
.t-left-content {
display: none;
color: var(--left-content-color);
line-height: 0;
Expand Down Expand Up @@ -314,3 +315,7 @@
border-radius: 100%;
}
}

.t-text {
.text-overflow();
}
11 changes: 9 additions & 2 deletions projects/kit/components/badge/badge.template.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
<span class="left-content"><ng-content></ng-content></span>
{{ outputValue }}
<span class="t-left-content"><ng-content></ng-content></span>
<span
#text
class="t-text"
[title]="titleText(text)"
(tuiResize)="(0)"
>
{{ outputValue }}
</span>