Skip to content

Commit

Permalink
Fix shadow root selector
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-harding committed Oct 17, 2024
1 parent 55a451e commit 79823de
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 32 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "superellipse-squircle",
"private": true,
"version": "0.1.16",
"version": "0.1.17",
"type": "module",
"main": "server.js",
"browser": "client.js",
Expand Down
6 changes: 0 additions & 6 deletions pages/public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,6 @@ main {
grid-template-areas: "tester";
}

ce-squircle {
display: grid;
contain: strict;
pointer-events: none;
}

th-tester {
grid-area: tester;
display: grid;
Expand Down
52 changes: 27 additions & 25 deletions src/squircle-canvas.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,46 @@
import { paint } from "@/drawing";

const styles = new CSSStyleSheet();
(() => {
styles.replace(`
:host {
const stylesString = `
body {
display: grid;
grid-template-rows: 100%;
grid-template-columns: 100%;
grid-template-rows: 1fr;
grid-template-columns: 1fr;
grid-template-areas: "fill";
padding: 0rem;
margin: 0rem;
width: 100%;
height: 100%;
}
.canvas {
grid-area: fill;
width: 100%;
height: 100%;
contain: strict;
z-index: -1000;
}
.content {
grid-area: fill;
z-index: 1;
}
`);
})();
`;

const template = new DocumentFragment();
const styles = new CSSStyleSheet();
styles.replace(stylesString);

(() => {
const canvas = document.createElement("canvas");
const div = document.createElement("div");
div.classList.add("canvas");
div.appendChild(canvas);
template.appendChild(div);
})();

(() => {
const slot = document.createElement("slot");
const div = document.createElement("div");
div.classList.add("content");
div.appendChild(slot);
template.appendChild(div);
})();
const templateString = `
<div class="canvas">
<canvas></canvas>
</div>
<div class="content">
<slot></slot>
</div>
`;

const template = new DocumentFragment();
template.append(
new DOMParser().parseFromString(templateString, "text/html").body,
);

export default class SquircleCanvas extends HTMLElement {
_radius = 0;
Expand Down

0 comments on commit 79823de

Please sign in to comment.