Skip to content

Commit 6e5f367

Browse files
WIP shoelace integration
1 parent 07c5755 commit 6e5f367

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
@@ -27,6 +27,7 @@
2727
"start": "pnpm run serve"
2828
},
2929
"dependencies": {
30+
"@shoelace-style/shoelace": "^2.18.0",
3031
"lit": "^3.2.1"
3132
},
3233
"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.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class Card extends LitElement {
8282
<div>
8383
<h3>${title}</h3>
8484
<img src="${thumbnail}" alt="${title}" loading="lazy" width="100%">
85-
<button @click="${this.selectItem}">View Item Details</button>
85+
<sl-button variant="neutral" @click="${this.selectItem}">View Item Details</sl-button>
8686
</div>
8787
`;
8888
}

src/components/modal.ts

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

6060
firstUpdated() {
61-
const button = this.shadowRoot.querySelector('button');
61+
const button = this.shadowRoot.querySelector('sl-button');
6262
const dialog = this.shadowRoot.querySelector('dialog');
6363

6464
button.addEventListener("click", () => dialog.close());
@@ -70,7 +70,7 @@ export class Modal extends LitElement {
7070
return html`
7171
<dialog>
7272
<h3 id="content">${content}</h3>
73-
<button autofocus>Close</button>
73+
<sl-button variant="neutral" autofocus>Close</sl-button>
7474
</dialog>
7575
`;
7676
}

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.ts"></script>
1417
<script type="module" src="../components/modal.ts"></script>
1518
</head>

src/pages/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ <h2>JSON API</h2>
4141
<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>
4242
<form>
4343
<label>
44-
<input type="text" name="name" placeholder="your name..." required/>
44+
<sl-input type="text" name="name" placeholder="your name..." required></sl-input>
4545
</label>
46-
<button type="submit">Click me for a greeting!</button>
46+
<sl-button variant="neutral" type="submit">Click me for a greeting!</sl-button>
4747
</form>
4848
<h2 id="greeting-output"></h2>
4949
</article>
5050
<article>
5151
<h2>Fragments API (w/ Lit+SSR)</h2>
5252
<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>
5353
<div id="load-products-output" class="products-cards-container" aria-live="polite"></div>
54-
<button id="load-products">Load More Products</button>
54+
<sl-button id="load-products" variant="neutral">Load More Products</sl-button>
5555
</article>
5656
</body>
5757
</html>

src/pages/search.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ <h2>Search API (w/ Lit+SSR)</h2>
3131
<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>
3232
<form id="search">
3333
<label for="term">
34-
<input type="search" name="term" placeholder="a product..." required/>
34+
<sl-input size="small" type="search" name="term" placeholder="a product..." required></sl-input>
3535
</label>
36-
<button type="submit">Search</button>
36+
<sl-button type="submit" variant="neutral">Search</sl-button>
3737
</form>
3838
<div id="search-products-output" class="products-cards-container" aria-live="polite"></div>
3939
</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)