Skip to content

Commit 25ee116

Browse files
WIP shoelace integration
1 parent 8caeedb commit 25ee116

File tree

8 files changed

+107
-19
lines changed

8 files changed

+107
-19
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"lint:types": "tsc --project ./tsconfig.json"
2929
},
3030
"dependencies": {
31+
"@shoelace-style/shoelace": "^2.18.0",
3132
"lit": "^3.2.1"
3233
},
3334
"devDependencies": {

pnpm-lock.yaml

Lines changed: 93 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/card/card.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class Card extends LitElement {
4141
<div>
4242
<h3>${title}</h3>
4343
<img src="${thumbnail}" alt="${title}" loading="lazy" width="100%">
44-
<button @click="${this.selectItem}">View Item Details</button>
44+
<sl-button variant="neutral" @click="${this.selectItem}">View Item Details</sl-button>
4545
</div>
4646
`;
4747
}

src/components/modal/modal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class Modal extends LitElement {
2929
}
3030

3131
firstUpdated() {
32-
const button = this.shadowRoot.querySelector('button');
32+
const button = this.shadowRoot.querySelector('sl-button');
3333
const dialog = this.shadowRoot.querySelector('dialog');
3434

3535
button.addEventListener("click", () => dialog.close());
@@ -41,7 +41,7 @@ export class Modal extends LitElement {
4141
return html`
4242
<dialog>
4343
<h3 id="content">${unsafeHTML(content)}</h3>
44-
<button autofocus>Close</button>
44+
<sl-button variant="neutral" autofocus>Close</sl-button>
4545
</dialog>
4646
`;
4747
}

src/layouts/app.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
<link rel="icon" href="/favicon.ico"/>
1010

1111
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro">
12+
<link rel="stylesheet" href="/node_modules/@shoelace-style/shoelace/dist/themes/light.css" />
1213
<link rel="stylesheet" href="../styles/main.css">
14+
15+
<script type="module" src="/node_modules/@shoelace-style/shoelace/dist/shoelace.js"></script>
1316
<script type="module" src="../components/card/card.ts"></script>
1417
<script type="module" src="../components/modal/modal.ts"></script>
1518
</head>

src/pages/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ <h2>JSON API</h2>
3939
<p>This is an example of a Greenwood API Route returning JSON when fetched on-submit of the form to display a message on the page. You can see it fire in the network tab as <i>/api/greeting</i></p>
4040
<form>
4141
<label>
42-
<input type="text" name="name" placeholder="your name..." required/>
42+
<sl-input type="text" name="name" placeholder="your name..." required></sl-input>
4343
</label>
44-
<button type="submit">Click me for a greeting!</button>
44+
<sl-button variant="neutral" type="submit">Click me for a greeting!</sl-button>
4545
</form>
4646
<h2 id="greeting-output"></h2>
4747
</article>
4848
<article>
4949
<h2>Fragments API (w/ Lit+SSR)</h2>
5050
<p>This is an example of a Greenwood API route returning an HTML response that is generated by server-rendering a Web Component (with Declarative Shadow DOM). This same component is loaded on the client-side too, so that when you click the <i>Product Details</i> button, state and interactivity can still be resumed. You can see it fire in the network tab as <i>/api/fragment</i></p>
5151
<div id="load-products-output" class="products-cards-container" aria-live="polite"></div>
52-
<button id="load-products">Load More Products</button>
52+
<sl-button id="load-products" variant="neutral">Load More Products</sl-button>
5353
</article>
5454
</body>
5555
</html>

src/pages/search.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ <h2>Search API (w/ Lit+SSR)</h2>
2929
<p>This is an example of a Greenwood API leveraging the FormData API and returning an HTML response that is generated by server-rendering a Web Component (with Declarative Shadow DOM). This same component is loaded on the client-side too, so that when you click the <i>Item Details</i> button, state and interactivity can still be resumed. You can see it fire in the network tab as <i>/api/search</i></p>
3030
<form id="search">
3131
<label for="term">
32-
<input type="search" name="term" placeholder="a product..." required/>
32+
<sl-input size="small" type="search" name="term" placeholder="a product..." required></sl-input>
3333
</label>
34-
<button type="submit">Search</button>
34+
<sl-button type="submit" variant="neutral">Search</sl-button>
3535
</form>
3636
<div id="search-products-output" class="products-cards-container" aria-live="polite"></div>
3737
</article>

src/styles/main.css

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,11 @@ h2 {
6060
text-decoration: underline;
6161
}
6262

63-
button {
64-
background: var(--color-accent);
65-
color: var(--color-white);
66-
padding: 1rem 2rem;
67-
border: 0;
68-
font-size: 1rem;
69-
border-radius: 5px;
70-
cursor: pointer;
71-
}
72-
73-
input {
63+
sl-input {
7464
padding: 1rem;
7565
margin: 0 10px;
7666
font-size: 16px;
67+
display: inline-block;
7768
}
7869

7970
label {

0 commit comments

Comments
 (0)