@kmotion/animation 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/package.json +1 -1
- package/src/core.js +3 -2
- package/src/js.js +1 -1
- package/src/react.js +1 -1
- package/src/solid.js +1 -1
- package/src/svelte.js +1 -1
- package/src/vue.js +1 -1
package/README.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# @kmotion/animation
|
|
2
2
|
|
|
3
|
-
Embed
|
|
3
|
+
Embed the **full live animation** (same page as “Open full page” on Kmotion) in **React, Vue, Svelte, Solid, or vanilla JS**. This is not the small gallery card preview.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npm install @kmotion/animation
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
`<Preview id="neo-museum" />` loads `/p/neo-museum` — the complete template you built from the prompt. Scroll inside the preview to move through the site.
|
|
10
|
+
|
|
11
|
+
Default origin is `http://localhost:5173`. After you deploy, call `setOrigin('https://your-domain.com')` once, or pass `origin` on each preview.
|
|
10
12
|
|
|
11
13
|
## React
|
|
12
14
|
|
|
@@ -61,7 +63,7 @@ Preview(document.querySelector('#app'), { id: 'heritage-grove' });
|
|
|
61
63
|
Or the web component after any import:
|
|
62
64
|
|
|
63
65
|
```html
|
|
64
|
-
<kmotion-preview template="heritage-grove" height="
|
|
66
|
+
<kmotion-preview template="heritage-grove" height="100vh"></kmotion-preview>
|
|
65
67
|
```
|
|
66
68
|
|
|
67
69
|
## Props
|
|
@@ -70,7 +72,7 @@ Or the web component after any import:
|
|
|
70
72
|
| --- | --- | --- | --- |
|
|
71
73
|
| `id` | string | required | Template id, e.g. `heritage-grove` |
|
|
72
74
|
| `origin` | string | `http://localhost:5173` | Kmotion site origin |
|
|
73
|
-
| `height` | string | `
|
|
75
|
+
| `height` | string | `100vh` | Preview height |
|
|
74
76
|
| `title` | string | `Kmotion preview` | iframe title |
|
|
75
77
|
|
|
76
78
|
```js
|
package/package.json
CHANGED
package/src/core.js
CHANGED
|
@@ -36,7 +36,8 @@ export function embedUrl(id, origin) {
|
|
|
36
36
|
if (!templateId) {
|
|
37
37
|
throw new Error('kmotion: Preview needs an id, e.g. "heritage-grove"');
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
// Full live page — same as “Open full page”, not the gallery card (?embed=1).
|
|
40
|
+
return `${getOrigin(origin)}/p/${encodeURIComponent(templateId)}`;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
function escapeAttr(value) {
|
|
@@ -68,7 +69,7 @@ class KmotionPreview extends HTMLElement {
|
|
|
68
69
|
|
|
69
70
|
const templateId = this.getTemplateId();
|
|
70
71
|
const origin = this.getAttribute('origin') || '';
|
|
71
|
-
const height = this.getAttribute('height') || '
|
|
72
|
+
const height = this.getAttribute('height') || '100vh';
|
|
72
73
|
const title = this.getAttribute('title') || 'Kmotion preview';
|
|
73
74
|
|
|
74
75
|
let src = '';
|
package/src/js.js
CHANGED
|
@@ -4,7 +4,7 @@ definePreview();
|
|
|
4
4
|
|
|
5
5
|
export { TEMPLATES, embedUrl, setOrigin, getOrigin, definePreview } from './core.js';
|
|
6
6
|
|
|
7
|
-
function applyProps(el, { id, origin, height = '
|
|
7
|
+
function applyProps(el, { id, origin, height = '100vh', title = 'Kmotion preview' }) {
|
|
8
8
|
el.setAttribute('template', id);
|
|
9
9
|
if (origin) el.setAttribute('origin', origin);
|
|
10
10
|
else el.removeAttribute('origin');
|
package/src/react.js
CHANGED
package/src/solid.js
CHANGED
|
@@ -9,7 +9,7 @@ function applyProps(el, props) {
|
|
|
9
9
|
el.setAttribute('template', props.id || '');
|
|
10
10
|
if (props.origin) el.setAttribute('origin', props.origin);
|
|
11
11
|
else el.removeAttribute('origin');
|
|
12
|
-
el.setAttribute('height', props.height || '
|
|
12
|
+
el.setAttribute('height', props.height || '100vh');
|
|
13
13
|
el.setAttribute('title', props.title || 'Kmotion preview');
|
|
14
14
|
}
|
|
15
15
|
|
package/src/svelte.js
CHANGED
|
@@ -4,7 +4,7 @@ definePreview();
|
|
|
4
4
|
|
|
5
5
|
export { TEMPLATES, embedUrl, setOrigin, getOrigin, definePreview } from './core.js';
|
|
6
6
|
|
|
7
|
-
function applyProps(el, { id, origin, height = '
|
|
7
|
+
function applyProps(el, { id, origin, height = '100vh', title = 'Kmotion preview' }) {
|
|
8
8
|
el.setAttribute('template', id);
|
|
9
9
|
if (origin) el.setAttribute('origin', origin);
|
|
10
10
|
else el.removeAttribute('origin');
|
package/src/vue.js
CHANGED
|
@@ -10,7 +10,7 @@ export const Preview = defineComponent({
|
|
|
10
10
|
props: {
|
|
11
11
|
id: { type: String, required: true },
|
|
12
12
|
origin: { type: String, default: '' },
|
|
13
|
-
height: { type: String, default: '
|
|
13
|
+
height: { type: String, default: '100vh' },
|
|
14
14
|
title: { type: String, default: 'Kmotion preview' },
|
|
15
15
|
},
|
|
16
16
|
setup(props) {
|