@promakeai/cli 0.2.0 → 0.2.2
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 +32 -31
- package/dist/registry/cart-drawer.json +1 -1
- package/package.json +1 -1
- package/template/src/components/LanguageSwitcher.tsx +8 -2
- package/template/src/components/Logo.tsx +6 -0
- package/template/src/components/ThemeSwitcher.tsx +7 -2
- package/template/src/constants/constants.json +1 -1
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"path": "cart-drawer/cart-drawer.tsx",
|
|
21
21
|
"type": "registry:component",
|
|
22
22
|
"target": "$modules$/cart-drawer/cart-drawer.tsx",
|
|
23
|
-
"content": "import { Link } from \"react-router\";\
|
|
23
|
+
"content": "import { Link } from \"react-router\";\nimport { Minus, Plus } from \"lucide-react\";\nimport { Button } from \"@/components/ui/button\";\nimport {\n Sheet,\n SheetContent,\n SheetHeader,\n SheetTitle,\n} from \"@/components/ui/sheet\";\nimport { useTranslation } from \"react-i18next\";\nimport { useCart, formatPrice } from \"@/modules/ecommerce-core\";\nimport constants from \"@/constants/constants.json\";\n\ninterface CartDrawerProps {\n checkoutHref?: string;\n className?: string;\n}\n\nexport function CartDrawer({\n checkoutHref = \"/checkout\",\n className,\n}: CartDrawerProps) {\n const { t } = useTranslation(\"cart-drawer\");\n const {\n state,\n removeItem,\n updateQuantity,\n isDrawerOpen,\n setDrawerOpen,\n } = useCart();\n const { items, total } = state;\n const currency = (constants.site as any).currency || \"USD\";\n\n const getProductPrice = (product: {\n price: number;\n sale_price?: number;\n on_sale?: boolean;\n }) => {\n return product.on_sale && product.sale_price\n ? product.sale_price\n : product.price;\n };\n\n const handleQuantityChange = (id: string | number, newQuantity: number) => {\n if (newQuantity <= 0) {\n removeItem(id);\n } else {\n updateQuantity(id, newQuantity);\n }\n };\n\n return (\n <Sheet open={isDrawerOpen} onOpenChange={setDrawerOpen} className={className}>\n <SheetContent className=\"w-full sm:max-w-md flex flex-col px-6 pb-8\">\n <SheetHeader>\n <SheetTitle>{t(\"title\", \"Shopping cart\")}</SheetTitle>\n </SheetHeader>\n\n <div className=\"flex-1 overflow-y-auto mt-8\">\n {items.length === 0 ? (\n <p className=\"text-center text-muted-foreground py-8\">\n {t(\"empty\", \"Your cart is empty\")}\n </p>\n ) : (\n <ul className=\"-my-6 divide-y divide-border\">\n {items.map((item) => (\n <li key={item.id} className=\"flex py-6\">\n <div className=\"size-24 shrink-0 overflow-hidden rounded-md border border-border\">\n <img\n alt={item.product.name}\n src={item.product.images[0] || \"/images/placeholder.png\"}\n className=\"size-full object-cover\"\n />\n </div>\n\n <div className=\"ml-4 flex flex-1 flex-col\">\n <div>\n <div className=\"flex justify-between text-base font-medium\">\n <h3>\n <Link\n to={`/products/${item.product.slug}`}\n onClick={() => setDrawerOpen(false)}\n >\n {item.product.name}\n </Link>\n </h3>\n <p className=\"ml-4\">\n {formatPrice(getProductPrice(item.product), currency)}\n </p>\n </div>\n {item.product.category_name && (\n <p className=\"mt-1 text-sm text-muted-foreground\">\n {item.product.category_name}\n </p>\n )}\n </div>\n <div className=\"flex flex-1 items-end justify-between text-sm\">\n <div className=\"flex items-center gap-1\">\n <Button\n variant=\"outline\"\n size=\"icon\"\n className=\"h-6 w-6\"\n onClick={() =>\n handleQuantityChange(item.id, item.quantity - 1)\n }\n >\n <Minus className=\"h-3 w-3\" />\n </Button>\n <span className=\"w-8 text-center text-sm\">\n {item.quantity}\n </span>\n <Button\n variant=\"outline\"\n size=\"icon\"\n className=\"h-6 w-6\"\n onClick={() =>\n handleQuantityChange(item.id, item.quantity + 1)\n }\n >\n <Plus className=\"h-3 w-3\" />\n </Button>\n </div>\n\n <button\n type=\"button\"\n onClick={() => removeItem(item.id)}\n className=\"font-medium text-primary hover:text-primary/80\"\n >\n {t(\"remove\", \"Remove\")}\n </button>\n </div>\n </div>\n </li>\n ))}\n </ul>\n )}\n </div>\n\n <div className=\"border-t border-border pt-6 mt-6\">\n <div className=\"flex justify-between text-base font-medium\">\n <p>{t(\"subtotal\", \"Subtotal\")}</p>\n <p>{formatPrice(total, currency)}</p>\n </div>\n <p className=\"mt-0.5 text-sm text-muted-foreground\">\n {t(\"shippingNote\", \"Shipping and taxes calculated at checkout.\")}\n </p>\n <div className=\"mt-6\">\n <Button asChild className=\"w-full\" disabled={items.length === 0}>\n <Link to={checkoutHref} onClick={() => setDrawerOpen(false)}>\n {t(\"checkout\", \"Checkout\")}\n </Link>\n </Button>\n </div>\n </div>\n </SheetContent>\n </Sheet>\n );\n}\n"
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
"path": "cart-drawer/lang/en.json",
|
package/package.json
CHANGED
|
@@ -10,10 +10,15 @@ import { changeLanguage } from "@/lang";
|
|
|
10
10
|
import { cn } from "@/lib/utils";
|
|
11
11
|
import constants from "@/constants/constants.json";
|
|
12
12
|
|
|
13
|
+
interface LanguageSwitcherProps {
|
|
14
|
+
className?: string;
|
|
15
|
+
style?: React.CSSProperties;
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
const languages: Record<string, string> =
|
|
14
19
|
constants?.site?.availableLanguages || {};
|
|
15
20
|
|
|
16
|
-
export function LanguageSwitcher() {
|
|
21
|
+
export function LanguageSwitcher({ className, style }: LanguageSwitcherProps) {
|
|
17
22
|
const { i18n } = useTranslation();
|
|
18
23
|
const currentLang = i18n.language;
|
|
19
24
|
|
|
@@ -23,7 +28,8 @@ export function LanguageSwitcher() {
|
|
|
23
28
|
<Button
|
|
24
29
|
variant="ghost"
|
|
25
30
|
size="sm"
|
|
26
|
-
className="h-9 px-2 text-sm font-medium"
|
|
31
|
+
className={cn("h-9 px-2 text-sm font-medium", className)}
|
|
32
|
+
style={style}
|
|
27
33
|
>
|
|
28
34
|
{languages?.[currentLang] || currentLang.toUpperCase()}
|
|
29
35
|
</Button>
|
|
@@ -5,12 +5,16 @@ interface LogoProps {
|
|
|
5
5
|
className?: string;
|
|
6
6
|
size?: "sm" | "md" | "lg" | "xl";
|
|
7
7
|
variant?: "default" | "light" | "dark";
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
textStyle?: React.CSSProperties;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
export function Logo({
|
|
11
13
|
className = "",
|
|
12
14
|
size = "md",
|
|
13
15
|
variant = "default",
|
|
16
|
+
style,
|
|
17
|
+
textStyle,
|
|
14
18
|
}: LogoProps) {
|
|
15
19
|
// Text boyutları
|
|
16
20
|
const textSizes = {
|
|
@@ -42,6 +46,7 @@ export function Logo({
|
|
|
42
46
|
return (
|
|
43
47
|
<Link
|
|
44
48
|
to="/"
|
|
49
|
+
style={style}
|
|
45
50
|
className={`flex items-center gap-1.5 sm:gap-2 md:gap-3 ${className}`}
|
|
46
51
|
>
|
|
47
52
|
{/* Logo Image (if exists) */}
|
|
@@ -55,6 +60,7 @@ export function Logo({
|
|
|
55
60
|
|
|
56
61
|
{/* Site Name */}
|
|
57
62
|
<span
|
|
63
|
+
style={textStyle}
|
|
58
64
|
className={`${textSizes[size]} font-bold ${currentVariant} truncate`}
|
|
59
65
|
>
|
|
60
66
|
{siteName}
|
|
@@ -9,6 +9,11 @@ import {
|
|
|
9
9
|
import { useTheme, type Theme } from "@/hooks/use-theme";
|
|
10
10
|
import { cn } from "@/lib/utils";
|
|
11
11
|
|
|
12
|
+
interface ThemeSwitcherProps {
|
|
13
|
+
className?: string;
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
const themes: {
|
|
13
18
|
value: Theme;
|
|
14
19
|
label: string;
|
|
@@ -19,7 +24,7 @@ const themes: {
|
|
|
19
24
|
{ value: "system", label: "System", icon: Monitor },
|
|
20
25
|
];
|
|
21
26
|
|
|
22
|
-
export function ThemeSwitcher() {
|
|
27
|
+
export function ThemeSwitcher({ className, style }: ThemeSwitcherProps) {
|
|
23
28
|
const { theme, setTheme, effectiveTheme } = useTheme();
|
|
24
29
|
|
|
25
30
|
const currentTheme = themes.find((t) => t.value === theme);
|
|
@@ -33,7 +38,7 @@ export function ThemeSwitcher() {
|
|
|
33
38
|
return (
|
|
34
39
|
<DropdownMenu>
|
|
35
40
|
<DropdownMenuTrigger asChild>
|
|
36
|
-
<Button variant="ghost" size="sm" className="h-9 w-9 px-0">
|
|
41
|
+
<Button variant="ghost" size="sm" className={cn("h-9 w-9 px-0", className)} style={style}>
|
|
37
42
|
<CurrentIcon className="h-4 w-4" />
|
|
38
43
|
<span className="sr-only">Toggle theme</span>
|
|
39
44
|
</Button>
|