@operato/contact 1.1.52 → 1.1.53
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/CHANGELOG.md +11 -0
- package/demo/ox-pfp.html +45 -0
- package/demo/pfp-edit.html +59 -0
- package/demo/pfp-view.html +46 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/ox-contact copy.d.ts +38 -1
- package/dist/src/ox-contact copy.js +66 -2
- package/dist/src/ox-contact copy.js.map +1 -1
- package/dist/src/ox-contact-edit.d.ts +3 -0
- package/dist/src/ox-contact-edit.js +9 -16
- package/dist/src/ox-contact-edit.js.map +1 -1
- package/dist/src/ox-contact-view.d.ts +1 -0
- package/dist/src/ox-contact-view.js +5 -16
- package/dist/src/ox-contact-view.js.map +1 -1
- package/dist/src/ox-contact.d.ts +2 -0
- package/dist/src/ox-contact.js.map +1 -1
- package/dist/src/ox-pfp-edit.d.ts +28 -0
- package/dist/src/ox-pfp-edit.js +314 -0
- package/dist/src/ox-pfp-edit.js.map +1 -0
- package/dist/src/ox-pfp-editor copy.d.ts +11 -0
- package/dist/src/ox-pfp-editor copy.js +71 -0
- package/dist/src/ox-pfp-editor copy.js.map +1 -0
- package/dist/src/ox-pfp-editor.d.ts +20 -0
- package/dist/src/ox-pfp-editor.js +165 -0
- package/dist/src/ox-pfp-editor.js.map +1 -0
- package/dist/src/ox-pfp-view.d.ts +15 -0
- package/dist/src/ox-pfp-view.js +100 -0
- package/dist/src/ox-pfp-view.js.map +1 -0
- package/dist/src/ox-pfp-viewer.d.ts +14 -0
- package/dist/src/ox-pfp-viewer.js +63 -0
- package/dist/src/ox-pfp-viewer.js.map +1 -0
- package/dist/src/ox-pfp.d.ts +14 -0
- package/dist/src/ox-pfp.js +104 -0
- package/dist/src/ox-pfp.js.map +1 -0
- package/dist/stories/index.stories copy.d.ts +24 -0
- package/dist/stories/index.stories copy.js +79 -0
- package/dist/stories/index.stories copy.js.map +1 -0
- package/dist/stories/ox-contact.stories.d.ts +24 -0
- package/dist/stories/ox-contact.stories.js +79 -0
- package/dist/stories/ox-contact.stories.js.map +1 -0
- package/dist/stories/ox-pfp.stories.d.ts +28 -0
- package/dist/stories/ox-pfp.stories.js +37 -0
- package/dist/stories/ox-pfp.stories.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -5
- package/src/index.ts +2 -0
- package/src/ox-contact-edit.ts +8 -16
- package/src/ox-contact-view.ts +6 -16
- package/src/ox-contact.ts +2 -0
- package/src/ox-pfp-edit.ts +351 -0
- package/src/ox-pfp-view.ts +98 -0
- package/src/ox-pfp.ts +97 -0
- package/stories/{index.stories.ts → ox-contact.stories.ts} +0 -0
- package/stories/ox-pfp.stories.ts +53 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, css, LitElement } from 'lit';
|
|
3
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
4
|
+
function getPoint(e) {
|
|
5
|
+
var _a;
|
|
6
|
+
if (e.button == 0) {
|
|
7
|
+
return {
|
|
8
|
+
x: e.clientX,
|
|
9
|
+
y: e.clientY
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
else if (((_a = e.touches) === null || _a === void 0 ? void 0 : _a.length) == 1) {
|
|
13
|
+
const touch = e.touches[0];
|
|
14
|
+
return {
|
|
15
|
+
x: touch.clientX,
|
|
16
|
+
y: touch.clientY
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
let OxPfpEditor = class OxPfpEditor extends LitElement {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.profile = {};
|
|
27
|
+
this.dragEndHandler = this.onDragEnd.bind(this);
|
|
28
|
+
this.dragMoveHandler = this.onDragMove.bind(this);
|
|
29
|
+
this.dragStartHandler = this.onDragStart.bind(this);
|
|
30
|
+
this.wheelEventHandler = this.onWheelEvent.bind(this);
|
|
31
|
+
}
|
|
32
|
+
connectedCallback() {
|
|
33
|
+
super.connectedCallback();
|
|
34
|
+
this.addEventListener('mousewheel', this.wheelEventHandler, false);
|
|
35
|
+
this.addEventListener('mousedown', this.dragStartHandler);
|
|
36
|
+
this.addEventListener('touchstart', this.dragStartHandler);
|
|
37
|
+
document.addEventListener('mouseup', this.dragEndHandler);
|
|
38
|
+
document.addEventListener('touchend', this.dragEndHandler);
|
|
39
|
+
document.addEventListener('touchcancel', this.dragEndHandler);
|
|
40
|
+
document.addEventListener('mousemove', this.dragMoveHandler);
|
|
41
|
+
document.addEventListener('touchmove', this.dragMoveHandler);
|
|
42
|
+
}
|
|
43
|
+
disconnectedCallback() {
|
|
44
|
+
this.removeEventListener('mousewheel', this.wheelEventHandler, false);
|
|
45
|
+
this.removeEventListener('mousedown', this.dragStartHandler);
|
|
46
|
+
this.removeEventListener('touchstart', this.dragStartHandler);
|
|
47
|
+
document.removeEventListener('mouseup', this.dragEndHandler);
|
|
48
|
+
document.removeEventListener('touchend', this.dragEndHandler);
|
|
49
|
+
document.removeEventListener('touchcancel', this.dragEndHandler);
|
|
50
|
+
document.removeEventListener('mousemove', this.dragMoveHandler);
|
|
51
|
+
document.removeEventListener('touchmove', this.dragMoveHandler);
|
|
52
|
+
super.disconnectedCallback();
|
|
53
|
+
}
|
|
54
|
+
render() {
|
|
55
|
+
return html ` <div circle></div> `;
|
|
56
|
+
}
|
|
57
|
+
onWheelEvent(e) {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
var delta = Math.max(-1, Math.min(1, e.deltaY || -e.detail));
|
|
60
|
+
const { top = 0, left = 0, zoom = 1, picture } = this.profile;
|
|
61
|
+
this.profile = {
|
|
62
|
+
top,
|
|
63
|
+
left,
|
|
64
|
+
zoom: zoom * (1 - delta / 20),
|
|
65
|
+
picture
|
|
66
|
+
};
|
|
67
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
68
|
+
detail: this.profile
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
onDragStart(e) {
|
|
72
|
+
const point = getPoint(e);
|
|
73
|
+
if (point) {
|
|
74
|
+
this.dragStart = point;
|
|
75
|
+
e.stopPropagation();
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
onDragMove(e) {
|
|
80
|
+
if (!this.dragStart) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const point = getPoint(e);
|
|
84
|
+
if (!point) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
e.stopPropagation();
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
const dragStart = point;
|
|
90
|
+
var { x, y } = point;
|
|
91
|
+
x -= this.dragStart.x;
|
|
92
|
+
y -= this.dragStart.y;
|
|
93
|
+
this.dragStart = dragStart;
|
|
94
|
+
const { top = 0, left = 0, zoom = 1, picture } = this.profile;
|
|
95
|
+
const { offsetHeight, offsetWidth } = this;
|
|
96
|
+
this.profile = {
|
|
97
|
+
top: top + (y / offsetHeight) * 100,
|
|
98
|
+
left: left + (x / offsetWidth) * 100,
|
|
99
|
+
zoom,
|
|
100
|
+
picture
|
|
101
|
+
};
|
|
102
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
103
|
+
detail: this.profile
|
|
104
|
+
}));
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
onDragEnd(e) {
|
|
108
|
+
if (this.dragStart) {
|
|
109
|
+
e.stopPropagation();
|
|
110
|
+
e.preventDefault();
|
|
111
|
+
delete this.dragStart;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
updated(changes) {
|
|
115
|
+
const { picture = 'linear-gradient(var(--primary-color, gray), var(--primary-color, gray)', zoom = 1, left = 0, top = 0 } = this.profile;
|
|
116
|
+
const style = this.style;
|
|
117
|
+
style.setProperty('--background-image', `url(${picture})`);
|
|
118
|
+
style.setProperty('--image-transform', ` translate(${left}%, ${top}%) scale(${zoom}, ${zoom})`);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
OxPfpEditor.styles = css `
|
|
122
|
+
:host {
|
|
123
|
+
display: inline-block;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
[circle] {
|
|
127
|
+
width: 100%;
|
|
128
|
+
height: 100%;
|
|
129
|
+
border-radius: 50%;
|
|
130
|
+
position: relative;
|
|
131
|
+
background-color: lightgray;
|
|
132
|
+
|
|
133
|
+
overflow: hidden;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
[circle]::before {
|
|
137
|
+
content: '';
|
|
138
|
+
display: block;
|
|
139
|
+
position: absolute;
|
|
140
|
+
text-align: left;
|
|
141
|
+
line-height: 24px;
|
|
142
|
+
top: 0;
|
|
143
|
+
right: 0;
|
|
144
|
+
width: 100%;
|
|
145
|
+
height: 100%;
|
|
146
|
+
background-repeat: no-repeat;
|
|
147
|
+
background-image: var(
|
|
148
|
+
--background-image,
|
|
149
|
+
linear-gradient(var(--primary-color, gray), var(--primary-color, gray))
|
|
150
|
+
);
|
|
151
|
+
transform: var(--image-transform, '');
|
|
152
|
+
background-size: 100% 100%;
|
|
153
|
+
}
|
|
154
|
+
`;
|
|
155
|
+
__decorate([
|
|
156
|
+
property({ type: Object })
|
|
157
|
+
], OxPfpEditor.prototype, "profile", void 0);
|
|
158
|
+
__decorate([
|
|
159
|
+
query('[circle]')
|
|
160
|
+
], OxPfpEditor.prototype, "circle", void 0);
|
|
161
|
+
OxPfpEditor = __decorate([
|
|
162
|
+
customElement('ox-pfp-edit')
|
|
163
|
+
], OxPfpEditor);
|
|
164
|
+
export { OxPfpEditor };
|
|
165
|
+
//# sourceMappingURL=ox-pfp-edit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-pfp-edit.js","sourceRoot":"","sources":["../../src/ox-pfp-edit.ts"],"names":[],"mappings":";AAAA,OAAO,EA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AE,cAAc,IAAI,MAAM,GAAG,YAAY,IAAI,KAAK,IAAI,GAAG,CAAC,CAAA;IACjG,CAAC;;AA1KM,kBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiClB,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAsB;AAE9B;IAAlB,KAAK,CAAC,UAAU,CAAC;2CAAwB;AAtC/B,WAAW;IADvB,aAAa,CAAC,eAAe,CAAC;GAClB,WAAW,CA4KvB;SA5KY,WAAW","sourcesContent":["import { html, css, LitElement, PropertyValues } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { Profile } from './ox-pfp-view'\n\nfunction getPoint(e: Event): { x: number; y: number } | undefined {\n if ((e as MouseEvent).button == 0) {\n return {\n x: (e as MouseEvent).clientX,\n y: (e as MouseEvent).clientY\n }\n } else if ((e as TouchEvent).touches?.length == 1) {\n const touch = (e as TouchEvent).touches[0]\n return {\n x: touch.clientX,\n y: touch.clientY\n }\n } else {\n return\n }\n}\n\n@customElement('ox-pfp-edit')\nexport class OxPfpEditor extends LitElement {\n static styles = css`\n :host {\n display: inline-block;\n }\n\n [circle] {\n width: 100%;\n height: 100%;\n border-radius: 50%;\n position: relative;\n background-color: lightgray;\n\n overflow: hidden;\n }\n\n [circle]::before {\n content: '';\n display: block;\n position: absolute;\n text-align: left;\n line-height: 24px;\n top: 0;\n right: 0;\n width: 100%;\n height: 100%;\n background-repeat: no-repeat;\n background-image: var(\n --background-image,\n linear-gradient(var(--primary-color, gray), var(--primary-color, gray))\n );\n transform: var(--image-transform, '');\n background-size: 100% 100%;\n }\n `\n\n @property({ type: Object }) profile: Profile = {}\n\n @query('[circle]') circle!: HTMLDivElement\n\n private dragStart?: { x: number; y: number }\n private dragEndHandler = this.onDragEnd.bind(this) as EventListener\n private dragMoveHandler = this.onDragMove.bind(this) as EventListener\n private dragStartHandler = this.onDragStart.bind(this) as EventListener\n private wheelEventHandler = this.onWheelEvent.bind(this) as EventListener\n\n connectedCallback(): void {\n super.connectedCallback()\n\n this.addEventListener('mousewheel', this.wheelEventHandler, false)\n\n this.addEventListener('mousedown', this.dragStartHandler)\n this.addEventListener('touchstart', this.dragStartHandler)\n\n document.addEventListener('mouseup', this.dragEndHandler)\n document.addEventListener('touchend', this.dragEndHandler)\n document.addEventListener('touchcancel', this.dragEndHandler)\n document.addEventListener('mousemove', this.dragMoveHandler)\n document.addEventListener('touchmove', this.dragMoveHandler)\n }\n\n disconnectedCallback() {\n this.removeEventListener('mousewheel', this.wheelEventHandler, false)\n\n this.removeEventListener('mousedown', this.dragStartHandler!)\n this.removeEventListener('touchstart', this.dragStartHandler!)\n\n document.removeEventListener('mouseup', this.dragEndHandler!)\n document.removeEventListener('touchend', this.dragEndHandler!)\n document.removeEventListener('touchcancel', this.dragEndHandler!)\n document.removeEventListener('mousemove', this.dragMoveHandler!)\n document.removeEventListener('touchmove', this.dragMoveHandler!)\n\n super.disconnectedCallback()\n }\n\n render() {\n return html` <div circle></div> `\n }\n\n onWheelEvent(e: Event) {\n e.preventDefault()\n\n var delta = Math.max(-1, Math.min(1, (e as WheelEvent).deltaY || -(e as WheelEvent).detail))\n\n const { top = 0, left = 0, zoom = 1, picture } = this.profile\n this.profile = {\n top,\n left,\n zoom: zoom * (1 - delta / 20),\n picture\n }\n\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: this.profile\n })\n )\n }\n\n onDragStart(e: Event) {\n const point = getPoint(e)\n\n if (point) {\n this.dragStart = point\n e.stopPropagation()\n return false\n }\n }\n\n onDragMove(e: Event) {\n if (!this.dragStart) {\n return false\n }\n\n const point = getPoint(e)\n\n if (!point) {\n return false\n }\n\n e.stopPropagation()\n e.preventDefault()\n\n const dragStart = point\n var { x, y } = point\n\n x -= this.dragStart.x\n y -= this.dragStart.y\n\n this.dragStart = dragStart\n\n const { top = 0, left = 0, zoom = 1, picture } = this.profile\n const { offsetHeight, offsetWidth } = this\n\n this.profile = {\n top: top + (y / offsetHeight) * 100,\n left: left + (x / offsetWidth) * 100,\n zoom,\n picture\n }\n\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: this.profile\n })\n )\n\n return false\n }\n\n onDragEnd(e: Event) {\n if (this.dragStart) {\n e.stopPropagation()\n e.preventDefault()\n\n delete this.dragStart\n }\n }\n\n updated(changes: PropertyValues<this>) {\n const {\n picture = 'linear-gradient(var(--primary-color, gray), var(--primary-color, gray)',\n zoom = 1,\n left = 0,\n top = 0\n } = this.profile\n const style = this.style\n\n style.setProperty('--background-image', `url(${picture})`)\n style.setProperty('--image-transform', ` translate(${left}%, ${top}%) scale(${zoom}, ${zoom})`)\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
export type Profile = {
|
|
3
|
+
left?: number;
|
|
4
|
+
top?: number;
|
|
5
|
+
zoom?: number;
|
|
6
|
+
picture?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class OxPfpView extends LitElement {
|
|
9
|
+
static styles: import("lit").CSSResult;
|
|
10
|
+
profile: Profile;
|
|
11
|
+
name?: string;
|
|
12
|
+
circle: HTMLDivElement;
|
|
13
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
14
|
+
updated(changes: PropertyValues<this>): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, css, LitElement } from 'lit';
|
|
3
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
4
|
+
let OxPfpView = class OxPfpView extends LitElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.profile = {};
|
|
8
|
+
}
|
|
9
|
+
render() {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
return html `
|
|
12
|
+
${((_a = this.profile) === null || _a === void 0 ? void 0 : _a.picture)
|
|
13
|
+
? html `<div circle></div>`
|
|
14
|
+
: html `<div monogram><div>${(_b = this.name) === null || _b === void 0 ? void 0 : _b.replace(/\s/g, '').slice(0, 2)}</div></div>`}
|
|
15
|
+
|
|
16
|
+
<slot></slot>
|
|
17
|
+
`;
|
|
18
|
+
}
|
|
19
|
+
updated(changes) {
|
|
20
|
+
const { picture, zoom = 1, left = 0, top = 0 } = this.profile || {};
|
|
21
|
+
if (picture) {
|
|
22
|
+
const style = this.style;
|
|
23
|
+
style.setProperty('--background-image', `url(${picture})`);
|
|
24
|
+
style.setProperty('--image-transform', `translate(${left}%, ${top}%) scale(${zoom}, ${zoom})`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
OxPfpView.styles = css `
|
|
29
|
+
:host {
|
|
30
|
+
display: inline-block;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[circle] {
|
|
34
|
+
width: 100%;
|
|
35
|
+
height: 100%;
|
|
36
|
+
border-radius: 50%;
|
|
37
|
+
position: relative;
|
|
38
|
+
background-color: lightgray;
|
|
39
|
+
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
[circle]::before {
|
|
44
|
+
content: '';
|
|
45
|
+
display: block;
|
|
46
|
+
position: absolute;
|
|
47
|
+
text-align: left;
|
|
48
|
+
line-height: 24px;
|
|
49
|
+
top: 0;
|
|
50
|
+
right: 0;
|
|
51
|
+
width: 100%;
|
|
52
|
+
height: 100%;
|
|
53
|
+
background-repeat: no-repeat;
|
|
54
|
+
background-image: var(
|
|
55
|
+
--background-image,
|
|
56
|
+
linear-gradient(var(--primary-color, gray), var(--primary-color, gray))
|
|
57
|
+
);
|
|
58
|
+
transform: var(--image-transform, '');
|
|
59
|
+
background-size: 100% 100%;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
[monogram] {
|
|
63
|
+
width: 100%;
|
|
64
|
+
height: 100%;
|
|
65
|
+
border-radius: 50%;
|
|
66
|
+
border: 1px solid darkgray;
|
|
67
|
+
box-sizing: border-box;
|
|
68
|
+
padding: 0;
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
background-color: gray;
|
|
71
|
+
color: white;
|
|
72
|
+
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
justify-content: center;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[monogram] div {
|
|
79
|
+
flex: 1;
|
|
80
|
+
text-transform: uppercase;
|
|
81
|
+
font-size: 2em;
|
|
82
|
+
font-family: system-ui;
|
|
83
|
+
text-align: center;
|
|
84
|
+
vertical-align: center;
|
|
85
|
+
}
|
|
86
|
+
`;
|
|
87
|
+
__decorate([
|
|
88
|
+
property({ type: Object })
|
|
89
|
+
], OxPfpView.prototype, "profile", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
property({ type: String })
|
|
92
|
+
], OxPfpView.prototype, "name", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
query('[circle]')
|
|
95
|
+
], OxPfpView.prototype, "circle", void 0);
|
|
96
|
+
OxPfpView = __decorate([
|
|
97
|
+
customElement('ox-pfp-view')
|
|
98
|
+
], OxPfpView);
|
|
99
|
+
export { OxPfpView };
|
|
100
|
+
//# sourceMappingURL=ox-pfp-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-pfp-view.js","sourceRoot":"","sources":["../../src/ox-pfp-view.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAS,MAAM,mBAAmB,CAAA;AAUlE,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,UAAU;IAAlC;;QA6DuB,YAAO,GAAY,EAAE,CAAA;IAyBnD,CAAC;IApBC,MAAM;;QACJ,OAAO,IAAI,CAAA;QACP,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO;YACrB,CAAC,CAAC,IAAI,CAAA,oBAAoB;YAC1B,CAAC,CAAC,IAAI,CAAA,sBAAsB,MAAA,IAAI,CAAC,IAAI,0CAAE,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,cAAc;;;KAGtF,CAAA;IACH,CAAC;IAED,OAAO,CAAC,OAA6B;QACnC,MAAM,EAAE,OAAO,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAA;QAEnE,IAAI,OAAO,EAAE;YACX,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;YAExB,KAAK,CAAC,WAAW,CAAC,oBAAoB,EAAE,OAAO,OAAO,GAAG,CAAC,CAAA;YAC1D,KAAK,CAAC,WAAW,CAAC,mBAAmB,EAAE,aAAa,IAAI,MAAM,GAAG,YAAY,IAAI,KAAK,IAAI,GAAG,CAAC,CAAA;SAC/F;IACH,CAAC;;AApFM,gBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DlB,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAsB;AACrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAAc;AAEtB;IAAlB,KAAK,CAAC,UAAU,CAAC;yCAAwB;AAhE/B,SAAS;IADrB,aAAa,CAAC,aAAa,CAAC;GAChB,SAAS,CAsFrB;SAtFY,SAAS","sourcesContent":["import { html, css, LitElement, PropertyValues } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nexport type Profile = {\n left?: number\n top?: number\n zoom?: number\n picture?: string\n}\n\n@customElement('ox-pfp-view')\nexport class OxPfpView extends LitElement {\n static styles = css`\n :host {\n display: inline-block;\n }\n\n [circle] {\n width: 100%;\n height: 100%;\n border-radius: 50%;\n position: relative;\n background-color: lightgray;\n\n overflow: hidden;\n }\n\n [circle]::before {\n content: '';\n display: block;\n position: absolute;\n text-align: left;\n line-height: 24px;\n top: 0;\n right: 0;\n width: 100%;\n height: 100%;\n background-repeat: no-repeat;\n background-image: var(\n --background-image,\n linear-gradient(var(--primary-color, gray), var(--primary-color, gray))\n );\n transform: var(--image-transform, '');\n background-size: 100% 100%;\n }\n\n [monogram] {\n width: 100%;\n height: 100%;\n border-radius: 50%;\n border: 1px solid darkgray;\n box-sizing: border-box;\n padding: 0;\n overflow: hidden;\n background-color: gray;\n color: white;\n\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n [monogram] div {\n flex: 1;\n text-transform: uppercase;\n font-size: 2em;\n font-family: system-ui;\n text-align: center;\n vertical-align: center;\n }\n `\n\n @property({ type: Object }) profile: Profile = {}\n @property({ type: String }) name?: string\n\n @query('[circle]') circle!: HTMLDivElement\n\n render() {\n return html`\n ${this.profile?.picture\n ? html`<div circle></div>`\n : html`<div monogram><div>${this.name?.replace(/\\s/g, '').slice(0, 2)}</div></div>`}\n\n <slot></slot>\n `\n }\n\n updated(changes: PropertyValues<this>) {\n const { picture, zoom = 1, left = 0, top = 0 } = this.profile || {}\n\n if (picture) {\n const style = this.style\n\n style.setProperty('--background-image', `url(${picture})`)\n style.setProperty('--image-transform', `translate(${left}%, ${top}%) scale(${zoom}, ${zoom})`)\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
export type Profile = {
|
|
3
|
+
left?: number;
|
|
4
|
+
top?: number;
|
|
5
|
+
zoom?: number;
|
|
6
|
+
picture?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class OxPfpViewer extends LitElement {
|
|
9
|
+
static styles: import("lit").CSSResult;
|
|
10
|
+
profile: Profile;
|
|
11
|
+
circle: HTMLDivElement;
|
|
12
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
13
|
+
updated(changes: PropertyValues<this>): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, css, LitElement } from 'lit';
|
|
3
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
4
|
+
let OxPfpViewer = class OxPfpViewer extends LitElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.profile = {};
|
|
8
|
+
}
|
|
9
|
+
render() {
|
|
10
|
+
return html ` <div circle></div> `;
|
|
11
|
+
}
|
|
12
|
+
updated(changes) {
|
|
13
|
+
const { picture = 'linear-gradient(var(--primary-color, gray), var(--primary-color, gray)', zoom = 1, left = 0, top = 0 } = this.profile;
|
|
14
|
+
const style = this.style;
|
|
15
|
+
style.setProperty('--background-image', `url(${picture})`);
|
|
16
|
+
style.setProperty('--image-transform', `translate(${left}%, ${top}%) scale(${zoom}, ${zoom})`);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
OxPfpViewer.styles = css `
|
|
20
|
+
:host {
|
|
21
|
+
display: inline-block;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
[circle] {
|
|
25
|
+
width: 100%;
|
|
26
|
+
height: 100%;
|
|
27
|
+
border-radius: 50%;
|
|
28
|
+
position: relative;
|
|
29
|
+
background-color: lightgray;
|
|
30
|
+
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
[circle]::before {
|
|
35
|
+
content: '';
|
|
36
|
+
display: block;
|
|
37
|
+
position: absolute;
|
|
38
|
+
text-align: left;
|
|
39
|
+
line-height: 24px;
|
|
40
|
+
top: 0;
|
|
41
|
+
right: 0;
|
|
42
|
+
width: 100%;
|
|
43
|
+
height: 100%;
|
|
44
|
+
background-repeat: no-repeat;
|
|
45
|
+
background-image: var(
|
|
46
|
+
--background-image,
|
|
47
|
+
linear-gradient(var(--primary-color, gray), var(--primary-color, gray))
|
|
48
|
+
);
|
|
49
|
+
transform: var(--image-transform, '');
|
|
50
|
+
background-size: 100% 100%;
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
__decorate([
|
|
54
|
+
property({ type: Object })
|
|
55
|
+
], OxPfpViewer.prototype, "profile", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
query('[circle]')
|
|
58
|
+
], OxPfpViewer.prototype, "circle", void 0);
|
|
59
|
+
OxPfpViewer = __decorate([
|
|
60
|
+
customElement('ox-pfp-view')
|
|
61
|
+
], OxPfpViewer);
|
|
62
|
+
export { OxPfpViewer };
|
|
63
|
+
//# sourceMappingURL=ox-pfp-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-pfp-view.js","sourceRoot":"","sources":["../../src/ox-pfp-view.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAS,MAAM,mBAAmB,CAAA;AAUlE,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAoCuB,YAAO,GAAY,EAAE,CAAA;IAoBnD,CAAC;IAhBC,MAAM;QACJ,OAAO,IAAI,CAAA,sBAAsB,CAAA;IACnC,CAAC;IAED,OAAO,CAAC,OAA6B;QACnC,MAAM,EACJ,OAAO,GAAG,wEAAwE,EAClF,IAAI,GAAG,CAAC,EACR,IAAI,GAAG,CAAC,EACR,GAAG,GAAG,CAAC,EACR,GAAG,IAAI,CAAC,OAAO,CAAA;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;QAExB,KAAK,CAAC,WAAW,CAAC,oBAAoB,EAAE,OAAO,OAAO,GAAG,CAAC,CAAA;QAC1D,KAAK,CAAC,WAAW,CAAC,mBAAmB,EAAE,aAAa,IAAI,MAAM,GAAG,YAAY,IAAI,KAAK,IAAI,GAAG,CAAC,CAAA;IAChG,CAAC;;AAtDM,kBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiClB,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAsB;AAE9B;IAAlB,KAAK,CAAC,UAAU,CAAC;2CAAwB;AAtC/B,WAAW;IADvB,aAAa,CAAC,eAAe,CAAC;GAClB,WAAW,CAwDvB;SAxDY,WAAW","sourcesContent":["import { html, css, LitElement, PropertyValues } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nexport type Profile = {\n left?: number\n top?: number\n zoom?: number\n picture?: string\n}\n\n@customElement('ox-pfp-view')\nexport class OxPfpViewer extends LitElement {\n static styles = css`\n :host {\n display: inline-block;\n }\n\n [circle] {\n width: 100%;\n height: 100%;\n border-radius: 50%;\n position: relative;\n background-color: lightgray;\n\n overflow: hidden;\n }\n\n [circle]::before {\n content: '';\n display: block;\n position: absolute;\n text-align: left;\n line-height: 24px;\n top: 0;\n right: 0;\n width: 100%;\n height: 100%;\n background-repeat: no-repeat;\n background-image: var(\n --background-image,\n linear-gradient(var(--primary-color, gray), var(--primary-color, gray))\n );\n transform: var(--image-transform, '');\n background-size: 100% 100%;\n }\n `\n\n @property({ type: Object }) profile: Profile = {}\n\n @query('[circle]') circle!: HTMLDivElement\n\n render() {\n return html` <div circle></div> `\n }\n\n updated(changes: PropertyValues<this>) {\n const {\n picture = 'linear-gradient(var(--primary-color, gray), var(--primary-color, gray)',\n zoom = 1,\n left = 0,\n top = 0\n } = this.profile\n const style = this.style\n\n style.setProperty('--background-image', `url(${picture})`)\n style.setProperty('--image-transform', `translate(${left}%, ${top}%) scale(${zoom}, ${zoom})`)\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import './ox-pfp-edit.js';
|
|
2
|
+
import './ox-pfp-view.js';
|
|
3
|
+
import '@material/mwc-icon-button';
|
|
4
|
+
import { LitElement } from 'lit';
|
|
5
|
+
import { Profile } from './ox-pfp-view.js';
|
|
6
|
+
import { OxPfpEdit } from './ox-pfp-edit.js';
|
|
7
|
+
export declare class OxPfp extends LitElement {
|
|
8
|
+
static styles: import("lit").CSSResult;
|
|
9
|
+
profile: Profile;
|
|
10
|
+
name?: string;
|
|
11
|
+
editMode?: boolean;
|
|
12
|
+
edit: OxPfpEdit;
|
|
13
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import './ox-pfp-edit.js';
|
|
3
|
+
import './ox-pfp-view.js';
|
|
4
|
+
import '@material/mwc-icon-button';
|
|
5
|
+
import { html, css, LitElement } from 'lit';
|
|
6
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
7
|
+
let OxPfp = class OxPfp extends LitElement {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.profile = {};
|
|
11
|
+
this.editMode = false;
|
|
12
|
+
}
|
|
13
|
+
render() {
|
|
14
|
+
return this.editMode
|
|
15
|
+
? html `<ox-pfp-edit .profile=${this.profile} name=${this.name || ''}>
|
|
16
|
+
<mwc-icon-button icon="fit_screen" @click=${() => this.edit.fit()}></mwc-icon-button>
|
|
17
|
+
<mwc-icon-button icon="clear" @click=${() => this.edit.clear()}></mwc-icon-button>
|
|
18
|
+
<mwc-icon-button
|
|
19
|
+
icon="save"
|
|
20
|
+
@click=${() => {
|
|
21
|
+
this.profile = this.edit.profile;
|
|
22
|
+
this.editMode = false;
|
|
23
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
24
|
+
detail: this.profile
|
|
25
|
+
}));
|
|
26
|
+
}}
|
|
27
|
+
></mwc-icon-button>
|
|
28
|
+
<mwc-icon-button icon="cancel" @click=${() => (this.editMode = false)}></mwc-icon-button>
|
|
29
|
+
</ox-pfp-edit> `
|
|
30
|
+
: html `
|
|
31
|
+
<ox-pfp-view .profile=${this.profile} name=${this.name || ''}>
|
|
32
|
+
<mwc-icon-button icon="edit" @click=${() => (this.editMode = true)}></mwc-icon-button>
|
|
33
|
+
</ox-pfp-view>
|
|
34
|
+
`;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
OxPfp.styles = css `
|
|
38
|
+
:host {
|
|
39
|
+
display: block;
|
|
40
|
+
|
|
41
|
+
--mdc-icon-button-size: 20px;
|
|
42
|
+
--mdc-icon-size: 20px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
ox-pfp-edit,
|
|
46
|
+
ox-pfp-view {
|
|
47
|
+
position: relative;
|
|
48
|
+
width: 100%;
|
|
49
|
+
height: 100%;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
[buttons] {
|
|
53
|
+
position: absolute;
|
|
54
|
+
bottom: 0;
|
|
55
|
+
right: 0;
|
|
56
|
+
display: flex;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
mwc-icon-button {
|
|
60
|
+
position: absolute;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
mwc-icon-button[icon='fit_screen'] {
|
|
64
|
+
bottom: 0;
|
|
65
|
+
left: 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
mwc-icon-button[icon='save'] {
|
|
69
|
+
bottom: 0;
|
|
70
|
+
right: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
mwc-icon-button[icon='edit'] {
|
|
74
|
+
bottom: 0;
|
|
75
|
+
right: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
mwc-icon-button[icon='cancel'] {
|
|
79
|
+
top: 0;
|
|
80
|
+
right: 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
mwc-icon-button[icon='clear'] {
|
|
84
|
+
top: 0;
|
|
85
|
+
right: 16px;
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
88
|
+
__decorate([
|
|
89
|
+
property({ type: Object })
|
|
90
|
+
], OxPfp.prototype, "profile", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
property({ type: String })
|
|
93
|
+
], OxPfp.prototype, "name", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
state()
|
|
96
|
+
], OxPfp.prototype, "editMode", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
query('ox-pfp-edit')
|
|
99
|
+
], OxPfp.prototype, "edit", void 0);
|
|
100
|
+
OxPfp = __decorate([
|
|
101
|
+
customElement('ox-pfp')
|
|
102
|
+
], OxPfp);
|
|
103
|
+
export { OxPfp };
|
|
104
|
+
//# sourceMappingURL=ox-pfp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-pfp.js","sourceRoot":"","sources":["../../src/ox-pfp.ts"],"names":[],"mappings":";AAAA,OAAO,kBAAkB,CAAA;AACzB,OAAO,kBAAkB,CAAA;AAEzB,OAAO,2BAA2B,CAAA;AAElC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAKlE,IAAM,KAAK,GAAX,MAAM,KAAM,SAAQ,UAAU;IAA9B;;QAqDuB,YAAO,GAAY,EAAE,CAAA;QAGxC,aAAQ,GAAa,KAAK,CAAA;IA6BrC,CAAC;IAzBC,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ;YAClB,CAAC,CAAC,IAAI,CAAA,yBAAyB,IAAI,CAAC,OAAO,SAAS,IAAI,CAAC,IAAI,IAAI,EAAE;sDACnB,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;iDAC1B,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;;;qBAGnD,GAAG,EAAE;gBACZ,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAA;gBAChC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;gBACrB,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,QAAQ,EAAE;oBACxB,MAAM,EAAE,IAAI,CAAC,OAAO;iBACrB,CAAC,CACH,CAAA;YACH,CAAC;;kDAEqC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;wBACvD;YAClB,CAAC,CAAC,IAAI,CAAA;kCACsB,IAAI,CAAC,OAAO,SAAS,IAAI,CAAC,IAAI,IAAI,EAAE;kDACpB,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;;SAErE,CAAA;IACP,CAAC;;AAnFM,YAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDlB,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCAAsB;AACrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mCAAc;AAEhC;IAAR,KAAK,EAAE;uCAA2B;AAEb;IAArB,KAAK,CAAC,aAAa,CAAC;mCAAiB;AA1D3B,KAAK;IADjB,aAAa,CAAC,QAAQ,CAAC;GACX,KAAK,CAqFjB;SArFY,KAAK","sourcesContent":["import './ox-pfp-edit.js'\nimport './ox-pfp-view.js'\n\nimport '@material/mwc-icon-button'\n\nimport { html, css, LitElement } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { Profile } from './ox-pfp-view.js'\nimport { OxPfpEdit } from './ox-pfp-edit.js'\n\n@customElement('ox-pfp')\nexport class OxPfp extends LitElement {\n static styles = css`\n :host {\n display: block;\n\n --mdc-icon-button-size: 20px;\n --mdc-icon-size: 20px;\n }\n\n ox-pfp-edit,\n ox-pfp-view {\n position: relative;\n width: 100%;\n height: 100%;\n }\n\n [buttons] {\n position: absolute;\n bottom: 0;\n right: 0;\n display: flex;\n }\n\n mwc-icon-button {\n position: absolute;\n }\n\n mwc-icon-button[icon='fit_screen'] {\n bottom: 0;\n left: 0;\n }\n\n mwc-icon-button[icon='save'] {\n bottom: 0;\n right: 0;\n }\n\n mwc-icon-button[icon='edit'] {\n bottom: 0;\n right: 0;\n }\n\n mwc-icon-button[icon='cancel'] {\n top: 0;\n right: 0;\n }\n\n mwc-icon-button[icon='clear'] {\n top: 0;\n right: 16px;\n }\n `\n\n @property({ type: Object }) profile: Profile = {}\n @property({ type: String }) name?: string\n\n @state() editMode?: boolean = false\n\n @query('ox-pfp-edit') edit!: OxPfpEdit\n\n render() {\n return this.editMode\n ? html`<ox-pfp-edit .profile=${this.profile} name=${this.name || ''}>\n <mwc-icon-button icon=\"fit_screen\" @click=${() => this.edit.fit()}></mwc-icon-button>\n <mwc-icon-button icon=\"clear\" @click=${() => this.edit.clear()}></mwc-icon-button>\n <mwc-icon-button\n icon=\"save\"\n @click=${() => {\n this.profile = this.edit.profile\n this.editMode = false\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: this.profile\n })\n )\n }}\n ></mwc-icon-button>\n <mwc-icon-button icon=\"cancel\" @click=${() => (this.editMode = false)}></mwc-icon-button>\n </ox-pfp-edit> `\n : html`\n <ox-pfp-view .profile=${this.profile} name=${this.name || ''}>\n <mwc-icon-button icon=\"edit\" @click=${() => (this.editMode = true)}></mwc-icon-button>\n </ox-pfp-view>\n `\n }\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import '@material/mwc-icon';
|
|
3
|
+
import '@material/mwc-icon-button';
|
|
4
|
+
import '../src/ox-contact.js';
|
|
5
|
+
import { Contact } from '../src/ox-contact.js';
|
|
6
|
+
declare const _default: {
|
|
7
|
+
title: string;
|
|
8
|
+
component: string;
|
|
9
|
+
argTypes: {
|
|
10
|
+
contact: {
|
|
11
|
+
control: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
16
|
+
interface Story<T> {
|
|
17
|
+
(args: T): TemplateResult;
|
|
18
|
+
args?: Partial<T>;
|
|
19
|
+
argTypes?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
interface ArgTypes {
|
|
22
|
+
contact?: Contact;
|
|
23
|
+
}
|
|
24
|
+
export declare const Regular: Story<ArgTypes>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import '@material/mwc-icon';
|
|
3
|
+
import '@material/mwc-icon-button';
|
|
4
|
+
import '../src/ox-contact.js';
|
|
5
|
+
import { ContactField } from '../src/ox-contact.js';
|
|
6
|
+
export default {
|
|
7
|
+
title: 'OxContact',
|
|
8
|
+
component: 'ox-contact',
|
|
9
|
+
argTypes: {
|
|
10
|
+
contact: { control: 'object' }
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const Template = ({ contact }) => html `
|
|
14
|
+
<link href="/themes/app-theme.css" rel="stylesheet" />
|
|
15
|
+
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
|
|
16
|
+
<style>
|
|
17
|
+
body {
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
20
|
+
|
|
21
|
+
<ox-contact .contact=${contact}> </ox-contact>
|
|
22
|
+
`;
|
|
23
|
+
export const Regular = Template.bind({});
|
|
24
|
+
Regular.args = {
|
|
25
|
+
contact: {
|
|
26
|
+
note: 'abcdefg',
|
|
27
|
+
items: [
|
|
28
|
+
{
|
|
29
|
+
id: '1',
|
|
30
|
+
type: ContactField.Name,
|
|
31
|
+
label: 'name',
|
|
32
|
+
value: '남 상혁'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: '2',
|
|
36
|
+
type: ContactField.Phone,
|
|
37
|
+
label: 'home',
|
|
38
|
+
value: '010-1223-3443'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: '3',
|
|
42
|
+
type: ContactField.Phone,
|
|
43
|
+
label: 'mobile',
|
|
44
|
+
value: '010-1122-3344'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: '4',
|
|
48
|
+
type: ContactField.Email,
|
|
49
|
+
label: 'work',
|
|
50
|
+
value: 'heartyoh@hatiolab.com'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: '5',
|
|
54
|
+
type: ContactField.Email,
|
|
55
|
+
label: 'home',
|
|
56
|
+
value: 'shnam2k@gmail.com'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: '6',
|
|
60
|
+
type: ContactField.Address,
|
|
61
|
+
label: 'home',
|
|
62
|
+
value: '경기도 성남시 분당구 123'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: '7',
|
|
66
|
+
type: ContactField.Address,
|
|
67
|
+
label: 'work',
|
|
68
|
+
value: '경기도 성남시 분당구 234'
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: '8',
|
|
72
|
+
type: ContactField.Address,
|
|
73
|
+
label: 'work',
|
|
74
|
+
value: '서울특별시 종로구 123'
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=index.stories%20copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.stories copy.js","sourceRoot":"","sources":["../../stories/index.stories copy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC1C,OAAO,oBAAoB,CAAA;AAC3B,OAAO,2BAA2B,CAAA;AAClC,OAAO,sBAAsB,CAAA;AAE7B,OAAO,EAAW,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAE5D,eAAe;IACb,KAAK,EAAE,WAAW;IAClB,SAAS,EAAE,YAAY;IACvB,QAAQ,EAAE;QACR,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;KAC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EAAE,MAAM;gBACb,KAAK,EAAE,eAAe;aACvB;SACF;KACF;CACF,CAAA","sourcesContent":["import { html, TemplateResult } from 'lit'\nimport '@material/mwc-icon'\nimport '@material/mwc-icon-button'\nimport '../src/ox-contact.js'\n\nimport { Contact, ContactField } from '../src/ox-contact.js'\n\nexport default {\n title: 'OxContact',\n component: 'ox-contact',\n argTypes: {\n contact: { control: 'object' }\n }\n}\n\ninterface Story<T> {\n (args: T): TemplateResult\n args?: Partial<T>\n argTypes?: Record<string, unknown>\n}\n\ninterface ArgTypes {\n contact?: Contact\n}\n\nconst Template: Story<ArgTypes> = ({ contact }: ArgTypes) => html`\n <link href=\"/themes/app-theme.css\" rel=\"stylesheet\" />\n <link href=\"https://fonts.googleapis.com/css?family=Material+Icons&display=block\" rel=\"stylesheet\" />\n <style>\n body {\n }\n </style>\n\n <ox-contact .contact=${contact}> </ox-contact>\n`\n\nexport const Regular = Template.bind({})\nRegular.args = {\n contact: {\n note: 'abcdefg',\n items: [\n {\n id: '1',\n type: ContactField.Name,\n label: 'name',\n value: '남 상혁'\n },\n {\n id: '2',\n type: ContactField.Phone,\n label: 'home',\n value: '010-1223-3443'\n },\n {\n id: '3',\n type: ContactField.Phone,\n label: 'mobile',\n value: '010-1122-3344'\n },\n {\n id: '4',\n type: ContactField.Email,\n label: 'work',\n value: 'heartyoh@hatiolab.com'\n },\n {\n id: '5',\n type: ContactField.Email,\n label: 'home',\n value: 'shnam2k@gmail.com'\n },\n {\n id: '6',\n type: ContactField.Address,\n label: 'home',\n value: '경기도 성남시 분당구 123'\n },\n {\n id: '7',\n type: ContactField.Address,\n label: 'work',\n value: '경기도 성남시 분당구 234'\n },\n {\n id: '8',\n type: ContactField.Address,\n label: 'work',\n value: '서울특별시 종로구 123'\n }\n ]\n }\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import '@material/mwc-icon';
|
|
3
|
+
import '@material/mwc-icon-button';
|
|
4
|
+
import '../src/ox-contact.js';
|
|
5
|
+
import { Contact } from '../src/ox-contact.js';
|
|
6
|
+
declare const _default: {
|
|
7
|
+
title: string;
|
|
8
|
+
component: string;
|
|
9
|
+
argTypes: {
|
|
10
|
+
contact: {
|
|
11
|
+
control: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
16
|
+
interface Story<T> {
|
|
17
|
+
(args: T): TemplateResult;
|
|
18
|
+
args?: Partial<T>;
|
|
19
|
+
argTypes?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
interface ArgTypes {
|
|
22
|
+
contact?: Contact;
|
|
23
|
+
}
|
|
24
|
+
export declare const Regular: Story<ArgTypes>;
|