Skip to content

Commit

Permalink
Type option to switch between ordered and unordered list for list com…
Browse files Browse the repository at this point in the history
…ponent
  • Loading branch information
givanz committed Oct 15, 2024
1 parent 1a7e4a7 commit 409ede1
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 13 deletions.
4 changes: 2 additions & 2 deletions css/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -17793,7 +17793,7 @@ https://github.com/givanz/VvvebJs
.tree > ol li.file:hover .file-actions {
display: block; }
.tree > ol li.file > label {
background: url(../libs/builder/icons/file.svg);
background-image: url(../libs/builder/icons/file.svg);
background-position: 8px 4px;
background-size: 19px 19px;
background-repeat: no-repeat;
Expand Down Expand Up @@ -18867,7 +18867,7 @@ li[data-type] {
.sections-container > div.section-item .controls .info .type {
font-size: 12px; }
.sections-container > div.section-item .controls .buttons {
margin-right: 2rem;
margin-right: 1.3rem;
margin-top: 0.2rem; }
.sections-container > div.section-item .controls .buttons a {
padding: 0.3rem 0.5rem 0.3rem;
Expand Down
2 changes: 1 addition & 1 deletion demo/landing
Submodule landing updated 67 files
+48 −14 about.html
+48 −14 blank-breadcrumb.html
+48 −14 blank.html
+48 −14 cart/cart.html
+48 −14 cart/compare.html
+47 −13 checkout/checkout.html
+47 −13 checkout/confirm.html
+48 −14 checkout/order.html
+48 −14 contact.html
+48 −14 content/archive.html
+48 −14 content/category.html
+48 −14 content/index.html
+48 −14 content/page.html
+50 −15 content/post-image-header.html
+50 −15 content/post-image-hero.html
+50 −15 content/post.html
+55 −21 content/tag.html
+55 −21 content/user.html
+16 −0 css/admin-post-editor.css
+18 −4 css/style.bundle.css
+16 −0 css/style.css
+49 −15 download.html
+48 −14 error404.html
+48 −14 error500.html
+55 −21 index-blog.html
+55 −21 index-excerpts.html
+28 −1 index-landing.html
+48 −14 index-nav-hero.html
+55 −21 index-no-sidebar.html
+48 −14 index-slider.html
+48 −14 index.coming-soon.html
+48 −14 index.html
+48 −14 index.maintenance.html
+48 −14 portfolio.html
+48 −14 pricing.html
+335 −301 product/category.html
+332 −276 product/index.html
+55 −21 product/manufacturer.html
+47 −13 product/product.html
+55 −21 product/vendor.html
+26 −0 scss/_base.scss
+2 −3 scss/sections/hero/hero-1.scss
+149 −28 search/index.html
+69 −48 sections/sections.js
+48 −14 services.html
+2 −2 src/_includes/author-box.html
+27 −0 src/_includes/footer-scripts.html
+8 −1 src/_includes/top-menu.html
+1 −1 src/product/index.html
+88 −1 src/search/index.html
+48 −14 user/address.html
+48 −14 user/address/edit.html
+55 −21 user/comments.html
+55 −21 user/downloads.html
+48 −14 user/edit.html
+48 −14 user/index.html
+48 −14 user/login.html
+48 −14 user/order-tracking.html
+48 −14 user/order.html
+55 −21 user/orders.html
+48 −14 user/orders/order.html
+48 −14 user/profile.html
+48 −14 user/reset.html
+48 −14 user/reset/reset.html
+48 −14 user/return-form.html
+48 −14 user/signup.html
+55 −21 user/wishlist.html
6 changes: 3 additions & 3 deletions libs/builder/components-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ function changeNodeName(node, newNodeName) {
newNode.setAttribute(attributes[i].nodeName, attributes[i].nodeValue);
}

for (e of node.childNodes) {
newNode.append(e);
while (node.hasChildNodes()) {
newNode.appendChild(node.removeChild(node.firstChild))
}

node.replaceWith(newNode);

return newNode;
Expand Down
61 changes: 58 additions & 3 deletions libs/builder/components-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -900,10 +900,65 @@ Vvveb.Components.extend("_base", "html/list", {
name: "List",
image: "icons/list.svg",
html: `<ul>
<li>Today I shall be meeting with interference, ingratitude, insolence, disloyalty, ill-will, and selfishness all of them due to the offenders' ignorance of what is good or evil..</li>
<li>Today I shall be meeting with interference, ingratitude, insolence, disloyalty, ill-will, and selfishness all of them due to the offenders' ignorance of what is good or evil..</li>
<li>Today I shall be meeting with interference, ingratitude, insolence, disloyalty, ill-will, and selfishness all of them due to the offenders' ignorance of what is good or evil..</li>
<li>Begin with the possible; begin with one step.</li>
<li>Never think of results, just do!</li>
<li>Patience is the mother of will.</li>
<li>Man must use what he has, not hope for what is not.</li>
<li>Only super-efforts count.</li>
</ul>`,
properties: [{
name: "Type",
key: "type",
inputtype: SelectInput,

onChange: function(node, value) {
return changeNodeName(node, value);
},

init: function(node) {
return node.nodeName.toLowerCase()
},

data:{
options: [{
value: "ul",
text: "Unorderd"
}, {
value: "ol",
text: "Ordered"
}]
},
},{
name: "Items",
key: "items",
inputtype: ListInput,
htmlAttr:"data-slides-per-view",
inline:true,
data: {
selector:"li",
container:"",
prefix:"Item ",
removeElement: true,
"newElement": `<li>Do everything quickly and well.</li>`
},
onChange: function(node, value, input, component, event) {
let element = node;

if (event.action) {
if (event.action == "add") {
//node.append(generateElements(`<li>List item</li>`)[0]);

//temporary solution to better update list
Vvveb.Components.render("html/list");
}
if (event.action == "remove") {
} else if (event.action == "select") {
}
}

return node;
},
}]
});

Vvveb.Components.extend("_base", "html/preformatted", {
Expand Down
14 changes: 11 additions & 3 deletions libs/builder/inputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,11 @@ let ListInput = { ...Input, ...{
let data = input.data;

if (data.removeElement) {
input.node.querySelector(data.container + " " + data.selector + ":nth-child(" + (index + 1) + ")").remove();
let container = input.node;
if (data.container) {
container.querySelector(data.container);
}
container.querySelector(data.selector + ":nth-child(" + (index + 1) + ")").remove();
}
sectionItem.remove();

Expand All @@ -746,7 +750,11 @@ let ListInput = { ...Input, ...{
add: function(event, node, input) {
let newElement = input.data.newElement ?? false;
if (newElement) {
event.data.input.node.querySelector(input.data.container).append(generateElements(newElement)[0]);
let container = input.node;
if (data.container) {
container.querySelector(data.container);
}
container.append(generateElements(newElement)[0]);
}

event.action = "add";
Expand Down Expand Up @@ -782,7 +790,7 @@ let ListInput = { ...Input, ...{
if (data.nameElement) {
element = element.querySelector(data.nameElement);
}
let name = (data.name = "text" ? element.textContent : element.id);
let name = (data.name = "text" ? element.textContent.substr(0, 15) : element.id);
options.push({
name: name,
type: (data.prefix ?? "") + (i + 1) + (data.suffix ?? ""),
Expand Down
2 changes: 1 addition & 1 deletion scss/_builder.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,7 @@ width:100%;
}

.buttons {
margin-right:2rem;
margin-right:1.3rem;
margin-top:0.2rem;

//align-self: flex-end;
Expand Down

0 comments on commit 409ede1

Please sign in to comment.