@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,91 +0,0 @@
|
|
|
1
|
-
import { customElement, property, query, state } from "lit/decorators.js";
|
|
2
|
-
import { html, unsafeCSS } from "lit";
|
|
3
|
-
import type { CSSResultGroup } from "lit";
|
|
4
|
-
import componentStyles from "../../styles/component.styles.js";
|
|
5
|
-
import PairboElement from "../../internal/pairbo-element.js";
|
|
6
|
-
import styles from "./category.styles.js";
|
|
7
|
-
import splideCss from "@splidejs/splide/dist/css/themes/splide-default.min.css?inline";
|
|
8
|
-
import Splide from "@splidejs/splide";
|
|
9
|
-
import { map } from "lit/directives/map.js";
|
|
10
|
-
|
|
11
|
-
@customElement("pbo-category")
|
|
12
|
-
export default class PboCategory extends PairboElement {
|
|
13
|
-
static styles: CSSResultGroup = [componentStyles, styles, unsafeCSS(splideCss)];
|
|
14
|
-
|
|
15
|
-
@query("#category-carousel") imageCarousel!: HTMLDivElement;
|
|
16
|
-
@state() private imageSplide!: Splide;
|
|
17
|
-
@state() private slides: Card[] = [];
|
|
18
|
-
@property({
|
|
19
|
-
type: Array,
|
|
20
|
-
converter: {
|
|
21
|
-
fromAttribute(value: string) {
|
|
22
|
-
try {
|
|
23
|
-
return JSON.parse(value || "[]"); // Convert from string to array
|
|
24
|
-
} catch (e) {
|
|
25
|
-
console.error("Invalid JSON for 'cards':", value);
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
toAttribute(value: Card[]) {
|
|
30
|
-
return JSON.stringify(value); // Convert array back to string
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
})
|
|
34
|
-
cards: Card[] = [];
|
|
35
|
-
|
|
36
|
-
protected firstUpdated = (): void => {
|
|
37
|
-
this.imageSplide = new Splide(this.imageCarousel, {
|
|
38
|
-
fixedWidth: "24.5%",
|
|
39
|
-
heightRatio: 0.3,
|
|
40
|
-
gap: "2%",
|
|
41
|
-
rewind: false,
|
|
42
|
-
pagination: false,
|
|
43
|
-
isNavigation: false,
|
|
44
|
-
perPage: 2,
|
|
45
|
-
});
|
|
46
|
-
this.imageSplide.mount();
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
disconnectedCallback = (): void => {
|
|
50
|
-
super.disconnectedCallback();
|
|
51
|
-
this.imageSplide?.destroy();
|
|
52
|
-
};
|
|
53
|
-
clickHandler = (event: MouseEvent) => {
|
|
54
|
-
const target = event.target as HTMLImageElement;
|
|
55
|
-
this.emit("pbo-category-card-selected", {
|
|
56
|
-
detail: {
|
|
57
|
-
cardId: target.dataset.cardId,
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
render() {
|
|
63
|
-
return html`
|
|
64
|
-
<div class="category-container">
|
|
65
|
-
<slot name="title"></slot>
|
|
66
|
-
<section
|
|
67
|
-
id="category-carousel"
|
|
68
|
-
class="splide"
|
|
69
|
-
aria-label="The carousel with thumbnails. Selecting a thumbnail will change the Beautiful Gallery carousel."
|
|
70
|
-
>
|
|
71
|
-
<div class="splide__track">
|
|
72
|
-
<ul class="splide__list">
|
|
73
|
-
${map(this.cards, (card: Card) => {
|
|
74
|
-
return html`
|
|
75
|
-
<li class="splide__slide">
|
|
76
|
-
<img
|
|
77
|
-
src=${card.medias.cover.url}
|
|
78
|
-
alt="${card.medias.cover.alt}"
|
|
79
|
-
@click=${this.clickHandler}
|
|
80
|
-
data-card-id="${card.id}"
|
|
81
|
-
/>
|
|
82
|
-
</li>
|
|
83
|
-
`;
|
|
84
|
-
})}
|
|
85
|
-
</ul>
|
|
86
|
-
</div>
|
|
87
|
-
</section>
|
|
88
|
-
</div>
|
|
89
|
-
`;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { css } from "lit";
|
|
2
|
-
|
|
3
|
-
export default css`
|
|
4
|
-
:host {
|
|
5
|
-
display: block;
|
|
6
|
-
}
|
|
7
|
-
.splide {
|
|
8
|
-
margin: 0 auto;
|
|
9
|
-
width: 100%;
|
|
10
|
-
}
|
|
11
|
-
.splide__slide img {
|
|
12
|
-
width: 100%;
|
|
13
|
-
height: 100%;
|
|
14
|
-
aspect-ratio: 4/3;
|
|
15
|
-
object-fit: cover;
|
|
16
|
-
cursor: pointer;
|
|
17
|
-
}
|
|
18
|
-
.splide__slide img:hover {
|
|
19
|
-
border: 2px solid red;
|
|
20
|
-
box-sizing: border-box;
|
|
21
|
-
}
|
|
22
|
-
.splide__slide {
|
|
23
|
-
max-width: 300px;
|
|
24
|
-
width: 100%;
|
|
25
|
-
height: auto;
|
|
26
|
-
}
|
|
27
|
-
`;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { customElement, property } from "lit/decorators.js";
|
|
2
|
-
import { html, LitElement, unsafeCSS } from "lit";
|
|
3
|
-
import type { CSSResultGroup } from "lit";
|
|
4
|
-
import componentStyles from "../../styles/component.styles.js";
|
|
5
|
-
import PairboElement from "../../internal/pairbo-element.js";
|
|
6
|
-
import styles from "./category-image.styles.js";
|
|
7
|
-
import splideCss from "@splidejs/splide/dist/css/themes/splide-default.min.css?inline";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @summary Short summary of the component's intended use.
|
|
11
|
-
* @status experimental
|
|
12
|
-
*
|
|
13
|
-
* @dependency pbo-example
|
|
14
|
-
*
|
|
15
|
-
* @event pbo-event-name - Emitted as an example.
|
|
16
|
-
*
|
|
17
|
-
* @slot - The default slot.
|
|
18
|
-
* @slot example - An example slot.
|
|
19
|
-
*
|
|
20
|
-
* @csspart base - The component's base wrapper.
|
|
21
|
-
*
|
|
22
|
-
* @cssproperty --example - An example CSS custom property.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
@customElement("pbo-category-image")
|
|
26
|
-
export default class PboCategoryImage extends PairboElement {
|
|
27
|
-
static styles: CSSResultGroup = [componentStyles, styles, unsafeCSS(splideCss)];
|
|
28
|
-
|
|
29
|
-
/** An example attribute. */
|
|
30
|
-
@property() attr = "example";
|
|
31
|
-
render() {
|
|
32
|
-
return html`
|
|
33
|
-
<li class="splide__slide">
|
|
34
|
-
<slot></slot>
|
|
35
|
-
</li>
|
|
36
|
-
`;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { customElement, property, query } from "lit/decorators.js";
|
|
2
|
-
import { html, LitElement } 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 "./drawer.styles.js";
|
|
7
|
-
import { classMap } from "lit/directives/class-map.js";
|
|
8
|
-
import { watch } from "../../internal/watch.js";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @summary Short summary of the component's intended use.
|
|
12
|
-
* @status experimental
|
|
13
|
-
*
|
|
14
|
-
* @dependency pbo-example
|
|
15
|
-
*
|
|
16
|
-
* @event pbo-event-name - Emitted as an example.
|
|
17
|
-
*
|
|
18
|
-
* @slot - The default slot.
|
|
19
|
-
* @slot example - An example slot.
|
|
20
|
-
*
|
|
21
|
-
* @csspart base - The component's base wrapper.
|
|
22
|
-
*
|
|
23
|
-
* @cssproperty --example - An example CSS custom property.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
@customElement("pbo-drawer")
|
|
27
|
-
export default class PboModal extends PairboElement {
|
|
28
|
-
static styles: CSSResultGroup = [componentStyles, styles];
|
|
29
|
-
|
|
30
|
-
@query(".drawer") drawer!: HTMLDivElement;
|
|
31
|
-
@property({ type: Boolean, reflect: true }) open = false;
|
|
32
|
-
|
|
33
|
-
private requestClose(source: "close-button" | "keyboard" | "overlay") {
|
|
34
|
-
this.hide();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async hide() {
|
|
38
|
-
this.open = false;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async show() {
|
|
42
|
-
if (this.open) {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
this.open = true;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
@watch("open", { waitUntilFirstUpdate: true })
|
|
49
|
-
handleOpenChange() {
|
|
50
|
-
if (this.open) this.drawer.hidden = false;
|
|
51
|
-
else this.drawer.hidden = true;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Init the component
|
|
55
|
-
protected firstUpdated(): void {
|
|
56
|
-
this.drawer.hidden = !this.open;
|
|
57
|
-
}
|
|
58
|
-
render() {
|
|
59
|
-
return html`
|
|
60
|
-
<div
|
|
61
|
-
part="base"
|
|
62
|
-
class=${classMap({
|
|
63
|
-
drawer: true,
|
|
64
|
-
"drawer--bottom": true,
|
|
65
|
-
"drawer--open": this.open,
|
|
66
|
-
})}
|
|
67
|
-
>
|
|
68
|
-
<div part="overlay" class="drawer__overlay" @click=${() => this.requestClose("overlay")}></div>
|
|
69
|
-
<div
|
|
70
|
-
part="panel"
|
|
71
|
-
class="drawer__panel"
|
|
72
|
-
role="dialog"
|
|
73
|
-
aria-modal="true"
|
|
74
|
-
aria-hidden=${this.open ? "false" : "true"}
|
|
75
|
-
tabindex="0"
|
|
76
|
-
>
|
|
77
|
-
<slot part="body" class="drawer__body"></slot>
|
|
78
|
-
</div>
|
|
79
|
-
</div>
|
|
80
|
-
`;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { css } from "lit";
|
|
2
|
-
|
|
3
|
-
export default css`
|
|
4
|
-
:host {
|
|
5
|
-
--size: 30rem;
|
|
6
|
-
--header-spacing: var(--sl-spacing-large);
|
|
7
|
-
--body-spacing: var(--sl-spacing-large);
|
|
8
|
-
--footer-spacing: var(--sl-spacing-large);
|
|
9
|
-
|
|
10
|
-
display: contents;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.drawer {
|
|
14
|
-
top: 0;
|
|
15
|
-
inset-inline-start: 0;
|
|
16
|
-
width: 100%;
|
|
17
|
-
height: 100%;
|
|
18
|
-
pointer-events: none;
|
|
19
|
-
overflow: hidden;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.drawer__overlay {
|
|
23
|
-
display: block;
|
|
24
|
-
position: fixed;
|
|
25
|
-
top: 0;
|
|
26
|
-
right: 0;
|
|
27
|
-
bottom: 0;
|
|
28
|
-
left: 0;
|
|
29
|
-
background-color: var(--sl-overlay-background-color);
|
|
30
|
-
pointer-events: all;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.drawer__panel {
|
|
34
|
-
position: absolute;
|
|
35
|
-
display: flex;
|
|
36
|
-
flex-direction: column;
|
|
37
|
-
z-index: 2;
|
|
38
|
-
max-width: 100%;
|
|
39
|
-
max-height: 100%;
|
|
40
|
-
background-color: var(--sl-panel-background-color);
|
|
41
|
-
box-shadow: var(--sl-shadow-x-large);
|
|
42
|
-
overflow: auto;
|
|
43
|
-
pointer-events: all;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.drawer--bottom .drawer__panel {
|
|
47
|
-
top: auto;
|
|
48
|
-
inset-inline-end: auto;
|
|
49
|
-
bottom: 0;
|
|
50
|
-
inset-inline-start: 0;
|
|
51
|
-
width: 100%;
|
|
52
|
-
height: var(--size);
|
|
53
|
-
}
|
|
54
|
-
`;
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { customElement, property, query, state } from "lit/decorators.js";
|
|
2
|
-
import { html, LitElement } 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.styles.js";
|
|
7
|
-
import FabricExample from "../fabric-example/fabric-example.component.js";
|
|
8
|
-
import PboTypeForm from "../type-form/type-form.component.js";
|
|
9
|
-
import { styleMap } from "lit/directives/style-map.js";
|
|
10
|
-
import PboEditorCardSlider from "../image-slider/editor-card-slider.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
|
-
interface FormData {
|
|
29
|
-
cardId: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface TypingFormData extends FormData {
|
|
33
|
-
font: string;
|
|
34
|
-
text: string;
|
|
35
|
-
color: string;
|
|
36
|
-
alignment: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@customElement("pbo-editor")
|
|
40
|
-
export default class PboEditor extends PairboElement {
|
|
41
|
-
static styles: CSSResultGroup = [componentStyles, styles];
|
|
42
|
-
static dependencies = {
|
|
43
|
-
"editor-card-slider": PboEditorCardSlider,
|
|
44
|
-
"fabric-example": FabricExample,
|
|
45
|
-
"pbo-type-form": PboTypeForm,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
@property({ type: String, reflect: true }) cardInnerImageUrl = "../../../public/Greeting Card from Pairbo.png";
|
|
49
|
-
|
|
50
|
-
@query("pbo-type-form") typingForm!: PboTypeForm;
|
|
51
|
-
private handleTypingFormChange() {
|
|
52
|
-
console.log(this.typingForm.form);
|
|
53
|
-
}
|
|
54
|
-
@query("pbo-editor-card-slider") slider!: PboEditorCardSlider;
|
|
55
|
-
// private _card: Card | null = null;
|
|
56
|
-
|
|
57
|
-
@property({ type: Object }) card: Card | null = null;
|
|
58
|
-
@state()
|
|
59
|
-
private formData = { font: "Monsieur La Doulaise", text: "", color: "rgb(0,0,0)", alignment: "left" };
|
|
60
|
-
|
|
61
|
-
protected firstUpdated(): void {
|
|
62
|
-
this.typingForm.addEventListener("pbo-change", event => {
|
|
63
|
-
this.formData = this.typingForm.form;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
isCardType(obj: any): obj is Card {
|
|
68
|
-
return (
|
|
69
|
-
obj &&
|
|
70
|
-
typeof obj === "object" &&
|
|
71
|
-
"id" in obj &&
|
|
72
|
-
"name" in obj &&
|
|
73
|
-
"category" in obj &&
|
|
74
|
-
"medias" in obj &&
|
|
75
|
-
typeof obj.medias === "object" &&
|
|
76
|
-
"cover" in obj.medias &&
|
|
77
|
-
"render_1" in obj.medias &&
|
|
78
|
-
"render_2" in obj.medias &&
|
|
79
|
-
"inner" in obj.medias
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
updated(changedProperties: PropertyValues<this>): void {
|
|
84
|
-
if (changedProperties.has("cardInnerImageUrl")) {
|
|
85
|
-
this.requestUpdate();
|
|
86
|
-
}
|
|
87
|
-
if (changedProperties.has("card")) {
|
|
88
|
-
this.slider.card = this.card;
|
|
89
|
-
this.requestUpdate();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
disconnectedCallback(): void {
|
|
94
|
-
this.typingForm.removeEventListener("pbo-change", this.handleTypingFormChange);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
render() {
|
|
98
|
-
return html`
|
|
99
|
-
${JSON.stringify(this.card)} In the editor
|
|
100
|
-
<div class="editor">
|
|
101
|
-
<div
|
|
102
|
-
style=${styleMap({
|
|
103
|
-
maxWidth: "500px",
|
|
104
|
-
})}
|
|
105
|
-
>
|
|
106
|
-
<!--
|
|
107
|
-
<fabric-example
|
|
108
|
-
backgroundUrl=${this.cardInnerImageUrl}
|
|
109
|
-
alignment=${this.formData?.alignment || ""}
|
|
110
|
-
message=${this.formData?.text || ""}
|
|
111
|
-
color=${this.formData?.color || ""}
|
|
112
|
-
fontFamily=${this.formData?.font || ""}
|
|
113
|
-
></fabric-example>
|
|
114
|
-
-->
|
|
115
|
-
<pbo-editor-card-slider focusIndex="0" .livePreviewProps=${this.formData}></pbo-editor-card-slider>
|
|
116
|
-
</div>
|
|
117
|
-
|
|
118
|
-
<div>
|
|
119
|
-
<pbo-type-form></pbo-type-form>
|
|
120
|
-
${JSON.stringify(this.formData)}
|
|
121
|
-
</div>
|
|
122
|
-
</div>
|
|
123
|
-
<button
|
|
124
|
-
@click=${() => {
|
|
125
|
-
const slider = this.shadowRoot?.querySelector("pbo-editor-card-slider");
|
|
126
|
-
if (slider && slider.getAttribute("focusIndex") !== "1") {
|
|
127
|
-
slider.setAttribute("focusIndex", "1");
|
|
128
|
-
}
|
|
129
|
-
}}
|
|
130
|
-
>
|
|
131
|
-
Set main image to canvas
|
|
132
|
-
</button>
|
|
133
|
-
`;
|
|
134
|
-
}
|
|
135
|
-
}
|