import Vue, { CreateElement, VNode } from 'vue';
import {
Component,
Emit,
Inject,
Model,
Prop,
Provide,
Watch,
} from 'vue-property-decorator';
import {
ClassName,
Theme,
ThemeComponent,
LinkLikeComponent,
FlexDirection,
} from '../../base';
/**
* Component: Card
*/
@Component
export class VdCard extends Vue implements ThemeComponent, LinkLikeComponent {
@Prop({ type: String, default: 'section' })
public readonly tag!: string;
@Prop({ type: Boolean, default: false })
public readonly routerLink!: boolean;
@Prop({ type: String })
public readonly theme?: Theme;
public get themeValue(): Theme {
return this.theme || this.$vd_theme.theme;
}
@Prop(String)
public readonly direction?: FlexDirection;
@Prop({ type: Boolean, default: false })
public readonly bordered!: boolean;
@Prop({ type: [Boolean, Number], default: false })
public readonly raise!: boolean | number;
@Prop(Number)
public readonly hoverRaise?: number;
@Prop({ type: Boolean, default: false })
public readonly transparent!: boolean;
@Prop({ type: Boolean, default: false })
public readonly translucent!: boolean;
@Prop({ type: Boolean, default: false })
public readonly center!: boolean;
@Prop({ type: String })
public readonly title?: string;
@Prop({ type: String, default: 'h3' })
public readonly titleTag!: string;
public get classes(): ClassName {
return [
`vdp-theme_${this.themeValue}`,
{
[`vdp-direction_${this.direction}`]: this.direction,
'is-bordered': this.bordered,
'is-raise': this.raise && typeof this.raise === 'boolean',
[`vdp-raise_${this.raise}`]: this.raise && typeof this.raise === 'number',
[`vdp-hover-raise_${this.hoverRaise}`]:
this.hoverRaise && typeof this.hoverRaise === 'number',
'is-transparent': this.transparent,
'is-translucent': this.translucent,
'is-center': this.center,
},
];
}
private render(h: CreateElement): VNode {
return h(
this.routerLink ? 'router-link' : this.tag,
{
staticClass: 'vd-card',
class: this.classes,
props: this.routerLink
? {
tag: this.tag,
...this.$attrs,
}
: undefined,
},
[
this.title ? (