Browse Source

Format code

pull/332/head
Thomas Kaul 4 years ago
committed by Thomas
parent
commit
38bfb71156
  1. 13
      libs/ui/src/lib/ui.module.ts
  2. 87
      libs/ui/src/lib/value/value.component.html
  3. 5
      libs/ui/src/lib/value/value.component.spec.ts
  4. 15
      libs/ui/src/lib/value/value.component.stories.ts
  5. 2
      libs/ui/src/lib/value/value.component.ts

13
libs/ui/src/lib/ui.module.ts

@ -1,15 +1,12 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { ValueComponent } from './value/value.component';
// import { GfValueModule } from './value/value.module';
@NgModule({
imports: [CommonModule/*, GfValueModule*/],
declarations: [
ValueComponent
],
exports: [
ValueComponent
]
imports: [CommonModule /*, GfValueModule*/],
declarations: [ValueComponent],
exports: [ValueComponent]
})
export class UiModule {}

87
libs/ui/src/lib/value/value.component.html

@ -1,46 +1,45 @@
<ng-container *ngIf="value || value === 0 || value === null">
<div
class="d-flex"
[ngClass]="position === 'end' ? 'justify-content-end' : ''"
>
<ng-container *ngIf="isNumber || value === null">
<div *ngIf="colorizeSign && value > 0" class="mr-1 text-success">+</div>
<div *ngIf="colorizeSign && value < 0" class="mr-1 text-danger">-</div>
<div *ngIf="isPercent" [ngClass]="size === 'medium' ? 'h4 mb-0' : ''">
{{ formattedValue }}%
</div>
<div *ngIf="!isPercent" [ngClass]="size === 'medium' ? 'h4 mb-0' : ''">
<ng-container *ngIf="value === null">
<span class="text-monospace text-muted">***</span>
</ng-container>
<ng-container *ngIf="value !== null">
{{ formattedValue }}
</ng-container>
</div>
<small *ngIf="currency && size === 'medium'" class="ml-1">
{{ currency }}
</small>
<div *ngIf="currency && size !== 'medium'" class="ml-1">
{{ currency }}
</div>
</ng-container>
<ng-container *ngIf="isDate">
<div [ngClass]="size === 'medium' ? 'h4 mb-0' : ''">
{{ formattedDate }}
</div>
</ng-container>
</div>
<small *ngIf="label">
{{ label }}
</small>
</ng-container>
<ngx-skeleton-loader
*ngIf="value === undefined"
animation="pulse"
[theme]="{
height: '1.5rem',
width: '5rem'
}"
></ngx-skeleton-loader>
<div
class="d-flex"
[ngClass]="position === 'end' ? 'justify-content-end' : ''"
>
<ng-container *ngIf="isNumber || value === null">
<div *ngIf="colorizeSign && value > 0" class="mr-1 text-success">+</div>
<div *ngIf="colorizeSign && value < 0" class="mr-1 text-danger">-</div>
<div *ngIf="isPercent" [ngClass]="size === 'medium' ? 'h4 mb-0' : ''">
{{ formattedValue }}%
</div>
<div *ngIf="!isPercent" [ngClass]="size === 'medium' ? 'h4 mb-0' : ''">
<ng-container *ngIf="value === null">
<span class="text-monospace text-muted">***</span>
</ng-container>
<ng-container *ngIf="value !== null">
{{ formattedValue }}
</ng-container>
</div>
<small *ngIf="currency && size === 'medium'" class="ml-1">
{{ currency }}
</small>
<div *ngIf="currency && size !== 'medium'" class="ml-1">
{{ currency }}
</div>
</ng-container>
<ng-container *ngIf="isDate">
<div [ngClass]="size === 'medium' ? 'h4 mb-0' : ''">
{{ formattedDate }}
</div>
</ng-container>
</div>
<small *ngIf="label">
{{ label }}
</small>
</ng-container>
<ngx-skeleton-loader
*ngIf="value === undefined"
animation="pulse"
[theme]="{
height: '1.5rem',
width: '5rem'
}"
></ngx-skeleton-loader>

5
libs/ui/src/lib/value/value.component.spec.ts

@ -8,9 +8,8 @@ describe('ValueComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ValueComponent ]
})
.compileComponents();
declarations: [ValueComponent]
}).compileComponents();
});
beforeEach(() => {

15
libs/ui/src/lib/value/value.component.stories.ts

@ -1,5 +1,6 @@
import { moduleMetadata, Story, Meta } from '@storybook/angular';
import { Meta, Story, moduleMetadata } from '@storybook/angular';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { ValueComponent } from './value.component';
export default {
@ -7,26 +8,26 @@ export default {
component: ValueComponent,
decorators: [
moduleMetadata({
imports: [NgxSkeletonLoaderModule],
imports: [NgxSkeletonLoaderModule]
})
],
]
} as Meta<ValueComponent>;
const Template: Story<ValueComponent> = (args: ValueComponent) => ({
props: args,
props: args
});
export const Loading = Template.bind({});
Loading.args = {
value: undefined
}
};
export const Integer = Template.bind({});
Integer.args = {
isInteger: true,
locale: 'en',
value: 7
}
};
export const Currency = Template.bind({});
Currency.args = {
@ -35,4 +36,4 @@ Currency.args = {
label: 'Label',
locale: 'en',
value: 7
}
};

2
libs/ui/src/lib/value/value.component.ts

@ -2,7 +2,7 @@ import {
ChangeDetectionStrategy,
Component,
Input,
OnChanges,
OnChanges
} from '@angular/core';
import { DEFAULT_DATE_FORMAT } from '@ghostfolio/common/config';
import { format, isDate } from 'date-fns';

Loading…
Cancel
Save