import React from 'react' import { FlexLayout } from './utils' import { getAnimations } from '../getStyles' export default class Card { public hideBorder = false public hideTitle = false public css = '' public paddingX = 25 public paddingY = 35 public animations = true constructor( public width = 100, public height = 100, public colors: {titleColor?: string | Array, textColor?: string | Array, bgColor?: string | Array, iconColor?: string | Array} = {}, public title = "", public titlePrefixIcon?: string ) {} disableAnimations() { this.animations = false; } setCSS(value: string) { this.css = value; } setHideBorder(value: boolean) { this.hideBorder = value; } setHideTitle(value: boolean) { this.hideTitle = value; if (value) { this.height -= 30; } } setTitle(text: string) { this.title = text; } renderTitle() { const titleText = ( {this.title} ) const prefixIcon = ( ${this.titlePrefixIcon} ) return ( {FlexLayout({ items: [this.titlePrefixIcon && prefixIcon, titleText], gap: 25, })} ) } renderGradient() { if (typeof this.colors.bgColor !== "object") return; const gradients = this.colors.bgColor.slice(1); return typeof this.colors.bgColor === "object" ? ( {gradients.map((grad, index) => { let offset = (index * 100) / (gradients.length - 1); return ``; })} ) : ""; } render(body: JSX.Element) { return ( {this.renderGradient()} {this.hideTitle ? "" : this.renderTitle()} {body} ) } }