create-skybridge 0.0.0-dev.e38035c → 0.0.0-dev.e3941b0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +101 -71
- package/dist/index.test.js +11 -1
- package/package.json +8 -7
- package/template/AGENTS.md +1 -0
- package/template/README.md +36 -19
- package/template/_gitignore +6 -0
- package/template/alpic.json +1 -2
- package/template/node_modules/.bin/alpic +21 -0
- package/template/node_modules/.bin/sb +21 -0
- package/template/node_modules/.bin/skybridge +21 -0
- package/template/node_modules/.bin/tsc +2 -2
- package/template/node_modules/.bin/tsserver +2 -2
- package/template/node_modules/.bin/tsx +2 -2
- package/template/node_modules/.bin/vite +2 -2
- package/template/package.json +18 -25
- package/template/src/components/ball.tsx +22 -0
- package/template/src/helpers.ts +4 -0
- package/template/src/index.css +152 -0
- package/template/{server/src → src}/server.ts +8 -7
- package/template/src/views/magic-8-ball.tsx +10 -0
- package/template/tsconfig.json +7 -19
- package/template/{web/vite.config.ts → vite.config.ts} +0 -2
- package/template/node_modules/.bin/mcp-inspector +0 -21
- package/template/node_modules/.bin/nodemon +0 -21
- package/template/node_modules/.bin/shx +0 -21
- package/template/nodemon.json +0 -5
- package/template/server/src/index.ts +0 -39
- package/template/server/src/middleware.ts +0 -54
- package/template/tsconfig.server.json +0 -11
- package/template/web/src/helpers.ts +0 -4
- package/template/web/src/index.css +0 -31
- package/template/web/src/widgets/magic-8-ball.tsx +0 -24
- package/template-ecom/README.md +0 -89
- package/template-ecom/alpic.json +0 -4
- package/template-ecom/nodemon.json +0 -5
- package/template-ecom/package.json +0 -40
- package/template-ecom/server/src/index.ts +0 -39
- package/template-ecom/server/src/middleware.ts +0 -54
- package/template-ecom/server/src/server.ts +0 -73
- package/template-ecom/tsconfig.json +0 -23
- package/template-ecom/tsconfig.server.json +0 -11
- package/template-ecom/web/src/helpers.ts +0 -4
- package/template-ecom/web/src/index.css +0 -194
- package/template-ecom/web/src/widgets/ecom-carousel.tsx +0 -181
- package/template-ecom/web/vite.config.ts +0 -15
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
2
|
-
import type { NextFunction, Request, Response } from "express";
|
|
3
|
-
|
|
4
|
-
import type { McpServer } from "skybridge/server";
|
|
5
|
-
|
|
6
|
-
export const mcp =
|
|
7
|
-
(server: McpServer) =>
|
|
8
|
-
async (req: Request, res: Response, next: NextFunction) => {
|
|
9
|
-
// Only handle requests to the /mcp path
|
|
10
|
-
if (req.path !== "/mcp") {
|
|
11
|
-
return next();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (req.method === "POST") {
|
|
15
|
-
try {
|
|
16
|
-
const transport = new StreamableHTTPServerTransport({
|
|
17
|
-
sessionIdGenerator: undefined,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
res.on("close", () => {
|
|
21
|
-
transport.close();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
await server.connect(transport);
|
|
25
|
-
|
|
26
|
-
await transport.handleRequest(req, res, req.body);
|
|
27
|
-
} catch (error) {
|
|
28
|
-
console.error("Error handling MCP request:", error);
|
|
29
|
-
if (!res.headersSent) {
|
|
30
|
-
res.status(500).json({
|
|
31
|
-
jsonrpc: "2.0",
|
|
32
|
-
error: {
|
|
33
|
-
code: -32603,
|
|
34
|
-
message: "Internal server error",
|
|
35
|
-
},
|
|
36
|
-
id: null,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
} else if (req.method === "GET" || req.method === "DELETE") {
|
|
41
|
-
res.writeHead(405).end(
|
|
42
|
-
JSON.stringify({
|
|
43
|
-
jsonrpc: "2.0",
|
|
44
|
-
error: {
|
|
45
|
-
code: -32000,
|
|
46
|
-
message: "Method not allowed.",
|
|
47
|
-
},
|
|
48
|
-
id: null,
|
|
49
|
-
}),
|
|
50
|
-
);
|
|
51
|
-
} else {
|
|
52
|
-
next();
|
|
53
|
-
}
|
|
54
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { McpServer } from "skybridge/server";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
interface Product {
|
|
5
|
-
id: number;
|
|
6
|
-
title: string;
|
|
7
|
-
price: number;
|
|
8
|
-
description: string;
|
|
9
|
-
category: string;
|
|
10
|
-
image: string;
|
|
11
|
-
rating: {
|
|
12
|
-
rate: number;
|
|
13
|
-
count: number;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const server = new McpServer(
|
|
18
|
-
{
|
|
19
|
-
name: "ecom-carousel-app",
|
|
20
|
-
version: "0.0.1",
|
|
21
|
-
},
|
|
22
|
-
{ capabilities: {} },
|
|
23
|
-
).registerWidget(
|
|
24
|
-
"ecom-carousel",
|
|
25
|
-
{
|
|
26
|
-
description: "E-commerce Product Carousel",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
description: "Display a carousel of products from the store.",
|
|
30
|
-
inputSchema: {
|
|
31
|
-
category: z
|
|
32
|
-
.enum(["electronics", "jewelery", "men's clothing", "women's clothing"])
|
|
33
|
-
.optional()
|
|
34
|
-
.describe("Filter by product category"),
|
|
35
|
-
maxPrice: z.number().optional().describe("Maximum price filter"),
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
async ({ category, maxPrice }) => {
|
|
39
|
-
try {
|
|
40
|
-
const response = await fetch("https://fakestoreapi.com/products");
|
|
41
|
-
if (!response.ok) {
|
|
42
|
-
throw new Error(`API request failed: ${response.status}`);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const products: Product[] = await response.json();
|
|
46
|
-
const filtered: Product[] = [];
|
|
47
|
-
|
|
48
|
-
for (const product of products) {
|
|
49
|
-
if (category && product.category !== category) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
if (maxPrice !== undefined && product.price > maxPrice) {
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
filtered.push(product);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
structuredContent: { products: filtered },
|
|
60
|
-
content: [{ type: "text", text: JSON.stringify(filtered) }],
|
|
61
|
-
isError: false,
|
|
62
|
-
};
|
|
63
|
-
} catch (error) {
|
|
64
|
-
return {
|
|
65
|
-
content: [{ type: "text", text: `Error: ${error}` }],
|
|
66
|
-
isError: true,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
export default server;
|
|
73
|
-
export type AppType = typeof server;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
-
"jsx": "react-jsx",
|
|
8
|
-
|
|
9
|
-
"strict": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"esModuleInterop": true,
|
|
12
|
-
"forceConsistentCasingInFileNames": true,
|
|
13
|
-
"verbatimModuleSyntax": true,
|
|
14
|
-
|
|
15
|
-
"noUnusedLocals": true,
|
|
16
|
-
"noUnusedParameters": true,
|
|
17
|
-
"noFallthroughCasesInSwitch": true,
|
|
18
|
-
|
|
19
|
-
"noEmit": true
|
|
20
|
-
},
|
|
21
|
-
"include": ["server/src", "web/src", "web/vite.config.ts"],
|
|
22
|
-
"exclude": ["dist", "node_modules"]
|
|
23
|
-
}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
.light {
|
|
2
|
-
--bg: #fff;
|
|
3
|
-
--bg-alt: #f5f5f5;
|
|
4
|
-
--text: #333;
|
|
5
|
-
--text-muted: #666;
|
|
6
|
-
--shadow: rgba(0, 0, 0, 0.1);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.dark {
|
|
10
|
-
--bg: #2a2a2a;
|
|
11
|
-
--bg-alt: #333;
|
|
12
|
-
--text: #eee;
|
|
13
|
-
--text-muted: #aaa;
|
|
14
|
-
--shadow: rgba(0, 0, 0, 0.3);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.container,
|
|
18
|
-
.checkout {
|
|
19
|
-
--accent: mediumseagreen;
|
|
20
|
-
--accent-text: #fff;
|
|
21
|
-
display: flex;
|
|
22
|
-
flex-direction: column;
|
|
23
|
-
font-family: sans-serif;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.carousel {
|
|
27
|
-
display: flex;
|
|
28
|
-
gap: 1rem;
|
|
29
|
-
padding: 1rem;
|
|
30
|
-
overflow-x: auto;
|
|
31
|
-
scrollbar-width: none;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.product-wrapper {
|
|
35
|
-
flex: 0 0 150px;
|
|
36
|
-
max-width: 150px;
|
|
37
|
-
display: flex;
|
|
38
|
-
flex-direction: column;
|
|
39
|
-
gap: 0.5rem;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.product-card {
|
|
43
|
-
background: var(--bg);
|
|
44
|
-
border: none;
|
|
45
|
-
border-radius: 8px;
|
|
46
|
-
box-shadow: 0 2px 8px var(--shadow);
|
|
47
|
-
cursor: pointer;
|
|
48
|
-
padding: 0;
|
|
49
|
-
text-align: left;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.product-card.selected {
|
|
53
|
-
outline: 2px solid var(--accent);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.product-image {
|
|
57
|
-
width: 100%;
|
|
58
|
-
height: 100px;
|
|
59
|
-
object-fit: contain;
|
|
60
|
-
background: var(--bg-alt);
|
|
61
|
-
padding: 0.5rem;
|
|
62
|
-
box-sizing: border-box;
|
|
63
|
-
border-radius: 8px 8px 0 0;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.product-info {
|
|
67
|
-
padding: 0.5rem;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.product-title {
|
|
71
|
-
font-size: 0.75rem;
|
|
72
|
-
color: var(--text);
|
|
73
|
-
overflow: hidden;
|
|
74
|
-
text-overflow: ellipsis;
|
|
75
|
-
white-space: nowrap;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.product-price {
|
|
79
|
-
font-size: 0.875rem;
|
|
80
|
-
font-weight: bold;
|
|
81
|
-
color: var(--accent);
|
|
82
|
-
margin-top: 0.25rem;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.product-detail {
|
|
86
|
-
margin: 0 1rem 1rem;
|
|
87
|
-
padding: 1rem;
|
|
88
|
-
background: var(--bg);
|
|
89
|
-
border-radius: 8px;
|
|
90
|
-
box-shadow: 0 2px 8px var(--shadow);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.detail-title {
|
|
94
|
-
font-weight: bold;
|
|
95
|
-
color: var(--text);
|
|
96
|
-
margin-bottom: 0.5rem;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.detail-rating {
|
|
100
|
-
font-size: 0.875rem;
|
|
101
|
-
color: var(--text-muted);
|
|
102
|
-
margin-bottom: 0.5rem;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.detail-description {
|
|
106
|
-
font-size: 0.8rem;
|
|
107
|
-
color: var(--text-muted);
|
|
108
|
-
line-height: 1.4;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.message {
|
|
112
|
-
margin: 1rem;
|
|
113
|
-
padding: 1rem;
|
|
114
|
-
background: var(--bg);
|
|
115
|
-
border-radius: 8px;
|
|
116
|
-
box-shadow: 0 2px 8px var(--shadow);
|
|
117
|
-
color: var(--text-muted);
|
|
118
|
-
text-align: center;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.cart-indicator {
|
|
122
|
-
padding: 0.5rem 1rem;
|
|
123
|
-
align-self: flex-end;
|
|
124
|
-
color: var(--accent-text);
|
|
125
|
-
background: var(--accent);
|
|
126
|
-
border: none;
|
|
127
|
-
border-radius: 6px;
|
|
128
|
-
cursor: pointer;
|
|
129
|
-
font-weight: bold;
|
|
130
|
-
margin-right: 1rem;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.cart-indicator:disabled {
|
|
134
|
-
background: var(--bg-alt);
|
|
135
|
-
color: var(--text-muted);
|
|
136
|
-
cursor: default;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.cart-button {
|
|
140
|
-
padding: 0.5rem;
|
|
141
|
-
border: none;
|
|
142
|
-
border-radius: 6px;
|
|
143
|
-
cursor: pointer;
|
|
144
|
-
background: var(--accent);
|
|
145
|
-
color: var(--accent-text);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.cart-button.in-cart {
|
|
149
|
-
background: var(--bg-alt);
|
|
150
|
-
color: var(--text-muted);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
.checkout {
|
|
154
|
-
gap: 1rem;
|
|
155
|
-
padding: 1.25rem;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.checkout-title {
|
|
159
|
-
font-weight: bold;
|
|
160
|
-
font-size: 1rem;
|
|
161
|
-
color: var(--text);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.checkout-items {
|
|
165
|
-
display: flex;
|
|
166
|
-
flex-direction: column;
|
|
167
|
-
gap: 0.5rem;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
.checkout-item {
|
|
171
|
-
display: flex;
|
|
172
|
-
justify-content: space-between;
|
|
173
|
-
font-size: 0.875rem;
|
|
174
|
-
color: var(--text);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
.checkout-total {
|
|
178
|
-
display: flex;
|
|
179
|
-
justify-content: space-between;
|
|
180
|
-
font-weight: bold;
|
|
181
|
-
color: var(--text);
|
|
182
|
-
border-top: 1px solid var(--bg-alt);
|
|
183
|
-
padding-top: 0.5rem;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
.checkout-button {
|
|
187
|
-
padding: 0.75rem;
|
|
188
|
-
border: none;
|
|
189
|
-
border-radius: 6px;
|
|
190
|
-
cursor: pointer;
|
|
191
|
-
background: var(--accent);
|
|
192
|
-
color: var(--accent-text);
|
|
193
|
-
font-weight: bold;
|
|
194
|
-
}
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import "@/index.css";
|
|
2
|
-
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import {
|
|
5
|
-
mountWidget,
|
|
6
|
-
useLayout,
|
|
7
|
-
useOpenExternal,
|
|
8
|
-
useRequestModal,
|
|
9
|
-
useUser,
|
|
10
|
-
useWidgetState,
|
|
11
|
-
} from "skybridge/web";
|
|
12
|
-
import { useToolInfo } from "../helpers.js";
|
|
13
|
-
|
|
14
|
-
const translations: Record<string, Record<string, string>> = {
|
|
15
|
-
en: {
|
|
16
|
-
loading: "Loading products...",
|
|
17
|
-
noProducts: "No product found",
|
|
18
|
-
addToCart: "Add to cart",
|
|
19
|
-
removeFromCart: "Remove",
|
|
20
|
-
},
|
|
21
|
-
fr: {
|
|
22
|
-
loading: "Chargement des produits...",
|
|
23
|
-
noProducts: "Aucun produit trouvé",
|
|
24
|
-
addToCart: "Ajouter",
|
|
25
|
-
removeFromCart: "Retirer",
|
|
26
|
-
},
|
|
27
|
-
es: {
|
|
28
|
-
loading: "Cargando productos...",
|
|
29
|
-
noProducts: "No se encontraron productos",
|
|
30
|
-
addToCart: "Añadir",
|
|
31
|
-
removeFromCart: "Quitar",
|
|
32
|
-
},
|
|
33
|
-
de: {
|
|
34
|
-
loading: "Produkte werden geladen...",
|
|
35
|
-
noProducts: "Keine Produkte gefunden",
|
|
36
|
-
addToCart: "Hinzufügen",
|
|
37
|
-
removeFromCart: "Entfernen",
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const CHECKOUT_URL = "https://alpic.ai";
|
|
42
|
-
|
|
43
|
-
function EcomCarousel() {
|
|
44
|
-
const { theme } = useLayout();
|
|
45
|
-
const { locale } = useUser();
|
|
46
|
-
const { open, isOpen } = useRequestModal();
|
|
47
|
-
const openExternal = useOpenExternal();
|
|
48
|
-
|
|
49
|
-
const lang = locale?.split("-")[0] ?? "en";
|
|
50
|
-
|
|
51
|
-
function translate(key: string) {
|
|
52
|
-
return translations[lang]?.[key] ?? translations.en[key];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const { output, isPending } = useToolInfo<"ecom-carousel">();
|
|
56
|
-
type Product = NonNullable<typeof output>["products"][number];
|
|
57
|
-
const [selected, setSelected] = useState<Product | null>(null);
|
|
58
|
-
|
|
59
|
-
const [cart, setCart] = useWidgetState<{ ids: number[] }>({ ids: [] });
|
|
60
|
-
|
|
61
|
-
function toggleCart(productId: number) {
|
|
62
|
-
if (cart.ids.includes(productId)) {
|
|
63
|
-
setCart({ ids: cart.ids.filter((id) => id !== productId) });
|
|
64
|
-
} else {
|
|
65
|
-
setCart({ ids: [...cart.ids, productId] });
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (isPending) {
|
|
70
|
-
return (
|
|
71
|
-
<div className={`${theme} container`}>
|
|
72
|
-
<div className="message">{translate("loading")}</div>
|
|
73
|
-
</div>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (!output || output.products.length === 0) {
|
|
78
|
-
return (
|
|
79
|
-
<div className={`${theme} container`}>
|
|
80
|
-
<div className="message">{translate("noProducts")}</div>
|
|
81
|
-
</div>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (isOpen) {
|
|
86
|
-
const cartItems: Product[] = [];
|
|
87
|
-
let total = 0;
|
|
88
|
-
for (const p of output.products) {
|
|
89
|
-
if (cart.ids.includes(p.id)) {
|
|
90
|
-
cartItems.push(p);
|
|
91
|
-
total += p.price;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
const checkoutUrl = new URL(CHECKOUT_URL);
|
|
95
|
-
checkoutUrl.searchParams.set("cart", cart.ids.join(","));
|
|
96
|
-
|
|
97
|
-
return (
|
|
98
|
-
<div className={`${theme} checkout`}>
|
|
99
|
-
<div className="checkout-title">Order summary</div>
|
|
100
|
-
<div className="checkout-items">
|
|
101
|
-
{cartItems.map((item) => (
|
|
102
|
-
<div key={item.id} className="checkout-item">
|
|
103
|
-
<span>{item.title}</span>
|
|
104
|
-
<span>${item.price.toFixed(2)}</span>
|
|
105
|
-
</div>
|
|
106
|
-
))}
|
|
107
|
-
</div>
|
|
108
|
-
<div className="checkout-total">
|
|
109
|
-
<span>Total</span>
|
|
110
|
-
<span>${total.toFixed(2)}</span>
|
|
111
|
-
</div>
|
|
112
|
-
<button
|
|
113
|
-
type="button"
|
|
114
|
-
className="checkout-button"
|
|
115
|
-
onClick={() => openExternal(checkoutUrl.toString())}
|
|
116
|
-
>
|
|
117
|
-
Checkout
|
|
118
|
-
</button>
|
|
119
|
-
</div>
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const activeProduct = selected ?? output.products[0];
|
|
124
|
-
|
|
125
|
-
return (
|
|
126
|
-
<div className={`${theme} container`}>
|
|
127
|
-
<button
|
|
128
|
-
type="button"
|
|
129
|
-
className="cart-indicator"
|
|
130
|
-
onClick={() => open({ title: "Proceed to checkout ?" })}
|
|
131
|
-
disabled={cart.ids.length === 0}
|
|
132
|
-
>
|
|
133
|
-
🛒 {cart.ids.length}
|
|
134
|
-
</button>
|
|
135
|
-
<div className="carousel">
|
|
136
|
-
{output.products.map((product) => {
|
|
137
|
-
const inCart = cart.ids.includes(product.id);
|
|
138
|
-
return (
|
|
139
|
-
<div key={product.id} className="product-wrapper">
|
|
140
|
-
<button
|
|
141
|
-
type="button"
|
|
142
|
-
className={`product-card ${activeProduct?.id === product.id ? "selected" : ""}`}
|
|
143
|
-
onClick={() => setSelected(product)}
|
|
144
|
-
>
|
|
145
|
-
<img
|
|
146
|
-
src={product.image}
|
|
147
|
-
alt={product.title}
|
|
148
|
-
className="product-image"
|
|
149
|
-
/>
|
|
150
|
-
<div className="product-info">
|
|
151
|
-
<div className="product-title">{product.title}</div>
|
|
152
|
-
<div className="product-price">
|
|
153
|
-
${product.price.toFixed(2)}
|
|
154
|
-
</div>
|
|
155
|
-
</div>
|
|
156
|
-
</button>
|
|
157
|
-
<button
|
|
158
|
-
type="button"
|
|
159
|
-
className={`cart-button ${inCart ? "in-cart" : ""}`}
|
|
160
|
-
onClick={() => toggleCart(product.id)}
|
|
161
|
-
>
|
|
162
|
-
{inCart ? translate("removeFromCart") : translate("addToCart")}
|
|
163
|
-
</button>
|
|
164
|
-
</div>
|
|
165
|
-
);
|
|
166
|
-
})}
|
|
167
|
-
</div>
|
|
168
|
-
<div className="product-detail">
|
|
169
|
-
<div className="detail-title">{activeProduct.title}</div>
|
|
170
|
-
<div className="detail-rating">
|
|
171
|
-
⭐ {activeProduct.rating.rate} ({activeProduct.rating.count} reviews)
|
|
172
|
-
</div>
|
|
173
|
-
<div className="detail-description">{activeProduct.description}</div>
|
|
174
|
-
</div>
|
|
175
|
-
</div>
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export default EcomCarousel;
|
|
180
|
-
|
|
181
|
-
mountWidget(<EcomCarousel />);
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import react from "@vitejs/plugin-react";
|
|
3
|
-
import { skybridge } from "skybridge/web";
|
|
4
|
-
import { defineConfig } from "vite";
|
|
5
|
-
|
|
6
|
-
// https://vite.dev/config/
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
plugins: [skybridge(), react()],
|
|
9
|
-
root: __dirname,
|
|
10
|
-
resolve: {
|
|
11
|
-
alias: {
|
|
12
|
-
"@": path.resolve(__dirname, "./src"),
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
});
|