Added some updates from master branch
This commit is contained in:
parent
ac3ccb1d7d
commit
7312caa8d0
@ -36,4 +36,8 @@
|
||||
&.mdc-list-item--disabled {
|
||||
color: rgba(var(--iqser-text-rgb), 0.7);
|
||||
}
|
||||
|
||||
> span {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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],
|
||||
|
||||
@ -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>[] = [];
|
||||
|
||||
@ -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';
|
||||
|
||||
12
src/lib/standalone/pipes/size.pipe.ts
Normal file
12
src/lib/standalone/pipes/size.pipe.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user