@pairbo/ui-kit 0.0.1 → 0.0.3
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/dist/pairbo.es.js +15027 -0
- package/dist/pairbo.umd.js +1633 -0
- package/dist/src/components/button/button.component.d.ts +32 -0
- package/dist/src/components/button/button.d.ts +8 -0
- package/dist/src/components/button/button.styles.d.ts +2 -0
- package/dist/src/components/button-group/button-group.component.d.ts +23 -0
- package/dist/src/components/button-group/button-group.d.ts +8 -0
- package/dist/src/components/button-group/button-group.styles.d.ts +2 -0
- package/dist/src/components/card-selection/card-selection.component.d.ts +23 -0
- package/dist/src/components/card-selection/card-selection.d.ts +8 -0
- package/dist/src/components/card-selection/card-selection.styles.d.ts +2 -0
- package/dist/src/components/category/category.component.d.ts +13 -0
- package/dist/src/components/category/category.d.ts +8 -0
- package/dist/src/components/category/category.styles.d.ts +2 -0
- package/dist/src/components/category-image/category-image.component.d.ts +23 -0
- package/dist/src/components/category-image/category-image.d.ts +8 -0
- package/dist/src/components/category-image/category-image.styles.d.ts +2 -0
- package/dist/src/components/drawer/drawer.component.d.ts +28 -0
- package/dist/src/components/drawer/drawer.d.ts +8 -0
- package/dist/src/components/drawer/drawer.styles.d.ts +2 -0
- package/dist/src/components/editor/editor.component.d.ts +24 -0
- package/dist/src/components/editor/editor.d.ts +8 -0
- package/dist/src/components/editor/editor.styles.d.ts +2 -0
- package/dist/src/components/fabric-example/fabric-example.component.d.ts +26 -0
- package/dist/src/components/fabric-example/fabric-example.d.ts +8 -0
- package/dist/src/components/fabric-example/fabric-example.styles.d.ts +2 -0
- package/dist/src/components/image-slider/editor-card-slider.component.d.ts +41 -0
- package/dist/src/components/image-slider/editor-card-slider.d.ts +8 -0
- package/dist/src/components/image-slider/editor-card-slider.styles.d.ts +2 -0
- package/dist/src/components/main.d.ts +15 -0
- package/dist/src/components/message-selector/message-selector.component.d.ts +38 -0
- package/dist/src/components/message-selector/message-selector.d.ts +8 -0
- package/dist/src/components/message-selector/message-selector.styles.d.ts +2 -0
- package/dist/src/components/message-selector/message-selector.test.d.ts +1 -0
- package/dist/src/components/page-manager/page-manager.component.d.ts +41 -0
- package/dist/src/components/page-manager/page-manager.d.ts +8 -0
- package/dist/src/components/page-manager/page-manager.styles.d.ts +2 -0
- package/dist/src/components/radio-button/radio-button.component.d.ts +37 -0
- package/dist/src/components/radio-button/radio-button.d.ts +8 -0
- package/dist/src/components/radio-button/radio-button.styles.d.ts +2 -0
- package/dist/src/components/radio-group/radio-group.component.d.ts +56 -0
- package/dist/src/components/radio-group/radio-group.d.ts +8 -0
- package/dist/src/components/radio-group/radio-group.styles.d.ts +2 -0
- package/dist/src/components/selector/selector.component.d.ts +18 -0
- package/dist/src/components/selector/selector.d.ts +8 -0
- package/dist/src/components/selector/selector.styles.d.ts +2 -0
- package/dist/src/components/textarea/textarea.component.d.ts +78 -0
- package/dist/src/components/textarea/textarea.d.ts +8 -0
- package/dist/src/components/textarea/textarea.styles.d.ts +2 -0
- package/dist/src/components/type-form/type-form.component.d.ts +48 -0
- package/dist/src/components/type-form/type-form.d.ts +8 -0
- package/dist/src/components/type-form/type-form.styles.d.ts +2 -0
- package/dist/src/events/events.d.ts +1 -0
- package/dist/src/events/pbo-category-card-select.d.ts +8 -0
- package/dist/src/internal/form.d.ts +43 -0
- package/{src/internal/pairbo-element.ts → dist/src/internal/pairbo-element.d.ts} +21 -46
- package/dist/src/internal/slots.d.ts +12 -0
- package/dist/src/internal/watch.d.ts +28 -0
- package/dist/src/styles/component.styles.d.ts +2 -0
- package/dist/src/styles/form-control.styles.d.ts +2 -0
- package/package.json +12 -8
- package/.husky/pre-commit +0 -1
- package/.prettierignore +0 -16
- package/.prettierrc.json +0 -17
- package/cspell.json +0 -9
- package/dev.html +0 -101
- package/docs/README.md +0 -1
- package/docs/_includes/component.njk +0 -16
- package/docs/_includes/default.njk +0 -39
- package/docs/_includes/sidebar.njk +0 -16
- package/docs/eleventy.config.mjs +0 -72
- package/docs/pages/components/message-selector.md +0 -17
- package/docs/pages/fabric-example.html +0 -46
- package/docs/pages/fabric-example.js +0 -28
- package/docs/pages/index.md +0 -76
- package/eslint.config.mjs +0 -32
- package/ignote_temp +0 -3
- package/index.html +0 -162
- package/lint-stage.confg.js +0 -6
- package/pages/card-selection.html +0 -65
- package/pages/drawer.html +0 -47
- package/pages/editor.html +0 -45
- package/pages/page-mgn.html +0 -51
- package/pages/test_build.html +0 -47
- package/scripts/plop/plopfile.js +0 -51
- package/scripts/plop/templates/components/component.hbs +0 -34
- package/scripts/plop/templates/components/define.hbs +0 -10
- package/scripts/plop/templates/components/styles.hbs +0 -7
- package/src/components/button/button.component.ts +0 -93
- package/src/components/button/button.styles.ts +0 -273
- package/src/components/button/button.ts +0 -10
- package/src/components/button-group/button-group.component.ts +0 -36
- package/src/components/button-group/button-group.styles.ts +0 -7
- package/src/components/button-group/button-group.ts +0 -10
- package/src/components/card-selection/card-selection.component.ts +0 -43
- package/src/components/card-selection/card-selection.styles.ts +0 -7
- package/src/components/card-selection/card-selection.ts +0 -10
- package/src/components/category/category.component.ts +0 -91
- package/src/components/category/category.styles.ts +0 -27
- package/src/components/category/category.ts +0 -10
- package/src/components/category-image/category-image.component.ts +0 -38
- package/src/components/category-image/category-image.styles.ts +0 -11
- package/src/components/category-image/category-image.ts +0 -10
- package/src/components/drawer/drawer.component.ts +0 -82
- package/src/components/drawer/drawer.styles.ts +0 -54
- package/src/components/drawer/drawer.ts +0 -10
- package/src/components/editor/editor.component.ts +0 -135
- package/src/components/editor/editor.styles.ts +0 -13
- package/src/components/editor/editor.ts +0 -10
- package/src/components/fabric-example/fabric-example.component.ts +0 -268
- package/src/components/fabric-example/fabric-example.styles.ts +0 -23
- package/src/components/fabric-example/fabric-example.ts +0 -12
- package/src/components/image-slider/editor-card-slider.component.ts +0 -136
- package/src/components/image-slider/editor-card-slider.styles.ts +0 -46
- package/src/components/image-slider/editor-card-slider.ts +0 -9
- package/src/components/main.ts +0 -17
- package/src/components/message-selector/message-selector.component.ts +0 -154
- package/src/components/message-selector/message-selector.styles.ts +0 -16
- package/src/components/message-selector/message-selector.test.ts +0 -64
- package/src/components/message-selector/message-selector.ts +0 -13
- package/src/components/page-manager/page-manager.component.ts +0 -228
- package/src/components/page-manager/page-manager.styles.ts +0 -9
- package/src/components/page-manager/page-manager.ts +0 -10
- package/src/components/radio-button/radio-button.component.ts +0 -118
- package/src/components/radio-button/radio-button.styles.ts +0 -13
- package/src/components/radio-button/radio-button.ts +0 -10
- package/src/components/radio-group/radio-group.component.ts +0 -203
- package/src/components/radio-group/radio-group.styles.ts +0 -19
- package/src/components/radio-group/radio-group.ts +0 -10
- package/src/components/selector/selector.component.ts +0 -115
- package/src/components/selector/selector.styles.ts +0 -9
- package/src/components/selector/selector.ts +0 -10
- package/src/components/textarea/textarea.component.ts +0 -234
- package/src/components/textarea/textarea.styles.ts +0 -178
- package/src/components/textarea/textarea.ts +0 -10
- package/src/components/type-form/type-form.component.ts +0 -121
- package/src/components/type-form/type-form.styles.ts +0 -7
- package/src/components/type-form/type-form.ts +0 -10
- package/src/declaration.d.ts +0 -44
- package/src/events/events.ts +0 -1
- package/src/events/pbo-category-card-select.ts +0 -7
- package/src/internal/form.ts +0 -376
- package/src/internal/slots.ts +0 -54
- package/src/internal/watch.ts +0 -79
- package/src/styles/component.styles.ts +0 -17
- package/src/styles/form-control.styles.ts +0 -59
- package/temp +0 -20
- package/tsconfig.json +0 -28
- package/vite.config.ts +0 -26
- /package/{public → dist}/Greeting Card from Pairbo.png +0 -0
- /package/{src/components/fabric-example/fabric-example.test.ts → dist/src/components/fabric-example/fabric-example.test.d.ts} +0 -0
- /package/{src → dist/src}/themes/default.css +0 -0
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { LitElement, html, css } from "lit";
|
|
2
|
-
import { customElement, property, query, state } from "lit/decorators.js";
|
|
3
|
-
import { Canvas, ITextEvents, SerializedTextboxProps, Textbox, TextboxProps, TOptions, FabricImage } from "fabric";
|
|
4
|
-
import { prototype } from "mocha";
|
|
5
|
-
|
|
6
|
-
@customElement("fabric-example")
|
|
7
|
-
export default class FabricExample extends LitElement {
|
|
8
|
-
@property() backgroundUrl: string =
|
|
9
|
-
"https://upload.wikimedia.org/wikipedia/commons/0/06/Daedalus_Spaceship_concept.jpg";
|
|
10
|
-
@property()
|
|
11
|
-
message: string = "Dear fridends,\n\nMy name is xxxxx. sadf;lkasdf\ngood aklsdfja";
|
|
12
|
-
@property({ type: String, reflect: true }) alignment: "left" | "center" | "right" = "left";
|
|
13
|
-
@property({ type: String }) fontFamily: string = "Arial";
|
|
14
|
-
@property({ type: String }) color: string = "#000";
|
|
15
|
-
|
|
16
|
-
@query(".fabric-container")
|
|
17
|
-
private _fabricContainer!: HTMLDivElement;
|
|
18
|
-
|
|
19
|
-
@state()
|
|
20
|
-
private _canvas?: Canvas;
|
|
21
|
-
@state()
|
|
22
|
-
private _canvasElement?: HTMLCanvasElement;
|
|
23
|
-
@state()
|
|
24
|
-
private _textbox?: Textbox<TOptions<TextboxProps>, SerializedTextboxProps, ITextEvents>;
|
|
25
|
-
@state()
|
|
26
|
-
private _backgroundImg: HTMLImageElement = new Image();
|
|
27
|
-
@state()
|
|
28
|
-
private _natureSize: { width: number; height: number } = { width: 0, height: 0 };
|
|
29
|
-
@state()
|
|
30
|
-
private _scale: number = 1;
|
|
31
|
-
@state()
|
|
32
|
-
private _lineHeight: number = 0;
|
|
33
|
-
@state()
|
|
34
|
-
private _fontSize: number = 0;
|
|
35
|
-
|
|
36
|
-
constructor() {
|
|
37
|
-
super();
|
|
38
|
-
this._backgroundImg = new Image();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
static styles = css`
|
|
42
|
-
:host {
|
|
43
|
-
display: block;
|
|
44
|
-
height: 100%;
|
|
45
|
-
width: 100%;
|
|
46
|
-
}
|
|
47
|
-
.fabric-container {
|
|
48
|
-
display: block;
|
|
49
|
-
border: 2px solid #333;
|
|
50
|
-
border-radius: 4px;
|
|
51
|
-
background: #fff;
|
|
52
|
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
53
|
-
height: 100%;
|
|
54
|
-
width: 100%;
|
|
55
|
-
}
|
|
56
|
-
canvas {
|
|
57
|
-
border: 1px solid #ccc;
|
|
58
|
-
width: 100%;
|
|
59
|
-
height: 100%;
|
|
60
|
-
}
|
|
61
|
-
.grechen-fuemen-regular {
|
|
62
|
-
font-family: "Grechen Fuemen", serif;
|
|
63
|
-
font-weight: 400;
|
|
64
|
-
font-style: normal;
|
|
65
|
-
}
|
|
66
|
-
`;
|
|
67
|
-
connectedCallback() {
|
|
68
|
-
super.connectedCallback();
|
|
69
|
-
this._backgroundImg.src = this.backgroundUrl;
|
|
70
|
-
this._backgroundImg.onload = () => {
|
|
71
|
-
this._natureSize = { width: this._backgroundImg.naturalWidth, height: this._backgroundImg.naturalHeight };
|
|
72
|
-
};
|
|
73
|
-
this._canvasElement = document.createElement("canvas");
|
|
74
|
-
}
|
|
75
|
-
formatTextbox(textbox: Textbox<TOptions<TextboxProps>, SerializedTextboxProps, ITextEvents>) {
|
|
76
|
-
console.log({
|
|
77
|
-
line: textbox?.textLines,
|
|
78
|
-
text: textbox?.text,
|
|
79
|
-
});
|
|
80
|
-
let lines = textbox.textLines;
|
|
81
|
-
console.log(lines.length);
|
|
82
|
-
if (lines.length > 12) {
|
|
83
|
-
// Prevent adding more lines after 12
|
|
84
|
-
const limitedLines = lines.slice(0, 12);
|
|
85
|
-
textbox.set("text", limitedLines.join("\n"));
|
|
86
|
-
textbox.setSelectionStart(textbox.text.length);
|
|
87
|
-
textbox.setSelectionEnd(textbox.text.length);
|
|
88
|
-
this._canvas?.renderAll();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
firstUpdated() {
|
|
93
|
-
const canvasElement = document.createElement("canvas");
|
|
94
|
-
this._fabricContainer.appendChild(canvasElement);
|
|
95
|
-
|
|
96
|
-
this._backgroundImg.onload = () => {
|
|
97
|
-
const fabricBackgroundImage = new FabricImage(this._backgroundImg);
|
|
98
|
-
|
|
99
|
-
this._canvas = new Canvas(canvasElement, {
|
|
100
|
-
backgroundImage: fabricBackgroundImage,
|
|
101
|
-
width: this._backgroundImg.naturalWidth,
|
|
102
|
-
height: this._backgroundImg.naturalHeight,
|
|
103
|
-
});
|
|
104
|
-
this._lineHeight = (0.45 * this._backgroundImg.height) / 12;
|
|
105
|
-
this._fontSize = this._lineHeight / 1.16;
|
|
106
|
-
|
|
107
|
-
const props: TOptions<TextboxProps> = {
|
|
108
|
-
fontSize: 16,
|
|
109
|
-
left: 0.084 * this._backgroundImg.naturalWidth,
|
|
110
|
-
// top: 0.4874 * this._backgroundImg.naturalHeight,
|
|
111
|
-
top: 0.52 * this._backgroundImg.naturalHeight,
|
|
112
|
-
width: 0.832 * this._backgroundImg.naturalWidth,
|
|
113
|
-
height: 0.45 * this._backgroundImg.naturalHeight,
|
|
114
|
-
hasControls: false,
|
|
115
|
-
editable: false,
|
|
116
|
-
breakWords: false,
|
|
117
|
-
splitByGrapheme: false, // Ensure text wraps correctly
|
|
118
|
-
textAlign: this.alignment,
|
|
119
|
-
lockMovementX: true,
|
|
120
|
-
lockMovementY: true,
|
|
121
|
-
selectable: false, // Make the textbox non-interactive
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
this._textbox = new Textbox(this.message, props);
|
|
125
|
-
this._textbox.set("fill", this.color);
|
|
126
|
-
// Custom logic to handle continuous characters without splitting words
|
|
127
|
-
this._textbox.on("changed", () => {
|
|
128
|
-
const maxLines = 12;
|
|
129
|
-
const maxCharsPerLine = 20;
|
|
130
|
-
if (!this._textbox) return;
|
|
131
|
-
let lines = this._textbox.text.split("\n");
|
|
132
|
-
let newLines: string[] = [];
|
|
133
|
-
lines.forEach(line => {
|
|
134
|
-
if (line.length > maxCharsPerLine) {
|
|
135
|
-
const words = line.split(" ");
|
|
136
|
-
let newLine = "";
|
|
137
|
-
let currentLength = 0;
|
|
138
|
-
words.forEach(word => {
|
|
139
|
-
if (currentLength + word.length > maxCharsPerLine) {
|
|
140
|
-
newLines.push(newLine.trim());
|
|
141
|
-
newLine = word + " ";
|
|
142
|
-
currentLength = word.length + 1;
|
|
143
|
-
} else {
|
|
144
|
-
newLine += word + " ";
|
|
145
|
-
currentLength += word.length + 1;
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
if (newLine.trim().length > 0) {
|
|
149
|
-
newLines.push(newLine.trim());
|
|
150
|
-
}
|
|
151
|
-
} else {
|
|
152
|
-
newLines.push(line);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
if (newLines.length > maxLines) {
|
|
156
|
-
newLines = newLines.slice(0, maxLines);
|
|
157
|
-
}
|
|
158
|
-
this._textbox.text = newLines.join("\n");
|
|
159
|
-
this._textbox.setSelectionStart(this._textbox.text.length);
|
|
160
|
-
this._textbox.setSelectionEnd(this._textbox.text.length);
|
|
161
|
-
this._canvas?.renderAll();
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
// Add text to canvas
|
|
165
|
-
this._canvas.add(this._textbox);
|
|
166
|
-
this._canvas.centerObject(this._textbox);
|
|
167
|
-
this._canvas.renderAll();
|
|
168
|
-
};
|
|
169
|
-
window.addEventListener("resize", () => {
|
|
170
|
-
canvasElement.width = this._fabricContainer.clientWidth;
|
|
171
|
-
canvasElement.height = this._fabricContainer.clientHeight;
|
|
172
|
-
this.adjustCanvasElements();
|
|
173
|
-
this._canvas?.renderAll(); // Re-render canvas content if necessary
|
|
174
|
-
});
|
|
175
|
-
setTimeout(() => this.adjustCanvasElements(), 100);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
adjustCanvasElements() {
|
|
179
|
-
if (this._canvas && this._textbox && this._backgroundImg && this._backgroundImg.complete) {
|
|
180
|
-
// Now we can safely work with the loaded image
|
|
181
|
-
|
|
182
|
-
const containerDiv = this.shadowRoot?.querySelector(".fabric-container");
|
|
183
|
-
if (!containerDiv) return;
|
|
184
|
-
const parentWidth = containerDiv.clientWidth;
|
|
185
|
-
const parentHeight = containerDiv.clientHeight;
|
|
186
|
-
const naturalWidth = this._backgroundImg.naturalWidth;
|
|
187
|
-
const naturalHeight = this._backgroundImg.naturalHeight;
|
|
188
|
-
const heightRatio = parentHeight / naturalHeight;
|
|
189
|
-
const widthRatio = parentWidth / naturalWidth;
|
|
190
|
-
const scale = Math.min(heightRatio, widthRatio);
|
|
191
|
-
this._scale = scale;
|
|
192
|
-
console.log({ parentWidth, parentHeight, naturalWidth, naturalHeight });
|
|
193
|
-
|
|
194
|
-
// Set the canvas dimensions
|
|
195
|
-
this._canvas.setWidth(naturalWidth * scale);
|
|
196
|
-
this._canvas.setHeight(naturalHeight * scale);
|
|
197
|
-
|
|
198
|
-
// Scale the background image
|
|
199
|
-
const background = this._canvas.backgroundImage;
|
|
200
|
-
if (background) {
|
|
201
|
-
background.scaleToWidth(naturalWidth * scale);
|
|
202
|
-
background.scaleToHeight(naturalHeight * scale);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// Scale the textbox
|
|
206
|
-
this._textbox.set({
|
|
207
|
-
left: 0.084 * naturalWidth * scale,
|
|
208
|
-
top: 0.52 * naturalHeight * scale,
|
|
209
|
-
width: 0.832 * naturalWidth * scale,
|
|
210
|
-
height: 0.45 * naturalHeight * scale,
|
|
211
|
-
fontSize: this._fontSize * scale,
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
console.log(((0.45 * naturalHeight) / 12) * 0.9 * scale);
|
|
215
|
-
console.log(`Line height pixel: ${this._textbox.get("lineHeight") * this._textbox.get("fontSize")}px`);
|
|
216
|
-
console.log(`Line height: ${this._textbox.get("lineHeight")}`);
|
|
217
|
-
console.log(`Font size: ${this._textbox.get("fontSize")}px`);
|
|
218
|
-
const lineHeight = (0.45 * naturalHeight * scale) / 12;
|
|
219
|
-
console.log(`desired line height: ${lineHeight}`);
|
|
220
|
-
console.log(`scale width: ${0.832 * naturalWidth * scale} - scale height: ${0.45 * naturalHeight * scale}`);
|
|
221
|
-
|
|
222
|
-
this._canvas.renderAll(); // Re-render canvas content if necessary
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
updated(changedProperties: Map<string | number | symbol, unknown>) {
|
|
227
|
-
console.log(changedProperties);
|
|
228
|
-
if (!this._textbox) return;
|
|
229
|
-
if (changedProperties.has("message")) {
|
|
230
|
-
this._textbox?.set("text", this.message);
|
|
231
|
-
this.formatTextbox(this._textbox);
|
|
232
|
-
this._canvas?.renderAll();
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if (changedProperties.has("alignment")) {
|
|
236
|
-
this._textbox?.set("textAlign", this.alignment);
|
|
237
|
-
this._canvas?.renderAll();
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
if (changedProperties.has("fontFamily")) {
|
|
241
|
-
this._textbox?.set("fontFamily", this.fontFamily);
|
|
242
|
-
this._canvas?.renderAll();
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (changedProperties.has("color")) {
|
|
246
|
-
this._textbox?.set("fill", this.color);
|
|
247
|
-
this._canvas?.renderAll();
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
render() {
|
|
252
|
-
return html`
|
|
253
|
-
<div
|
|
254
|
-
style="position: fixed; top: 0; left: 0; padding: 1rem; z-index: 1000; background: rgba(255, 255, 255, 0.5); color: rgba(0, 0, 0, 0.5);"
|
|
255
|
-
>
|
|
256
|
-
Nature font size: ${this._fontSize} <br />
|
|
257
|
-
Nature line height: ${this._lineHeight} <br />
|
|
258
|
-
Line height: ${this._textbox?.get("lineHeight")} <br />
|
|
259
|
-
Font size: ${this._textbox?.get("fontSize")} <br />
|
|
260
|
-
real textbox width: ${this._backgroundImg.width * 0.382} <br />
|
|
261
|
-
real textbox height: ${this._backgroundImg.height * 0.45} <br />
|
|
262
|
-
Textbox width: ${this._textbox?.width} <br />
|
|
263
|
-
Textbox height: ${this._textbox?.height} <br />
|
|
264
|
-
</div>
|
|
265
|
-
<div class="fabric-container"></div>
|
|
266
|
-
`;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { css } from "lit";
|
|
2
|
-
|
|
3
|
-
export default css`
|
|
4
|
-
:host {
|
|
5
|
-
display: block;
|
|
6
|
-
font-family: Arial, sans-serif;
|
|
7
|
-
}
|
|
8
|
-
.message-selector {
|
|
9
|
-
border: 1px solid #ccc;
|
|
10
|
-
padding: 1rem;
|
|
11
|
-
border-radius: 4px;
|
|
12
|
-
background-color: #fff;
|
|
13
|
-
color: black;
|
|
14
|
-
}
|
|
15
|
-
.fabric-container {
|
|
16
|
-
display: block;
|
|
17
|
-
margin-top: 1rem;
|
|
18
|
-
position: absolute;
|
|
19
|
-
top: 50%;
|
|
20
|
-
left: 50%;
|
|
21
|
-
transform: translate(-50%, -50%);
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import FabricExample from "./fabric-example.component.js";
|
|
2
|
-
|
|
3
|
-
export * from "./fabric-example.component.js";
|
|
4
|
-
export default FabricExample;
|
|
5
|
-
|
|
6
|
-
// customElements.define("pairbo-message-selector", PairboMessageSelector);
|
|
7
|
-
|
|
8
|
-
declare global {
|
|
9
|
-
interface HTMLElementTagNameMap {
|
|
10
|
-
"fabric-example": FabricExample;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { customElement, property, query, queryAll, state } from "lit/decorators.js";
|
|
2
|
-
import { css, html, LitElement, unsafeCSS } from "lit";
|
|
3
|
-
import type { CSSResultGroup, PropertyValues } from "lit";
|
|
4
|
-
import componentStyles from "../../styles/component.styles.js";
|
|
5
|
-
import PairboElement from "../../internal/pairbo-element.js";
|
|
6
|
-
import styles from "./editor-card-slider.styles.js";
|
|
7
|
-
// Default theme
|
|
8
|
-
import splideCss from "@splidejs/splide/dist/css/themes/splide-default.min.css?inline";
|
|
9
|
-
import Splide from "@splidejs/splide";
|
|
10
|
-
import FabricExample from "../fabric-example/fabric-example.component.js";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @summary Short summary of the component's intended use.
|
|
14
|
-
* @status experimental
|
|
15
|
-
*
|
|
16
|
-
* @dependency pbo-example
|
|
17
|
-
*
|
|
18
|
-
* @event pbo-event-name - Emitted as an example.
|
|
19
|
-
*
|
|
20
|
-
* @slot - The default slot.
|
|
21
|
-
* @slot example - An example slot.
|
|
22
|
-
*
|
|
23
|
-
* @csspart base - The component's base wrapper.
|
|
24
|
-
*
|
|
25
|
-
* @cssproperty --example - An example CSS custom property.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
@customElement("pbo-editor-card-slider")
|
|
29
|
-
export default class PboEditorCardSlider extends PairboElement {
|
|
30
|
-
// static styles: CSSResultGroup = [componentStyles, styles];
|
|
31
|
-
static styles: CSSResultGroup = [componentStyles, styles, unsafeCSS(splideCss)];
|
|
32
|
-
static dependencies = {
|
|
33
|
-
"fabric-example": FabricExample,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
@property({ type: Object }) card: Card | null = null;
|
|
37
|
-
@property({ type: Number, reflect: true }) focusIndex = 0;
|
|
38
|
-
|
|
39
|
-
@property({ type: Object }) livePreviewProps: {
|
|
40
|
-
font: string;
|
|
41
|
-
text: string;
|
|
42
|
-
color: string;
|
|
43
|
-
alignment: string;
|
|
44
|
-
} = { font: "Monsieur La Doulaise", text: "", color: "rgb(0,0,0)", alignment: "left" };
|
|
45
|
-
|
|
46
|
-
@query("#thumbnails") thumbnailCarousel!: HTMLDivElement;
|
|
47
|
-
@query("#main-carousel") mainCarousel!: HTMLDivElement;
|
|
48
|
-
@queryAll(".thumbnail") thumbnailElements!: NodeListOf<HTMLDivElement>;
|
|
49
|
-
@state() thumbnailSplide!: Splide;
|
|
50
|
-
@state() mainSplide!: Splide;
|
|
51
|
-
|
|
52
|
-
protected firstUpdated(): void {
|
|
53
|
-
this.mainSplide = new Splide(this.mainCarousel, {
|
|
54
|
-
width: 300,
|
|
55
|
-
height: 400,
|
|
56
|
-
pagination: false,
|
|
57
|
-
arrows: false,
|
|
58
|
-
direction: "ttb",
|
|
59
|
-
cover: true,
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const initThumbnail = (thumbnail: HTMLDivElement, index: number) => {
|
|
63
|
-
thumbnail.addEventListener("click", () => {
|
|
64
|
-
this.mainSplide.go(index);
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
console.log(this.thumbnailElements);
|
|
69
|
-
for (let i = 0; i < this.thumbnailElements.length; i++) {
|
|
70
|
-
initThumbnail(this.thumbnailElements[i], i);
|
|
71
|
-
}
|
|
72
|
-
let current: Element | null = null;
|
|
73
|
-
this.mainSplide.on("mounted move", () => {
|
|
74
|
-
this.focusIndex = this.mainSplide.index;
|
|
75
|
-
if (current !== null) {
|
|
76
|
-
current.classList.remove("is-active");
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
let thumbnail = this.thumbnailElements[this.mainSplide.index];
|
|
80
|
-
if (thumbnail) {
|
|
81
|
-
thumbnail.classList.add("is-active");
|
|
82
|
-
current = thumbnail;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
this.mainSplide.mount();
|
|
87
|
-
// The function to initialize each thumbnail.
|
|
88
|
-
}
|
|
89
|
-
updated(changedProperties: Map<string | number | symbol, unknown>) {
|
|
90
|
-
if (changedProperties.has("focusIndex")) {
|
|
91
|
-
this.mainSplide.go(this.focusIndex);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
render() {
|
|
96
|
-
return html`
|
|
97
|
-
${JSON.stringify(this.card)}
|
|
98
|
-
<div class="card--slider--wrapper">
|
|
99
|
-
<ul id="thumbnails" class="thumbnails">
|
|
100
|
-
<li class="thumbnail">
|
|
101
|
-
<img src="${this.card?.medias.cover.url || "https://picsum.photos/id/1/300/400"}" alt="" />
|
|
102
|
-
</li>
|
|
103
|
-
<li class="thumbnail">
|
|
104
|
-
<img src="${this.card?.medias.render_1.url || "https://picsum.photos/id/10/300/400"}" alt="" />
|
|
105
|
-
</li>
|
|
106
|
-
<li class="thumbnail">
|
|
107
|
-
<img src="${this.card?.medias.render_2.url || "https://picsum.photos/id/10/300/400"}" alt="" />
|
|
108
|
-
</li>
|
|
109
|
-
</ul>
|
|
110
|
-
|
|
111
|
-
<section id="main-carousel" class="splide" aria-label="My Awesome Gallery">
|
|
112
|
-
<div class="splide__track">
|
|
113
|
-
<ul class="splide__list">
|
|
114
|
-
<li class="splide__slide">
|
|
115
|
-
${this.card?.medias.cover.url}
|
|
116
|
-
<img src="${this.card?.medias.cover.url || "https://picsum.photos/id/1/300/400"}" alt="" />
|
|
117
|
-
</li>
|
|
118
|
-
<li class="splide__slide">
|
|
119
|
-
<fabric-example
|
|
120
|
-
backgroundUrl="${this.card?.medias.render_1.url || "https://picsum.photos/id/10/300/400"}"
|
|
121
|
-
alignment=${this.livePreviewProps?.alignment || "left"}
|
|
122
|
-
message=${this.livePreviewProps?.text}
|
|
123
|
-
color=${this.livePreviewProps?.color}
|
|
124
|
-
fontFamily=${this.livePreviewProps?.font}
|
|
125
|
-
></fabric-example>
|
|
126
|
-
</li>
|
|
127
|
-
<li class="splide__slide">
|
|
128
|
-
<img src="${this.card?.medias.render_2.url || "https://picsum.photos/id/10/300/400"}" alt="" />
|
|
129
|
-
</li>
|
|
130
|
-
</ul>
|
|
131
|
-
</div>
|
|
132
|
-
</section>
|
|
133
|
-
</div>
|
|
134
|
-
`;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { css } from "lit";
|
|
2
|
-
|
|
3
|
-
export default css`
|
|
4
|
-
:host {
|
|
5
|
-
display: block;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.card--slider--wrapper {
|
|
9
|
-
display: flex;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.splide {
|
|
13
|
-
margin: 0 auto;
|
|
14
|
-
width: 100%;
|
|
15
|
-
}
|
|
16
|
-
img {
|
|
17
|
-
-webkit-user-drag: none;
|
|
18
|
-
pointer-events: none;
|
|
19
|
-
}
|
|
20
|
-
.thumbnails {
|
|
21
|
-
display: flex;
|
|
22
|
-
flex-direction: column;
|
|
23
|
-
gap: 0.5rem;
|
|
24
|
-
padding: 0;
|
|
25
|
-
justify-content: start;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.thumbnail {
|
|
29
|
-
width: 70px;
|
|
30
|
-
height: 70px;
|
|
31
|
-
overflow: hidden;
|
|
32
|
-
list-style: none;
|
|
33
|
-
margin: 0 0.2rem;
|
|
34
|
-
cursor: pointer;
|
|
35
|
-
opacity: 0.3;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.thumbnail.is-active {
|
|
39
|
-
opacity: 1;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.thumbnail img {
|
|
43
|
-
width: 100%;
|
|
44
|
-
height: auto;
|
|
45
|
-
}
|
|
46
|
-
`;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import PboEditorCardSlider from "./editor-card-slider.component.js";
|
|
2
|
-
export * from "./editor-card-slider.component.js";
|
|
3
|
-
export default PboEditorCardSlider;
|
|
4
|
-
|
|
5
|
-
declare global {
|
|
6
|
-
interface HTMLElementTagNameMap {
|
|
7
|
-
"pbo-image-slider": PboEditorCardSlider;
|
|
8
|
-
}
|
|
9
|
-
}
|
package/src/components/main.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export { default as MessageSelector } from "./message-selector/message-selector.component.js";
|
|
2
|
-
export { default as FabricExample } from "./fabric-example/fabric-example.component.js";
|
|
3
|
-
|
|
4
|
-
export { default as PboSelector } from "./selector/selector.component.js";
|
|
5
|
-
export { default as PboButton } from "./button/button.js";
|
|
6
|
-
export { default as PboButtonGroup } from "./button-group/button-group.js";
|
|
7
|
-
export { default as PboRadioButton } from "./radio-button/radio-button.js";
|
|
8
|
-
export { default as PboRadioGroup } from "./radio-group/radio-group.js";
|
|
9
|
-
export { default as PboTextarea } from "./textarea/textarea.js";
|
|
10
|
-
export { default as PboEditor } from "./editor/editor.js";
|
|
11
|
-
export { default as PboTypeForm } from "./type-form/type-form.js";
|
|
12
|
-
export { default as PboEditorCardSlider } from "./image-slider/editor-card-slider.js";
|
|
13
|
-
export { default as PboCategory } from "./category/category.js";
|
|
14
|
-
export { default as PboDrawer } from "./drawer/drawer.js";
|
|
15
|
-
export { default as PboPageManager } from "./page-manager/page-manager.js";
|
|
16
|
-
export { default as PboCardSelection } from "./card-selection/card-selection.js";
|
|
17
|
-
/* plop:component */
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { LitElement, html, css } from "lit";
|
|
2
|
-
import { customElement } from "lit/decorators.js";
|
|
3
|
-
import styles from "./message-selector.styles.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A component for selecting messages.
|
|
7
|
-
*
|
|
8
|
-
* @element pairbo-message-selector
|
|
9
|
-
*/
|
|
10
|
-
@customElement("pairbo-message-selector")
|
|
11
|
-
export default class PairboMessageSelector extends LitElement {
|
|
12
|
-
static styles = [
|
|
13
|
-
styles,
|
|
14
|
-
css`
|
|
15
|
-
.message-selector {
|
|
16
|
-
text-align: left;
|
|
17
|
-
}
|
|
18
|
-
.message-selector > div {
|
|
19
|
-
margin-bottom: 1rem;
|
|
20
|
-
}
|
|
21
|
-
.message-selector-hidden {
|
|
22
|
-
display: none;
|
|
23
|
-
}
|
|
24
|
-
pre {
|
|
25
|
-
background: #f7f7f7;
|
|
26
|
-
padding: 1rem;
|
|
27
|
-
border: 1px solid #ddd;
|
|
28
|
-
border-radius: 4px;
|
|
29
|
-
overflow-x: auto;
|
|
30
|
-
margin-top: 1rem;
|
|
31
|
-
}
|
|
32
|
-
code {
|
|
33
|
-
font-family: monospace;
|
|
34
|
-
}
|
|
35
|
-
`,
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
static properties = {
|
|
39
|
-
giftLabel: { type: String },
|
|
40
|
-
premiumLabel: { type: String },
|
|
41
|
-
premiumDescription: { type: String },
|
|
42
|
-
noteLabel: { type: String },
|
|
43
|
-
giftSelected: { type: Boolean },
|
|
44
|
-
premiumSelected: { type: Boolean },
|
|
45
|
-
freeMessageSelected: { type: Boolean },
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
constructor() {
|
|
49
|
-
super();
|
|
50
|
-
// Set default values.
|
|
51
|
-
(this as any).giftLabel = "This is a gift?";
|
|
52
|
-
(this as any).premiumLabel = "Add a premium greeting card";
|
|
53
|
-
(this as any).premiumDescription =
|
|
54
|
-
"Select a premium greeting card and add your personal message. You'll choose from our 100% recycled paper cards, priced at $6, and we'll package it with your gift for that extra thoughtful touch.";
|
|
55
|
-
(this as any).noteLabel = "Add a free message";
|
|
56
|
-
(this as any).giftSelected = false;
|
|
57
|
-
(this as any).premiumSelected = false;
|
|
58
|
-
(this as any).freeMessageSelected = false;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
public toggleMessageSelector() {
|
|
62
|
-
const messageSelector = this.shadowRoot?.querySelector(".message-selector");
|
|
63
|
-
if (messageSelector) {
|
|
64
|
-
messageSelector.classList.toggle("message-selector-hidden");
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
private _onGiftChange(e: Event) {
|
|
69
|
-
const target = e.target as HTMLInputElement;
|
|
70
|
-
(this as any).giftSelected = target.checked;
|
|
71
|
-
if (!(this as any).giftSelected) {
|
|
72
|
-
// Clear premium and free-message selections if gift is not selected.
|
|
73
|
-
(this as any).premiumSelected = false;
|
|
74
|
-
(this as any).freeMessageSelected = false;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private _onPremiumChange(e: Event) {
|
|
79
|
-
const target = e.target as HTMLInputElement;
|
|
80
|
-
if (target.checked) {
|
|
81
|
-
(this as any).premiumSelected = true;
|
|
82
|
-
(this as any).freeMessageSelected = false;
|
|
83
|
-
} else {
|
|
84
|
-
(this as any).premiumSelected = false;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private _onFreeMessageChange(e: Event) {
|
|
89
|
-
const target = e.target as HTMLInputElement;
|
|
90
|
-
if (target.checked) {
|
|
91
|
-
(this as any).freeMessageSelected = true;
|
|
92
|
-
(this as any).premiumSelected = false;
|
|
93
|
-
} else {
|
|
94
|
-
(this as any).freeMessageSelected = false;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
render() {
|
|
99
|
-
return html`
|
|
100
|
-
<div class="message-selector">
|
|
101
|
-
<!-- Gift Checkbox: Always visible -->
|
|
102
|
-
<div>
|
|
103
|
-
<input
|
|
104
|
-
type="checkbox"
|
|
105
|
-
id="is-gift"
|
|
106
|
-
name="is-gift"
|
|
107
|
-
.checked=${(this as any).giftSelected}
|
|
108
|
-
@change=${this._onGiftChange}
|
|
109
|
-
/>
|
|
110
|
-
<label for="is-gift">${(this as any).giftLabel}</label>
|
|
111
|
-
</div>
|
|
112
|
-
|
|
113
|
-
<!-- Premium and Free Message Options: Only visible if gift is selected -->
|
|
114
|
-
${(this as any).giftSelected
|
|
115
|
-
? html`
|
|
116
|
-
<div>
|
|
117
|
-
<input
|
|
118
|
-
type="checkbox"
|
|
119
|
-
id="premium-card"
|
|
120
|
-
name="premium-card"
|
|
121
|
-
value="premium-card"
|
|
122
|
-
.checked=${(this as any).premiumSelected}
|
|
123
|
-
@change=${this._onPremiumChange}
|
|
124
|
-
/>
|
|
125
|
-
<label for="premium-card">${(this as any).premiumLabel}</label>
|
|
126
|
-
<p class="description">${(this as any).premiumDescription}</p>
|
|
127
|
-
</div>
|
|
128
|
-
<div>
|
|
129
|
-
<input
|
|
130
|
-
type="checkbox"
|
|
131
|
-
id="free-message"
|
|
132
|
-
name="free-message"
|
|
133
|
-
value="free-message"
|
|
134
|
-
.checked=${(this as any).freeMessageSelected}
|
|
135
|
-
@change=${this._onFreeMessageChange}
|
|
136
|
-
/>
|
|
137
|
-
<label for="free-message">${(this as any).noteLabel}</label>
|
|
138
|
-
</div>
|
|
139
|
-
`
|
|
140
|
-
: null}
|
|
141
|
-
|
|
142
|
-
<!-- Display current selection summary -->
|
|
143
|
-
<div class="current-selection">
|
|
144
|
-
<strong>Current Selection:</strong>
|
|
145
|
-
<ul>
|
|
146
|
-
<li>Gift: ${(this as any).giftSelected ? "Yes" : "No"}</li>
|
|
147
|
-
<li>Premium Card: ${(this as any).premiumSelected ? "Yes" : "No"}</li>
|
|
148
|
-
<li>Free Message: ${(this as any).freeMessageSelected ? "Yes" : "No"}</li>
|
|
149
|
-
</ul>
|
|
150
|
-
</div>
|
|
151
|
-
</div>
|
|
152
|
-
`;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// components/message-selector/message-selector.styles.ts
|
|
2
|
-
import { css } from "lit";
|
|
3
|
-
|
|
4
|
-
export default css`
|
|
5
|
-
:host {
|
|
6
|
-
display: block;
|
|
7
|
-
font-family: Arial, sans-serif;
|
|
8
|
-
}
|
|
9
|
-
.message-selector {
|
|
10
|
-
border: 1px solid #ccc;
|
|
11
|
-
padding: 1rem;
|
|
12
|
-
border-radius: 4px;
|
|
13
|
-
background-color: #fff;
|
|
14
|
-
color: black;
|
|
15
|
-
}
|
|
16
|
-
`;
|