import { html } from 'lit'
import { customElement, property } from 'lit/decorators.js'
import { PktElementWithSlot } from '@/base-elements/element-with-slot'
import { slotContent } from '@/directives/slot-content'
import '@/components/icon'
import { ifDefined } from 'lit/directives/if-defined.js'
export type TLinkCardSkin =
| 'normal'
| 'no-padding'
| 'blue'
| 'beige'
| 'green'
| 'gray'
| 'beige-outline'
| 'gray-outline';
export interface IPktLinkCard {
title?: string
href?: string
iconName?: string
external?: boolean
openInNewTab?: boolean
skin?: TLinkCardSkin
}
export class PktLinkCard extends PktElementWithSlot implements IPktLinkCard {
@property({ type: String, reflect: true }) title: string = ''
@property({ type: String, reflect: true }) href: string = '#'
@property({ type: String, reflect: true }) iconName: string = ''
@property({ type: Boolean, reflect: true }) external: boolean = false
@property({ type: Boolean, reflect: true }) openInNewTab: boolean = false
@property({ type: String, reflect: true }) skin: TLinkCardSkin = 'normal'
render() {
const classes = ['pkt-linkcard', this.skin && `pkt-linkcard--${this.skin}`]
.filter(Boolean)
.join(' ')
const titleClasses = ['pkt-linkcard__title', this.external && 'pkt-link pkt-link--external']
.filter(Boolean)
.join(' ')
return html`
${this.iconName && html``}
${this.title && html`${this.title}
`}
${slotContent(this)}
`
}
}
try {
customElement('pkt-linkcard')(PktLinkCard)
} catch (e) {
console.warn('Forsøker å definere , men den er allerede definert')
}