Skip to content

Commit

Permalink
A bit better demo for #13
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Nov 12, 2022
1 parent b876f8e commit 115c459
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
4 changes: 4 additions & 0 deletions demo-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ is-land[ready] {
background-color: rgba(112, 110, 233, 0.2);
outline: 2px solid rgb(97, 82, 173);
}
.test-c-finish:defined {
color: blue;
font-weight: bold;
}

/* List logos */
.examples {
Expand Down
2 changes: 1 addition & 1 deletion is-land.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Island extends HTMLElement {
static prefix = "is-land--"

static fallback = {
":scope:not([ssr]) :not(:defined)": (readyPromise, node, prefix) => {
":scope :not(:defined):not([ssr])": (readyPromise, node, prefix) => {
// remove from document to prevent web component init
let cloned = document.createElement(prefix + node.localName);
for(let attr of node.getAttributeNames()) {
Expand Down
18 changes: 4 additions & 14 deletions issues/13.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,10 @@ <h1><a href="/">is-land</a></h1>
</details-utils>
</is-land> -->

<is-land ssr on:interaction import="/lib/details-utils.js">
<is-land on:interaction import="/lib/chocolate-web-component.js">
<button type="button" onclick="console.log('Click test')">Click test (log to console)</button>

<details-utils close-click-outside>
<details open>
<summary>Toggle Menu (Default open: click outside to close after island initializes)</summary>
<p>Note that interacting with content inside of the menu works without closing the menu.</p>
</details>
</details-utils>
<chocolate-web-component class="demo-component" ssr>Vanilla web component</chocolate-web-component>
</is-land>

<!-- <is-land on:idle import="/lib/details-utils.js">
Expand Down Expand Up @@ -76,15 +71,10 @@ <h1><a href="/">is-land</a></h1>
<br>
<br>

<is-land ssr on:visible import="/lib/details-utils.js">
<is-land on:visible import="/lib/chocolate-web-component.js">
<button type="button" onclick="console.log('Click test')">Click test (log to console)</button>

<details-utils close-click-outside>
<details open>
<summary>Toggle Menu (Default open: click outside to close after island initializes)</summary>
<p>Note that interacting with content inside of the menu works without closing the menu.</p>
</details>
</details-utils>
<chocolate-web-component class="demo-component" ssr>Vanilla web component</chocolate-web-component>
</is-land>

<!-- <is-land on:visible>
Expand Down
16 changes: 16 additions & 0 deletions lib/chocolate-web-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Programmatic usage
// import { ready } from "/is-land.js";

class ChocolateWebComponent extends HTMLElement {
async connectedCallback() {
// Programmatic API: waiting to lazy load
// await ready(this);

// ready to go
this.classList.add("test-c-finish");
}
}

if("customElements" in window) {
customElements.define("chocolate-web-component", ChocolateWebComponent);
}

0 comments on commit 115c459

Please sign in to comment.