@obliczeniowo/elementary
Version:
Library made in Angular version 20
58 lines (54 loc) • 2.17 kB
JavaScript
import * as i0 from '@angular/core';
import { input, effect, Directive } from '@angular/core';
import { keys } from '@obliczeniowo/elementary/objects';
class BadgeDirective {
ref;
badge;
show = input(true);
constructor(ref) {
this.ref = ref;
ref.nativeElement.style.position = 'relative';
this.badge = document.createElement('div');
const styles = {
position: 'absolute',
top: '2px',
right: '2px',
height: 'var(--obl-badge-size, 7px)',
width: 'var(--obl-badge-size, 7px)',
borderRadius: 'var(--obl-badge-size, 7px)',
backgroundColor: 'var(--obl-badge-background-color, gray)',
};
keys(styles).forEach((key) => (this.badge.style[key] = styles[key]));
effect(() => {
this.set();
});
}
set() {
if (this.show()) {
this.ref.nativeElement.appendChild(this.badge);
}
else {
try {
this.ref.nativeElement.removeChild(this.badge);
}
catch (e) { }
}
}
ngAfterViewInit() {
setTimeout(() => this.set());
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: BadgeDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.0.4", type: BadgeDirective, isStandalone: true, selector: "[oblBadge]", inputs: { show: { classPropertyName: "show", publicName: "show", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: BadgeDirective, decorators: [{
type: Directive,
args: [{
selector: '[oblBadge]',
standalone: true,
}]
}], ctorParameters: () => [{ type: i0.ElementRef }] });
/**
* Generated bundle index. Do not edit.
*/
export { BadgeDirective };
//# sourceMappingURL=obliczeniowo-elementary-badge.mjs.map