4 Commits
Author SHA1 Message Date
poli0981andClaude Opus 4.7 25cac76373 chore(release): v1.4.2 (#49)
Patch release for the mobile-viewport overlap reported after v1.4.1 (#47):
- Tabs UI for Input/Output on mobile (<md); side-by-side grid stays on md+
- Unread-output dot on the Output tab
- Compact FormatPicker — bottom Sheet on mobile instead of 12 chips inline
- README EN + VI disclose minimum viewport (360×640)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 12:50:13 +07:00
poli0981andClaude Opus 4.7 e91af0f676 fix(mobile): Tabs UI for Input/Output + compact FormatPicker on small viewports (#47)
After v1.4.1 user retested and reported the UI still breaks below ~400x700:
panels overlap below 600h, become nearly invisible below 500h. Root cause is
the grid-rows-2 mobile stack still gives each panel only half the available
height, and when the workspace toolbar wraps 2-3 rows (FormatPicker's 12 chips)
plus header / Home hero / Footer / StatusBar chrome, each row drops below
CodeMirror's minimum rendered content height and the two panels visually overlap.

Tabs UI on mobile (<md)
- Add shadcn Tabs primitive (@radix-ui/react-tabs, MIT)
- ConverterWorkspace renders Tabs on mobile (Input | Output, full-height active
  tab) and the side-by-side grid on md+. Both layouts render in parallel so
  CodeMirror state survives viewport resize without a remount.
- Output tab shows a 6px dot when output changes while the user is on the Input
  tab; the dot clears when they switch over. No auto-switch — user controls.

Compact FormatPicker on mobile
- Mobile: a single "Target format: CSV" button opens a bottom Sheet listing all
  12 chips in a 2-3 column grid (reuses the Sheet primitive already shipped
  with BatchPanel / SettingsPanel). Saves ~50-80px of toolbar height that
  would otherwise be eaten by the chip flex-wrap.
- Desktop: unchanged — 12 chips inline.

Minimum viewport documented
- README EN + VI now state "designed for viewports ≥ 360 × 640; smaller
  screens still work but may feel cramped".

THIRD-PARTY.md adds @radix-ui/react-tabs.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 12:48:42 +07:00
poli0981andClaude Opus 4.7 71b7ba2837 chore(release): v1.4.1 (#44)
Patch release for the mobile regressions reported on iPhone 14 Pro (#42):
- Header no longer overflows the viewport on phones (brand wordmark hidden below sm)
- Workspace panels stay visible on short and landscape phones (grid-rows-2 mobile split + h-dvh)
- THIRD-PARTY.md catches up with the CodeMirror lang packs (yaml/xml/markdown/sql/legacy-modes)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 11:55:42 +07:00
poli0981andClaude Opus 4.7 14f41c3775 fix(mobile): header overflow on small viewports + workspace panels disappearing on short/landscape phones (#42)
Three viewport regressions reported on iPhone 14 Pro (393 portrait, 852x393 landscape) and shorter phones; iPad and tablets were unaffected.

Header overflow
- iPhone 14 Pro is 393px wide; the header's brand wordmark + nav + lang switcher + theme + GitHub icon row summed to ~460px, forcing horizontal page scroll. Hide the "JSONPrism" wordmark below sm (640px) and rely on the BrandMark SVG alone on phones — saves ~90px and the row now fits.

Workspace panels collapsing
- "Output trên một số mẫu điện thoại có chiều dài ngắn không có" + "Khi xoay ngang -> Toàn bộ trường Input và output bị biến mất". Root causes:
  1. min-h-[40vh] on each stacked panel (added in 1.4.0 for usable mobile heights) summed to 80vh, which exceeded the available height after the header / Home padding / workspace toolbar / status bar / footer chrome on short phones. The workspace container's overflow-hidden then clipped the lower panel off-screen.
  2. h-screen (= 100vh) on the Layout root doesn't account for iOS Safari's dynamic toolbar — the computed height could exceed the actual visible area on rotation.
- Swap min-h-[40vh] for grid-rows-2 (mobile) / md:grid-rows-1 (desktop). Each panel now takes exactly half the workspace height share — always visible, no overflow.
- Swap h-screen for h-dvh (Tailwind v4 dynamic viewport height) so iOS Safari's actual visible area drives the layout.

THIRD-PARTY.md
- Add the five CodeMirror language packs that landed across 1.3.0 + 1.4.0 but weren't listed: lang-yaml, lang-xml, lang-markdown, lang-sql, legacy-modes. All MIT, all @codemirror/*.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 11:54:12 +07:00
17 changed files with 413 additions and 51 deletions

No files matched your search

+33
View File
@@ -8,6 +8,39 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
No unreleased changes at this time. Future work tracked in `docs/ROADMAP.md` under "Beyond Phase 3".
## [1.4.2] — 2026-05-14
### Added
- **Tabs UI for Input/Output on mobile (`<md`).** New shadcn `Tabs` primitive (`src/components/ui/tabs.tsx`, wrapping `@radix-ui/react-tabs`). The workspace now renders Tabs on mobile so each active panel takes the full available height; desktop continues to use the side-by-side grid. Both layouts render in parallel so CodeMirror state (selection, scroll, cursor) survives a viewport resize without remounting.
- **"Unread output" dot** on the Output tab. When `output` changes while the user is on the Input tab, a small primary-colored dot appears on the Output tab label; it clears the next time the user switches over. No auto-switch — the user controls the flow.
- **Compact mobile FormatPicker.** On `<md`, the 12 format chips collapse into a single `Target format: <current>` trigger that opens a bottom Sheet with all chips in a 2-3 column grid (reusing the existing Sheet primitive shipped with BatchPanel / SettingsPanel). Saves ~50–80px of toolbar height that the chip flex-wrap was eating on narrow viewports — that vertical space was the underlying cause of the previous "panels overlap" regression below 600px height.
### Fixed
- **Workspace panels still overlapping on viewports <400×700.** v1.4.1's `grid-rows-2 md:grid-rows-1` mobile split allotted each panel half the workspace height, but when the workspace top toolbar wrapped 2–3 rows (the 12 FormatPicker chips on narrow viewports) plus header / Home hero / Footer / StatusBar chrome, each row fell below CodeMirror's minimum rendered content height and the two panels visually overlapped. The Tabs swap above resolves this by giving the active panel the full workspace height instead of half.
### Changed
- **README EN + VI** now disclose: *"designed for viewports ≥ 360 × 640; smaller screens still work but may feel cramped"*. Galaxy S / Pixel-class portrait is the minimum well-supported viewport.
### Dependencies
- Added `@radix-ui/react-tabs` (MIT). Also listed in `THIRD-PARTY.md`.
## [1.4.1] — 2026-05-14
### Fixed
- **Header overflowed the viewport on iPhone 14 Pro and other ≤sm phones**. The brand wordmark + nav links + language switcher + theme toggle + GitHub icon summed to ~460px and didn't fit the 393px iPhone viewport, forcing horizontal page scroll to reach the right-edge buttons. Hide the `JSONPrism` wordmark below `sm` (640px) — the brand SVG mark alone identifies the app on phones, and the row fits cleanly.
- **Workspace input/output panels disappearing on short / landscape phones**. Two compounding causes:
- `min-h-[40vh]` on each stacked panel (introduced in 1.4.0 to make mobile heights usable) summed to 80vh, exceeding the available height after header / Home padding / workspace toolbar / status bar / footer chrome on short phones. The workspace container's `overflow-hidden` then clipped the lower (output) panel off-screen. Replaced with `grid-rows-2 md:grid-rows-1` so each panel takes exactly half the workspace height share on mobile — always visible, no overflow.
- `h-screen` (= `100vh`) on the Layout root didn't account for iOS Safari's dynamic toolbar — the computed height could exceed the actual visible area, especially after rotating to landscape. Swapped for `h-dvh` (Tailwind v4 dynamic viewport height).
### Docs
- **`THIRD-PARTY.md`** now lists the five CodeMirror language packs that landed across 1.3.0 + 1.4.0 (`@codemirror/lang-yaml`, `@codemirror/lang-xml`, `@codemirror/lang-markdown`, `@codemirror/lang-sql`, `@codemirror/legacy-modes` — all MIT). The file was lagging behind the actual install set.
## [1.4.0] — 2026-05-14
### Added — Đợt UI/UX polish: dynamic placeholders, social, reverse highlight expansion, mobile
+1
View File
@@ -42,6 +42,7 @@ JSONPrism is a refracting tool for developers. It takes a single JSON input and
- **Smart shape detection** — recognizes flat objects, arrays of objects, scalars; suggests the best target format.
- **Per-format options** — pretty-print, indentation, dialect (for SQL), alignment (for Markdown), and more.
- **Dark + light themes** — Prism Spectrum palette with violet / cyan / amber / rose accents.
- **Responsive — designed for viewports ≥ 360 × 640.** Smaller screens still work but may feel cramped; on mobile, Input and Output use a Tabs UI to give each panel full height.
- **EN + VI** — bilingual interface out of the box. More languages welcome.
- **Tauri desktop build** — drag-and-drop file workflow, offline-first (Phase 2 milestone).
+1
View File
@@ -42,6 +42,7 @@ JSONPrism là công cụ "tán sắc" cho developer. Nhận một JSON đầu v
- **Phát hiện shape thông minh** — nhận diện flat object, mảng object, scalar; gợi ý format đích phù hợp.
- **Tuỳ chọn theo từng format** — pretty-print, indentation, dialect (SQL), alignment (Markdown), v.v.
- **Theme sáng/tối** — bảng màu Prism Spectrum với violet / cyan / amber / rose.
- **Responsive — tối ưu cho viewport ≥ 360 × 640.** Màn hình nhỏ hơn vẫn dùng được nhưng có thể chật; trên mobile, Input và Output dùng Tabs UI để mỗi panel có toàn bộ chiều cao.
- **Đa ngôn ngữ EN + VI** — sẵn sàng từ ngày đầu. Hoan nghênh thêm ngôn ngữ khác.
- **Bản desktop Tauri** — drag-and-drop file, hoạt động offline (mốc Phase 2).
+6
View File
@@ -29,6 +29,7 @@ the relevant notices. This file is a starting point.
| `@radix-ui/react-dialog` | ^1.1.0 | MIT | [radix-ui.com](https://www.radix-ui.com/) |
| `@radix-ui/react-slot` | ^1.1.0 | MIT | [radix-ui.com](https://www.radix-ui.com/) |
| `@radix-ui/react-switch` | ^1.1.0 | MIT | [radix-ui.com](https://www.radix-ui.com/) |
| `@radix-ui/react-tabs` | ^1.1.0 | MIT | [radix-ui.com](https://www.radix-ui.com/) |
| `lucide-react` | ^0.460.0 | ISC | [lucide.dev](https://lucide.dev/) |
| `sonner` | ^1.7.0 | MIT | [sonner.emilkowal.ski](https://sonner.emilkowal.ski/) |
| `react-dropzone` | ^14.3.0 | MIT | [react-dropzone.js.org](https://react-dropzone.js.org/) |
@@ -46,6 +47,11 @@ installed as a runtime dependency.
| `@codemirror/view` | ^6.34.0 | MIT | [codemirror.net](https://codemirror.net/) |
| `@codemirror/language` | ^6.10.0 | MIT | [codemirror.net](https://codemirror.net/) |
| `@codemirror/lang-json` | ^6.0.0 | MIT | [codemirror.net](https://codemirror.net/) |
| `@codemirror/lang-yaml` | ^6.1.3 | MIT | [codemirror.net](https://codemirror.net/) |
| `@codemirror/lang-xml` | ^6.1.0 | MIT | [codemirror.net](https://codemirror.net/) |
| `@codemirror/lang-markdown` | ^6.5.0 | MIT | [codemirror.net](https://codemirror.net/) |
| `@codemirror/lang-sql` | ^6.10.0 | MIT | [codemirror.net](https://codemirror.net/) |
| `@codemirror/legacy-modes` | ^6.5.2 | MIT | [codemirror.net](https://codemirror.net/) |
| `@codemirror/lint` | ^6.8.0 | MIT | [codemirror.net](https://codemirror.net/) |
| `@lezer/highlight` | ^1.2.0 | MIT | [lezer.codemirror.net](https://lezer.codemirror.net/) |
+123 -2
View File
@@ -1,12 +1,12 @@
{
"name": "jsonprism",
"version": "1.4.0",
"version": "1.4.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "jsonprism",
"version": "1.4.0",
"version": "1.4.2",
"license": "Apache-2.0",
"dependencies": {
"@codemirror/lang-json": "^6.0.0",
@@ -24,6 +24,7 @@
"@radix-ui/react-dialog": "^1.1.0",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-switch": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.13",
"@tauri-apps/api": "^2.0.0",
"@tauri-apps/plugin-dialog": "^2.0.0",
"@tauri-apps/plugin-fs": "^2.0.0",
@@ -1145,6 +1146,50 @@
"integrity": "sha512-JTF99U/6XIjCBo0wqkU5sK10glYe27MRRsfwoiq5zzOEZLHU3A3KCMa5X/azekYRCJ0HlwI0crAXS/5dEHTzDg==",
"license": "MIT"
},
"node_modules/@radix-ui/react-collection": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.1.7.tgz",
"integrity": "sha512-Fh9rGN0MoI4ZFUNyfFVNU4y9LUz93u9/0K+yLgA2bwRojxM8JU1DyvvMBabnZPBgMWREAJvU2jjVzq+LrFUglw==",
"license": "MIT",
"dependencies": {
"@radix-ui/react-compose-refs": "1.1.2",
"@radix-ui/react-context": "1.1.2",
"@radix-ui/react-primitive": "2.1.3",
"@radix-ui/react-slot": "1.2.3"
},
"peerDependencies": {
"@types/react": "*",
"@types/react-dom": "*",
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-collection/node_modules/@radix-ui/react-slot": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.3.tgz",
"integrity": "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==",
"license": "MIT",
"dependencies": {
"@radix-ui/react-compose-refs": "1.1.2"
},
"peerDependencies": {
"@types/react": "*",
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-compose-refs": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@radix-ui/react-compose-refs/-/react-compose-refs-1.1.2.tgz",
@@ -1229,6 +1274,21 @@
}
}
},
"node_modules/@radix-ui/react-direction": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@radix-ui/react-direction/-/react-direction-1.1.1.tgz",
"integrity": "sha512-1UEWRX6jnOA2y4H5WczZ44gOOjTEmlqv1uNW4GAJEO5+bauCBhv8snY65Iw5/VOS/ghKN9gr2KjnLKxrsvoMVw==",
"license": "MIT",
"peerDependencies": {
"@types/react": "*",
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-dismissable-layer": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/@radix-ui/react-dismissable-layer/-/react-dismissable-layer-1.1.11.tgz",
@@ -1403,6 +1463,37 @@
}
}
},
"node_modules/@radix-ui/react-roving-focus": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/@radix-ui/react-roving-focus/-/react-roving-focus-1.1.11.tgz",
"integrity": "sha512-7A6S9jSgm/S+7MdtNDSb+IU859vQqJ/QAtcYQcfFC6W8RS4IxIZDldLR0xqCFZ6DCyrQLjLPsxtTNch5jVA4lA==",
"license": "MIT",
"dependencies": {
"@radix-ui/primitive": "1.1.3",
"@radix-ui/react-collection": "1.1.7",
"@radix-ui/react-compose-refs": "1.1.2",
"@radix-ui/react-context": "1.1.2",
"@radix-ui/react-direction": "1.1.1",
"@radix-ui/react-id": "1.1.1",
"@radix-ui/react-primitive": "2.1.3",
"@radix-ui/react-use-callback-ref": "1.1.1",
"@radix-ui/react-use-controllable-state": "1.2.2"
},
"peerDependencies": {
"@types/react": "*",
"@types/react-dom": "*",
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-slot": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.4.tgz",
@@ -1450,6 +1541,36 @@
}
}
},
"node_modules/@radix-ui/react-tabs": {
"version": "1.1.13",
"resolved": "https://registry.npmjs.org/@radix-ui/react-tabs/-/react-tabs-1.1.13.tgz",
"integrity": "sha512-7xdcatg7/U+7+Udyoj2zodtI9H/IIopqo+YOIcZOq1nJwXWBZ9p8xiu5llXlekDbZkca79a/fozEYQXIA4sW6A==",
"license": "MIT",
"dependencies": {
"@radix-ui/primitive": "1.1.3",
"@radix-ui/react-context": "1.1.2",
"@radix-ui/react-direction": "1.1.1",
"@radix-ui/react-id": "1.1.1",
"@radix-ui/react-presence": "1.1.5",
"@radix-ui/react-primitive": "2.1.3",
"@radix-ui/react-roving-focus": "1.1.11",
"@radix-ui/react-use-controllable-state": "1.2.2"
},
"peerDependencies": {
"@types/react": "*",
"@types/react-dom": "*",
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-use-callback-ref": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.1.1.tgz",
+2 -1
View File
@@ -1,7 +1,7 @@
{
"name": "jsonprism",
"private": true,
"version": "1.4.0",
"version": "1.4.2",
"type": "module",
"description": "Disperse JSON into many formats — JSONL, CSV, YAML, XML, TOML, RESX, Markdown, SQL — fully client-side.",
"author": "poli0981 <https://github.com/poli0981>",
@@ -48,6 +48,7 @@
"@radix-ui/react-dialog": "^1.1.0",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-switch": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.13",
"@tauri-apps/api": "^2.0.0",
"@tauri-apps/plugin-dialog": "^2.0.0",
"@tauri-apps/plugin-fs": "^2.0.0",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "jsonprism"
version = "1.4.0"
version = "1.4.2"
description = "Disperse JSON into many formats."
authors = ["poli0981 <https://github.com/poli0981>"]
license = "Apache-2.0"
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "JSONPrism",
"version": "1.4.0",
"version": "1.4.2",
"identifier": "com.poli0981.jsonprism",
"build": {
"beforeDevCommand": "npm run dev",
@@ -1,6 +1,7 @@
import { useCallback, useMemo, useRef, useState } from 'react';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { toast } from '@/components/ui/sonner';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { getConverter } from '@/converters/registry';
import type { FormatId } from '@/converters/types';
import { parseJsonInput } from '@/lib/detect';
@@ -36,6 +37,11 @@ export function ConverterWorkspace() {
const actionsRef = useRef<{ copy: () => void; download: () => void } | null>(null);
const [batchOpen, setBatchOpen] = useState(false);
const [settingsOpen, setSettingsOpen] = useState(false);
// Mobile tab state — desktop ignores this and renders both panels side-by-side.
const [activeTab, setActiveTab] = useState<'input' | 'output'>('input');
// Badge dot on Output tab when output changes while user is on Input tab.
const [hasUnreadOutput, setHasUnreadOutput] = useState(false);
const prevOutputRef = useRef('');
const addBatchFiles = useBatchStore((s) => s.addFiles);
const handleMultiFileDrop = useCallback(
@@ -179,6 +185,21 @@ export function ConverterWorkspace() {
{ key: ',', mod: true, handler: () => setSettingsOpen((v) => !v) },
]);
// Flip the badge dot on the Output tab whenever output changes while the
// user is on the Input tab. Clearing happens once the user navigates over.
useEffect(() => {
if (output !== prevOutputRef.current) {
prevOutputRef.current = output;
if (output && activeTab !== 'output') {
setHasUnreadOutput(true);
}
}
}, [output, activeTab]);
useEffect(() => {
if (activeTab === 'output') setHasUnreadOutput(false);
}, [activeTab]);
const inputBytes = useMemo(() => new TextEncoder().encode(input).length, [input]);
const outputBytes = useMemo(() => new TextEncoder().encode(output).length, [output]);
@@ -215,8 +236,54 @@ export function ConverterWorkspace() {
</div>
<div className="border-border bg-card/40 flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border">
<div className="grid min-h-0 flex-1 md:grid-cols-2">
<div className="md:border-border/60 min-h-[40vh] border-b md:min-h-0 md:border-r md:border-b-0">
{/* Mobile: Tabs UI — each tab gets the full workspace height so panels
never overlap on short viewports. */}
<Tabs
value={activeTab}
onValueChange={(v) => setActiveTab(v as 'input' | 'output')}
className="flex min-h-0 flex-1 flex-col md:hidden"
>
<TabsList className="border-border/60 w-full justify-start gap-0 rounded-none border-b px-2">
<TabsTrigger value="input">{t('home.tab_input')}</TabsTrigger>
<TabsTrigger value="output" className="relative">
{t('home.tab_output')}
{hasUnreadOutput && (
<span
aria-hidden
className="bg-primary absolute top-1 right-1 h-1.5 w-1.5 rounded-full"
/>
)}
</TabsTrigger>
</TabsList>
<TabsContent value="input" className="min-h-0 flex-1">
<InputPanel
value={input}
onChange={setInput}
error={inputError}
format={format}
direction={direction}
onMultiFileDrop={handleMultiFileDrop}
/>
</TabsContent>
<TabsContent value="output" className="min-h-0 flex-1">
<OutputPanel
format={format}
content={output}
error={outputError}
options={currentOptions}
direction={direction}
registerActions={(a) => {
actionsRef.current = a;
}}
/>
</TabsContent>
</Tabs>
{/* Desktop: side-by-side grid (≥ md). Rendered in parallel with the
Tabs above so neither remounts on viewport resize and CodeMirror
state survives the swap. */}
<div className="hidden min-h-0 flex-1 md:grid md:grid-cols-2">
<div className="border-border/60 min-h-0 border-r">
<InputPanel
value={input}
onChange={setInput}
@@ -226,7 +293,7 @@ export function ConverterWorkspace() {
onMultiFileDrop={handleMultiFileDrop}
/>
</div>
<div className="min-h-[40vh] md:min-h-0">
<div className="min-h-0">
<OutputPanel
format={format}
content={output}
@@ -239,6 +306,7 @@ export function ConverterWorkspace() {
/>
</div>
</div>
<StatusBar inputBytes={inputBytes} outputBytes={outputBytes} parseMs={parseMs} />
</div>
</div>
+113 -40
View File
@@ -1,4 +1,7 @@
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { ChevronDown } from 'lucide-react';
import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from '@/components/ui/sheet';
import { ALL_FORMATS, getConverter } from '@/converters/registry';
import type { FormatId } from '@/converters/types';
import type { JsonShape } from '@/lib/detect';
@@ -17,51 +20,121 @@ interface FormatPickerProps {
export function FormatPicker({ value, onChange, shape, direction = 'forward' }: FormatPickerProps) {
const { t } = useTranslation();
const [sheetOpen, setSheetOpen] = useState(false);
const current = getConverter(value);
const handlePick = (id: FormatId) => {
onChange(id);
setSheetOpen(false);
};
return (
<div className="flex flex-wrap gap-1.5">
{ALL_FORMATS.map((id) => {
const c = getConverter(id);
const active = value === id;
const suggested = direction === 'forward' && shape ? isFormatSuggested(id, shape) : false;
const noReverse = direction === 'reverse' && typeof c.reverse !== 'function';
const enabled = c.meta.ready && !noReverse;
const dimmed = direction === 'forward' && shape && !suggested && c.meta.ready;
return (
<>
{/* Mobile: compact Sheet trigger — saves ~50-80px of toolbar height when
the 12 chip grid would otherwise wrap to 2-3 rows on narrow viewports. */}
<Sheet open={sheetOpen} onOpenChange={setSheetOpen}>
<SheetTrigger asChild>
<button
key={id}
type="button"
onClick={() => onChange(id)}
disabled={!enabled}
className={cn(
'group relative inline-flex items-center gap-1.5 rounded-md border px-2 py-0.5 text-[11px] font-medium transition sm:px-2.5 sm:py-1 sm:text-xs',
active
? 'border-primary/60 bg-primary/10 text-foreground'
: 'border-border bg-card/40 text-muted-foreground hover:text-foreground hover:border-border',
!enabled && 'cursor-not-allowed opacity-50',
dimmed && !active && 'opacity-50',
suggested && !active && 'ring-primary/30 ring-offset-background ring-1 ring-offset-1',
)}
title={
!c.meta.ready
? t('format_status.planned', { phase: c.meta.phase })
: noReverse
? t('format_status.no_reverse')
: suggested
? t('format_status.suggested')
: t('format_status.ready')
}
className="border-border bg-card/40 text-muted-foreground hover:border-primary/40 hover:text-foreground inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs font-medium transition md:hidden"
aria-label={t('home.format_picker_label')}
>
<span className="font-mono">{t(c.meta.labelKey)}</span>
{!c.meta.ready && (
<span className="border-border text-muted-foreground rounded border px-1 text-[10px] tracking-wide">
P{c.meta.phase}
</span>
)}
<span className="tracking-wider uppercase opacity-70">
{t('home.format_picker_label')}
</span>
<span className="text-foreground font-mono">{t(current.meta.labelKey)}</span>
<ChevronDown className="h-3 w-3" />
</button>
);
})}
</div>
</SheetTrigger>
<SheetContent side="bottom" className="max-h-[80vh] w-full overflow-y-auto">
<SheetHeader>
<SheetTitle>{t('home.format_picker_label')}</SheetTitle>
</SheetHeader>
<div className="grid grid-cols-2 gap-1.5 p-4 pt-2 sm:grid-cols-3">
{ALL_FORMATS.map((id) => (
<FormatChip
key={id}
id={id}
value={value}
onChange={handlePick}
shape={shape}
direction={direction}
expanded
/>
))}
</div>
</SheetContent>
</Sheet>
{/* Desktop: 12 chips inline. */}
<div className="hidden flex-wrap gap-1.5 md:flex">
{ALL_FORMATS.map((id) => (
<FormatChip
key={id}
id={id}
value={value}
onChange={onChange}
shape={shape}
direction={direction}
/>
))}
</div>
</>
);
}
interface FormatChipProps {
id: FormatId;
value: FormatId;
onChange: (id: FormatId) => void;
shape: JsonShape | null | undefined;
direction: Direction;
/** Expanded layout (fills the Sheet grid cell), vs the compact inline chip. */
expanded?: boolean;
}
function FormatChip({ id, value, onChange, shape, direction, expanded }: FormatChipProps) {
const { t } = useTranslation();
const c = getConverter(id);
const active = value === id;
const suggested = direction === 'forward' && shape ? isFormatSuggested(id, shape) : false;
const noReverse = direction === 'reverse' && typeof c.reverse !== 'function';
const enabled = c.meta.ready && !noReverse;
const dimmed = direction === 'forward' && shape && !suggested && c.meta.ready;
return (
<button
type="button"
onClick={() => onChange(id)}
disabled={!enabled}
className={cn(
'group relative inline-flex items-center gap-1.5 rounded-md border font-medium transition',
expanded
? 'justify-between px-3 py-2 text-sm'
: 'px-2 py-0.5 text-[11px] sm:px-2.5 sm:py-1 sm:text-xs',
active
? 'border-primary/60 bg-primary/10 text-foreground'
: 'border-border bg-card/40 text-muted-foreground hover:text-foreground hover:border-border',
!enabled && 'cursor-not-allowed opacity-50',
dimmed && !active && 'opacity-50',
suggested && !active && 'ring-primary/30 ring-offset-background ring-1 ring-offset-1',
)}
title={
!c.meta.ready
? t('format_status.planned', { phase: c.meta.phase })
: noReverse
? t('format_status.no_reverse')
: suggested
? t('format_status.suggested')
: t('format_status.ready')
}
>
<span className="font-mono">{t(c.meta.labelKey)}</span>
{!c.meta.ready && (
<span className="border-border text-muted-foreground rounded border px-1 text-[10px] tracking-wide">
P{c.meta.phase}
</span>
)}
</button>
);
}
+1 -1
View File
@@ -13,7 +13,7 @@ export function Header() {
<div className="mx-auto flex h-14 max-w-screen-2xl items-center gap-2 px-3 sm:gap-6 sm:px-6">
<Link to="/" className="group flex items-center gap-2 sm:gap-2.5">
<BrandMark className="h-6 w-6 sm:h-7 sm:w-7" />
<span className="font-display text-base leading-none tracking-tight sm:text-xl">
<span className="font-display hidden text-xl leading-none tracking-tight sm:inline">
JSON<span className="text-spectrum italic">Prism</span>
</span>
</Link>
+1 -1
View File
@@ -4,7 +4,7 @@ import { Footer } from './Footer';
export function Layout() {
return (
<div className="flex h-screen flex-col">
<div className="flex h-dvh flex-col">
<Header />
<main className="flex min-h-0 flex-1 flex-col">
<Outlet />
+50
View File
@@ -0,0 +1,50 @@
import * as React from 'react';
import * as TabsPrimitive from '@radix-ui/react-tabs';
import { cn } from '@/lib/utils';
const Tabs = TabsPrimitive.Root;
const TabsList = React.forwardRef<
React.ElementRef<typeof TabsPrimitive.List>,
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
>(({ className, ...props }, ref) => (
<TabsPrimitive.List
ref={ref}
className={cn(
'text-muted-foreground inline-flex items-center justify-center gap-1',
className,
)}
{...props}
/>
));
TabsList.displayName = TabsPrimitive.List.displayName;
const TabsTrigger = React.forwardRef<
React.ElementRef<typeof TabsPrimitive.Trigger>,
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
>(({ className, ...props }, ref) => (
<TabsPrimitive.Trigger
ref={ref}
className={cn(
'text-muted-foreground hover:text-foreground data-[state=active]:text-foreground data-[state=active]:border-primary inline-flex items-center justify-center gap-1.5 border-b-2 border-transparent px-3 py-1.5 text-xs font-medium tracking-wider uppercase transition focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50',
className,
)}
{...props}
/>
));
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
const TabsContent = React.forwardRef<
React.ElementRef<typeof TabsPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
>(({ className, ...props }, ref) => (
<TabsPrimitive.Content
ref={ref}
className={cn('focus-visible:outline-none', className)}
{...props}
/>
));
TabsContent.displayName = TabsPrimitive.Content.displayName;
export { Tabs, TabsList, TabsTrigger, TabsContent };
+2
View File
@@ -14,6 +14,8 @@
"input_label_format": "Input {{format}}",
"input_placeholder": "Paste your JSON here, drop files, or load a sample…",
"input_placeholder_format": "Paste your {{ext}} here, drop files, or load a sample…",
"tab_input": "Input",
"tab_output": "Output",
"output_label": "Output",
"output_empty": "Output will appear here once you provide valid JSON.",
"output_empty_format": "Output will appear here once you provide valid {{ext}}.",
+2
View File
@@ -14,6 +14,8 @@
"input_label_format": "{{format}} 入力",
"input_placeholder": "ここに JSON を貼り付け、ファイルをドロップ、またはサンプルを読み込み…",
"input_placeholder_format": "ここに {{ext}} を貼り付け、ファイルをドロップ、またはサンプルを読み込み…",
"tab_input": "入力",
"tab_output": "出力",
"output_label": "出力",
"output_empty": "有効な JSON を入力すると、ここに出力が表示されます。",
"output_empty_format": "有効な {{ext}} を入力すると、ここに出力が表示されます。",
+2
View File
@@ -14,6 +14,8 @@
"input_label_format": "Đầu vào {{format}}",
"input_placeholder": "Dán JSON vào đây, thả file, hoặc nạp mẫu…",
"input_placeholder_format": "Dán {{ext}} vào đây, thả file, hoặc nạp mẫu…",
"tab_input": "Đầu vào",
"tab_output": "Kết quả",
"output_label": "Kết quả",
"output_empty": "Kết quả sẽ hiện ở đây khi bạn cung cấp JSON hợp lệ.",
"output_empty_format": "Kết quả sẽ hiện ở đây khi bạn cung cấp {{ext}} hợp lệ.",
+2
View File
@@ -14,6 +14,8 @@
"input_label_format": "{{format}} 输入",
"input_placeholder": "在此处粘贴 JSON、拖入文件或加载示例…",
"input_placeholder_format": "在此处粘贴 {{ext}}、拖入文件或加载示例…",
"tab_input": "输入",
"tab_output": "输出",
"output_label": "输出",
"output_empty": "提供有效的 JSON 后,输出将显示在此处。",
"output_empty_format": "提供有效的 {{ext}} 后,输出将显示在此处。",