1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
- import { IconComponent } from '../icon/icon.component';
- import { SizeEnum } from '../../../model/components/size.enum';
- import { NgClass } from '@angular/common';
- import { VariantEnum } from '../../../model/components/variant.enum';
- import * as i0 from "@angular/core";
- export class ButtonComponent {
- constructor() {
- this.iconPosition = 'left';
- this.fullSize = false;
- this.size = 'base';
- this.type = 'primary';
- this.variant = 'solid';
- }
- get cssClassmap() {
- return {
- [`text-on-${this.type} dark:text-on-${this.type}-dark`]: this.variant === VariantEnum.SOLID || this.variant === VariantEnum.GRADIENT,
- [`text-neutral-950 dark:text-neutral-50 hover:text-${this.type}-dark dark:hover:text-${this.type}`]: this.variant === VariantEnum.GRADIENT || this.variant === VariantEnum.BLANK,
- [`bg-${this.type} dark:bg-${this.type}-dark hover:bg-${this.type}-variant hover:dark:bg-${this.type}-variant-dark`]: this.variant === VariantEnum.SOLID,
- [`from-${this.type}-variant from-30% to-${this.type} bg-gradient-to-tl hover:bg-gradient-to-br dark:from-${this.type}-variant-dark dark:to-${this.type}-dark`]: this.variant === VariantEnum.GRADIENT,
- [`border border-2 border-${this.type} hover:border-${this.type}-variant dark:border-${this.type}-dark`]: this.variant === VariantEnum.OUTLINE,
- 'px-3 py-2': (this.size === SizeEnum.XS || this.size === SizeEnum.SM) && !this.hasJustIcon(),
- 'px-5 py-2.5': (this.size === SizeEnum.BASE || this.size === SizeEnum.LG) && !this.hasJustIcon(),
- 'px-6 py-3': this.size === SizeEnum.XL && !this.hasJustIcon(),
- 'p-2': this.hasJustIcon() && this.variant !== 'blank',
- 'text-xs': this.size === SizeEnum.XS,
- 'text-sm': this.size === SizeEnum.SM || this.size === SizeEnum.BASE,
- 'text-base': this.size === SizeEnum.LG || this.size === SizeEnum.XL,
- 'w-full': this.fullSize,
- };
- }
- hasJustIcon() {
- return this.icon !== undefined && this.text === undefined;
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: ButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.2", type: ButtonComponent, isStandalone: true, selector: "ct-button", inputs: { text: "text", icon: "icon", iconPosition: "iconPosition", fullSize: "fullSize", size: "size", type: "type", variant: "variant" }, ngImport: i0, template: "<button class=\"flex flex-row items-center justify-center gap-1.5 rounded-md font-medium\" [ngClass]=\"cssClassmap\">\n @if (icon) {\n <ct-icon class=\"flex\" [size]=\"size\" [icon]=\"icon\" />\n }\n @if (text) {\n <span [class.order-first]=\"iconPosition === 'right'\">\n {{ text }}\n </span>\n }\n</button>\n", dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: IconComponent, selector: "ct-icon", inputs: ["icon", "fill", "strokeWidth", "strokeColor", "size", "variant"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: ButtonComponent, decorators: [{
- type: Component,
- args: [{ selector: 'ct-button', standalone: true, imports: [NgClass, IconComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<button class=\"flex flex-row items-center justify-center gap-1.5 rounded-md font-medium\" [ngClass]=\"cssClassmap\">\n @if (icon) {\n <ct-icon class=\"flex\" [size]=\"size\" [icon]=\"icon\" />\n }\n @if (text) {\n <span [class.order-first]=\"iconPosition === 'right'\">\n {{ text }}\n </span>\n }\n</button>\n" }]
- }], propDecorators: { text: [{
- type: Input
- }], icon: [{
- type: Input
- }], iconPosition: [{
- type: Input
- }], fullSize: [{
- type: Input
- }], size: [{
- type: Input
- }], type: [{
- type: Input
- }], variant: [{
- type: Input
- }] } });
|