@fluid-topics/ftds-event-card 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ The DS component for displaying an event card.
2
+
3
+ ## Install
4
+
5
+ ```shell
6
+ npm install @fluid-topics/ftds-event-card
7
+ yarn add @fluid-topics/ftds-event-card
8
+ ```
9
+
10
+ ## Usage
11
+
12
+ ```typescript
13
+ import { html } from "lit"
14
+ import "@fluid-topics/ftds-event-card/define"
15
+
16
+ function render() {
17
+ return html`
18
+ <ftds-event-card
19
+ primary
20
+ color="#5537E8"
21
+ icon="BOOKS">
22
+ Some content...
23
+ </ftds-event-card>
24
+ `
25
+ }
26
+ ```
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { customElements } from "@fluid-topics/ft-wc-utils";
2
+ import definitions from "./definitions";
3
+ customElements(definitions);
@@ -0,0 +1,9 @@
1
+ import { FtdsEventCard } from "./ftds-event-card";
2
+ import { FtdsEventCardTraceContent } from "./ftds-event-card-trace-content";
3
+ import { FtdsEventCardGroup } from "./ftds-event-card-group";
4
+ declare const _default: {
5
+ "ftds-event-card": typeof FtdsEventCard;
6
+ "ftds-event-card-group": typeof FtdsEventCardGroup;
7
+ "ftds-event-card-trace-content": typeof FtdsEventCardTraceContent;
8
+ };
9
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { FtdsEventCard } from "./ftds-event-card";
2
+ import { FtdsEventCardTraceContent } from "./ftds-event-card-trace-content";
3
+ import { FtdsEventCardGroup } from "./ftds-event-card-group";
4
+ export default {
5
+ "ftds-event-card": FtdsEventCard,
6
+ "ftds-event-card-group": FtdsEventCardGroup,
7
+ "ftds-event-card-trace-content": FtdsEventCardTraceContent,
8
+ };
@@ -0,0 +1,12 @@
1
+ import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
2
+ import { FtdsEventCardGroupProperties } from "./ftds-event-card-group.properties";
3
+ export declare class FtdsEventCardGroup extends FtLitElement implements FtdsEventCardGroupProperties {
4
+ static elementDefinitions: ElementDefinitionsMap;
5
+ collapsible?: boolean;
6
+ collapsed?: boolean;
7
+ closedText: string;
8
+ openText: string;
9
+ static styles: import("lit").CSSResult;
10
+ protected render(): import("lit-html").TemplateResult<1>;
11
+ private renderChildrenSlot;
12
+ }
@@ -0,0 +1,65 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { DesignSystemSize, FtLitElement, } from "@fluid-topics/ft-wc-utils";
8
+ import { property } from "lit/decorators.js";
9
+ import { html } from "lit";
10
+ import { FtdsCollapsible } from "@fluid-topics/ftds-collapsible";
11
+ import { ftdsEventCardGroupStyles } from "./ftds-event-card-group.styles";
12
+ import { when } from "lit/directives/when.js";
13
+ export class FtdsEventCardGroup extends FtLitElement {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.collapsible = false;
17
+ this.collapsed = false;
18
+ this.closedText = "";
19
+ this.openText = "";
20
+ }
21
+ render() {
22
+ return html `
23
+ <div class="container">
24
+ <slot name="parent"></slot>
25
+
26
+ <div class="body">
27
+ ${when(this.collapsible, () => html `
28
+ <ftds-collapsible
29
+ tertiary
30
+ size="${DesignSystemSize.small}"
31
+ ?open=${!this.collapsed}
32
+ openText="${this.openText}"
33
+ closedText="${this.closedText}"
34
+ >
35
+ ${this.renderChildrenSlot()}
36
+ </ftds-collapsible>
37
+ `, () => this.renderChildrenSlot())}
38
+ </div>
39
+ </div>
40
+ `;
41
+ }
42
+ renderChildrenSlot() {
43
+ return html `
44
+ <div class="children">
45
+ <slot></slot>
46
+ </div>
47
+ `;
48
+ }
49
+ }
50
+ FtdsEventCardGroup.elementDefinitions = {
51
+ "ftds-collapsible": FtdsCollapsible,
52
+ };
53
+ FtdsEventCardGroup.styles = ftdsEventCardGroupStyles;
54
+ __decorate([
55
+ property({ type: Boolean })
56
+ ], FtdsEventCardGroup.prototype, "collapsible", void 0);
57
+ __decorate([
58
+ property({ type: Boolean })
59
+ ], FtdsEventCardGroup.prototype, "collapsed", void 0);
60
+ __decorate([
61
+ property()
62
+ ], FtdsEventCardGroup.prototype, "closedText", void 0);
63
+ __decorate([
64
+ property()
65
+ ], FtdsEventCardGroup.prototype, "openText", void 0);
@@ -0,0 +1,6 @@
1
+ export interface FtdsEventCardGroupProperties {
2
+ closedText: string;
3
+ openText: string;
4
+ collapsible?: boolean;
5
+ collapsed?: boolean;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const ftdsEventCardGroupStyles: import("lit").CSSResult;
@@ -0,0 +1,19 @@
1
+ import { css } from "lit";
2
+ import { foundation } from "@fluid-topics/ft-wc-utils";
3
+ // language=CSS
4
+ export const ftdsEventCardGroupStyles = css `
5
+ .body {
6
+ margin-left: ${foundation.spacing6};
7
+ }
8
+
9
+ .children {
10
+ display: flex;
11
+ flex-direction: column;
12
+ gap: ${foundation.spacing3};
13
+ margin-top: ${foundation.spacing3};
14
+ }
15
+
16
+ :host([collapsible]) .children {
17
+ margin-top: 0;
18
+ }
19
+ `;
@@ -0,0 +1,22 @@
1
+ import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
2
+ import { FtdsEventCardTraceContentProperties } from "./ftds-event-card-trace-content.properties";
3
+ export declare class FtdsEventCardTraceContent extends FtLitElement implements FtdsEventCardTraceContentProperties {
4
+ static elementDefinitions: ElementDefinitionsMap;
5
+ headerText?: string;
6
+ headerBreadcrumb?: string[];
7
+ breadcrumbHref?: string;
8
+ body?: string;
9
+ chips?: string[];
10
+ breadcrumbTruncateThreshold: number;
11
+ static styles: import("lit").CSSResult;
12
+ protected render(): import("lit-html").TemplateResult<1>;
13
+ private renderTitle;
14
+ private renderBody;
15
+ private renderChips;
16
+ private renderBreadcrumb;
17
+ private renderSplitBreadcrumb;
18
+ private renderBreadcrumbItems;
19
+ private renderBreadcrumbLink;
20
+ private renderBreadcrumbLabel;
21
+ private renderSeparator;
22
+ }
@@ -0,0 +1,156 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { FtLitElement, numberProperty, splitBreadcrumbForMenu, } from "@fluid-topics/ft-wc-utils";
8
+ import { html, nothing } from "lit";
9
+ import { FtdsTypography, FtdsTypographyVariants } from "@fluid-topics/ftds-typography";
10
+ import { property } from "lit/decorators.js";
11
+ import { FtdsChip } from "@fluid-topics/ftds-chip";
12
+ import { repeat } from "lit/directives/repeat.js";
13
+ import { ftdsEventCardTraceContentStyles } from "./ftds-event-card-trace-content.styles";
14
+ import { when } from "lit/directives/when.js";
15
+ import { FtdsLink } from "@fluid-topics/ftds-link";
16
+ export class FtdsEventCardTraceContent extends FtLitElement {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.breadcrumbTruncateThreshold = 4;
20
+ }
21
+ render() {
22
+ return html `
23
+ <div class="container">
24
+ ${this.renderTitle()}
25
+ ${this.renderBreadcrumb()}
26
+ ${this.renderBody()}
27
+ ${this.renderChips()}
28
+ </div>
29
+ `;
30
+ }
31
+ renderTitle() {
32
+ if (!this.headerText) {
33
+ return nothing;
34
+ }
35
+ return html `
36
+ <ftds-typography
37
+ variant="${FtdsTypographyVariants.caption2medium}"
38
+ class="header">
39
+ ${this.headerText}
40
+ </ftds-typography>
41
+ `;
42
+ }
43
+ renderBody() {
44
+ return html `
45
+ ${when(this.body, () => html `
46
+ <ftds-typography
47
+ variant="${FtdsTypographyVariants.caption1medium}"
48
+ class="body">
49
+ ${this.body}
50
+ </ftds-typography>
51
+ `)}
52
+ <slot></slot>
53
+ `;
54
+ }
55
+ renderChips() {
56
+ if (!this.chips || this.chips.length === 0) {
57
+ return nothing;
58
+ }
59
+ return html `
60
+ <div class="chips">
61
+ ${repeat(this.chips, (chip) => html `
62
+ <ftds-chip>${chip}</ftds-chip>`)}
63
+ </div>
64
+ `;
65
+ }
66
+ renderBreadcrumb() {
67
+ if (!this.headerBreadcrumb) {
68
+ return nothing;
69
+ }
70
+ return html `
71
+ <div class="breadcrumb-wrapper">
72
+ <div class="breadcrumb">
73
+ ${this.renderSplitBreadcrumb(this.headerBreadcrumb)}
74
+ </div>
75
+ <slot name="breadcrumb-action"></slot>
76
+ </div>
77
+ `;
78
+ }
79
+ renderSplitBreadcrumb(breadcrumb) {
80
+ if (breadcrumb.length < this.breadcrumbTruncateThreshold) {
81
+ return this.renderBreadcrumbItems(breadcrumb, true);
82
+ }
83
+ const splitBreadcrumb = splitBreadcrumbForMenu(breadcrumb, 1);
84
+ return html `
85
+ ${this.renderBreadcrumbItems(splitBreadcrumb.beforeMenu, false)}
86
+ ${splitBreadcrumb.beforeMenu.length > 0 ? this.renderSeparator() : nothing}
87
+ ${when(splitBreadcrumb.inMenu.length > 0, () => html `
88
+ ${this.renderBreadcrumbLabel("...")}
89
+ ${this.renderSeparator()}`)}
90
+ ${this.renderBreadcrumbItems(splitBreadcrumb.afterMenu, true)}
91
+ `;
92
+ }
93
+ renderBreadcrumbItems(breadcrumbItems, containsLastItem) {
94
+ return repeat(breadcrumbItems, (breadcrumbItem, index) => {
95
+ const isLastItem = index === breadcrumbItems.length - 1;
96
+ return html `
97
+ ${isLastItem && containsLastItem
98
+ ? this.renderBreadcrumbLink(breadcrumbItem)
99
+ : this.renderBreadcrumbLabel(breadcrumbItem)}
100
+ ${isLastItem ? nothing : this.renderSeparator()}`;
101
+ });
102
+ }
103
+ renderBreadcrumbLink(breadcrumbItem) {
104
+ return html `
105
+ <ftds-link href="${this.breadcrumbHref}"
106
+ target="_blank" underlined
107
+ class="breadcrumb-element"
108
+ variant="${FtdsTypographyVariants.caption1semibold}">
109
+ ${breadcrumbItem}
110
+ </ftds-link>
111
+ `;
112
+ }
113
+ renderBreadcrumbLabel(breadcrumbItem) {
114
+ return html `
115
+ <ftds-typography
116
+ class="breadcrumb-element"
117
+ variant="${FtdsTypographyVariants.caption1semibold}">
118
+ ${breadcrumbItem}
119
+ </ftds-typography>
120
+ `;
121
+ }
122
+ renderSeparator() {
123
+ return html `
124
+ <ftds-typography
125
+ class="breadcrumb-element"
126
+ aria-hidden="true"
127
+ variant="${FtdsTypographyVariants.caption1semibold}">
128
+ &gt;
129
+ </ftds-typography>
130
+ `;
131
+ }
132
+ }
133
+ FtdsEventCardTraceContent.elementDefinitions = {
134
+ "ftds-chip": FtdsChip,
135
+ "ftds-link": FtdsLink,
136
+ "ftds-typography": FtdsTypography,
137
+ };
138
+ FtdsEventCardTraceContent.styles = ftdsEventCardTraceContentStyles;
139
+ __decorate([
140
+ property()
141
+ ], FtdsEventCardTraceContent.prototype, "headerText", void 0);
142
+ __decorate([
143
+ property({ attribute: false })
144
+ ], FtdsEventCardTraceContent.prototype, "headerBreadcrumb", void 0);
145
+ __decorate([
146
+ property()
147
+ ], FtdsEventCardTraceContent.prototype, "breadcrumbHref", void 0);
148
+ __decorate([
149
+ property()
150
+ ], FtdsEventCardTraceContent.prototype, "body", void 0);
151
+ __decorate([
152
+ property({ attribute: false })
153
+ ], FtdsEventCardTraceContent.prototype, "chips", void 0);
154
+ __decorate([
155
+ numberProperty()
156
+ ], FtdsEventCardTraceContent.prototype, "breadcrumbTruncateThreshold", void 0);
@@ -0,0 +1,8 @@
1
+ export interface FtdsEventCardTraceContentProperties {
2
+ headerText?: string;
3
+ headerBreadcrumb?: string[];
4
+ breadcrumbHref?: string;
5
+ breadcrumbTruncateThreshold?: number;
6
+ body?: string;
7
+ chips?: string[];
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const ftdsEventCardTraceContentStyles: import("lit").CSSResult;
@@ -0,0 +1,37 @@
1
+ import { css } from "lit";
2
+ import { foundation, semantic } from "@fluid-topics/ft-wc-utils";
3
+ // language=CSS
4
+ export const ftdsEventCardTraceContentStyles = css `
5
+ .container {
6
+ display: flex;
7
+ flex-direction: column;
8
+ gap: ${foundation.spacing1};
9
+ }
10
+
11
+ .header {
12
+ color: ${semantic.contentGlobalSubtle};
13
+ }
14
+
15
+ .breadcrumb-wrapper {
16
+ display: flex;
17
+ }
18
+
19
+ .breadcrumb {
20
+ flex-grow: 1;
21
+ }
22
+
23
+ .breadcrumb-element {
24
+ color: ${semantic.contentGlobalPrimary};
25
+ }
26
+
27
+ .body {
28
+ color: ${semantic.contentGlobalSecondary};
29
+ }
30
+
31
+ .chips {
32
+ display: flex;
33
+ margin-top: ${foundation.spacing1};
34
+ gap: ${foundation.spacing1};
35
+ flex-wrap: wrap;
36
+ }
37
+ `;
@@ -0,0 +1,13 @@
1
+ import { ElementDefinitionsMap, FtCssVariable, FtLitElement } from "@fluid-topics/ft-wc-utils";
2
+ import { FtdsEventCardProperties } from "./ftds-event-card.properties";
3
+ import { FtdsIcons, FtdsIconVariants } from "@fluid-topics/ftds-icon";
4
+ export declare class FtdsEventCard extends FtLitElement implements FtdsEventCardProperties {
5
+ static elementDefinitions: ElementDefinitionsMap;
6
+ color?: string | FtCssVariable;
7
+ icon?: FtdsIcons;
8
+ iconVariant?: FtdsIconVariants;
9
+ primary: boolean;
10
+ secondary: boolean;
11
+ static styles: import("lit").CSSResult;
12
+ protected render(): import("lit-html").TemplateResult<1>;
13
+ }
@@ -0,0 +1,61 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { html } from "lit";
8
+ import { eventCard, FtLitElement, } from "@fluid-topics/ft-wc-utils";
9
+ import { ftdsEventCardStyles } from "./ftds-event-card.styles";
10
+ import { FtdsIcon } from "@fluid-topics/ftds-icon";
11
+ import { property } from "lit/decorators.js";
12
+ import { classMap } from "lit/directives/class-map.js";
13
+ import { styleMap } from "lit/directives/style-map.js";
14
+ export class FtdsEventCard extends FtLitElement {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.primary = true;
18
+ this.secondary = false;
19
+ }
20
+ render() {
21
+ const classes = {
22
+ "primary": this.primary && !this.secondary,
23
+ "secondary": this.secondary,
24
+ };
25
+ const styles = {
26
+ [eventCard.backgroundColor.name]: this.color ? this.color.toString() : undefined,
27
+ };
28
+ return html `
29
+ <div class="container" style="${styleMap(styles)}">
30
+ <div class="icon ${classMap(classes)}">
31
+ <ftds-icon icon="${this.icon}"
32
+ variant="${this.iconVariant}">
33
+ </ftds-icon>
34
+ </div>
35
+
36
+ <div class="content">
37
+ <slot></slot>
38
+ </div>
39
+ </div>
40
+ `;
41
+ }
42
+ }
43
+ FtdsEventCard.elementDefinitions = {
44
+ "ftds-icon": FtdsIcon,
45
+ };
46
+ FtdsEventCard.styles = ftdsEventCardStyles;
47
+ __decorate([
48
+ property()
49
+ ], FtdsEventCard.prototype, "color", void 0);
50
+ __decorate([
51
+ property()
52
+ ], FtdsEventCard.prototype, "icon", void 0);
53
+ __decorate([
54
+ property()
55
+ ], FtdsEventCard.prototype, "iconVariant", void 0);
56
+ __decorate([
57
+ property({ type: Boolean })
58
+ ], FtdsEventCard.prototype, "primary", void 0);
59
+ __decorate([
60
+ property({ type: Boolean })
61
+ ], FtdsEventCard.prototype, "secondary", void 0);