Skip to content

Add badge component#50

Open
AndreyMorozow wants to merge 14 commits into
developfrom
feature/32-badge
Open

Add badge component#50
AndreyMorozow wants to merge 14 commits into
developfrom
feature/32-badge

Conversation

@AndreyMorozow
Copy link
Copy Markdown
Contributor

@feerzlay feerzlay changed the base branch from develop to feature/28-avatar March 12, 2021 09:42
@feerzlay feerzlay changed the title 32 badge Add badge component Mar 12, 2021
@feerzlay feerzlay added the enhancement New feature or request label Mar 12, 2021
Comment thread projects/elonkit/src/theme.scss Outdated
Comment thread projects/elonkit/src/ui/badge/badge.component.ts
Comment thread projects/elonkit/src/ui/badge/badge.component.ts

public ngOnInit() {
this._elementRef.nativeElement.style.setProperty('--right', `${-this.right + 1 + `px`}`);
this._elementRef.nativeElement.style.setProperty('--bottom', `${-this.bottom + 1 + `px`}`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Две стороны потерялись

Comment thread projects/elonkit/src/ui/badge/badge.component.html Outdated
Comment thread projects/elonkit/src/ui/badge/badge.types.ts Outdated
Comment thread projects/elonkit/src/ui/badge/badge.component.ts Outdated
Comment thread projects/elonkit/src/theme.scss Outdated
@@ -4,6 +4,7 @@
@import './ui/paginator/paginator.component.theme';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вообще этого файла в девелорпе уже нет, может в ветке аватара затисался?

</div>
</div>
<div #childElement>
<ng-content select="[es-role=child]"></ng-content>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это можно просто без select оставить

<div class="es-badge__content"
[ngStyle]="stylesObject()"
>
<ng-content select="[es-role=icon]"></ng-content>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше без префикса es-, просто <ng-content select="[role=icon]"></ng-content>

[ngStyle]="stylesObject()"
>
<ng-content select="[es-role=icon]"></ng-content>
<div data-testid="badge" class="es-caption es-badge__count">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

es-badge__count лишний видимо? А то в стилях не используется

offsetHorizontal?: number;
}

export type ESBadgePositionVariant =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не нравится это дублирование. Можно убрать этот union, ESBadgePositions переименовать в ESBadgePosition, а когда нужно получить union то делать так - position?: ${ESBadgePosition};.

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { MatIconModule } from '@angular/material/icon';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ему не нужно импортировать этот модуль, не использует же напрямую

}
this.setOffsets();
this.setStyles();
this.changeDetector.markForCheck();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вообще markForCheck иногда может долго думать и тогда лучше detectChanges делать

switch (this.position) {
case this.badgePosition.AboveAfter: {
this.positions = { 'top.px': 0, 'right.px': -1 };
this.offsetVertical = childElement - transparent;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему оно влияет на инпуты? Эти offset должны просто к прибавляться к / вычитаться из позиции, этакая небольшая коррекция.
А если нужны для позиции для маски то можно прямо тут их задавать, не сохраняя в промежуточную переменную

* @internal
* @ignore
*/
public stylesObject() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно ли это хранить в поле а не каждый раз в темплейте деграть функцию?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@feerzlay feerzlay force-pushed the feature/28-avatar branch from fbf8bfc to 0639efb Compare March 31, 2021 15:02
Base automatically changed from feature/28-avatar to develop March 31, 2021 15:08
public ngAfterContentInit() {
this.setAvatarsIndex(this.avatars);
this.avatars.changes.pipe(takeUntil(this.destroyed$)).subscribe((avatars) => {
if (avatars) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше вынести в filter

* @internal
* @ignore
*/
public destroyed$ = new Subject();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может нам использовать стороннюю библиотеку https://github.com/ngneat/until-destroy для этих случаев? Мне кажется, не лучший вариант писать такой Subject каждый раз

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А как по мне зачем тащить либу, которая возможно на проекте использоваться и не будет. Да и такой вариант с Subject не сильно больше кода требует.

return this._typography;
}
public set typography(value: string) {
this._typography = value || 'es-subtitle-2';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Какое-то неочевидное поведение. Я думаю, лучше сделать в get return this._typography || 'es-subtitle-2'

* Defines badge background color.
*/
@Input()
public get color(): string {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Думаю, здесь можно обойтись без set/get

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants