@fluid-topics/ft-in-product-help 1.0.33

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,19 @@
1
+ Embeddable fluid-topics iframe
2
+
3
+ ## Install
4
+
5
+ ```shell
6
+ npm install @fluid-topics/ft-in-product-help
7
+ yarn add @fluid-topics/ft-in-product-help
8
+ ```
9
+
10
+ ## Usage
11
+
12
+ ```typescript
13
+ import { html } from "lit"
14
+ import "@fluid-topics/ft-in-product-help"
15
+
16
+ function render() {
17
+ return html` <ft-in-product-help portalUrl="http://www.google.fr/" opened></ft-in-product-help> `
18
+ }
19
+ ```
@@ -0,0 +1,26 @@
1
+ export declare const FtInProductHelpCssVariables: {
2
+ standardSizeWidth: import("@fluid-topics/ft-wc-utils").FtCssVariable;
3
+ standardSizeHeight: import("@fluid-topics/ft-wc-utils").FtCssVariable;
4
+ topPosition: import("@fluid-topics/ft-wc-utils").FtCssVariable;
5
+ rightPosition: import("@fluid-topics/ft-wc-utils").FtCssVariable;
6
+ bottomPosition: import("@fluid-topics/ft-wc-utils").FtCssVariable;
7
+ leftPosition: import("@fluid-topics/ft-wc-utils").FtCssVariable;
8
+ zIndex: import("@fluid-topics/ft-wc-utils").FtCssVariable;
9
+ theaterSizeWidth: import("@fluid-topics/ft-wc-utils").FtCssVariable;
10
+ theaterSizeHeight: import("@fluid-topics/ft-wc-utils").FtCssVariable;
11
+ fullscreenSizeWidth: import("@fluid-topics/ft-wc-utils").FtCssVariable;
12
+ fullscreenSizeHeight: import("@fluid-topics/ft-wc-utils").FtCssVariable;
13
+ borderStyle: import("@fluid-topics/ft-wc-utils").FtCssVariable;
14
+ borderWidth: import("@fluid-topics/ft-wc-utils").FtCssVariable;
15
+ borderColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
16
+ borderRadius: import("@fluid-topics/ft-wc-utils").FtCssVariable;
17
+ shadow: import("@fluid-topics/ft-wc-utils").FtCssVariable;
18
+ topBarHeight: import("@fluid-topics/ft-wc-utils").FtCssVariable;
19
+ iconColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
20
+ iconGap: import("@fluid-topics/ft-wc-utils").FtCssVariable;
21
+ tabletBreakpoint: import("@fluid-topics/ft-wc-utils").FtCssVariable;
22
+ desktopBreakpoint: import("@fluid-topics/ft-wc-utils").FtCssVariable;
23
+ colorSurface: import("@fluid-topics/ft-wc-utils").FtCssVariable;
24
+ colorPrimary: import("@fluid-topics/ft-wc-utils").FtCssVariable;
25
+ };
26
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,83 @@
1
+ import { css } from "lit";
2
+ import { designSystemVariables, FtCssVariableFactory } from "@fluid-topics/ft-wc-utils";
3
+ export const FtInProductHelpCssVariables = {
4
+ standardSizeWidth: FtCssVariableFactory.create("--ft-in-product-help-standard-width", "SIZE", "400px"),
5
+ standardSizeHeight: FtCssVariableFactory.create("--ft-in-product-help-standard-height", "SIZE", "630px"),
6
+ topPosition: FtCssVariableFactory.create("--ft-in-product-help-top", "SIZE", "unset"),
7
+ rightPosition: FtCssVariableFactory.create("--ft-in-product-help-right", "SIZE", "1rem"),
8
+ bottomPosition: FtCssVariableFactory.create("--ft-in-product-help-bottom", "SIZE", "1rem"),
9
+ leftPosition: FtCssVariableFactory.create("--ft-in-product-help-left", "SIZE", "unset"),
10
+ zIndex: FtCssVariableFactory.create("--ft-in-product-help-zindex", "NUMBER", "10"),
11
+ theaterSizeWidth: FtCssVariableFactory.create("--ft-in-product-help-theater-width", "SIZE", "90%"),
12
+ theaterSizeHeight: FtCssVariableFactory.create("--ft-in-product-help-theater-height", "SIZE", "60%"),
13
+ fullscreenSizeWidth: FtCssVariableFactory.create("--ft-in-product-help-fullscreen-width", "SIZE", "100%"),
14
+ fullscreenSizeHeight: FtCssVariableFactory.create("--ft-in-product-help-fullscreen-height", "SIZE", "100%"),
15
+ borderStyle: FtCssVariableFactory.create("--ft-in-product-help-border-style", "UNKNOWN", "solid"),
16
+ borderWidth: FtCssVariableFactory.create("--ft-in-product-help-border-width", "SIZE", "0"),
17
+ borderColor: FtCssVariableFactory.extend("--ft-in-product-help-border-color", designSystemVariables.colorPrimary),
18
+ borderRadius: FtCssVariableFactory.extend("--ft-in-product-help-border-radius", designSystemVariables.borderRadiusM),
19
+ shadow: FtCssVariableFactory.extend("--ft-in-product-help-shadow", designSystemVariables.elevation02),
20
+ topBarHeight: FtCssVariableFactory.create("--ft-in-product-help-top-bar-height", "SIZE", "28px"),
21
+ iconColor: FtCssVariableFactory.extend("--ft-in-product-help-icon-color", designSystemVariables.colorOnSurface),
22
+ iconGap: FtCssVariableFactory.create("--ft-in-product-help-icon-gap", "SIZE", "8px"),
23
+ tabletBreakpoint: FtCssVariableFactory.create("--ft-in-product-help-tablet-breakpoint", "SIZE", "768px"),
24
+ desktopBreakpoint: FtCssVariableFactory.create("--ft-in-product-help-desktop-breakpoint", "SIZE", "1280px"),
25
+ colorSurface: FtCssVariableFactory.external(designSystemVariables.colorSurface, "Design system"),
26
+ colorPrimary: FtCssVariableFactory.external(designSystemVariables.colorPrimary, "Design system"),
27
+ };
28
+ // language=CSS
29
+ export const styles = css `
30
+ .ft-in-product-help {
31
+ display: none;
32
+ position: fixed;
33
+ width: ${FtInProductHelpCssVariables.standardSizeWidth};
34
+ height: ${FtInProductHelpCssVariables.standardSizeHeight};
35
+ top: ${FtInProductHelpCssVariables.topPosition};
36
+ right: ${FtInProductHelpCssVariables.rightPosition};
37
+ bottom: ${FtInProductHelpCssVariables.bottomPosition};
38
+ left: ${FtInProductHelpCssVariables.leftPosition};
39
+ z-index: ${FtInProductHelpCssVariables.zIndex};
40
+
41
+ border-style: ${FtInProductHelpCssVariables.borderStyle};
42
+ border-width: ${FtInProductHelpCssVariables.borderWidth};
43
+ border-color: ${FtInProductHelpCssVariables.borderColor};
44
+ border-radius: ${FtInProductHelpCssVariables.borderRadius};
45
+ box-shadow: ${FtInProductHelpCssVariables.shadow};
46
+ overflow: hidden;
47
+ }
48
+
49
+ .ft-in-product-help.ft-in-product-help--theater {
50
+ width: ${FtInProductHelpCssVariables.theaterSizeWidth};
51
+ height: ${FtInProductHelpCssVariables.theaterSizeHeight};
52
+ }
53
+
54
+ .ft-in-product-help.ft-in-product-help--fullscreen {
55
+ width: 100%;
56
+ height: 100%;
57
+ inset: 0;
58
+ border: none;
59
+ border-radius: 0;
60
+ }
61
+
62
+ .ft-in-product-help.ft-in-product-help--opened {
63
+ display: block;
64
+ }
65
+
66
+ .ft-in-product-help--top-bar {
67
+ height: ${FtInProductHelpCssVariables.topBarHeight};
68
+ background-color: ${FtInProductHelpCssVariables.colorSurface};
69
+ display: flex;
70
+ justify-content: flex-end;
71
+ gap: ${FtInProductHelpCssVariables.iconGap};
72
+ }
73
+
74
+ .ft-in-product-help--top-bar ft-button:not(.ft-in-product-help--active-mode) {
75
+ --ft-button-color: ${FtInProductHelpCssVariables.iconColor};
76
+ }
77
+
78
+ iframe {
79
+ width: 100%;
80
+ height: calc(100% - ${FtInProductHelpCssVariables.topBarHeight});
81
+ border: none;
82
+ }
83
+ `;
@@ -0,0 +1,32 @@
1
+ import { PropertyValues } from "lit";
2
+ import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
3
+ import { FtInProductHelpMode, FtInProductHelpProperties } from "./ft-in-product-help.properties";
4
+ import { FtIconVariants } from "@fluid-topics/ft-icon";
5
+ export declare class FtInProductHelp extends FtLitElement implements FtInProductHelpProperties {
6
+ static elementDefinitions: ElementDefinitionsMap;
7
+ static styles: import("lit").CSSResult;
8
+ portalUrl: string;
9
+ opened: boolean;
10
+ displayMode: FtInProductHelpMode;
11
+ closeIcon: string;
12
+ standardModeIcon: string;
13
+ disableStandardMode: boolean;
14
+ theaterModeIcon: string;
15
+ disableTheaterMode: boolean;
16
+ fullscreenModeIcon: string;
17
+ disableFullscreenMode: boolean;
18
+ iconVariant?: FtIconVariants;
19
+ allowStandardMode: boolean;
20
+ allowTheaterMode: boolean;
21
+ allowFullscreenMode: boolean;
22
+ protected render(): import("lit-html").TemplateResult<1>;
23
+ protected updated(props: PropertyValues): void;
24
+ private updateModeOnOpen;
25
+ private computeAllowedModes;
26
+ private onViewportChange;
27
+ private setMode;
28
+ private close;
29
+ private dispatchVisibilityChange;
30
+ private isTablet;
31
+ private isDesktop;
32
+ }
@@ -0,0 +1,188 @@
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, state } from "lit/decorators.js";
9
+ import { FtLitElement } from "@fluid-topics/ft-wc-utils";
10
+ import { FtInProductHelpMode, FtInProductHelpVisibilityChange } from "./ft-in-product-help.properties";
11
+ import { FtInProductHelpCssVariables, styles } from "./ft-in-product-help.css";
12
+ import { FtIcons } from "@fluid-topics/ft-icon";
13
+ import { classMap } from "lit/directives/class-map.js";
14
+ import { FtButton } from "@fluid-topics/ft-button";
15
+ import { FtSizeWatcher } from "@fluid-topics/ft-size-watcher";
16
+ class FtInProductHelp extends FtLitElement {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.portalUrl = "";
20
+ this.opened = false;
21
+ this.displayMode = FtInProductHelpMode.STANDARD;
22
+ this.closeIcon = FtIcons.X_MARK;
23
+ this.standardModeIcon = FtIcons.PIP;
24
+ this.disableStandardMode = false;
25
+ this.theaterModeIcon = FtIcons.PIP_WIDE;
26
+ this.disableTheaterMode = false;
27
+ this.fullscreenModeIcon = FtIcons.EXPAND_WIDE;
28
+ this.disableFullscreenMode = false;
29
+ this.allowStandardMode = true;
30
+ this.allowTheaterMode = true;
31
+ this.allowFullscreenMode = true;
32
+ }
33
+ render() {
34
+ const classes = {
35
+ "ft-in-product-help": true,
36
+ "ft-in-product-help--opened": this.opened,
37
+ "ft-in-product-help--standard": this.displayMode == FtInProductHelpMode.STANDARD,
38
+ "ft-in-product-help--theater": this.displayMode == FtInProductHelpMode.THEATER,
39
+ "ft-in-product-help--fullscreen": this.displayMode == FtInProductHelpMode.FULLSCREEN,
40
+ };
41
+ const showStandardIcon = this.allowStandardMode && (this.allowTheaterMode || this.allowFullscreenMode);
42
+ const showTheaterIcon = this.allowTheaterMode && (this.allowStandardMode || this.allowFullscreenMode);
43
+ const showFullscreenIcon = this.allowFullscreenMode && (this.allowStandardMode || this.allowTheaterMode);
44
+ return html `
45
+ <ft-size-watcher @change=${this.onViewportChange}></ft-size-watcher>
46
+ <div class="${classMap(classes)}" part="container">
47
+ <div class="ft-in-product-help--top-bar" part="top-bar">
48
+ ${showFullscreenIcon ? html `
49
+ <ft-button icon="${this.fullscreenModeIcon}"
50
+ class="${this.displayMode == FtInProductHelpMode.FULLSCREEN ? "ft-in-product-help--active-mode" : ""}"
51
+ dense
52
+ .iconVariant=${this.iconVariant}
53
+ part="button-fullscreen top-bar-button"
54
+ @click=${() => this.setMode(FtInProductHelpMode.FULLSCREEN)}
55
+ ></ft-button>
56
+ ` : nothing}
57
+ ${showTheaterIcon ? html `
58
+ <ft-button icon="${this.theaterModeIcon}"
59
+ class="${this.displayMode == FtInProductHelpMode.THEATER ? "ft-in-product-help--active-mode" : ""}"
60
+ dense
61
+ .iconVariant=${this.iconVariant}
62
+ part="button-theater top-bar-button"
63
+ @click=${() => this.setMode(FtInProductHelpMode.THEATER)}
64
+ ></ft-button>
65
+ ` : nothing}
66
+ ${showStandardIcon ? html `
67
+ <ft-button icon="${this.standardModeIcon}"
68
+ class="${this.displayMode == FtInProductHelpMode.STANDARD ? "ft-in-product-help--active-mode" : ""}"
69
+ dense
70
+ .iconVariant=${this.iconVariant}
71
+ part="button-standard top-bar-button"
72
+ @click=${() => this.setMode(FtInProductHelpMode.STANDARD)}
73
+ ></ft-button>
74
+ ` : nothing}
75
+ <ft-button icon="${this.closeIcon}"
76
+ dense
77
+ .iconVariant=${this.iconVariant}
78
+ part="button-close top-bar-button"
79
+ @click=${this.close}
80
+ ></ft-button>
81
+ </div>
82
+ <iframe src="${this.portalUrl}" part="iframe"/>
83
+ </div>
84
+ `;
85
+ }
86
+ updated(props) {
87
+ super.updated(props);
88
+ if (props.has("opened")) {
89
+ this.updateModeOnOpen();
90
+ }
91
+ if (props.has("disableStandardMode") || props.has("disableThreaterMode") || props.has("disableFullscreenMode")) {
92
+ this.computeAllowedModes();
93
+ }
94
+ }
95
+ updateModeOnOpen() {
96
+ if (this.allowStandardMode) {
97
+ this.displayMode = FtInProductHelpMode.STANDARD;
98
+ }
99
+ else if (this.allowTheaterMode) {
100
+ this.displayMode = FtInProductHelpMode.THEATER;
101
+ }
102
+ else {
103
+ this.displayMode = FtInProductHelpMode.FULLSCREEN;
104
+ }
105
+ }
106
+ computeAllowedModes() {
107
+ this.allowStandardMode = !this.disableStandardMode && (this.isTablet() || this.isDesktop());
108
+ this.allowTheaterMode = !this.disableTheaterMode && this.isDesktop();
109
+ this.allowFullscreenMode = !this.disableFullscreenMode;
110
+ }
111
+ onViewportChange() {
112
+ this.computeAllowedModes();
113
+ if (!this.allowStandardMode && this.displayMode == FtInProductHelpMode.STANDARD) {
114
+ this.displayMode = FtInProductHelpMode.THEATER;
115
+ }
116
+ if (!this.allowTheaterMode && this.displayMode == FtInProductHelpMode.THEATER) {
117
+ this.displayMode = FtInProductHelpMode.FULLSCREEN;
118
+ }
119
+ }
120
+ setMode(displayMode) {
121
+ this.displayMode = displayMode;
122
+ this.dispatchVisibilityChange();
123
+ }
124
+ close() {
125
+ this.opened = false;
126
+ this.displayMode = FtInProductHelpMode.STANDARD;
127
+ this.dispatchVisibilityChange();
128
+ }
129
+ dispatchVisibilityChange() {
130
+ this.dispatchEvent(new FtInProductHelpVisibilityChange(this.opened, this.displayMode));
131
+ }
132
+ isTablet() {
133
+ const tabletBreakpoint = getComputedStyle(this).getPropertyValue(FtInProductHelpCssVariables.tabletBreakpoint.name) || FtInProductHelpCssVariables.tabletBreakpoint.defaultValue;
134
+ return window.matchMedia(`(min-width: ${tabletBreakpoint})`).matches;
135
+ }
136
+ isDesktop() {
137
+ const desktopBreakpoint = getComputedStyle(this).getPropertyValue(FtInProductHelpCssVariables.desktopBreakpoint.name) || FtInProductHelpCssVariables.desktopBreakpoint.defaultValue;
138
+ return window.matchMedia(`(min-width: ${desktopBreakpoint})`).matches;
139
+ }
140
+ }
141
+ FtInProductHelp.elementDefinitions = {
142
+ "ft-button": FtButton,
143
+ "ft-size-watcher": FtSizeWatcher,
144
+ };
145
+ FtInProductHelp.styles = styles;
146
+ __decorate([
147
+ property()
148
+ ], FtInProductHelp.prototype, "portalUrl", void 0);
149
+ __decorate([
150
+ property({ reflect: true, type: Boolean })
151
+ ], FtInProductHelp.prototype, "opened", void 0);
152
+ __decorate([
153
+ property({ reflect: true })
154
+ ], FtInProductHelp.prototype, "displayMode", void 0);
155
+ __decorate([
156
+ property()
157
+ ], FtInProductHelp.prototype, "closeIcon", void 0);
158
+ __decorate([
159
+ property()
160
+ ], FtInProductHelp.prototype, "standardModeIcon", void 0);
161
+ __decorate([
162
+ property({ type: Boolean })
163
+ ], FtInProductHelp.prototype, "disableStandardMode", void 0);
164
+ __decorate([
165
+ property()
166
+ ], FtInProductHelp.prototype, "theaterModeIcon", void 0);
167
+ __decorate([
168
+ property({ type: Boolean })
169
+ ], FtInProductHelp.prototype, "disableTheaterMode", void 0);
170
+ __decorate([
171
+ property()
172
+ ], FtInProductHelp.prototype, "fullscreenModeIcon", void 0);
173
+ __decorate([
174
+ property({ type: Boolean })
175
+ ], FtInProductHelp.prototype, "disableFullscreenMode", void 0);
176
+ __decorate([
177
+ property()
178
+ ], FtInProductHelp.prototype, "iconVariant", void 0);
179
+ __decorate([
180
+ state()
181
+ ], FtInProductHelp.prototype, "allowStandardMode", void 0);
182
+ __decorate([
183
+ state()
184
+ ], FtInProductHelp.prototype, "allowTheaterMode", void 0);
185
+ __decorate([
186
+ state()
187
+ ], FtInProductHelp.prototype, "allowFullscreenMode", void 0);
188
+ export { FtInProductHelp };