Use Tailwind for transformer workbench

This commit is contained in:
Ritesh Kumar committed 2026-09-29 02:15:52 +05:30
1 parent de5b62b827
commit 420b6ef2bb
8 files changed
+449 -705

No files matched your search

+56 -28
View File
@@ -12,7 +12,10 @@ import "@styles/main.css";
function Icon({ name }: { name: string }) {
return (
<span className="material-symbols-outlined" aria-hidden="true">
<span
className="material-symbols-outlined text-[18px] leading-none"
aria-hidden="true"
>
{name}
</span>
);
@@ -70,11 +73,15 @@ export default function AppShell() {
}, [paletteOpen]);
return (
<div className="app-shell">
<header className="app-header">
<div className="header-start">
<div className="relative flex h-dvh flex-col overflow-hidden bg-[#f6f9fc] font-sans text-[#0a2540] antialiased">
<div
aria-hidden="true"
className="pointer-events-none absolute -top-40 left-1/2 h-[340px] w-[1000px] -translate-x-1/2 bg-gradient-to-r from-[#635bff]/[.07] via-[#00daf3]/[.05] to-[#635bff]/[.05] blur-[100px]"
/>
<header className="relative z-20 flex h-11 shrink-0 items-center justify-between border-b border-slate-200 bg-white/90 px-4 backdrop-blur-md max-[600px]:px-2">
<div className="flex min-w-0 items-center gap-3.5 max-[600px]:gap-2">
<button
className="icon-button sidebar-toggle"
className="flex size-7 items-center justify-center rounded-md text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700"
type="button"
onClick={() => setSidebarOpen(open => !open)}
aria-label="Toggle sidebar"
@@ -82,61 +89,74 @@ export default function AppShell() {
>
<Icon name="dock_to_left" />
</button>
<Link to="/" className="brand">
transform <span>tools</span>
<Link
to="/"
className="whitespace-nowrap text-sm font-semibold tracking-tight text-slate-800 no-underline"
>
transform <span className="font-normal text-[#635bff]">tools</span>
</Link>
<span className="header-divider">/</span>
<span className="font-mono text-slate-300 max-[600px]:hidden">/</span>
<button
className="route-switcher"
className="flex h-[25px] items-center gap-[7px] whitespace-nowrap rounded-md border border-slate-200 bg-slate-100 px-2 font-mono text-[11px] text-slate-500 hover:bg-slate-200"
type="button"
onClick={() => setPaletteOpen(true)}
aria-label="Switch transformer"
>
<strong>{active?.category || "SVG"}</strong>
<strong className="font-semibold text-slate-700">
{active?.category || "SVG"}
</strong>
<span>→</span>
<strong className="route-target">
<strong className="font-semibold text-[#635bff]">
{active?.label?.replace(/^to /, "") || "JSX"}
</strong>
<Icon name="expand_more" />
<kbd>⌘K</kbd>
<kbd className="rounded border border-slate-200 bg-white px-1 py-0.5 font-mono text-[10px] text-slate-400 max-[600px]:hidden">
⌘K
</kbd>
</button>
</div>
<div className="header-actions">
<div className="flex items-center gap-2">
<a
className="icon-button"
className="flex size-7 items-center justify-center rounded-md text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700"
href="https://github.com/ritz078/transform"
target="_blank"
rel="noreferrer"
aria-label="GitHub"
title="GitHub"
>
<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
<svg
className="size-[15px]"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden="true"
>
<path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z" />
</svg>
</a>
</div>
</header>
<div className="app-workspace">
<div className="relative z-10 flex min-h-0 min-w-0 flex-1">
{sidebarOpen && <Navigator />}
<main className="workspace-main" key={pathname}>
<main className="flex min-h-0 min-w-0 flex-1 bg-white" key={pathname}>
<Outlet />
</main>
</div>
{paletteOpen && (
<div
className="palette-backdrop"
className="fixed inset-0 z-50 flex items-start justify-center bg-slate-900/30 px-4 pt-24 max-[600px]:pt-15"
onMouseDown={() => setPaletteOpen(false)}
>
<div
className="command-palette"
className="w-full max-w-xl overflow-hidden rounded-xl border border-slate-200 bg-white shadow-2xl"
role="dialog"
aria-modal="true"
aria-label="Switch transformer"
onMouseDown={event => event.stopPropagation()}
>
<div className="palette-search">
<div className="flex h-[50px] items-center gap-3 border-b border-slate-200 bg-[#fafbfc] px-4">
<Icon name="search" />
<input
className="min-w-0 flex-1 border-0 bg-transparent text-[13px] text-[#0a2540] outline-none placeholder:text-slate-400"
ref={searchRef}
value={query}
onChange={event => setQuery(event.target.value)}
@@ -149,18 +169,22 @@ export default function AppShell() {
placeholder="Search converters (e.g. svg to jsx, json to typescript)..."
aria-label="Search converters"
/>
<kbd>ESC</kbd>
<kbd className="rounded border border-slate-200 bg-slate-100 px-1.5 py-0.5 font-mono text-[10px] text-slate-500">
ESC
</kbd>
</div>
<div className="palette-results">
<div className="palette-heading">
<div className="max-h-80 overflow-y-auto p-2">
<div className="px-3 py-2 font-mono text-[10px] uppercase tracking-wider text-slate-400">
{query ? "Results" : "Featured transformers"}
</div>
{matches.slice(0, 12).map(route => (
<button
type="button"
key={route.path}
className={`palette-result ${
pathname === route.path ? "active" : ""
className={`flex w-full items-center gap-2.5 rounded-lg border px-3 py-2 text-left text-xs transition-colors hover:bg-slate-50 ${
pathname === route.path
? "border-[#d8dcee] bg-[#eff2ff] text-[#635bff]"
: "border-transparent bg-white text-[#425466]"
}`}
onClick={() => {
navigate({ to: route.path });
@@ -169,14 +193,18 @@ export default function AppShell() {
>
<Icon name="polyline" />
<span>{route.searchTerm}</span>
<small>{route.category}</small>
<small className="ml-auto font-mono text-[10px] text-slate-400">
{route.category}
</small>
</button>
))}
{matches.length === 0 && (
<p className="palette-empty">No matching converters</p>
<p className="p-3 text-xs text-slate-500">
No matching converters
</p>
)}
</div>
<div className="palette-footer">
<div className="flex justify-between border-t border-slate-200 bg-[#fafbfc] px-4 py-2.5 font-mono text-[10px] text-slate-500">
<span>
Press <kbd>↵</kbd> to open the first result
</span>
+8 -27
View File
@@ -118,22 +118,8 @@ const ConversionPanel: React.FunctionComponent<ConversionPanelProps> = function(
return (
<>
<Pane
className="conversion-workspace"
display="flex"
flexDirection="row"
overflow="hidden"
flex={1}
height={"100%"}
>
<Pane
className="conversion-input-column"
display="flex"
flex={1}
borderRight
flexDirection="column"
overflow="hidden"
>
<div className="flex h-full min-h-0 min-w-0 flex-1 overflow-hidden max-[800px]:flex-col">
<div className="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden border-r border-slate-200 max-[800px]:border-r-0 max-[800px]:border-b">
<EditorPanel
language={getEditorLanguage(editorLanguage)}
onChange={setValue}
@@ -148,7 +134,7 @@ const ConversionPanel: React.FunctionComponent<ConversionPanelProps> = function(
/>
{splitTitle && (
<Pane display="flex" flex={1} borderTop>
<div className="flex min-h-0 flex-1 border-t border-slate-200">
<EditorPanel
title={splitTitle}
defaultValue={splitValue}
@@ -160,15 +146,10 @@ const ConversionPanel: React.FunctionComponent<ConversionPanelProps> = function(
hasClear
{...splitEditorProps}
/>
</Pane>
</div>
)}
</Pane>
<Pane
className="conversion-output-column"
display="flex"
flex={1}
position="relative"
>
</div>
<div className="relative flex min-h-0 min-w-0 flex-1">
{showUpdateSpinner && (
<Pane
display="inline-flex"
@@ -203,8 +184,8 @@ const ConversionPanel: React.FunctionComponent<ConversionPanelProps> = function(
packageDetails={packageDetails}
{...resultEditorProps}
/>
</Pane>
</Pane>
</div>
</div>
{message && (
<Alert
+86 -73
View File
@@ -3,14 +3,12 @@ import {
FilePicker,
Heading,
HTMLInputEvent,
IconButton,
Pane,
Popover,
TextInput,
toaster,
Tooltip
toaster
} from "evergreen-ui";
import React, { useCallback, useEffect, useRef, useState } from "react";
import React, { useCallback, useEffect, useState } from "react";
import { lazy, Suspense } from "react";
import copy from "clipboard-copy";
import { useDropzone } from "react-dropzone";
@@ -41,6 +39,8 @@ export interface EditorPanelProps {
}
const Monaco = lazy(() => import("./Monaco"));
const toolbarIconClass =
"inline-flex size-7 shrink-0 items-center justify-center rounded-md text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-700";
export default function EditorPanel({
editable = true,
@@ -86,14 +86,19 @@ export default function EditorPanel({
const getSettings = useCallback(
() => (
<>
<Button
marginRight={10}
iconBefore="cog"
<button
type="button"
className="inline-flex h-7 items-center gap-1 rounded-md px-2 font-mono text-[11px] text-slate-500 hover:bg-slate-100 hover:text-slate-700"
onClick={_toggleSettingsDialog}
height={28}
>
<span
className="material-symbols-outlined text-sm"
aria-hidden="true"
>
tune
</span>
Settings
</Button>
</button>
{settingElement?.({
toggle: _toggleSettingsDialog,
@@ -172,33 +177,21 @@ export default function EditorPanel({
}, [defaultValue]);
return (
<Pane
className={`editor-panel ${editable ? "input-panel" : "output-panel"}`}
display="flex"
flex={1}
flexDirection="column"
overflow="hidden"
>
<Pane
className="editor-header"
display="flex"
height={40}
paddingX={10}
alignItems={"center"}
borderBottom
zIndex={2}
backgroundColor="#FFFFFF"
flexShrink={0}
>
<Pane flex={1} className="editor-heading">
<span className="editor-heading-label">
<div className="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-white">
<div className="z-10 flex h-10 shrink-0 items-center border-b border-slate-200 bg-[#fafbfc] px-3">
<div className="flex min-w-0 flex-1 items-center gap-2">
<span className="font-mono text-[11px] font-semibold uppercase tracking-wider text-slate-400">
{editable ? "Input" : "Output"}
</span>
<span className="editor-heading-slash">/</span>
<Heading size={500} marginTop={0}>
<span className="font-mono text-xs text-slate-300">/</span>
<span
className={`truncate font-mono text-[11px] font-medium ${
editable ? "text-slate-600" : "text-[#635bff]"
}`}
>
{title}
</Heading>
</Pane>
</span>
</div>
{settingElement && getSettings()}
@@ -248,59 +241,78 @@ export default function EditorPanel({
)}
shouldCloseOnExternalClick
>
<Tooltip content="Load File">
<IconButton height={28} marginRight={10} icon="upload" />
</Tooltip>
<button
type="button"
className={toolbarIconClass}
title="Load file or URL"
aria-label="Load file or URL"
>
<span
className="material-symbols-outlined text-sm"
aria-hidden="true"
>
upload
</span>
</button>
</Popover>
)}
{hasClear && (
<Tooltip content="Clear">
<IconButton
height={28}
icon="trash"
intent="danger"
marginRight={10}
onClick={() => {
setValue("");
onChange?.("");
}}
/>
</Tooltip>
<button
type="button"
className={toolbarIconClass}
title="Clear input"
aria-label="Clear input"
onClick={() => {
setValue("");
onChange?.("");
}}
>
<span
className="material-symbols-outlined text-sm"
aria-hidden="true"
>
delete
</span>
</button>
)}
{!editable && (
<Tooltip content="Download output">
<IconButton
className="editor-download-button"
height={28}
icon="download"
onClick={downloadValue}
/>
</Tooltip>
<button
type="button"
className={toolbarIconClass}
title="Download output"
aria-label="Download output"
onClick={downloadValue}
>
<span
className="material-symbols-outlined text-sm"
aria-hidden="true"
>
download
</span>
</button>
)}
{hasCopy && (
<Button
className="editor-copy-button"
appearance="primary"
marginRight={10}
iconBefore={copied ? "tick" : "duplicate"}
<button
type="button"
className="inline-flex h-6 items-center gap-1.5 rounded-full bg-slate-900 px-2.5 font-mono text-[11px] font-medium text-white hover:bg-slate-800"
onClick={copyValue}
height={28}
>
<span
className="material-symbols-outlined text-[13px]"
aria-hidden="true"
>
{copied ? "check" : "content_copy"}
</span>
{copied ? "Copied!" : "Copy"}
</Button>
</button>
)}
</Pane>
</div>
<div
style={{
display: "flex",
flexDirection: "column",
flex: 1,
overflow: "hidden"
}}
className="flex min-h-0 flex-1 flex-col overflow-hidden"
{...getRootProps()}
>
{topNotifications &&
@@ -321,7 +333,7 @@ export default function EditorPanel({
/>
</Suspense>
</div>
<div className="editor-footer">
<div className="flex h-8 shrink-0 items-center justify-between border-t border-slate-200 bg-[#fafbfc] px-3 font-mono text-[10px] text-slate-500">
<span>
{editable
? `Source • ${new Blob([value]).size} B`
@@ -331,6 +343,7 @@ export default function EditorPanel({
{" "}
·{" "}
<a
className="text-[#635bff] no-underline hover:underline"
href={_packageDetails.url}
target="_blank"
rel="noreferrer"
@@ -341,7 +354,7 @@ export default function EditorPanel({
</>
)}
</span>
<span>
<span className={editable ? "text-emerald-500" : "text-slate-400"}>
{editable
? value
? "Ready to transform"
@@ -349,6 +362,6 @@ export default function EditorPanel({
: "Generated output"}
</span>
</div>
</Pane>
</div>
);
}
+26 -11
View File
@@ -6,19 +6,26 @@ export default function Navigator() {
const pathname = useRouterState({ select: state => state.location.pathname });
const [filter, setFilter] = useState("");
return (
<aside className="workbench-sidebar" aria-label="Transformers">
<div className="sidebar-search">
<span className="material-symbols-outlined" aria-hidden="true">
<aside
className="flex w-60 shrink-0 flex-col border-r border-slate-200 bg-[#fafbfc] max-[800px]:w-[190px] max-[600px]:absolute max-[600px]:inset-y-0 max-[600px]:left-0 max-[600px]:z-20 max-[600px]:w-60 max-[600px]:shadow-xl"
aria-label="Transformers"
>
<div className="relative border-b border-slate-200 p-2.5">
<span
className="material-symbols-outlined pointer-events-none absolute top-[17px] left-[18px] text-base text-slate-400"
aria-hidden="true"
>
search
</span>
<input
className="h-[29px] w-full rounded-md border border-slate-200 bg-white pr-2 pl-7 text-[11px] text-slate-700 outline-none placeholder:text-slate-400 focus:border-[#635bff]"
value={filter}
onChange={event => setFilter(event.target.value)}
placeholder="Filter transformers..."
aria-label="Filter transformers"
/>
</div>
<nav className="sidebar-list">
<nav className="min-h-0 flex-1 overflow-y-auto p-2">
{categorizedRoutes.map(group => {
const items = group.content.filter(item =>
`${group.category} ${item.label}`
@@ -27,22 +34,30 @@ export default function Navigator() {
);
if (!items.length) return null;
return (
<div className="sidebar-group" key={group.category}>
<div className="sidebar-group-title">
<div className="mb-3" key={group.category}>
<div className="flex items-center justify-between px-2 py-1 font-mono text-[10px] font-semibold uppercase tracking-wider text-slate-400">
<span>{group.category}</span>
<span>{items.length}</span>
</div>
<div className="sidebar-group-items">
<div className="grid gap-0.5">
{items.map(item => (
<Link
key={item.path}
to={item.path}
preload={false}
className={`sidebar-link ${
pathname === item.path ? "active" : ""
className={`flex min-h-7 items-center overflow-hidden rounded-md border px-2 py-1 text-[11px] whitespace-nowrap no-underline ${
pathname === item.path
? "border-[#d8dcee] bg-[#eff2ff] font-semibold text-[#635bff]"
: "border-transparent text-slate-600 hover:bg-slate-100 hover:text-slate-800"
}`}
>
<span className="sidebar-link-dot" />
<span
className={`mr-[7px] size-1.5 shrink-0 rounded-full ${
pathname === item.path
? "bg-[#635bff]"
: "bg-transparent"
}`}
/>
{group.category === "Others"
? item.label
: `${group.category} ${item.label}`}
@@ -53,7 +68,7 @@ export default function Navigator() {
);
})}
</nav>
<div className="sidebar-footer">
<div className="flex justify-between border-t border-slate-200 bg-[#f6f9fc] px-3 py-2 font-mono text-[10px] text-slate-400">
<span>{routes.length} Converters</span>
<span>v2.0.2</span>
</div>