Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/playground/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
},
"dependencies": {
"@meshsdk/midnight-react": "*",
"@meshsdk/midnight-core": "*",
"@meshsdk/midnight-wallet": "*",
"@radix-ui/react-dropdown-menu": "^2.1.15",
"@radix-ui/react-slot": "^1.2.3",
"@tailwindcss/vite": "^4.1.11",
Expand Down
24 changes: 14 additions & 10 deletions apps/playground/frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
import * as pino from "pino";
import { MidnightMeshProvider } from "@meshsdk/midnight-react";
import { ThemeProvider } from "@/components/theme-provider"
import "@meshsdk/midnight-react/styles.css";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import { Home } from "./pages/home";
import { MainLayout } from "./layouts/layout";
import { WalletUI } from "./pages/wallet-ui";
import { Counter } from "./pages/counter";

const logger = pino.pino({
level: "trace",
});

function App() {

return (
<>
return (
<ThemeProvider defaultTheme="light" storageKey="vite-ui-theme">
<MidnightMeshProvider logger={logger}>
<BrowserRouter basename="/">
<Routes>
<Route path="/" element={<Home />} />
</Routes>
</BrowserRouter>
<BrowserRouter basename="/">
<Routes>
<Route element={<MainLayout />}>
<Route path="/" element={<Home />} />
<Route path="/wallet-ui" element={<WalletUI />} />
<Route path="/counter" element={<Counter />} />
</Route>
</Routes>
</BrowserRouter>
</MidnightMeshProvider>
</ThemeProvider>
</>
</ThemeProvider>
)
}

Expand Down
7 changes: 7 additions & 0 deletions apps/playground/frontend/src/components/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const Loading = () => {
return (
<div>
<p>Loading...</p>
</div>
);
};
40 changes: 40 additions & 0 deletions apps/playground/frontend/src/layouts/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Outlet, NavLink } from 'react-router-dom';

export const MainLayout = () => {
return (
<div className="min-h-screen flex flex-col">
<header className="bg-primary text-primary-foreground shadow">
<nav className="container mx-auto flex gap-4 p-4">
<NavLink
to="/"
className={({ isActive }) =>
`font-semibold transition hover:opacity-80 ${isActive ? 'underline' : ''}`
}
end
>
Home
</NavLink>
<NavLink
to="/counter"
className={({ isActive }) =>
`font-semibold transition hover:opacity-80 ${isActive ? 'underline' : ''}`
}
>
Counter
</NavLink>
<NavLink
to="/wallet-ui"
className={({ isActive }) =>
`font-semibold transition hover:opacity-80 ${isActive ? 'underline' : ''}`
}
>
Wallet UI
</NavLink>
</nav>
</header>
<main className="container mx-auto flex-1 py-6">
<Outlet />
</main>
</div>
);
};
11 changes: 8 additions & 3 deletions apps/playground/frontend/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { StrictMode } from 'react'
import { StrictMode, Suspense, lazy } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App.tsx'
import { Loading } from '@/components/loading'

import './index.css'
import '@/global.ts'

const LazyApp = lazy(() => import('./App'));

createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
<Suspense fallback={<Loading />}>
<LazyApp />
</Suspense>
</StrictMode>,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import type { VariantProps } from "class-variance-authority";
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva } from "class-variance-authority";

import { cn } from "./cn";

const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
{
variants: {
variant: {
default:
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
destructive:
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
outline:
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
secondary:
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
default: "h-9 px-4 py-2",
sm: "h-8 rounded-md px-3 text-xs",
lg: "h-10 rounded-md px-8",
icon: "h-9 w-9",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
},
);

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean;
}

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button";
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
);
},
);
Button.displayName = "Button";

export { Button, buttonVariants };
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { ClassValue } from "clsx";
import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import * as React from "react";
import * as DialogPrimitive from "@radix-ui/react-dialog";
import { X } from "lucide-react";

import { cn } from "./cn";

const Dialog = DialogPrimitive.Root;

const DialogTrigger = DialogPrimitive.Trigger;

const DialogPortal = DialogPrimitive.Portal;

const DialogClose = DialogPrimitive.Close;

const DialogOverlay = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Overlay
ref={ref}
className={cn(
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
className,
)}
{...props}
/>
));
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;

const DialogContent = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
>(({ className, children, ...props }, ref) => (
<DialogPortal>
<DialogOverlay />
<DialogPrimitive.Content
ref={ref}
className={cn(
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg"
,
className,
)}
{...props}
>
{children}
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
<X className="h-4 w-4" />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
</DialogPrimitive.Content>
</DialogPortal>
));
DialogContent.displayName = DialogPrimitive.Content.displayName;

const DialogHeader = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col space-y-1.5 text-foreground text-center sm:text-left",
className,
)}
{...props}
/>
);
DialogHeader.displayName = "DialogHeader";

const DialogFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
className,
)}
{...props}
/>
);
DialogFooter.displayName = "DialogFooter";

const DialogTitle = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Title
ref={ref}
className={cn(
"text-lg font-semibold leading-none tracking-tight",
className,
)}
{...props}
/>
));
DialogTitle.displayName = DialogPrimitive.Title.displayName;

const DialogDescription = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Description
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
));
DialogDescription.displayName = DialogPrimitive.Description.displayName;

export {
Dialog,
DialogPortal,
DialogOverlay,
DialogTrigger,
DialogClose,
DialogContent,
DialogHeader,
DialogFooter,
DialogTitle,
DialogDescription,
};
Loading
Loading