Skip to content

Commit 8fa0b39

Browse files
committed
Add details
1 parent 4cd17f0 commit 8fa0b39

File tree

15 files changed

+548
-877
lines changed

15 files changed

+548
-877
lines changed

bun.lock

Lines changed: 0 additions & 708 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"dev": "vite",
88
"build": "tsc && vite build",
99
"preview": "vite preview",
10-
"format": "bunx prettier --write src/**/*",
11-
"format:check": "bunx prettier --check src/**/*",
10+
"format": "npx prettier --write src/**/*",
11+
"format:check": "npx prettier --check src/**/*",
1212
"lint": "eslint src --ext .ts",
1313
"lint:fix": "eslint src --ext .ts --fix"
1414
},

src/components/app-header.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import '@awesome.me/webawesome/dist/components/icon/icon.js';
12
import { LitElement, css, html } from 'lit';
23
import { customElement } from 'lit/decorators.js';
34

src/components/tool-card.ts

Lines changed: 15 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1+
import '@awesome.me/webawesome/dist/components/button/button.js';
12
import { LitElement, css, html } from 'lit';
23
import { customElement, property } from 'lit/decorators.js';
34

4-
interface CardLink {
5-
text: string;
6-
url: string;
7-
primary?: boolean;
8-
}
9-
105
@customElement('tool-card')
116
export class ToolCard extends LitElement {
127
@property({ type: String }) title = '';
138
@property({ type: String }) description = '';
149
@property({ type: String }) image = '';
1510
@property({ type: String }) url = '';
11+
@property({ type: String }) text = '';
1612
@property({ type: String }) category = '';
17-
@property({ type: Array }) links: CardLink[] = [];
1813

1914
static styles = css`
2015
:host {
@@ -77,7 +72,7 @@ export class ToolCard extends LitElement {
7772
.card-description {
7873
color: #666;
7974
line-height: 1.5;
80-
margin: 0 0 20px 0;
75+
margin: 0 0 40px 0;
8176
flex: 1;
8277
}
8378
@@ -88,38 +83,6 @@ export class ToolCard extends LitElement {
8883
margin-top: auto;
8984
}
9085
91-
.card-link {
92-
display: inline-flex;
93-
align-items: center;
94-
justify-content: center;
95-
padding: 10px 16px;
96-
text-decoration: none;
97-
border-radius: 8px;
98-
font-weight: 500;
99-
transition: all 0.2s ease;
100-
border: 1px solid transparent;
101-
font-size: 0.9rem;
102-
}
103-
104-
.card-link.primary {
105-
background: #03a9f4;
106-
color: white;
107-
}
108-
109-
.card-link.primary:hover {
110-
background: #0288d1;
111-
}
112-
113-
.card-link.secondary {
114-
background: transparent;
115-
color: #03a9f4;
116-
border-color: #03a9f4;
117-
}
118-
119-
.card-link.secondary:hover {
120-
background: #e3f2fd;
121-
}
122-
12386
.external-icon {
12487
width: 14px;
12588
height: 14px;
@@ -147,34 +110,18 @@ export class ToolCard extends LitElement {
147110
return url.startsWith('http') && !url.includes('#');
148111
}
149112

150-
private _handleCardClick() {
113+
private _handleButtonClick(event: Event) {
114+
event.stopPropagation();
115+
151116
if (this.url && this.url !== '#') {
152117
const isExternal = this._isExternalLink(this.url);
153118
if (isExternal) {
154119
window.open(this.url, '_blank', 'noopener,noreferrer');
155-
} else {
156-
this.dispatchEvent(
157-
new CustomEvent('card-action', {
158-
detail: { url: this.url },
159-
bubbles: true,
160-
composed: true,
161-
})
162-
);
163-
}
164-
}
165-
}
166-
167-
private _handleLinkClick(link: CardLink, event: Event) {
168-
event.stopPropagation();
169-
170-
if (link.url && link.url !== '#') {
171-
const isExternal = this._isExternalLink(link.url);
172-
if (isExternal) {
173-
window.open(link.url, '_blank', 'noopener,noreferrer');
120+
return;
174121
} else {
175122
this.dispatchEvent(
176123
new CustomEvent('tool-action', {
177-
detail: { url: link.url, text: link.text },
124+
detail: { url: this.url, text: this.text },
178125
bubbles: true,
179126
composed: true,
180127
})
@@ -185,7 +132,7 @@ export class ToolCard extends LitElement {
185132

186133
render() {
187134
return html`
188-
<div class="card" @click="${this._handleCardClick}">
135+
<div class="card">
189136
<img src="${this.image}" alt="${this.title}" class="card-image" />
190137
191138
<div class="card-content">
@@ -197,26 +144,12 @@ export class ToolCard extends LitElement {
197144
</div>
198145
199146
<p class="card-description">${this.description}</p>
200-
201-
<div class="card-actions">
202-
${this.links.map(
203-
link => html`
204-
<a
205-
href="${link.url || '#'}"
206-
class="card-link ${link.primary ? 'primary' : 'secondary'}"
207-
target="${this._isExternalLink(link.url)
208-
? '_blank'
209-
: '_self'}"
210-
rel="${this._isExternalLink(link.url)
211-
? 'noopener noreferrer'
212-
: ''}"
213-
@click="${(e: Event) => this._handleLinkClick(link, e)}"
214-
>
215-
${link.text}
216-
</a>
217-
`
218-
)}
219-
</div>
147+
<wa-button
148+
href="${!this._isExternalLink(this.url) ? this.url : '#'}"
149+
variant="brand"
150+
@click="${(e: Event) => this._handleButtonClick(e)}"
151+
>${this.text}</wa-button
152+
>
220153
</div>
221154
</div>
222155
`;

src/main-app.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ import { match } from 'ts-pattern';
44

55
import './components/app-header.js';
66

7+
import './pages/bluetooth-proxy-details';
8+
import './pages/empty-esphome-details';
9+
import './pages/esphome-details';
710
import './pages/home-page.js';
11+
import './pages/improv-details';
12+
import './pages/media-player-details';
813
import './pages/vpe-details';
14+
import './pages/zbt1-details';
915
import './pages/zwa2-details';
1016

1117
import { router } from './utils/router';
@@ -25,10 +31,6 @@ export class MainApp extends LitElement {
2531
connectedCallback() {
2632
super.connectedCallback();
2733

28-
router.addRoute('/', 'home-page');
29-
router.addRoute('/vpe', 'vpe-details');
30-
router.addRoute('/zwa2', 'zwa2-details');
31-
3234
window.addEventListener('route-changed', this._handleRouteChange);
3335
this.currentRoute = router.getCurrentRoute();
3436
}
@@ -47,6 +49,21 @@ export class MainApp extends LitElement {
4749
return match(this.currentRoute)
4850
.with('/vpe', () => html`<vpe-details></vpe-details>`)
4951
.with('/zwa2', () => html`<zwa2-details></zwa2-details>`)
52+
.with('/zbt1', () => html`<zbt1-details></zbt1-details>`)
53+
.with('/esphome', () => html`<esphome-details></esphome-details>`)
54+
.with(
55+
'/media-player',
56+
() => html`<media-player-details></media-player-details>`
57+
)
58+
.with('/improv', () => html`<improv-details></improv-details>`)
59+
.with(
60+
'/empty-esphome',
61+
() => html`<empty-esphome-details></empty-esphome-details>`
62+
)
63+
.with(
64+
'/bluetooth-proxy',
65+
() => html`<bluetooth-proxy-details></bluetooth-proxy-details>`
66+
)
5067
.otherwise(() => html`<home-page></home-page>`);
5168
}
5269

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { LitElement, html } from 'lit';
2+
import { customElement } from 'lit/decorators.js';
3+
4+
import '../components/details.js';
5+
import { detailsByKey } from '../utils/details.js';
6+
7+
@customElement('bluetooth-proxy-details')
8+
export class BluetoothProxyDetails extends LitElement {
9+
render() {
10+
return html`<details-page
11+
.config=${detailsByKey.bluetooth}
12+
></details-page>`;
13+
}
14+
}

src/pages/empty-esphome-details.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { LitElement, html } from 'lit';
2+
import { customElement } from 'lit/decorators.js';
3+
4+
import '../components/details.js';
5+
import { detailsByKey } from '../utils/details.js';
6+
7+
@customElement('empty-esphome-details')
8+
export class EmptyESPHomeDetails extends LitElement {
9+
render() {
10+
return html`<details-page .config=${detailsByKey.empty}></details-page>`;
11+
}
12+
}

src/pages/esphome-details.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { LitElement, html } from 'lit';
2+
import { customElement } from 'lit/decorators.js';
3+
4+
import '../components/details.js';
5+
import { detailsByKey } from '../utils/details.js';
6+
7+
@customElement('esphome-details')
8+
export class ESPHomeDetails extends LitElement {
9+
render() {
10+
return html`<details-page .config=${detailsByKey.esphome}></details-page>`;
11+
}
12+
}

src/pages/home-page.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { LitElement, css, html } from 'lit';
22
import { customElement } from 'lit/decorators.js';
33

44
import '../components/tool-card.js';
5-
import tools from '../utils/tools.js';
5+
import { tools } from '../utils/tools.js';
66

77
@customElement('home-page')
88
export class HomePage extends LitElement {
@@ -81,8 +81,8 @@ export class HomePage extends LitElement {
8181
description="${tool.description}"
8282
image="${tool.image}"
8383
url="${tool.url}"
84+
text="${tool.text}"
8485
category="${tool.category ?? ''}"
85-
.links=${tool.links}
8686
></tool-card>
8787
`
8888
)}

src/pages/improv-details.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { LitElement, html } from 'lit';
2+
import { customElement } from 'lit/decorators.js';
3+
4+
import '../components/details.js';
5+
import { detailsByKey } from '../utils/details.js';
6+
7+
@customElement('improv-details')
8+
export class ImprovDetails extends LitElement {
9+
render() {
10+
return html`<details-page .config=${detailsByKey.improv}></details-page>`;
11+
}
12+
}

0 commit comments

Comments
 (0)