import React from 'react' import themes from '../../themes/themes.json' import FlexLayout from '../components/FlexLayout' import { getColor, parseBoolean } from './utils' export interface CardOptions { title_color?: string bg_color?: string hide_border?: boolean hide_title?: boolean theme?: keyof typeof themes } export default class Card { public hideBorder = false public hideTitle = false public css = '' public paddingX = 25 public paddingY = 35 public animations = true public height = 100 public width = 100 public title = '' public colors: { titleColor?: string | Array, bgColor?: string | Array } = {} public titlePrefix?: JSX.Element constructor(options?: CardOptions) { if (options) { this.hideBorder = parseBoolean(options.hide_border) this.hideTitle = parseBoolean(options.hide_title) this.colors = { titleColor: getColor('title_color', options?.title_color, options?.theme), bgColor: getColor('bg_color', options?.bg_color, options?.theme) } } } renderTitle() { const titleText = ( {this.title} ) const prefixIcon = ( {this.titlePrefix} ) return ( ) } 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) => { const offset = (index * 100) / (gradients.length - 1) return `` })} ) : '' } render(body: JSX.Element) { return ( {this.renderGradient()} {this.hideTitle ? '' : this.renderTitle()} {body} ) } }