mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 18:10:18 +05:30
Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2c1d0c11a | ||
|
|
e0d6315204 | ||
|
|
68ff7d076a | ||
|
|
67b57eae78 | ||
|
|
301c51ac84 | ||
|
|
904ffbdd5b | ||
|
|
ea383783ec | ||
|
|
e758a81c4c | ||
|
|
ea0f3f93bf | ||
|
|
188e73d7c1 | ||
|
|
8265e4ff88 | ||
|
|
8a8671b128 |
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"$schema": "https://ui.shadcn.com/schema.json",
|
||||
"style": "new-york",
|
||||
"rsc": false,
|
||||
"tsx": true,
|
||||
"tailwind": {
|
||||
"config": "tailwind.config.js",
|
||||
"css": "src/renderer/styles/globals.css",
|
||||
"baseColor": "neutral",
|
||||
"cssVariables": true,
|
||||
"prefix": ""
|
||||
},
|
||||
"aliases": {
|
||||
"components": "@/components",
|
||||
"ui": "@/components/ui",
|
||||
"lib": "@/lib",
|
||||
"hooks": "@/hooks"
|
||||
},
|
||||
"iconLibrary": "lucide"
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Generated
+1423
-107
File diff suppressed because it is too large
Load Diff
+24
-1
@@ -8,6 +8,9 @@
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"test:coverage": "jest --coverage",
|
||||
"test:renderer": "vitest run",
|
||||
"test:renderer:watch": "vitest",
|
||||
"test:renderer:coverage": "vitest run --coverage",
|
||||
"lint": "eslint src tests",
|
||||
"lint:fix": "eslint src tests --fix",
|
||||
"format": "prettier --write src tests",
|
||||
@@ -43,10 +46,16 @@
|
||||
"url": "https://github.com/amitwh/markdown-converter"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.60.0",
|
||||
"@testing-library/dom": "^10.4.1",
|
||||
"@testing-library/jest-dom": "^6.9.1",
|
||||
"@testing-library/react": "^16.3.2",
|
||||
"@testing-library/user-event": "^14.6.1",
|
||||
"@types/node": "^25.9.1",
|
||||
"@types/react": "^19.2.16",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^6.0.2",
|
||||
"@vitest/ui": "^4.1.8",
|
||||
"autoprefixer": "^10.5.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
@@ -58,6 +67,7 @@
|
||||
"eslint-plugin-prettier": "^5.5.4",
|
||||
"jest": "^30.2.0",
|
||||
"jest-environment-jsdom": "^30.2.0",
|
||||
"jsdom": "^29.1.1",
|
||||
"lucide-react": "^1.17.0",
|
||||
"postcss": "^8.5.15",
|
||||
"prettier": "^3.7.4",
|
||||
@@ -66,7 +76,8 @@
|
||||
"tailwindcss": "^3.4.19",
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
"typescript": "^6.0.3",
|
||||
"vite": "^8.0.16"
|
||||
"vite": "^8.0.16",
|
||||
"vitest": "^4.1.8"
|
||||
},
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.20.1",
|
||||
@@ -83,6 +94,11 @@
|
||||
"@codemirror/state": "^6.5.4",
|
||||
"@codemirror/theme-one-dark": "^6.1.3",
|
||||
"@codemirror/view": "^6.39.16",
|
||||
"@dnd-kit/core": "^6.3.1",
|
||||
"@dnd-kit/sortable": "^10.0.0",
|
||||
"@dnd-kit/utilities": "^3.2.2",
|
||||
"@hookform/resolvers": "^5.4.0",
|
||||
"@radix-ui/react-slot": "^1.2.4",
|
||||
"@tanstack/react-table": "^8.21.3",
|
||||
"codemirror": "^6.0.2",
|
||||
"core-util-is": "^1.0.3",
|
||||
@@ -93,18 +109,25 @@
|
||||
"ffmpeg-static": "^5.3.0",
|
||||
"highlight.js": "^11.11.1",
|
||||
"html2pdf.js": "^0.14.0",
|
||||
"immer": "^11.1.8",
|
||||
"marked": "^17.0.3",
|
||||
"marked-footnote": "^1.4.0",
|
||||
"marked-highlight": "^2.2.3",
|
||||
"mermaid": "^11.12.3",
|
||||
"motion": "^12.40.0",
|
||||
"next-themes": "^0.4.6",
|
||||
"pdf-lib": "^1.17.1",
|
||||
"pdfjs-dist": "^5.5.207",
|
||||
"pdfkit": "^0.17.2",
|
||||
"pizzip": "^3.2.0",
|
||||
"react": "^19.2.7",
|
||||
"react-dom": "^19.2.7",
|
||||
"react-hook-form": "^7.77.0",
|
||||
"react-resizable-panels": "^4.11.2",
|
||||
"simple-git": "^3.32.3",
|
||||
"sonner": "^2.0.7",
|
||||
"tslib": "^2.8.1",
|
||||
"zod": "^4.4.3",
|
||||
"zustand": "^5.0.14"
|
||||
},
|
||||
"overrides": {
|
||||
|
||||
+16
-37
@@ -1,45 +1,24 @@
|
||||
import React from 'react';
|
||||
import { AppHeader } from './components/layout/AppHeader';
|
||||
import { TabBar } from './components/layout/TabBar';
|
||||
import { Toolbar } from './components/layout/Toolbar';
|
||||
import { Breadcrumb } from './components/layout/Breadcrumb';
|
||||
import { Sidebar } from './components/sidebar/Sidebar';
|
||||
import { EditorPane } from './components/editor/EditorPane';
|
||||
import { PreviewPane } from './components/preview/PreviewPane';
|
||||
import { StatusBar } from './components/layout/StatusBar';
|
||||
import { CommandPalette } from './components/modals/CommandPalette';
|
||||
import { ExportDialog } from './components/modals/ExportDialog';
|
||||
import { SettingsDialog } from './components/modals/SettingsDialog';
|
||||
import { useAppStore } from './stores/appStore';
|
||||
import { ThemeToggle } from './components/theme-toggle';
|
||||
import { Button } from './components/ui/button';
|
||||
|
||||
function App() {
|
||||
const { sidebarVisible, previewVisible, activeTabId } = useAppStore();
|
||||
|
||||
return (
|
||||
<div className="flex flex-col h-screen bg-background text-foreground overflow-hidden">
|
||||
<AppHeader />
|
||||
<TabBar />
|
||||
<Toolbar />
|
||||
<Breadcrumb />
|
||||
|
||||
<main className="flex flex-1 overflow-hidden">
|
||||
{sidebarVisible && <Sidebar />}
|
||||
|
||||
<div className="flex flex-1 overflow-hidden">
|
||||
<EditorPane className={previewVisible ? 'flex-1' : 'flex-1'} />
|
||||
{previewVisible && (
|
||||
<>
|
||||
<div className="w-px bg-border cursor-col-resize hover:bg-brand transition-colors" />
|
||||
<PreviewPane className="flex-1" />
|
||||
</>
|
||||
)}
|
||||
<div className="flex h-screen flex-col bg-background text-foreground">
|
||||
<header className="flex h-14 items-center justify-between border-b border-border px-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="h-7 w-7 rounded-md bg-brand" aria-label="MarkdownConverter logo" />
|
||||
<h1 className="text-sm font-semibold">MarkdownConverter</h1>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button variant="ghost" size="sm">File</Button>
|
||||
<Button variant="ghost" size="sm">Edit</Button>
|
||||
<Button variant="ghost" size="sm">View</Button>
|
||||
<ThemeToggle />
|
||||
</div>
|
||||
</header>
|
||||
<main className="flex flex-1 items-center justify-center text-muted-foreground">
|
||||
<p>Shell skeleton — implementation phases in progress.</p>
|
||||
</main>
|
||||
|
||||
<StatusBar />
|
||||
<CommandPalette />
|
||||
<ExportDialog />
|
||||
<SettingsDialog />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { ThemeProvider as NextThemesProvider } from 'next-themes';
|
||||
import type { ComponentProps } from 'react';
|
||||
|
||||
export function ThemeProvider({ children, ...props }: ComponentProps<typeof NextThemesProvider>) {
|
||||
return <NextThemesProvider {...props}>{children}</NextThemesProvider>;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { useTheme } from 'next-themes';
|
||||
import { Moon, Sun } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
export function ThemeToggle() {
|
||||
const { resolvedTheme, setTheme } = useTheme();
|
||||
const [mounted, setMounted] = useState(false);
|
||||
useEffect(() => setMounted(true), []);
|
||||
|
||||
if (!mounted) {
|
||||
return (
|
||||
<Button variant="ghost" size="icon" aria-label="Toggle theme" className="opacity-0">
|
||||
<Sun className="h-4 w-4" />
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
const isDark = resolvedTheme === 'dark';
|
||||
return (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
aria-label="Toggle theme"
|
||||
onClick={() => setTheme(isDark ? 'light' : 'dark')}
|
||||
>
|
||||
{isDark ? <Sun className="h-4 w-4" /> : <Moon className="h-4 w-4" />}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import * as React from "react"
|
||||
import { Slot } from "@radix-ui/react-slot"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
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 }
|
||||
@@ -0,0 +1,94 @@
|
||||
import type {
|
||||
IpcResult,
|
||||
FileResult,
|
||||
FileEntry,
|
||||
PdfOptions,
|
||||
DocxOptions,
|
||||
HtmlOptions,
|
||||
ExportResult,
|
||||
BatchItem,
|
||||
BatchOptions,
|
||||
BatchResult,
|
||||
} from '@/types/ipc';
|
||||
|
||||
type ChannelMissing = { code: 'CHANNEL_MISSING'; message: string };
|
||||
|
||||
function wrap<T>(fn: () => Promise<T>): Promise<IpcResult<T | ChannelMissing>> {
|
||||
if (typeof window === 'undefined' || !window.electronAPI) {
|
||||
return Promise.resolve({
|
||||
ok: false,
|
||||
error: { code: 'NO_BRIDGE', message: 'window.electronAPI is unavailable' },
|
||||
});
|
||||
}
|
||||
return fn().then(
|
||||
(data) => ({ ok: true as const, data }),
|
||||
(err: Error) => ({
|
||||
ok: false as const,
|
||||
error: { code: err.name || 'IPC_ERROR', message: err.message || String(err) },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
function safeCall<T extends (...args: any[]) => Promise<any>>(
|
||||
channel: string,
|
||||
method: string,
|
||||
...args: Parameters<T>
|
||||
): Promise<IpcResult<Awaited<ReturnType<T>> | ChannelMissing>> {
|
||||
if (typeof window === 'undefined' || !window.electronAPI) {
|
||||
return Promise.resolve({
|
||||
ok: false,
|
||||
error: { code: 'NO_BRIDGE', message: 'window.electronAPI is unavailable' },
|
||||
});
|
||||
}
|
||||
const target = (window.electronAPI as any)[channel]?.[method];
|
||||
if (!target) {
|
||||
return Promise.resolve({
|
||||
ok: false,
|
||||
error: { code: 'CHANNEL_MISSING', message: `Missing channel: ${channel}.${method}` },
|
||||
});
|
||||
}
|
||||
if (typeof target !== 'function') {
|
||||
return Promise.resolve({
|
||||
ok: false,
|
||||
error: { code: 'CHANNEL_MISSING', message: `Not a function: ${channel}.${method}` },
|
||||
});
|
||||
}
|
||||
return wrap(() => target(...args));
|
||||
}
|
||||
|
||||
export const ipc = {
|
||||
file: {
|
||||
open: (): Promise<IpcResult<FileResult | ChannelMissing>> =>
|
||||
safeCall('file', 'open'),
|
||||
read: (path: string): Promise<IpcResult<string | ChannelMissing>> =>
|
||||
safeCall('file', 'read', path),
|
||||
write: (path: string, content: string): Promise<IpcResult<void | ChannelMissing>> =>
|
||||
safeCall('file', 'write', path, content),
|
||||
list: (dir: string): Promise<IpcResult<FileEntry[] | ChannelMissing>> =>
|
||||
safeCall('file', 'list', dir),
|
||||
onChange: (cb: (path: string) => void): (() => void) => {
|
||||
if (typeof window === 'undefined' || !window.electronAPI?.file?.onChange) {
|
||||
return () => {};
|
||||
}
|
||||
return window.electronAPI.file.onChange(cb);
|
||||
},
|
||||
},
|
||||
export: {
|
||||
pdf: (opts: PdfOptions): Promise<IpcResult<ExportResult | ChannelMissing>> =>
|
||||
safeCall('export', 'pdf', opts),
|
||||
docx: (opts: DocxOptions): Promise<IpcResult<ExportResult | ChannelMissing>> =>
|
||||
safeCall('export', 'docx', opts),
|
||||
html: (opts: HtmlOptions): Promise<IpcResult<ExportResult | ChannelMissing>> =>
|
||||
safeCall('export', 'html', opts),
|
||||
batch: (items: BatchItem[], opts: BatchOptions): Promise<IpcResult<BatchResult | ChannelMissing>> =>
|
||||
safeCall('export', 'batch', items, opts),
|
||||
},
|
||||
app: {
|
||||
getVersion: (): Promise<IpcResult<string | ChannelMissing>> =>
|
||||
safeCall('app', 'getVersion'),
|
||||
openExternal: (url: string): Promise<IpcResult<void | ChannelMissing>> =>
|
||||
safeCall('app', 'openExternal', url),
|
||||
showItemInFolder: (path: string): Promise<IpcResult<void | ChannelMissing>> =>
|
||||
safeCall('app', 'showItemInFolder', path),
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
import type { Transition, Variants } from 'motion/react';
|
||||
|
||||
export const fadeIn: Transition = {
|
||||
duration: 0.2,
|
||||
ease: 'easeOut',
|
||||
};
|
||||
|
||||
export const slideInRight: Variants = {
|
||||
x: '100%',
|
||||
initial: { x: '100%', opacity: 0 },
|
||||
animate: { x: 0, opacity: 1, transition: { duration: 0.3, ease: [0.16, 1, 0.3, 1] } },
|
||||
exit: { x: '100%', opacity: 0, transition: { duration: 0.2, ease: 'easeIn' } },
|
||||
};
|
||||
|
||||
export const modalPop: Variants = {
|
||||
scale: 0.96,
|
||||
opacity: 0,
|
||||
initial: { scale: 0.96, opacity: 0 },
|
||||
animate: { scale: 1, opacity: 1, transition: { duration: 0.2, ease: 'easeOut' } },
|
||||
exit: { scale: 0.96, opacity: 0, transition: { duration: 0.15, ease: 'easeIn' } },
|
||||
};
|
||||
|
||||
export const toastSpring: Transition = {
|
||||
type: 'spring',
|
||||
stiffness: 300,
|
||||
damping: 30,
|
||||
};
|
||||
|
||||
export const sidebarToggle: Transition = {
|
||||
duration: 0.25,
|
||||
ease: 'easeInOut',
|
||||
width: {
|
||||
duration: 0.25,
|
||||
ease: 'easeInOut',
|
||||
},
|
||||
};
|
||||
|
||||
export const tabSwitch: Transition = {
|
||||
duration: 0.2,
|
||||
ease: 'easeOut',
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
import { clsx, type ClassValue } from 'clsx';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
|
||||
export function cn(...inputs: ClassValue[]): string {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import App from './App';
|
||||
import { ThemeProvider } from './components/theme-provider';
|
||||
import './styles/globals.css';
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
<ThemeProvider defaultTheme="dark" attribute="class" enableSystem>
|
||||
<App />
|
||||
</ThemeProvider>
|
||||
</React.StrictMode>
|
||||
);
|
||||
@@ -24,6 +24,14 @@
|
||||
--input: 0 0% 90%;
|
||||
--ring: 11 79% 51%;
|
||||
--radius: 0.5rem;
|
||||
--shadow-sm: 0 1px 2px rgba(13, 11, 9, 0.06);
|
||||
--shadow-md: 0 4px 12px rgba(13, 11, 9, 0.08), 0 0 0 1px rgba(13, 11, 9, 0.04);
|
||||
--shadow-lg: 0 12px 32px rgba(13, 11, 9, 0.12), 0 0 0 1px rgba(13, 11, 9, 0.06);
|
||||
--shadow-glow-brand: 0 0 24px rgba(229, 70, 31, 0.25);
|
||||
--glass-bg-light: rgba(255, 255, 255, 0.72);
|
||||
--glass-bg-dark: rgba(13, 11, 9, 0.72);
|
||||
--glass-border-light: rgba(255, 255, 255, 0.4);
|
||||
--glass-border-dark: rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
.dark {
|
||||
@@ -46,6 +54,14 @@
|
||||
--border: 30 6% 15%;
|
||||
--input: 30 6% 15%;
|
||||
--ring: 11 79% 51%;
|
||||
--shadow-sm: 0 1px 2px rgba(13, 11, 9, 0.06);
|
||||
--shadow-md: 0 4px 12px rgba(13, 11, 9, 0.08), 0 0 0 1px rgba(13, 11, 9, 0.04);
|
||||
--shadow-lg: 0 12px 32px rgba(13, 11, 9, 0.12), 0 0 0 1px rgba(13, 11, 9, 0.06);
|
||||
--shadow-glow-brand: 0 0 24px rgba(229, 70, 31, 0.25);
|
||||
--glass-bg-light: rgba(255, 255, 255, 0.72);
|
||||
--glass-bg-dark: rgba(13, 11, 9, 0.72);
|
||||
--glass-border-light: rgba(255, 255, 255, 0.4);
|
||||
--glass-border-dark: rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
* {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import '@testing-library/jest-dom/vitest';
|
||||
|
||||
// Mock window.electronAPI for tests
|
||||
declare global {
|
||||
interface Window {
|
||||
electronAPI: any;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined' && !window.electronAPI) {
|
||||
window.electronAPI = {};
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
export type IpcResult<T> =
|
||||
| { ok: true; data: T }
|
||||
| { ok: false; error: { code: string; message: string } };
|
||||
|
||||
export interface FileEntry {
|
||||
name: string;
|
||||
path: string;
|
||||
isDirectory: boolean;
|
||||
size?: number;
|
||||
modifiedAt?: string;
|
||||
}
|
||||
|
||||
export interface FileResult {
|
||||
path: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
export interface PdfOptions {
|
||||
inputPath: string;
|
||||
outputPath: string;
|
||||
format?: 'letter' | 'a4' | 'legal';
|
||||
margins?: { top: number; right: number; bottom: number; left: number };
|
||||
toc?: boolean;
|
||||
embedFonts?: boolean;
|
||||
}
|
||||
|
||||
export interface DocxOptions {
|
||||
inputPath: string;
|
||||
outputPath: string;
|
||||
template?: string;
|
||||
referenceDoc?: string;
|
||||
}
|
||||
|
||||
export interface HtmlOptions {
|
||||
inputPath: string;
|
||||
outputPath: string;
|
||||
standalone?: boolean;
|
||||
highlightStyle?: string;
|
||||
}
|
||||
|
||||
export interface ExportResult {
|
||||
outputPath: string;
|
||||
bytes: number;
|
||||
durationMs: number;
|
||||
}
|
||||
|
||||
export interface BatchItem {
|
||||
inputPath: string;
|
||||
outputPath: string;
|
||||
}
|
||||
|
||||
export interface BatchOptions {
|
||||
format: 'pdf' | 'docx' | 'html' | 'png';
|
||||
concurrency?: number;
|
||||
}
|
||||
|
||||
export interface BatchResult {
|
||||
total: number;
|
||||
succeeded: number;
|
||||
failed: number;
|
||||
results: Array<{ item: BatchItem; ok: boolean; error?: string }>;
|
||||
}
|
||||
+60
-20
@@ -1,3 +1,5 @@
|
||||
const animate = require('tailwindcss-animate')
|
||||
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
module.exports = {
|
||||
darkMode: ['class'],
|
||||
@@ -6,42 +8,80 @@ module.exports = {
|
||||
'./src/renderer/index.html',
|
||||
],
|
||||
theme: {
|
||||
container: {
|
||||
center: true,
|
||||
padding: '2rem',
|
||||
screens: { '2xl': '1400px' },
|
||||
},
|
||||
extend: {
|
||||
colors: {
|
||||
border: 'hsl(var(--border))',
|
||||
input: 'hsl(var(--input))',
|
||||
ring: 'hsl(var(--ring))',
|
||||
background: 'hsl(var(--background))',
|
||||
foreground: 'hsl(var(--foreground))',
|
||||
primary: {
|
||||
DEFAULT: 'hsl(var(--primary))',
|
||||
foreground: 'hsl(var(--primary-foreground))',
|
||||
},
|
||||
secondary: {
|
||||
DEFAULT: 'hsl(var(--secondary))',
|
||||
foreground: 'hsl(var(--secondary-foreground))',
|
||||
},
|
||||
destructive: {
|
||||
DEFAULT: 'hsl(var(--destructive))',
|
||||
foreground: 'hsl(var(--destructive-foreground))',
|
||||
},
|
||||
muted: {
|
||||
DEFAULT: 'hsl(var(--muted))',
|
||||
foreground: 'hsl(var(--muted-foreground))',
|
||||
},
|
||||
accent: {
|
||||
DEFAULT: 'hsl(var(--accent))',
|
||||
foreground: 'hsl(var(--accent-foreground))',
|
||||
},
|
||||
popover: {
|
||||
DEFAULT: 'hsl(var(--popover))',
|
||||
foreground: 'hsl(var(--popover-foreground))',
|
||||
},
|
||||
card: {
|
||||
DEFAULT: 'hsl(var(--card))',
|
||||
foreground: 'hsl(var(--card-foreground))',
|
||||
},
|
||||
brand: {
|
||||
DEFAULT: '#e5461f',
|
||||
dark: '#c93a18',
|
||||
light: '#ff6b47',
|
||||
},
|
||||
success: '#1a7a56',
|
||||
warning: '#eab308',
|
||||
danger: '#ef4444',
|
||||
info: '#0ea5e9',
|
||||
warning: 'hsl(45 93% 47%)',
|
||||
danger: 'hsl(0 84% 60%)',
|
||||
info: 'hsl(199 89% 48%)',
|
||||
warm: {
|
||||
50: '#fafbfc',
|
||||
100: '#f5f5f5',
|
||||
200: '#e3e3e3',
|
||||
300: '#d1d1d1',
|
||||
400: '#b0b0b0',
|
||||
500: '#9a9696',
|
||||
600: '#7a7878',
|
||||
700: '#5a5858',
|
||||
800: '#4e4e4e',
|
||||
900: '#464646',
|
||||
950: '#0d0b09',
|
||||
50: '#fafbfc', 100: '#f5f5f5', 200: '#e3e3e3', 300: '#d1d1d1',
|
||||
400: '#b0b0b0', 500: '#9a9696', 600: '#7a7878', 700: '#5a5858',
|
||||
800: '#4e4e4e', 900: '#464646', 950: '#0d0b09',
|
||||
},
|
||||
},
|
||||
borderRadius: {
|
||||
lg: 'var(--radius)',
|
||||
md: 'calc(var(--radius) - 2px)',
|
||||
sm: 'calc(var(--radius) - 4px)',
|
||||
},
|
||||
fontFamily: {
|
||||
sans: ['"Plus Jakarta Sans"', 'system-ui', 'sans-serif'],
|
||||
display: ['"Barlow Condensed"', 'system-ui', 'sans-serif'],
|
||||
mono: ['"JetBrains Mono"', '"Fira Code"', '"SF Mono"', 'Consolas', 'monospace'],
|
||||
},
|
||||
borderRadius: {
|
||||
lg: '0.75rem',
|
||||
md: '0.5rem',
|
||||
sm: '0.25rem',
|
||||
keyframes: {
|
||||
'accordion-down': { from: { height: '0' }, to: { height: 'var(--radix-accordion-content-height)' } },
|
||||
'accordion-up': { from: { height: 'var(--radix-accordion-content-height)' }, to: { height: '0' } },
|
||||
},
|
||||
animation: {
|
||||
'accordion-down': 'accordion-down 0.2s ease-out',
|
||||
'accordion-up': 'accordion-up 0.2s ease-out',
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [require('tailwindcss-animate')],
|
||||
};
|
||||
plugins: [animate],
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { ThemeProvider } from '@/components/theme-provider';
|
||||
import { ThemeToggle } from '@/components/theme-toggle';
|
||||
|
||||
Object.defineProperty(window, 'matchMedia', {
|
||||
writable: true,
|
||||
value: vi.fn().mockImplementation((query) => ({
|
||||
matches: false,
|
||||
media: query,
|
||||
onchange: null,
|
||||
addListener: vi.fn(),
|
||||
removeListener: vi.fn(),
|
||||
addEventListener: vi.fn(),
|
||||
removeEventListener: vi.fn(),
|
||||
dispatchEvent: vi.fn(),
|
||||
})),
|
||||
});
|
||||
|
||||
describe('ThemeToggle', () => {
|
||||
beforeEach(() => {
|
||||
localStorage.clear();
|
||||
document.documentElement.classList.remove('dark', 'light');
|
||||
});
|
||||
|
||||
it('toggles between light and dark when clicked', async () => {
|
||||
render(
|
||||
<ThemeProvider defaultTheme="light" attribute="class">
|
||||
<ThemeToggle />
|
||||
</ThemeProvider>
|
||||
);
|
||||
const btn = screen.getByRole('button');
|
||||
expect(btn).toHaveAccessibleName(/toggle theme/i);
|
||||
await userEvent.click(btn);
|
||||
expect(document.documentElement.classList.contains('dark')).toBe(true);
|
||||
await userEvent.click(btn);
|
||||
expect(document.documentElement.classList.contains('light')).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
describe('Button', () => {
|
||||
it('renders children', () => {
|
||||
render(<Button>Click me</Button>);
|
||||
expect(screen.getByRole('button', { name: /click me/i })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('calls onClick when clicked', async () => {
|
||||
let count = 0;
|
||||
render(<Button onClick={() => count++}>+</Button>);
|
||||
await userEvent.click(screen.getByRole('button'));
|
||||
expect(count).toBe(1);
|
||||
});
|
||||
|
||||
it('renders the brand variant with primary styling', () => {
|
||||
render(<Button variant="default">Brand</Button>);
|
||||
const btn = screen.getByRole('button');
|
||||
expect(btn.className).toContain('bg-primary');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
describe('cn', () => {
|
||||
it('merges class names', () => {
|
||||
expect(cn('a', 'b')).toBe('a b');
|
||||
});
|
||||
|
||||
it('deduplicates conflicting tailwind classes', () => {
|
||||
expect(cn('p-2', 'p-4')).toBe('p-4');
|
||||
});
|
||||
|
||||
it('ignores falsy values', () => {
|
||||
expect(cn('a', false, null, undefined, '', 'b')).toBe('a b');
|
||||
});
|
||||
|
||||
it('accepts conditional class objects', () => {
|
||||
expect(cn('base', { active: true, disabled: false })).toBe('base active');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||
import { ipc } from '@/lib/ipc';
|
||||
import type { FileResult } from '@/types/ipc';
|
||||
|
||||
describe('ipc wrapper', () => {
|
||||
beforeEach(() => {
|
||||
window.electronAPI = {
|
||||
file: {
|
||||
read: vi.fn().mockResolvedValue('# hello'),
|
||||
write: vi.fn().mockResolvedValue(undefined),
|
||||
list: vi.fn().mockResolvedValue([]),
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
it('file.read returns ok result on success', async () => {
|
||||
const result = await ipc.file.read('/foo.md');
|
||||
expect(result.ok).toBe(true);
|
||||
if (result.ok) {
|
||||
expect(result.data).toBe('# hello');
|
||||
}
|
||||
});
|
||||
|
||||
it('file.read returns err result when channel throws', async () => {
|
||||
window.electronAPI.file.read = vi.fn().mockRejectedValue(new Error('ENOENT'));
|
||||
const result = await ipc.file.read('/missing.md');
|
||||
expect(result.ok).toBe(false);
|
||||
if (!result.ok) {
|
||||
expect(result.error.message).toBe('ENOENT');
|
||||
}
|
||||
});
|
||||
|
||||
it('file.read returns err result when channel missing', async () => {
|
||||
delete (window.electronAPI.file as any).read;
|
||||
const result = await ipc.file.read('/foo.md');
|
||||
expect(result.ok).toBe(false);
|
||||
if (!result.ok) {
|
||||
expect(result.error.code).toBe('CHANNEL_MISSING');
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
fadeIn,
|
||||
slideInRight,
|
||||
modalPop,
|
||||
toastSpring,
|
||||
sidebarToggle,
|
||||
} from '@/lib/motion';
|
||||
|
||||
describe('motion presets', () => {
|
||||
it('fadeIn is a valid transition object', () => {
|
||||
expect(fadeIn.duration).toBeGreaterThan(0);
|
||||
expect(fadeIn.ease).toBeDefined();
|
||||
});
|
||||
|
||||
it('slideInRight uses translateX transform', () => {
|
||||
expect(slideInRight.x).toBe('100%');
|
||||
});
|
||||
|
||||
it('modalPop uses scale and opacity', () => {
|
||||
expect(modalPop.scale).toBeDefined();
|
||||
expect(modalPop.opacity).toBeDefined();
|
||||
});
|
||||
|
||||
it('toastSpring has spring physics', () => {
|
||||
expect(toastSpring.type).toBe('spring');
|
||||
});
|
||||
|
||||
it('sidebarToggle animates width', () => {
|
||||
expect(sidebarToggle.width.duration).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import path from 'path';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
test: {
|
||||
environment: 'jsdom',
|
||||
globals: true,
|
||||
setupFiles: ['./src/renderer/test/setup.ts'],
|
||||
include: ['tests/**/*.{test,spec}.{ts,tsx}'],
|
||||
coverage: {
|
||||
provider: 'v8',
|
||||
include: ['src/renderer/**/*.{ts,tsx}'],
|
||||
exclude: ['src/renderer/test/**', 'src/renderer/**/*.test.*'],
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.join(__dirname, 'src/renderer'),
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user