Added some updates from master branch

This commit is contained in:
Adina Țeudan 2023-10-02 11:38:49 +03:00
parent ac3ccb1d7d
commit 7312caa8d0
6 changed files with 35 additions and 2 deletions

View File

@ -36,4 +36,8 @@
&.mdc-list-item--disabled {
color: rgba(var(--iqser-text-rgb), 0.7);
}
> span {
width: 100%;
}
}

View File

@ -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],

View File

@ -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<T extends string> {
@Input() configs: readonly StatusBarConfig<T>[] = [];

View File

@ -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';

View File

@ -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);
}
}

View File

@ -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<T extends unknown | string>(unsafe: T, options?: { ignoreTags: string[] }) {
if (typeof unsafe !== 'string') {
return unsafe;