Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better background support #410

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/web-component-designer/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"description": "A UI designer for Polymer apps",
"name": "@node-projects/web-component-designer",
"version": "0.1.70",
"version": "0.1.71",
"type": "module",
"main": "./dist/index.js",
"author": "[email protected]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend implements
* {
touch-action: none;
}
#node-projects-designer-canvas-canvas {
#node-projects-designer-canvas-canvasContainer {
background: var(--node-projects-web-component-designer-background, border-box fixed 0px 0px repeat url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAFXmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS41LjAiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICAgeG1sbnM6ZXhpZj0iaHR0cDovL25zLmFkb2JlLmNvbS9leG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gIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJwcm9kdWNlZCIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iQWZmaW5pdHkgRGVzaWduZXIgMS4xMC42IgogICAgICBzdEV2dDp3aGVuPSIyMDIyLTEyLTA4VDA5OjE1OjQ4KzAxOjAwIi8+CiAgICA8L3JkZjpTZXE+CiAgIDwveG1wTU06SGlzdG9yeT4KICA8L3JkZjpEZXNjcmlwdGlvbj4KIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cjw/eHBhY2tldCBlbmQ9InIiPz4fvgn+AAABgWlDQ1BzUkdCIElFQzYxOTY2LTIuMQAAKJF1kc8rRFEUxz8GjRhRLCiLl7BCftTExmLkV2ExnvJr8+bNvBk1b+b13kiyVbaKEhu/FvwFbJW1UkRKlrImNug5b2ZqJplzO/d87vfec7r3XPCpSd10KnrATGXs8FhImZtfUPwvBKjCTx/Nmu5YUzOjKiXt854yL952ebVKn/vXaqIxR4eyKuEh3bIzwuPCk6sZy+Md4UY9oUWFz4Q7bbmg8J2nR3L86nE8x98e22p4GHz1wkq8iCNFrCdsU1heTpuZXNHz9/FeEoilZmcktoq34BBmjBAKE4wwTJBeBmUO0iX96ZYVJfJ7svnTpCVXl9liDZtl4iTI0CnqilSPSTREj8lIsub1/29fHaO/L1c9EILKZ9d9bwf/Nvxsue7Xkev+HEP5E1ymCvnpQxj4EH2roLUdQN0GnF8VtMguXGxC06Ol2VpWKhf3GQa8nULtPDTcQPVirmf5fU4eQF2Xr7qGvX3okPN1S790cWfsRnax1QAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAC9JREFUOI1jfPr0KQNuICUlhUeWCY8cQTCqeWRoZvz//z8e6WfPntHK5lHNI0MzAMChCNMTuPcnAAAAAElFTkSuQmCC));
}
#node-projects-designer-canvas-canvas {
image-rendering: pixelated;
box-sizing: border-box;
width: 100%;
Expand Down Expand Up @@ -387,21 +389,6 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend implements
.map(x => cssFromString(x.content)));
}

let backgroundSet = false;
for (const s of styles) {
for (let r of s.cssRules) {
if (r instanceof CSSStyleRule) {
if (r.selectorText.split(',').includes(':host')) {
if (r.style.background) {
this._canvas.style.background = r.style.background;
backgroundSet = true;
}
}
}
}
}
if (!backgroundSet)
this._canvas.style.background = ''
this._canvasShadowRoot.adoptedStyleSheets = styles;
}

Expand Down Expand Up @@ -487,11 +474,11 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend implements
}

public disableBackgroud() {
this._canvas.style.backgroundImage = 'none';
this._canvasContainer.style.backgroundImage = 'none';
}

public enableBackground() {
this._canvas.style.backgroundImage = 'var(--node-projects-web-component-designer-background)';
this._canvasContainer.style.backgroundImage = 'var(--node-projects-web-component-designer-background)';
}

public zoomToFit() {
Expand Down