From 7312caa8d0119c5c153f02ddc22075ec9e945451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Mon, 2 Oct 2023 11:38:49 +0300 Subject: [PATCH] Added some updates from master branch --- src/assets/styles/common-select.scss | 4 ++++ src/lib/shared/shared.module.ts | 4 ++-- src/lib/shared/status-bar/status-bar.component.ts | 4 ++++ src/lib/standalone/index.ts | 1 + src/lib/standalone/pipes/size.pipe.ts | 12 ++++++++++++ src/lib/utils/functions.ts | 12 ++++++++++++ 6 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 src/lib/standalone/pipes/size.pipe.ts diff --git a/src/assets/styles/common-select.scss b/src/assets/styles/common-select.scss index de7a56c..66b685c 100644 --- a/src/assets/styles/common-select.scss +++ b/src/assets/styles/common-select.scss @@ -36,4 +36,8 @@ &.mdc-list-item--disabled { color: rgba(var(--iqser-text-rgb), 0.7); } + + > span { + width: 100%; + } } diff --git a/src/lib/shared/shared.module.ts b/src/lib/shared/shared.module.ts index 4267ad1..f622401 100644 --- a/src/lib/shared/shared.module.ts +++ b/src/lib/shared/shared.module.ts @@ -1,10 +1,10 @@ import { NgModule } from '@angular/core'; -import { LogoComponent, SideNavComponent, SmallChipComponent, StatusBarComponent } from './index'; +import { LogoComponent, SideNavComponent, SmallChipComponent } from './index'; import { CommonModule } from '@angular/common'; import { MatTooltipModule } from '@angular/material/tooltip'; import { IqserIconsModule } from '../icons'; -const components = [SmallChipComponent, StatusBarComponent, SideNavComponent, LogoComponent]; +const components = [SmallChipComponent, SideNavComponent, LogoComponent]; @NgModule({ declarations: [...components], diff --git a/src/lib/shared/status-bar/status-bar.component.ts b/src/lib/shared/status-bar/status-bar.component.ts index 5bdbcf1..00885a7 100644 --- a/src/lib/shared/status-bar/status-bar.component.ts +++ b/src/lib/shared/status-bar/status-bar.component.ts @@ -1,5 +1,7 @@ import { ChangeDetectionStrategy, Component, Input, ViewEncapsulation } from '@angular/core'; import { StatusBarConfig } from './status-bar-config.model'; +import { NgClass, NgForOf, NgIf, NgStyle } from '@angular/common'; +import { MatTooltipModule } from '@angular/material/tooltip'; @Component({ selector: 'iqser-status-bar', @@ -7,6 +9,8 @@ import { StatusBarConfig } from './status-bar-config.model'; styleUrls: ['./status-bar.component.scss'], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, + standalone: true, + imports: [NgClass, NgStyle, NgForOf, MatTooltipModule, NgIf], }) export class StatusBarComponent { @Input() configs: readonly StatusBarConfig[] = []; diff --git a/src/lib/standalone/index.ts b/src/lib/standalone/index.ts index 0a4a2be..8e7b2fc 100644 --- a/src/lib/standalone/index.ts +++ b/src/lib/standalone/index.ts @@ -2,3 +2,4 @@ export * from './pipes/log.pipe'; export * from './pipes/humanize-camel-case.pipe'; export * from './pipes/capitalize.pipe'; export * from './pipes/humanize.pipe'; +export * from './pipes/size.pipe'; diff --git a/src/lib/standalone/pipes/size.pipe.ts b/src/lib/standalone/pipes/size.pipe.ts new file mode 100644 index 0000000..aded12f --- /dev/null +++ b/src/lib/standalone/pipes/size.pipe.ts @@ -0,0 +1,12 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import { size } from '../../utils'; + +@Pipe({ + name: 'size', + standalone: true, +}) +export class SizePipe implements PipeTransform { + transform(value: number): string { + return size(value); + } +} diff --git a/src/lib/utils/functions.ts b/src/lib/utils/functions.ts index 425c4ab..39c1119 100644 --- a/src/lib/utils/functions.ts +++ b/src/lib/utils/functions.ts @@ -25,6 +25,18 @@ export function humanizeCamelCase(value: string): string { return value.replace(/([a-z])([A-Z])/g, '$1 $2').toLowerCase(); } +export function size(value: number): string { + if (value >= 1000 ** 3) { + return `${(value / 1000 ** 3).toFixed(2)} GB`; + } + + if (value >= 1000 ** 2) { + return `${(value / 1000 ** 2).toFixed(2)} MB`; + } + + return `${(value / 1000).toFixed(2)} KB`; +} + export function escapeHtml(unsafe: T, options?: { ignoreTags: string[] }) { if (typeof unsafe !== 'string') { return unsafe;