-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathBaseCard.ts
More file actions
56 lines (51 loc) · 1.77 KB
/
BaseCard.ts
File metadata and controls
56 lines (51 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { LitElement, html } from 'lit';
import { SlotController } from '@patternfly/pfe-core/controllers/slot-controller.js';
import { classMap } from 'lit/directives/class-map.js';
import style from './BaseCard.css';
/**
* This element creates a header, body, and footer region in which to place
* content or other components.
*
* @summary Gives a preview of information in a small layout
*
* @slot header
* If this slot is used, we expect a heading level tag (h1, h2, h3, h4, h5, h6).
* An icon, svg, or use of the icon component are also valid in this region.
* @slot - Any content that is not designated for the header or footer slot, will go to this slot.
* @slot footer
* Use this slot for anything that you want to be stuck to the base of the card.
*
* @csspart header - The container for *header* content
* @csspart body - The container for *body* content
* @csspart footer - The container for *footer* content
*/
export abstract class BaseCard extends LitElement {
static readonly styles = [style];
protected slots = new SlotController(
this,
'header',
SlotController.anonymous,
'footer',
);
render() {
return html`
<article>
<header id="header"
part="header"
class="${classMap({ empty: !this.slots.hasSlotted('header') })}">
<slot name="header"></slot>
</header>
<div id="body"
part="body"
class="${classMap({ empty: !this.slots.hasSlotted(SlotController.anonymous) })}">
<slot></slot>
</div>
<footer id="footer"
part="footer"
class="${classMap({ empty: !this.slots.hasSlotted('footer') })}">
<slot name="footer"></slot>
</footer>
</article>
`;
}
}