mirror of https://github.com/ghostfolio/ghostfolio
Browse Source
* Introduce ActivityTypeComponent with localized label * Update changelogpull/2377/head
committed by
GitHub
9 changed files with 122 additions and 89 deletions
@ -0,0 +1,32 @@ |
|||||
|
<div |
||||
|
class="d-inline-flex p-1 activity-type-badge" |
||||
|
[ngClass]="{ |
||||
|
buy: activityType === 'BUY', |
||||
|
dividend: activityType === 'DIVIDEND', |
||||
|
fee: activityType === 'FEE', |
||||
|
interest: activityType === 'INTEREST', |
||||
|
item: activityType === 'ITEM', |
||||
|
liability: activityType === 'LIABILITY', |
||||
|
sell: activityType === 'SELL' |
||||
|
}" |
||||
|
> |
||||
|
<ion-icon |
||||
|
*ngIf="activityType === 'BUY'" |
||||
|
name="arrow-up-circle-outline" |
||||
|
></ion-icon> |
||||
|
<ion-icon |
||||
|
*ngIf="activityType === 'DIVIDEND' || activityType === 'INTEREST'" |
||||
|
name="add-circle-outline" |
||||
|
></ion-icon> |
||||
|
<ion-icon *ngIf="activityType === 'FEE'" name="hammer-outline"></ion-icon> |
||||
|
<ion-icon *ngIf="activityType === 'ITEM'" name="cube-outline"></ion-icon> |
||||
|
<ion-icon |
||||
|
*ngIf="activityType === 'LIABILITY'" |
||||
|
name="flame-outline" |
||||
|
></ion-icon> |
||||
|
<ion-icon |
||||
|
*ngIf="activityType === 'SELL'" |
||||
|
name="arrow-down-circle-outline" |
||||
|
></ion-icon> |
||||
|
<span class="d-none d-lg-block mx-1">{{ activityTypeLabel }}</span> |
||||
|
</div> |
@ -0,0 +1,47 @@ |
|||||
|
:host { |
||||
|
display: block; |
||||
|
|
||||
|
.activity-type-badge { |
||||
|
background-color: rgba(var(--palette-foreground-text), 0.05); |
||||
|
border-radius: 1rem; |
||||
|
line-height: 1em; |
||||
|
|
||||
|
ion-icon { |
||||
|
font-size: 1rem; |
||||
|
} |
||||
|
|
||||
|
&.buy { |
||||
|
color: var(--green); |
||||
|
} |
||||
|
|
||||
|
&.dividend { |
||||
|
color: var(--blue); |
||||
|
} |
||||
|
|
||||
|
&.fee { |
||||
|
color: var(--gray); |
||||
|
} |
||||
|
|
||||
|
&.interest { |
||||
|
color: var(--cyan); |
||||
|
} |
||||
|
|
||||
|
&.item { |
||||
|
color: var(--purple); |
||||
|
} |
||||
|
|
||||
|
&.liability { |
||||
|
color: var(--red); |
||||
|
} |
||||
|
|
||||
|
&.sell { |
||||
|
color: var(--orange); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
:host-context(.is-dark-theme) { |
||||
|
.activity-type-badge { |
||||
|
background-color: rgba(var(--palette-foreground-text-dark), 0.1) !important; |
||||
|
} |
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
import { |
||||
|
ChangeDetectionStrategy, |
||||
|
Component, |
||||
|
Input, |
||||
|
OnChanges |
||||
|
} from '@angular/core'; |
||||
|
import { translate } from '@ghostfolio/ui/i18n'; |
||||
|
import { Type as ActivityType } from '@prisma/client'; |
||||
|
|
||||
|
@Component({ |
||||
|
changeDetection: ChangeDetectionStrategy.OnPush, |
||||
|
selector: 'gf-activity-type', |
||||
|
styleUrls: ['./activity-type.component.scss'], |
||||
|
templateUrl: './activity-type.component.html' |
||||
|
}) |
||||
|
export class ActivityTypeComponent implements OnChanges { |
||||
|
@Input() activityType: ActivityType; |
||||
|
|
||||
|
public activityTypeLabel: string; |
||||
|
|
||||
|
public constructor() {} |
||||
|
|
||||
|
public ngOnChanges() { |
||||
|
this.activityTypeLabel = translate(this.activityType); |
||||
|
} |
||||
|
} |
@ -0,0 +1,12 @@ |
|||||
|
import { CommonModule } from '@angular/common'; |
||||
|
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; |
||||
|
|
||||
|
import { ActivityTypeComponent } from './activity-type.component'; |
||||
|
|
||||
|
@NgModule({ |
||||
|
declarations: [ActivityTypeComponent], |
||||
|
exports: [ActivityTypeComponent], |
||||
|
imports: [CommonModule], |
||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA] |
||||
|
}) |
||||
|
export class GfActivityTypeModule {} |
@ -0,0 +1 @@ |
|||||
|
export * from './activity-type.module'; |
Loading…
Reference in new issue