Skip to content

Commit

Permalink
Lottie component
Browse files Browse the repository at this point in the history
  • Loading branch information
givanz committed Apr 20, 2024
1 parent 118a0b9 commit 162f349
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 76 deletions.
3 changes: 1 addition & 2 deletions .dockerignore
@@ -1,2 +1 @@
node_modules
**/node_modules
*
2 changes: 1 addition & 1 deletion Dockerfile
@@ -1,4 +1,4 @@
FROM php:8.2.11-apache
FROM php:8.3-apache

ARG UNAME=www-data
ARG UGROUP=www-data
Expand Down
35 changes: 23 additions & 12 deletions README.md
Expand Up @@ -3,9 +3,9 @@
<p align="center">
<img src="https://www.vvveb.com/admin/themes/default/img/biglogo.png" alt="Vvveb">
<br><br>
<strong>Drag and drop website builder javascript library.</strong>
<strong>Drag and drop page builder javascript library.</strong>
<br>
<span>Built with Vanilla Js with no dependencies and Bootstrap 5</span>
<span>Built with Vanilla Js with no dependencies or build tools and Bootstrap 5</span>
</p>
<p align="center">
<a href="https://www.vvveb.com">Website</a> |
Expand Down Expand Up @@ -75,13 +75,33 @@ Because of browser iframe security you need to use a webserver such as apache/xa
To use the image upload or page save feature you need to have php installed.


## Docker

### Local development

From VvvebJs folder run

```bash
docker-compose up
```

### Image

Or run image

```bash
docker run -p 8080:80 vvveb/vvvebjs
```

Open http://localhost:8080/editor.php or http://localhost:8080/editor.html

## Save page

Save page function needs either php or node

### PHP

If you use xampp or a shared hosting account php should work without any change.
If you use docker, xampp or a shared hosting account php should work without any change.

Saving is done using [save.php](save.php)

Expand All @@ -98,15 +118,6 @@ Open http://localhost:8080/editor.html

Saving is done using [save.js](save.js)

### Docker

From VvvebJs folder run

```bash
docker-compose up
```

Open http://localhost:8080/editor.php

## [Landing template](https://github.com/givanz/landing)

Expand Down
1 change: 1 addition & 0 deletions css/vvvebjs-editor-helpers.css
Expand Up @@ -56,6 +56,7 @@ body {
/*
Prevents iframe mouse events that prevents clicking on the component
*/
[data-component-lottie] > svg,
[data-component-oembed] > iframe,
[data-component-video] > iframe,
[data-component-maps] > iframe,
Expand Down
2 changes: 1 addition & 1 deletion demo/landing
Submodule landing updated 87 files
+3 −3 about.html
+3 −3 blank-breadcrumb.html
+3 −3 blank.html
+2 −2 blocks/product/product-1.html
+10 −4 cart/cart.html
+10 −7 checkout/checkout.html
+7 −4 checkout/confirm.html
+6 −3 checkout/order.html
+3 −3 contact.html
+7 −4 content/archive.html
+7 −4 content/category.html
+29 −5 content/index.html
+6 −3 content/page.html
+24 −4 content/post-image-header.html
+23 −3 content/post-image-hero.html
+46 −3 content/post.html
+7 −4 content/tag.html
+10 −7 content/user.html
+4 −1 css/admin-post-editor.css
+4 −1 css/style.bundle.css
+4 −1 css/style.css
+3 −3 download.html
+2 −2 email/order/new.html
+2 −2 email/order/new.txt.html
+3 −3 error404.html
+3 −3 error500.html
+1,722 −0 img/illustrations.co/118-macbook.svg
+1,266 −0 img/illustrations.co/day95-app-development.svg
+3 −3 index-blog.html
+3 −3 index-excerpts.html
+3 −3 index-no-sidebar.html
+20 −18 index-slider.html
+3 −3 index.coming-soon.html
+20 −18 index.html
+3 −3 index.maintenance.html
+43 −29 js/theme.js
+20 −9 js/vvvebjs.js
+3 −3 portfolio.html
+3 −3 pricing.html
+77 −39 product/category.html
+76 −39 product/index.html
+12 −326 product/manufacturer.html
+45 −40 product/product.html
+16 −296 product/vendor.html
+1 −1 scss/_base.scss
+5 −1 scss/_product-page.scss
+3 −3 search/index.html
+27 −25 sections/sections.js
+3 −3 services.html
+14 −0 src/_includes/author-box.html
+2 −0 src/_includes/blog-post-single.html
+1 −1 src/_includes/pagination.html
+3 −3 src/_includes/top-menu.html
+20 −0 src/blank-breadcrumb.html
+1 −1 src/blank.html
+2 −2 src/checkout/_billing_address.html
+2 −2 src/checkout/_shipping_address.html
+1 −1 src/checkout/confirm.html
+1 −0 src/content/index.html
+6 −3 src/content/post.html
+3 −3 src/content/user.html
+2 −2 src/email/order/new.html
+2 −2 src/email/order/new.txt.html
+3 −3 src/index.maintenance.html
+228 −6 src/product/_sidebar.html
+14 −8 src/product/category.html
+18 −7 src/product/index.html
+13 −13 src/product/manufacturer.html
+35 −30 src/product/product.html
+41 −7 src/product/vendor.html
+15 −13 src/sections/features/features-1.html
+1 −1 src/user/address/edit.html
+2 −2 src/user/profile.html
+3 −3 user/address.html
+4 −4 user/address/edit.html
+3 −3 user/comments.html
+3 −3 user/downloads.html
+3 −3 user/edit.html
+3 −3 user/index.html
+3 −3 user/login.html
+3 −3 user/order.html
+3 −3 user/orders.html
+5 −5 user/profile.html
+3 −3 user/reset.html
+3 −3 user/reset/reset.html
+3 −3 user/return-form.html
+3 −3 user/signup.html
4 changes: 2 additions & 2 deletions libs/builder/builder.js
Expand Up @@ -3412,7 +3412,7 @@ Vvveb.FileManager = {

//allow event to change page or cancel by setting page to false
window.dispatchEvent(new CustomEvent("vvveb.FileManager.deletePage", {
detail: page,
detail: page
}));

if (page) {
Expand Down Expand Up @@ -3450,7 +3450,7 @@ Vvveb.FileManager = {

//allow event to change page or newfile or cancel by setting page to false
window.dispatchEvent(new CustomEvent("vvveb.FileManager.renamePage", {
detail: page,
detail: {page, newfile}
}));

if (page) {
Expand Down
90 changes: 89 additions & 1 deletion libs/builder/components-widgets.js
Expand Up @@ -16,7 +16,7 @@ limitations under the License.
https://github.com/givanz/VvvebJs
*/

Vvveb.ComponentsGroup['Widgets'] = ["widgets/googlemaps", "widgets/embed-video", "widgets/chartjs",/* "widgets/facebookpage", */"widgets/paypal", /*"widgets/instagram",*/ "widgets/twitter", "widgets/openstreetmap"/*, "widgets/facebookcomments"*/];
Vvveb.ComponentsGroup['Widgets'] = ["widgets/googlemaps", "widgets/embed-video", "widgets/chartjs", "widgets/lottie",/* "widgets/facebookpage", */"widgets/paypal", /*"widgets/instagram",*/ "widgets/twitter", "widgets/openstreetmap"/*, "widgets/facebookcomments"*/];

Vvveb.Components.extend("_base", "widgets/googlemaps", {
name: "Google Maps",
Expand Down Expand Up @@ -749,3 +749,91 @@ Vvveb.Components.extend("_base", "widgets/chartjs", {
}
}]
});

function lottieAfterDrop(node) {
//check if lottie js is included and if not add it when drag starts to allow the script to load
body = Vvveb.Builder.frameBody;

if (!body.querySelector("#lottie-js")) {
let lib = document.createElement('script');
let code = document.createElement('script');
lib.id = 'lottie-js';
lib.type = 'text/javascript';
lib.src = 'https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.12.2/lottie.min.js';
code.type = 'text/javascript';
code.text = `
let lottie = [];
function initLottie(onlyNew = false) {
if (typeof bodymovin == "undefined") return;
let list = document.querySelectorAll('.lottie' + (onlyNew ? ":not(.lottie-initialized)" : "") );
list.forEach(el => {
el.replaceChildren();
let animItem = bodymovin.loadAnimation({
wrapper: el,
animType: 'svg',
loop: (el.dataset.loop == "true" ? true : false),
autoplay: (el.dataset.autoplay == "true" ? true : false),
path: el.dataset.path
});
});
}
if (document.readyState !== 'loading') {
initLottie();
} else {
document.addEventListener('DOMContentLoaded', initLottie);
}`;

body.appendChild(lib);
body.appendChild(code);

lib.addEventListener('load', function() {
Vvveb.Builder.iframe.contentWindow.initLottie();
});
} else {
Vvveb.Builder.iframe.contentWindow.initLottie(true);
}

return node;
};

Vvveb.Components.add("widgets/lottie", {
name: "Lottie",
image: "icons/lottie.svg",
attributes: ["data-component-lottie"],
html: `
<div class="lottie" data-component-lottie data-path="https://labs.nearpod.com/bodymovin/demo/markus/isometric/markus2.json" data-loop="true" data-autoplay="true">
</div>
`,
afterDrop: lottieAfterDrop,

onChange: function (node, property, value) {
Vvveb.Builder.iframe.contentWindow.initLottie();
Vvveb.Builder.selectNode(node);
return node;
},

properties: [{
name: "Path",
key: "path",
//inputtype: ImageInput,
inputtype: TextInput,
htmlAttr:"data-path",
},{
name: "Autoplay",
key: "autoplay",
htmlAttr:"data-autoplay",
inputtype: CheckboxInput,
inline:true,
col:4
},{ name: "Loop",
key: "loop",
htmlAttr:"data-loop",
inputtype: CheckboxInput,
inline:true,
col:4
}]
});
1 change: 1 addition & 0 deletions libs/builder/icons/lottie.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 2 additions & 6 deletions libs/builder/inputs.js
Expand Up @@ -26,7 +26,6 @@ let Input = {
if (event && event.target) {
const e = new CustomEvent('propertyChange', { detail: {value : input.value ?? this.value, input: this, origEvent:event} });
event.currentTarget.dispatchEvent(e);
//event.data.element.trigger('propertyChange', [this.value, this, event]);
}
},

Expand Down Expand Up @@ -55,7 +54,6 @@ let Input = {
fun = this[ this.events[i][1] ];
el = this.events[i][2];

//this.element[0].querySelector(el).addEventListener(ev, function (ev, el, fun, target, event) {
this.element[0].addEventListener(ev, function (ev, el, fun, target, event) {
if (event.target.closest(el)) {
//target, event, element, input
Expand All @@ -71,7 +69,7 @@ let Input = {
let TextInput = { ...Input, ...{

events: [
//event, listener, child element
//event, listener, child element
["focusout", "onChange", "input"],
],

Expand Down Expand Up @@ -751,7 +749,7 @@ let ListInput = { ...Input, ...{
},

select: function(event, node, input) {
let index = [...this.parentNode.children].indexOf(el);//sectionItem.index();
let index = [...this.parentNode.children].indexOf(el);

event.action = "select";
event.index = index;
Expand Down Expand Up @@ -821,7 +819,6 @@ let AutocompleteList = { ...Input, ...{

onAutocompleteChange: function(event, node, input) {
input.value = event.detail;
//return input.onChange(event, node, input);
return input.onChange.call(this, event, node, input);
},

Expand Down Expand Up @@ -868,7 +865,6 @@ let TagsInput = { ...Input, ...{

}
}
//$('input', this.element).data("tagsInput").setValue(value);
},

init: function(data) {
Expand Down
8 changes: 4 additions & 4 deletions libs/builder/plugin-bootstrap-colorpicker.js
@@ -1,18 +1,18 @@
var ColorInput = $.extend({}, ColorInput, {
let ColorInput = { ...ColorInput, ...{

events: [
["change", "onChange", "input"],
],

setValue: function(value) {
var color = this.rgb2hex(value);
let color = this.rgb2hex(value);
$('input', this.element).val();
$('i', this.element).css('background-color', value);
},

init: function(data) {
var colorinput = this.render("bootstrap-color-picker-input", data);
var colorpicker = $('.input-group', colorinput).colorpicker();
let colorinput = this.render("bootstrap-color-picker-input", data);
let colorpicker = $('.input-group', colorinput).colorpicker();
return colorinput;
},
}
Expand Down

0 comments on commit 162f349

Please sign in to comment.