@fluid-topics/ft-page-layout 1.2.0

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.
@@ -0,0 +1,26 @@
1
+ import { ClassInfo } from "lit/directives/class-map.js";
2
+ import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
3
+ import { FtdsPageLayoutBreadcrumbItem, FtdsPageLayoutChipContent, FtdsPageLayoutProperties } from "./ftds-page-layout.properties";
4
+ import { FtLitElementWithI18n } from "@fluid-topics/ft-i18n";
5
+ export declare class FtdsPageLayout extends FtLitElementWithI18n implements FtdsPageLayoutProperties {
6
+ static elementDefinitions: ElementDefinitionsMap;
7
+ static styles: import("lit").CSSResult;
8
+ title: string;
9
+ breadcrumb?: FtdsPageLayoutBreadcrumbItem[];
10
+ subTitle?: string;
11
+ chipsContent?: FtdsPageLayoutChipContent[];
12
+ footerHasContent: boolean;
13
+ popoverHasContent: boolean;
14
+ protected footerLeftContent?: Node[];
15
+ protected footerRightContent?: Node[];
16
+ protected popoverContent?: Node[];
17
+ constructor();
18
+ get pageHeaderClasses(): ClassInfo;
19
+ protected render(): import("lit").TemplateResult<1>;
20
+ protected renderHeader(): import("lit").TemplateResult<1>;
21
+ protected renderFooter(): import("lit").TemplateResult<1>;
22
+ protected renderChip(): import("lit").TemplateResult<1>;
23
+ protected renderBreadcrumb(): import("lit").TemplateResult<1>;
24
+ protected renderPopover(): import("lit").TemplateResult<1>;
25
+ protected onSlotChange(e: Event): void;
26
+ }
@@ -0,0 +1,170 @@
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, nothing } from "lit";
8
+ import { property, queryAssignedNodes, state } from "lit/decorators.js";
9
+ import { repeat } from "lit/directives/repeat.js";
10
+ import { ifDefined } from "lit/directives/if-defined.js";
11
+ import { classMap } from "lit/directives/class-map.js";
12
+ import { styles } from "./ftds-page-layout.styles";
13
+ import { FtTypography, FtTypographyVariants } from "@fluid-topics/ft-typography";
14
+ import { FtdsPopover } from "@fluid-topics/ft-popover";
15
+ import { FtdsChip } from "@fluid-topics/ft-chip";
16
+ import { DesignSystemFamily, DesignSystemSize } from "@fluid-topics/design-system-variables";
17
+ import { FtdsLink } from "@fluid-topics/ft-link";
18
+ import { FtLitElementWithI18n, } from "@fluid-topics/ft-i18n";
19
+ import { defaultPageLayoutMessages, i18nContext } from "./FtdsPageLayoutMessages";
20
+ class FtdsPageLayout extends FtLitElementWithI18n {
21
+ constructor() {
22
+ super();
23
+ this.footerHasContent = false;
24
+ this.popoverHasContent = false;
25
+ this.addI18nContext(i18nContext, defaultPageLayoutMessages);
26
+ }
27
+ get pageHeaderClasses() {
28
+ return {
29
+ "ftds-page-layout--header": true,
30
+ "ftds-page-layout--child": this.breadcrumb !== undefined,
31
+ };
32
+ }
33
+ render() {
34
+ return html `
35
+ ${this.renderHeader()}
36
+ <main>
37
+ <slot></slot>
38
+ </main>
39
+ ${this.renderFooter()}
40
+ `;
41
+ }
42
+ renderHeader() {
43
+ return html `
44
+ <div class="${classMap(this.pageHeaderClasses)}">
45
+ <div class="ftds-page-layout--left-slot">
46
+ <div class="ftds-page-layout--title-container">
47
+ ${(this.breadcrumb ? this.renderBreadcrumb() : html `
48
+ <ft-typography class="ftds-page-layout--title"
49
+ variant="${FtTypographyVariants.title1}">
50
+ ${this.title}
51
+ </ft-typography>`)}
52
+ ${this.renderPopover()}
53
+ ${this.renderChip()}
54
+ </div>
55
+ ${this.subTitle ? html `
56
+ <ft-typography class="ftds-page-layout--sub-title"
57
+ variant="${FtTypographyVariants.body2regular}">
58
+ ${this.subTitle}
59
+ </ft-typography>` : nothing}
60
+ </div>
61
+ <div class="ftds-page-layout--right-slot">
62
+ <slot name="header-right"></slot>
63
+ </div>
64
+ </div>`;
65
+ }
66
+ renderFooter() {
67
+ return html `
68
+ <div ?hidden="${!this.footerHasContent}" class="ftds-page-layout--footer ftds-page-layout--child">
69
+ <div class="ftds-page-layout--left-slot">
70
+ <slot name="footer-left" @slotchange=${this.onSlotChange}></slot>
71
+ </div>
72
+ <div class="ftds-page-layout--right-slot">
73
+ <slot name="footer-right" @slotchange=${this.onSlotChange}></slot>
74
+ </div>
75
+ </div>
76
+ `;
77
+ }
78
+ renderChip() {
79
+ var _a;
80
+ return html `
81
+ <div class="ftds-page-layout--chips-container">
82
+ ${repeat((_a = this.chipsContent) !== null && _a !== void 0 ? _a : [], chip => html `
83
+ <ftds-chip family="${chip.family}" icon="${chip.icon}">
84
+ ${chip.label}
85
+ </ftds-chip>`)}
86
+ </div>
87
+ `;
88
+ }
89
+ renderBreadcrumb() {
90
+ return html `
91
+ <nav aria-label="Title breadcrumb" class="ftds-page-layout--breadcrumb">
92
+ <ol>
93
+ ${repeat(this.breadcrumb, (item, index) => html `
94
+ <li>
95
+ ${item.link ? html `
96
+ <ftds-link href=${item.link} underlined target="_self" family=${DesignSystemFamily.brand} variant="${FtTypographyVariants.body2medium}">
97
+ ${item.label}
98
+ </ftds-link>` : html `
99
+ <ft-typography variant="${FtTypographyVariants.body2medium}" class="ftds-page-layout--breadcrumb-item">
100
+ ${item.label}
101
+ </ft-typography>`}
102
+ </li>`)}
103
+ <li>
104
+ <ft-typography class="ftds-page-layout--title"
105
+ aria-current="${ifDefined(this.breadcrumb ? "page" : undefined)}"
106
+ variant="${FtTypographyVariants.body2semibold}">
107
+ ${this.title}
108
+ </ft-typography>
109
+ </li>
110
+ </ol>
111
+ </nav>
112
+ `;
113
+ }
114
+ renderPopover() {
115
+ return html `
116
+ <ftds-popover ?hidden=${!this.popoverHasContent} closeButtonLabel=${i18nContext.messages.popoverCloseButtonLabel()}
117
+ openButtonLabel=${i18nContext.messages.popoverOpenButtonLabel()} openButtonTooltipPosition="bottom"
118
+ openButtonFamily=${DesignSystemFamily.info} openButtonSize=${DesignSystemSize.medium}>
119
+ <slot name="popover-content" @slotchange=${this.onSlotChange}></slot>
120
+ </ftds-popover>`;
121
+ }
122
+ onSlotChange(e) {
123
+ const el = e.target;
124
+ switch (el.getAttribute("name")) {
125
+ case "popover-content":
126
+ this.popoverHasContent = this.popoverContent.length > 0;
127
+ break;
128
+ case "footer-right":
129
+ case "footer-left":
130
+ this.footerHasContent = this.footerLeftContent.length > 0 || this.footerRightContent.length > 0;
131
+ break;
132
+ }
133
+ e.stopPropagation();
134
+ }
135
+ }
136
+ FtdsPageLayout.elementDefinitions = {
137
+ "ft-typography": FtTypography,
138
+ "ftds-popover": FtdsPopover,
139
+ "ftds-chip": FtdsChip,
140
+ "ftds-link": FtdsLink,
141
+ };
142
+ FtdsPageLayout.styles = styles;
143
+ __decorate([
144
+ property()
145
+ ], FtdsPageLayout.prototype, "title", void 0);
146
+ __decorate([
147
+ property()
148
+ ], FtdsPageLayout.prototype, "breadcrumb", void 0);
149
+ __decorate([
150
+ property()
151
+ ], FtdsPageLayout.prototype, "subTitle", void 0);
152
+ __decorate([
153
+ property()
154
+ ], FtdsPageLayout.prototype, "chipsContent", void 0);
155
+ __decorate([
156
+ state()
157
+ ], FtdsPageLayout.prototype, "footerHasContent", void 0);
158
+ __decorate([
159
+ state()
160
+ ], FtdsPageLayout.prototype, "popoverHasContent", void 0);
161
+ __decorate([
162
+ queryAssignedNodes({ slot: "footer-left" })
163
+ ], FtdsPageLayout.prototype, "footerLeftContent", void 0);
164
+ __decorate([
165
+ queryAssignedNodes({ slot: "footer-right" })
166
+ ], FtdsPageLayout.prototype, "footerRightContent", void 0);
167
+ __decorate([
168
+ queryAssignedNodes({ slot: "popover-content" })
169
+ ], FtdsPageLayout.prototype, "popoverContent", void 0);
170
+ export { FtdsPageLayout };
@@ -0,0 +1,16 @@
1
+ import { DesignSystemFamily } from "@fluid-topics/design-system-variables";
2
+ export interface FtdsPageLayoutChipContent {
3
+ icon: string;
4
+ label: string;
5
+ family: DesignSystemFamily;
6
+ }
7
+ export interface FtdsPageLayoutBreadcrumbItem {
8
+ label: string;
9
+ link?: string;
10
+ }
11
+ export interface FtdsPageLayoutProperties {
12
+ title: string;
13
+ breadcrumb?: FtdsPageLayoutBreadcrumbItem[];
14
+ subTitle?: string;
15
+ chipsContent?: FtdsPageLayoutChipContent[];
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare const FtdsPageLayoutCssVariables: {
2
+ contentVerticalPadding: import("@fluid-topics/ft-wc-utils").FtCssVariable;
3
+ contentHorizontalPadding: import("@fluid-topics/ft-wc-utils").FtCssVariable;
4
+ };
5
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,135 @@
1
+ import { css } from "lit";
2
+ import { FtCssVariableFactory, } from "@fluid-topics/ft-wc-utils";
3
+ import { pageFooter, pageHeader, titleBreadcrumb, typographies } from "@fluid-topics/design-system-variables";
4
+ export const FtdsPageLayoutCssVariables = {
5
+ contentVerticalPadding: FtCssVariableFactory.create("--ft-page-layout--content-vertical-padding", "", "SIZE", "0"),
6
+ contentHorizontalPadding: FtCssVariableFactory.create("--ft-page-layout--content-horizontal-padding", "", "SIZE", "0"),
7
+ };
8
+ // language=CSS
9
+ export const styles = css `
10
+ :host {
11
+ display: flex;
12
+ flex-direction: column;
13
+ height: 100%;
14
+ background: ${pageHeader.backgroundColor};
15
+ color: ${pageHeader.parentTitleColor};
16
+ font-family: ${typographies["body-1-regular"].fontFamily}, system-ui, sans-serif;
17
+ font-size: ${typographies["body-1-regular"].fontSize};
18
+ }
19
+
20
+ .ftds-page-layout--left-slot {
21
+ flex-grow: 1;
22
+ height: 100%;
23
+ display: flex;
24
+ align-items: center;
25
+ min-width: 0;
26
+ }
27
+
28
+ .ftds-page-layout--right-slot {
29
+ height: 100%;
30
+ display: flex;
31
+ gap: ${pageHeader.parentButtonsGroupVerticalGap} ${pageHeader.parentButtonsGroupHorizontalGap};
32
+ align-items: center;
33
+ }
34
+
35
+ .ftds-page-layout--child .ftds-page-layout--right-slot {
36
+ gap: ${pageHeader.childButtonsGroupVerticalGap} ${pageHeader.childButtonsGroupHorizontalGap};
37
+ }
38
+
39
+ /* HEADER */
40
+ .ftds-page-layout--header {
41
+ display: flex;
42
+ text-align: center;
43
+ min-height: ${pageHeader.childMinHeight};
44
+ border-bottom: ${pageHeader.bottomBorderWidth} solid ${pageHeader.bottomBorderColor};
45
+ padding: ${pageHeader.parentTopPadding} ${pageHeader.parentHorizontalPadding} ${pageHeader.parentBottomPadding};
46
+ }
47
+
48
+ .ftds-page-layout--header .ftds-page-layout--left-slot {
49
+ flex-direction: column;
50
+ align-items: flex-start;
51
+ justify-content: center;
52
+ gap: ${pageHeader.parentVerticalGap}
53
+ }
54
+
55
+ .ftds-page-layout--header.ftds-page-layout--child {
56
+ min-height: ${pageHeader.childMinHeight};
57
+ padding: ${pageHeader.childTopPadding} ${pageHeader.childHorizontalPadding} ${pageHeader.childBottomPadding};
58
+ }
59
+
60
+ .ftds-page-layout--title-container {
61
+ display: flex;
62
+ align-items: center;
63
+ }
64
+
65
+ .ftds-page-layout--title {
66
+ color: ${pageHeader.parentTitleColor};
67
+ }
68
+
69
+ .ftds-page-layout--sub-title {
70
+ color: ${pageHeader.parentSubtitleColor};
71
+ }
72
+
73
+ ftds-popover {
74
+ margin-left: ${pageHeader.parentHelpLeftMargin};
75
+ }
76
+
77
+ .ftds-page-layout--chips-container {
78
+ margin-left: ${pageHeader.parentChipLeftMargin};
79
+ align-self: center;
80
+ }
81
+
82
+ /* BREADCRUMB */
83
+ nav.ftds-page-layout--breadcrumb {
84
+ display: flex;
85
+ gap: ${titleBreadcrumb.horizontalGap};
86
+ align-items: center;
87
+ }
88
+
89
+ nav.ftds-page-layout--breadcrumb ol {
90
+ margin: 0;
91
+ padding-left: 0;
92
+ list-style: none;
93
+ }
94
+
95
+ nav.ftds-page-layout--breadcrumb li {
96
+ display: inline;
97
+ }
98
+
99
+ nav.ftds-page-layout--breadcrumb ft-typography.ftds-page-layout--breadcrumb-item {
100
+ color: ${titleBreadcrumb.previousNonClickableColor};
101
+ }
102
+
103
+ nav.ftds-page-layout--breadcrumb li + li::before {
104
+ display: inline-block;
105
+ margin: 0 0.25em;
106
+ height: 0.8em;
107
+ content: ">";
108
+ color: ${titleBreadcrumb.iconColor};
109
+ }
110
+
111
+ nav.ftds-page-layout--breadcrumb .ftds-page-layout--title {
112
+ color: ${titleBreadcrumb.currentColor};
113
+ font-weight: 600;
114
+ }
115
+
116
+ /* MAIN */
117
+ main {
118
+ overflow: auto;
119
+ flex-grow: 1;
120
+ padding: ${FtdsPageLayoutCssVariables.contentVerticalPadding} ${FtdsPageLayoutCssVariables.contentHorizontalPadding};
121
+ }
122
+
123
+ /* FOOTER */
124
+ .ftds-page-layout--footer {
125
+ display: flex;
126
+ text-align: center;
127
+ min-height: ${pageFooter.minHeight};
128
+ border-top: ${pageFooter.topBorderWidth} solid ${pageFooter.topBorderColor};
129
+ padding: ${pageFooter.verticalPadding} ${pageFooter.horizontalPadding} ${pageFooter.verticalPadding} ${pageFooter.horizontalPadding}
130
+ }
131
+
132
+ .ftds-page-layout--footer[hidden] {
133
+ display: none;
134
+ }
135
+ `;
@@ -0,0 +1,3 @@
1
+ export * from "./ftds-page-layout.styles";
2
+ export * from "./ftds-page-layout.properties";
3
+ export * from "./ftds-page-layout";
package/build/index.js ADDED
@@ -0,0 +1,6 @@
1
+ import { customElement } from "@fluid-topics/ft-wc-utils";
2
+ import { FtdsPageLayout } from "./ftds-page-layout";
3
+ export * from "./ftds-page-layout.styles";
4
+ export * from "./ftds-page-layout.properties";
5
+ export * from "./ftds-page-layout";
6
+ customElement("ftds-page-layout")(FtdsPageLayout);
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@fluid-topics/ft-page-layout",
3
+ "version": "1.2.0",
4
+ "description": "A page layout component",
5
+ "keywords": [
6
+ "Lit"
7
+ ],
8
+ "author": "Fluid Topics <devtopics@antidot.net>",
9
+ "license": "ISC",
10
+ "main": "build/index.js",
11
+ "web": "build/ftds-page-layout.min.js",
12
+ "typings": "build/index",
13
+ "files": [
14
+ "build/**/*.js",
15
+ "build/**/*.ts"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
+ },
21
+ "dependencies": {
22
+ "@fluid-topics/design-system-variables": "0.1.5",
23
+ "@fluid-topics/ft-wc-utils": "1.2.0",
24
+ "lit": "3.1.0"
25
+ },
26
+ "devDependencies": {
27
+ "@fluid-topics/ft-wc-test-utils": "1.2.0"
28
+ },
29
+ "gitHead": "d1ed0b804f7bfe8e386c93c0b854cc4707d75377"
30
+ }