release: prepare Shift 0.1.15

Unify the front-end component library under src/ui and drop the duplicate
OCR core copies at the root of public/tesseract.
main
mula.liu 2026-11-30 16:24:26 +08:00
parent 968fe15291
commit 5cffbcafd9
28 changed files with 2834 additions and 2672 deletions

View File

@ -10,6 +10,17 @@ repository, not in the source tree. See [`docs/INSTALL.md`](docs/INSTALL.md)
for installation and [`docs/RELEASE.md`](docs/RELEASE.md) for the channel for installation and [`docs/RELEASE.md`](docs/RELEASE.md) for the channel
itself. itself.
## 0.1.15 — 2026-11-30
### Changed
- Unified the front-end component library: the main window, editor, annotation
toolbar, capture overlay, sharing panels, settings and update screens now use
one set of buttons, inputs, tabs, switches, banners, badges and progress
controls from `src/ui`.
- Removed the duplicate OCR core copies at the root of `public/tesseract`; the
worker already loads everything from `/tesseract/core/`.
## 0.1.14 — 2026-11-20 ## 0.1.14 — 2026-11-20
### Fixed ### Fixed

View File

@ -296,7 +296,7 @@ Each is overridable in Settings. File actions offer a *collect everything in one
Installing for the first time? [`docs/INSTALL.md`](docs/INSTALL.md) covers both platforms, first-run permissions and troubleshooting. Installing for the first time? [`docs/INSTALL.md`](docs/INSTALL.md) covers both platforms, first-run permissions and troubleshooting.
A new macOS machine installs **`Shift-0.1.14-macOS-universal.dmg`**: builds are ad-hoc signed and not notarized, so Gatekeeper calls Shift an unidentified developer. Double-click the image, drag `Shift.app` to /Applications, then allow the first launch once (right-click → Open, or Allow in System Settings → Privacy & Security). In-app updates download the same image without a browser, so they never prompt. Details in `docs/RELEASE.md`. A new macOS machine installs **`Shift-0.1.15-macOS-universal.dmg`**: builds are ad-hoc signed and not notarized, so Gatekeeper calls Shift an unidentified developer. Double-click the image, drag `Shift.app` to /Applications, then allow the first launch once (right-click → Open, or Allow in System Settings → Privacy & Security). In-app updates download the same image without a browser, so they never prompt. Details in `docs/RELEASE.md`.
The update channel is the upstream repository: a `releases` branch holding the installers plus `shift-update.json`, which names each artifact, its size and its SHA256. The feed URL is derived from the git remote at build time - Gitea, GitHub and GitLab forms are known, and `SHIFT_UPDATE_URL` overrides it - so no update service has to be deployed anywhere. The update channel is the upstream repository: a `releases` branch holding the installers plus `shift-update.json`, which names each artifact, its size and its SHA256. The feed URL is derived from the git remote at build time - Gitea, GitHub and GitLab forms are known, and `SHIFT_UPDATE_URL` overrides it - so no update service has to be deployed anywhere.
@ -381,7 +381,7 @@ pnpm mac:release
scripts/build-windows-release.sh scripts/build-windows-release.sh
``` ```
The release pipeline deliberately emits exactly two installers: `Shift-0.1.14-macOS-universal.dmg` and `Shift-Setup-0.1.14-win-x64.exe`. The macOS app is one universal Mach-O including universal drag, PDF-render and doc-render sidecars. Windows ARM64 uses the x64 installer through the update manifest's compatibility fallback. Full details are in `docs/BUILD_WINDOWS.md` and `docs/RELEASE.md`. The release pipeline deliberately emits exactly two installers: `Shift-0.1.15-macOS-universal.dmg` and `Shift-Setup-0.1.15-win-x64.exe`. The macOS app is one universal Mach-O including universal drag, PDF-render and doc-render sidecars. Windows ARM64 uses the x64 installer through the update manifest's compatibility fallback. Full details are in `docs/BUILD_WINDOWS.md` and `docs/RELEASE.md`.
**Permissions (macOS).** Screen Recording for capture, Files & Folders for the output folders you choose, Microphone when recording with audio, and Local Network for **Send to a device**. Shift checks Screen Recording before opening the overlay, so a denial surfaces an actionable error rather than a black screenshot. A denied Local Network grant is quieter: Shift still sends its beacons and still answers anyone who addresses it directly, but it receives no group traffic, so the device list simply stays empty. Ad-hoc signed builds get a new code identity on every rebuild and macOS keys these grants to that identity, so an upgrade can ask again; distribution with Developer ID keeps them stable. **Permissions (macOS).** Screen Recording for capture, Files & Folders for the output folders you choose, Microphone when recording with audio, and Local Network for **Send to a device**. Shift checks Screen Recording before opening the overlay, so a denial surfaces an actionable error rather than a black screenshot. A denied Local Network grant is quieter: Shift still sends its beacons and still answers anyone who addresses it directly, but it receives no group traffic, so the device list simply stays empty. Ad-hoc signed builds get a new code identity on every rebuild and macOS keys these grants to that identity, so an upgrade can ask again; distribution with Developer ID keeps them stable.

View File

@ -298,7 +298,7 @@ Shift 会持续维护局域网内其他 Shift 实例的列表,并据此提供
第一次安装?macOS 与 Windows 的安装步骤、首次运行授权与故障排查见 [`docs/INSTALL.md`](docs/INSTALL.md)。 第一次安装?macOS 与 Windows 的安装步骤、首次运行授权与故障排查见 [`docs/INSTALL.md`](docs/INSTALL.md)。
新的 macOS 机器请安装 **`Shift-0.1.14-macOS-universal.dmg`**:本项目的构建采用 ad-hoc 签名且未做公证,Gatekeeper 会把 Shift 判为身份不明的开发者。双击挂载镜像,把 `Shift.app` 拖进「应用程序」,然后允许首次启动一次(右键 → 打开,或在「系统设置 → 隐私与安全性」中点「允许」)。软件内升级自己下载的是同一个镜像、不经浏览器,因此不会弹窗。详见 `docs/RELEASE.md`。 新的 macOS 机器请安装 **`Shift-0.1.15-macOS-universal.dmg`**:本项目的构建采用 ad-hoc 签名且未做公证,Gatekeeper 会把 Shift 判为身份不明的开发者。双击挂载镜像,把 `Shift.app` 拖进「应用程序」,然后允许首次启动一次(右键 → 打开,或在「系统设置 → 隐私与安全性」中点「允许」)。软件内升级自己下载的是同一个镜像、不经浏览器,因此不会弹窗。详见 `docs/RELEASE.md`。
更新通道就是上游仓库:一条 `releases` 分支保存安装包以及 `shift-update.json` 清单,清单写明每个安装包的名称、体积与 SHA256。更新源地址在构建时由 git 远端推导——已适配 Gitea、GitHub、GitLab 三种形式,也可用 `SHIFT_UPDATE_URL` 覆盖——因此无需额外部署任何更新服务。 更新通道就是上游仓库:一条 `releases` 分支保存安装包以及 `shift-update.json` 清单,清单写明每个安装包的名称、体积与 SHA256。更新源地址在构建时由 git 远端推导——已适配 Gitea、GitHub、GitLab 三种形式,也可用 `SHIFT_UPDATE_URL` 覆盖——因此无需额外部署任何更新服务。
@ -372,7 +372,7 @@ pnpm mac:release
scripts/build-windows-release.sh scripts/build-windows-release.sh
``` ```
发布链只产出两个安装包:`Shift-0.1.14-macOS-universal.dmg` 与 `Shift-Setup-0.1.14-win-x64.exe`。macOS 是单个通用 Mach-O,内含通用版的拖拽、PDF 渲染与文档渲染伴生进程;Windows ARM64 通过更新清单的兼容回退使用 x64 安装包。完整步骤见 `docs/BUILD_WINDOWS.md` 与 `docs/RELEASE.md`。 发布链只产出两个安装包:`Shift-0.1.15-macOS-universal.dmg` 与 `Shift-Setup-0.1.15-win-x64.exe`。macOS 是单个通用 Mach-O,内含通用版的拖拽、PDF 渲染与文档渲染伴生进程;Windows ARM64 通过更新清单的兼容回退使用 x64 安装包。完整步骤见 `docs/BUILD_WINDOWS.md` 与 `docs/RELEASE.md`。
**权限(macOS)。** 截图与录屏需要「屏幕录制」,输出目录需要「文件与文件夹」授权,带声音录屏需要「麦克风」,「发送到设备」需要「本地网络」。Shift 会在打开截图遮罩前先检查屏幕录制权限,因此被拒绝时给出的是可操作的提示,而不是一张全黑的截图。「本地网络」被拒绝时比较安静:Shift 仍会发出广播、也能回应主动找它的实例,但收不到组播,设备列表于是始终为空。ad-hoc 签名每次重新构建都会得到新的代码身份,而 macOS 正是按这个身份记录上述授权,所以升级后可能重新询问;改用 Developer ID 签名即可保持稳定。 **权限(macOS)。** 截图与录屏需要「屏幕录制」,输出目录需要「文件与文件夹」授权,带声音录屏需要「麦克风」,「发送到设备」需要「本地网络」。Shift 会在打开截图遮罩前先检查屏幕录制权限,因此被拒绝时给出的是可操作的提示,而不是一张全黑的截图。「本地网络」被拒绝时比较安静:Shift 仍会发出广播、也能回应主动找它的实例,但收不到组播,设备列表于是始终为空。ad-hoc 签名每次重新构建都会得到新的代码身份,而 macOS 正是按这个身份记录上述授权,所以升级后可能重新询问;改用 Developer ID 签名即可保持稳定。

View File

@ -1,4 +1,4 @@
Shift 0.1.14 - macOS 通用(universal) Shift 0.1.15 - macOS 通用(universal)
本文件说明 macOS 安装包是怎么打出来的、在其它机器上会遇到什么,以及如何自己校验。 本文件说明 macOS 安装包是怎么打出来的、在其它机器上会遇到什么,以及如何自己校验。
完整细节见仓库 docs/RELEASE.md 的「macOS packaging」和 docs/ENGINEERING-NOTES.md 完整细节见仓库 docs/RELEASE.md 的「macOS packaging」和 docs/ENGINEERING-NOTES.md
@ -8,7 +8,7 @@ Shift 0.1.14 - macOS 通用(universal)
关于这个安装包 关于这个安装包
-------------- --------------
Shift 的 macOS 产物只有一个:Shift-0.1.14-macOS-universal.dmg,通用二进制,Apple silicon 与 Shift 的 macOS 产物只有一个:Shift-0.1.15-macOS-universal.dmg,通用二进制,Apple silicon 与
Intel 都能用。它既是新机器的首次安装方式,也是软件内升级的载体(更新清单里的 macos Intel 都能用。它既是新机器的首次安装方式,也是软件内升级的载体(更新清单里的 macos
键指向它)。清单的键必须是 .dmg,因为软件内升级的交接脚本要用 hdiutil 挂载镜像再 键指向它)。清单的键必须是 .dmg,因为软件内升级的交接脚本要用 hdiutil 挂载镜像再
取出应用包;早期曾随包发布的 .pkg 在验证过 DMG 可用后就撤掉了,不为它多维护一份 取出应用包;早期曾随包发布的 .pkg 在验证过 DMG 可用后就撤掉了,不为它多维护一份
@ -23,7 +23,7 @@ Intel 都能用。它既是新机器的首次安装方式,也是软件内升
---------------- ----------------
新机器首次安装 新机器首次安装
1. 下载并双击 Shift-0.1.14-macOS-universal.dmg 挂载镜像。 1. 下载并双击 Shift-0.1.15-macOS-universal.dmg 挂载镜像。
2. 把 Shift.app 拖进「应用程序」(或任何你有权限的位置)。 2. 把 Shift.app 拖进「应用程序」(或任何你有权限的位置)。
3. 首次启动会被拦:「无法打开,因为来自身份不明的开发者」。点取消,然后 3. 首次启动会被拦:「无法打开,因为来自身份不明的开发者」。点取消,然后
右键 Shift.app → 打开,或在「系统设置 → 隐私与安全性」中点「仍要打开」。 右键 Shift.app → 打开,或在「系统设置 → 隐私与安全性」中点「仍要打开」。
@ -70,7 +70,7 @@ macOS 权限
pnpm tauri build --target universal-apple-darwin --bundles app,dmg pnpm tauri build --target universal-apple-darwin --bundles app,dmg
`pnpm mac:release` 会构建、校验并复制为 artifacts/Shift-0.1.14-macOS-universal.dmg。 `pnpm mac:release` 会构建、校验并复制为 artifacts/Shift-0.1.15-macOS-universal.dmg。
发布流程(清单、签名、推送)见仓库 docs/RELEASE.md。 发布流程(清单、签名、推送)见仓库 docs/RELEASE.md。
若希望更新通道能校验来源,构建时把 ed25519 公钥编进去(发布流程见仓库 若希望更新通道能校验来源,构建时把 ed25519 公钥编进去(发布流程见仓库
@ -96,7 +96,7 @@ docs/RELEASE.md 的「Signing the channel」):
镜像完整性: 镜像完整性:
hdiutil verify Shift-0.1.14-macOS-universal.dmg hdiutil verify Shift-0.1.15-macOS-universal.dmg
校验后仍打不开的话,请确认不是在压缩包预览窗口里运行的,并按上面的「新机器首次安装」 校验后仍打不开的话,请确认不是在压缩包预览窗口里运行的,并按上面的「新机器首次安装」
处理首次允许:右键 → 打开,或在「系统设置 → 隐私与安全性」中点「仍要打开」。 处理首次允许:右键 → 打开,或在「系统设置 → 隐私与安全性」中点「仍要打开」。

View File

@ -12,8 +12,8 @@ An orphan branch named `releases` holds exactly one release:
releases/ releases/
├── shift-update.json ├── shift-update.json
├── shift-update.sig ├── shift-update.sig
├── Shift-0.1.14-macOS-universal.dmg ├── Shift-0.1.15-macOS-universal.dmg
└── Shift-Setup-0.1.14-win-x64.exe └── Shift-Setup-0.1.15-win-x64.exe
``` ```
`shift-update.json` names the version and, per platform, the artifact file, its size in `shift-update.json` names the version and, per platform, the artifact file, its size in
@ -22,12 +22,12 @@ bytes and its SHA256:
```json ```json
{ {
"schema": 1, "schema": 1,
"version": "0.1.14", "version": "0.1.15",
"date": "2026-10-26", "date": "2026-10-26",
"notes": "", "notes": "",
"artifacts": { "artifacts": {
"macos": { "file": "Shift-0.1.14-macOS-universal.dmg", "sha256": "…", "size": 0 }, "macos": { "file": "Shift-0.1.15-macOS-universal.dmg", "sha256": "…", "size": 0 },
"windows": { "file": "Shift-Setup-0.1.14-win-x64.exe", "sha256": "…", "size": 0 } "windows": { "file": "Shift-Setup-0.1.15-win-x64.exe", "sha256": "…", "size": 0 }
} }
} }
``` ```

View File

@ -1,7 +1,7 @@
{ {
"name": "shift", "name": "shift",
"private": true, "private": true,
"version": "0.1.14", "version": "0.1.15",
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"type": "module", "type": "module",
"scripts": { "scripts": {

File diff suppressed because one or more lines are too long

2
src-tauri/Cargo.lock generated
View File

@ -3899,7 +3899,7 @@ dependencies = [
[[package]] [[package]]
name = "shift" name = "shift"
version = "0.1.14" version = "0.1.15"
dependencies = [ dependencies = [
"base64 0.22.1", "base64 0.22.1",
"calamine", "calamine",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "shift" name = "shift"
version = "0.1.14" version = "0.1.15"
description = "A radial file utility with screenshot, recording and OCR." description = "A radial file utility with screenshot, recording and OCR."
authors = ["mula.liu"] authors = ["mula.liu"]
license = "GPL-3.0-only" license = "GPL-3.0-only"

View File

@ -1,7 +1,7 @@
{ {
"$schema": "https://schema.tauri.app/config/2", "$schema": "https://schema.tauri.app/config/2",
"productName": "Shift", "productName": "Shift",
"version": "0.1.14", "version": "0.1.15",
"identifier": "app.nex.shift", "identifier": "app.nex.shift",
"build": { "build": {
"beforeDevCommand": "pnpm dev", "beforeDevCommand": "pnpm dev",

View File

@ -7,6 +7,7 @@ import { api } from "../lib/api";
import { messageFrom, normalizeSelection } from "../lib/utils"; import { messageFrom, normalizeSelection } from "../lib/utils";
import { FEEDBACK } from "../lib/feedback"; import { FEEDBACK } from "../lib/feedback";
import type { CaptureSession, RecordingCapabilities } from "../types"; import type { CaptureSession, RecordingCapabilities } from "../types";
import { Button, IconButton, Kbd, Surface, Toolbar } from "../ui/primitives";
interface Point { interface Point {
x: number; x: number;
@ -216,8 +217,9 @@ export function CaptureOverlay() {
{Math.max(0, Math.round(selection.width))} × {Math.max(0, Math.round(selection.height))} {Math.max(0, Math.round(selection.width))} × {Math.max(0, Math.round(selection.height))}
</div> </div>
</div> </div>
<div <Toolbar
ref={toolbarRef} ref={toolbarRef}
tone="dark"
className="capture-toolbar" className="capture-toolbar"
style={{ top: toolbarTop, left: toolbarLeft }} style={{ top: toolbarTop, left: toolbarLeft }}
onPointerDown={(event) => event.stopPropagation()} onPointerDown={(event) => event.stopPropagation()}
@ -226,17 +228,21 @@ export function CaptureOverlay() {
{session.mode === "recording" ? ( {session.mode === "recording" ? (
<> <>
{capabilities.audio ? ( {capabilities.audio ? (
<button <IconButton
className={`capture-tool ${audio ? "is-selected" : ""}`} label={t("audio")}
variant="toolbar"
size="md"
active={audio}
onClick={() => setAudio((value) => !value)} onClick={() => setAudio((value) => !value)}
title={t("audio")}
> >
{audio ? <Mic size={17} /> : <MicOff size={17} />} {audio ? <Mic size={17} /> : <MicOff size={17} />}
</button> </IconButton>
) : null} ) : null}
{capabilities.fps ? ( {capabilities.fps ? (
<button <Button
className="capture-tool capture-fps" variant="toolbar"
size="md"
className="capture-fps"
onClick={() => onClick={() =>
setFps( setFps(
FRAME_RATES[ FRAME_RATES[
@ -248,42 +254,49 @@ export function CaptureOverlay() {
> >
<Gauge size={15} /> <Gauge size={15} />
{fps} {fps}
</button> </Button>
) : null} ) : null}
<button className="capture-tool capture-record" onClick={() => void confirm()}> <Button variant="toolbar-danger" size="md" onClick={() => void confirm()}>
<Square size={14} fill="currentColor" /> <Square size={14} fill="currentColor" />
{t("startRecording")} {t("startRecording")}
</button> </Button>
</> </>
) : ( ) : (
<button className="capture-tool capture-confirm" onClick={() => void confirm()}> <Button variant="toolbar-primary" size="md" onClick={() => void confirm()}>
<Check size={18} strokeWidth={2.4} /> <Check size={18} strokeWidth={2.4} />
{t("confirm")} {t("confirm")}
</button> </Button>
)} )}
<button className="capture-tool" onClick={() => void cancel()} title={t("cancel")}> <IconButton
label={t("cancel")}
variant="toolbar"
size="md"
onClick={() => void cancel()}
>
<X size={17} /> <X size={17} />
</button> </IconButton>
</div> </Toolbar>
</> </>
) : ( ) : (
<div className="capture-start-hint"> <Surface variant="dark" radius="lg" className="capture-start-hint">
<span className="capture-icon"> <span className="capture-icon">
{session.mode === "recording" ? <ScanLine size={22} /> : <ScanLine size={22} />} {session.mode === "recording" ? <ScanLine size={22} /> : <ScanLine size={22} />}
</span> </span>
<div> <div>
<strong>{t("dragSelect")}</strong> <strong>{t("dragSelect")}</strong>
</div> </div>
<kbd>ESC</kbd> <Kbd tone="dark">ESC</Kbd>
</div> </Surface>
)} )}
{busy ? ( {busy ? (
<div className="capture-processing" role="status" aria-live="polite"> <Surface variant="dark" radius="md" className="capture-processing" role="status" aria-live="polite">
<LoaderCircle size={20} className="spin" /> <LoaderCircle size={20} className="spin" />
{status || t("processing")} {status || t("processing")}
</div> </Surface>
) : status ? ( ) : status ? (
<div className="capture-status" role="status" aria-live="polite">{status}</div> <Surface variant="dark" radius="md" className="capture-status" role="status" aria-live="polite">
{status}
</Surface>
) : null} ) : null}
</div> </div>
); );

View File

@ -24,6 +24,14 @@ import { basename, dirname, extensionOf, IS_MAC, messageFrom } from "../lib/util
import { history } from "../lib/history"; import { history } from "../lib/history";
import type { EditorInfo } from "../types"; import type { EditorInfo } from "../types";
import { ImageAnnotator } from "./ImageAnnotator"; import { ImageAnnotator } from "./ImageAnnotator";
import {
Button,
IconButton,
ProgressBar,
Textarea,
Toast,
Toolbar,
} from "../ui/primitives";
export function Editor() { export function Editor() {
const { t } = useI18n(); const { t } = useI18n();
@ -141,7 +149,7 @@ export function Editor() {
setOcrRunning(true); setOcrRunning(true);
setOcrText(""); setOcrText("");
setOcrProgress(0); setOcrProgress(0);
setOcrFailed(false); setOcrFailed(false);
setOcrStatus(t("ocrRunning")); setOcrStatus(t("ocrRunning"));
try { try {
const source = isTauri() ? convertFileSrc(current.path) : current.path; const source = isTauri() ? convertFileSrc(current.path) : current.path;
@ -198,55 +206,72 @@ export function Editor() {
<div className="editor-title" data-tauri-drag-region> <div className="editor-title" data-tauri-drag-region>
{name} {name}
</div> </div>
<button <IconButton
className="home-icon-button editor-close" label={t("close")}
variant="ghost"
size="md"
className="editor-close"
onClick={() => void api.closeEditor()} onClick={() => void api.closeEditor()}
aria-label={t("close")}
title={t("close")}
> >
<X size={16} /> <X size={16} />
</button> </IconButton>
</header> </header>
<div className="editor-toolbar"> <Toolbar tone="light" variant="bar">
<div className="editor-tool-group"> <div className="editor-tool-group">
<button className="editor-button" onClick={() => void copy()}> <Button variant="secondary" size="sm" onClick={() => void copy()}>
<Copy size={16} /> <Copy size={16} />
{t("copy")} {t("copy")}
</button> </Button>
<button className="editor-button" onClick={() => void saveAs()}> <Button variant="secondary" size="sm" onClick={() => void saveAs()}>
<Clipboard size={16} /> <Clipboard size={16} />
{t("saveAs")} {t("saveAs")}
</button> </Button>
{session.kind === "image" ? ( {session.kind === "image" ? (
<button className={`editor-button ${ocrOpen ? "is-active" : ""}`} onClick={() => void runOcr()}> <Button
variant="secondary"
size="sm"
active={ocrOpen}
onClick={() => void runOcr()}
>
<ScanText size={16} /> <ScanText size={16} />
{t("ocr")} {t("ocr")}
</button> </Button>
) : null} ) : null}
{session.kind === "image" ? ( {session.kind === "image" ? (
<button <Button
className="editor-button" variant="secondary"
size="sm"
onClick={() => void pinToScreen()} onClick={() => void pinToScreen()}
disabled={pinBusy} disabled={pinBusy}
> >
{pinBusy ? <LoaderCircle size={16} className="spin" /> : <Pin size={16} />} {pinBusy ? <LoaderCircle size={16} className="spin" /> : <Pin size={16} />}
{t("pin")} {t("pin")}
</button> </Button>
) : null} ) : null}
</div> </div>
<div className="editor-tool-group"> <div className="editor-tool-group">
<span className="editor-path" title={session.path}> <span className="editor-path" title={session.path}>
{dirname(session.path)} {dirname(session.path)}
</span> </span>
<button className="editor-icon" title={t("open")} onClick={() => void api.openFile(session.path)}> <IconButton
label={t("open")}
variant="ghost"
size="sm"
onClick={() => void api.openFile(session.path)}
>
<ExternalLink size={16} /> <ExternalLink size={16} />
</button> </IconButton>
<button className="editor-icon" title={t("revealFile")} onClick={() => void api.revealFile(session.path)}> <IconButton
label={t("revealFile")}
variant="ghost"
size="sm"
onClick={() => void api.revealFile(session.path)}
>
<FolderOpen size={16} /> <FolderOpen size={16} />
</button> </IconButton>
</div> </div>
</div> </Toolbar>
<main className={`editor-main ${ocrOpen ? "has-ocr" : ""}`}> <main className={`editor-main ${ocrOpen ? "has-ocr" : ""}`}>
<section className="editor-canvas"> <section className="editor-canvas">
@ -271,7 +296,9 @@ export function Editor() {
<div className="editor-file-fallback"> <div className="editor-file-fallback">
<FileText size={54} strokeWidth={1.4} /> <FileText size={54} strokeWidth={1.4} />
<strong>{name}</strong> <strong>{name}</strong>
<button onClick={() => void api.openFile(session.path)}>{t("open")}</button> <Button variant="inverse" size="sm" onClick={() => void api.openFile(session.path)}>
{t("open")}
</Button>
</div> </div>
)} )}
</section> </section>
@ -283,14 +310,14 @@ export function Editor() {
<span className="ocr-eyebrow">{t("ocr")}</span> <span className="ocr-eyebrow">{t("ocr")}</span>
<h2>{t("ocrTitle")}</h2> <h2>{t("ocrTitle")}</h2>
</div> </div>
<button <IconButton
className="editor-icon" label={t("close")}
variant="ghost"
size="sm"
onClick={() => setOcrOpen(false)} onClick={() => setOcrOpen(false)}
aria-label={t("close")}
title={t("close")}
> >
<X size={16} /> <X size={16} />
</button> </IconButton>
</div> </div>
{ocrRunning ? ( {ocrRunning ? (
<div className="ocr-progress"> <div className="ocr-progress">
@ -299,41 +326,45 @@ export function Editor() {
<span>{ocrStatus}</span> <span>{ocrStatus}</span>
<b>{Math.round(ocrProgress * 100)}%</b> <b>{Math.round(ocrProgress * 100)}%</b>
</div> </div>
<div className="ocr-progress-bar"> <ProgressBar value={Math.max(4, ocrProgress * 100)} size="sm" />
<span style={{ width: `${Math.max(4, ocrProgress * 100)}%` }} />
</div>
</div> </div>
) : null} ) : null}
<textarea <Textarea
className="ocr-output" className="ocr-output ui-textarea--mono"
value={ocrText} value={ocrText}
onChange={(event) => setOcrText(event.target.value)} onChange={(event) => setOcrText(event.target.value)}
placeholder={t(ocrFailed ? "ocrNothing" : "ocrEmpty")} placeholder={t(ocrFailed ? "ocrNothing" : "ocrEmpty")}
spellCheck={false} spellCheck={false}
/> />
<div className="ocr-actions"> <div className="ocr-actions">
<button className="editor-primary" onClick={() => void writeText(ocrText).then(() => flashNotice(t("copyText")))}> <Button
variant="primary"
size="sm"
onClick={() => void writeText(ocrText).then(() => flashNotice(t("copyText")))}
>
<Copy size={15} /> <Copy size={15} />
{t("copyText")} {t("copyText")}
</button> </Button>
<button className="editor-secondary" onClick={() => void runOcr()}> <Button variant="secondary" size="sm" onClick={() => void runOcr()}>
<ScanText size={15} /> <ScanText size={15} />
{t("extractText")} {t("extractText")}
</button> </Button>
</div> </div>
</aside> </aside>
) : null} ) : null}
</main> </main>
{copied ? ( {copied ? (
<div <Toast
className={`editor-toast ${copiedIsError ? "is-error" : ""}`} tone={copiedIsError ? "error" : "neutral"}
size="sm"
className="editor-toast"
role={copiedIsError ? "alert" : "status"} role={copiedIsError ? "alert" : "status"}
aria-live="polite" aria-live="polite"
> >
{copiedIsError ? <CircleAlert size={15} /> : <Check size={15} />} {copiedIsError ? <CircleAlert size={15} /> : <Check size={15} />}
{copied} {copied}
</div> </Toast>
) : null} ) : null}
</div> </div>
); );

View File

@ -25,6 +25,14 @@ import { useEffect, useRef, useState } from "react";
import { useI18n } from "../i18n"; import { useI18n } from "../i18n";
import { api } from "../lib/api"; import { api } from "../lib/api";
import { messageFrom } from "../lib/utils"; import { messageFrom } from "../lib/utils";
import {
Button,
IconButton,
Input,
Toast,
Toolbar,
ToolbarDivider,
} from "../ui/primitives";
type Tool = type Tool =
| "rectangle" | "rectangle"
@ -563,63 +571,84 @@ export function ImageAnnotator({ path, onSaved }: Props) {
return ( return (
<div className="annotator-shell"> <div className="annotator-shell">
<div className="annotator-toolbar"> <Toolbar tone="dark" className="annotator-toolbar">
{tools.map(({ id, icon: Icon, label }) => ( {tools.map(({ id, icon: Icon, label }) => (
<button <Button
key={id} key={id}
className={`annotator-tool ${tool === id ? "is-active" : ""}`} variant="toolbar"
size="sm"
active={tool === id}
title={label} title={label}
onClick={() => setTool(id)} onClick={() => setTool(id)}
> >
<Icon size={15} /> <Icon size={15} />
<span>{label}</span> <span>{label}</span>
</button> </Button>
))} ))}
<span className="annotator-separator" /> <ToolbarDivider />
{tool === "stamp" {tool === "stamp"
? stamps.map(({ id, icon: Icon, label }) => ( ? stamps.map(({ id, icon: Icon, label }) => (
<button <IconButton
key={id} key={id}
className={`annotator-tool annotator-stamp ${stamp === id ? "is-active" : ""}`} label={label}
variant="toolbar"
size="sm"
active={stamp === id}
title={label} title={label}
onClick={() => setStamp(id)} onClick={() => setStamp(id)}
> >
<Icon size={15} /> <Icon size={15} />
</button> </IconButton>
)) ))
: null} : null}
<span className="annotator-separator" /> <ToolbarDivider />
{cropRect ? ( {cropRect ? (
<button className="annotator-tool is-primary" onClick={applyCrop}> <Button
variant="toolbar-primary"
size="sm"
title={t("applyCrop")}
onClick={applyCrop}
>
<Check size={15} /> <Check size={15} />
{t("applyCrop")} <span>{t("applyCrop")}</span>
</button> </Button>
) : null} ) : null}
<button className="annotator-tool" onClick={addBackground} title={t("addBackground")}> <Button variant="toolbar" size="sm" onClick={addBackground} title={t("addBackground")}>
<ImagePlus size={15} /> <ImagePlus size={15} />
{t("addBackground")} <span>{t("addBackground")}</span>
</button> </Button>
<button className="annotator-tool" onClick={removeBackground} title={t("cutout")}> <Button variant="toolbar" size="sm" onClick={removeBackground} title={t("cutout")}>
<Scissors size={15} /> <Scissors size={15} />
{t("cutout")} <span>{t("cutout")}</span>
</button> </Button>
<button <IconButton
className="annotator-tool" label={t("undo")}
title={t("undo")} variant="toolbar"
size="sm"
disabled={annotations.length === 0 && imageHistory.length === 0} disabled={annotations.length === 0 && imageHistory.length === 0}
onClick={undo} onClick={undo}
> >
<Undo2 size={15} /> <Undo2 size={15} />
</button> </IconButton>
<button className="annotator-tool is-primary" onClick={() => void saveCopy(false)}> <Button
variant="toolbar-primary"
size="sm"
title={t("saveCopy")}
onClick={() => void saveCopy(false)}
>
{busy && !copying ? <LoaderCircle size={15} className="spin" /> : <Save size={15} />} {busy && !copying ? <LoaderCircle size={15} className="spin" /> : <Save size={15} />}
{t("saveCopy")} <span>{t("saveCopy")}</span>
</button> </Button>
<button className="annotator-tool" onClick={() => void saveCopy(true)}> <Button
variant="toolbar"
size="sm"
title={t("copy")}
onClick={() => void saveCopy(true)}
>
{copying ? <LoaderCircle size={15} className="spin" /> : <Copy size={15} />} {copying ? <LoaderCircle size={15} className="spin" /> : <Copy size={15} />}
{t("copy")} <span>{t("copy")}</span>
</button> </Button>
</div> </Toolbar>
<div className="annotator-canvas-wrap"> <div className="annotator-canvas-wrap">
<canvas <canvas
ref={canvasRef} ref={canvasRef}
@ -686,10 +715,15 @@ export function ImageAnnotator({ path, onSaved }: Props) {
event.currentTarget.releasePointerCapture(event.pointerId); event.currentTarget.releasePointerCapture(event.pointerId);
}} }}
/> />
{error ? <div className="annotator-error" role="alert">{error}</div> : null} {error ? (
<Toast tone="error" size="sm" className="annotator-error" role="alert">
{error}
</Toast>
) : null}
{textPoint ? ( {textPoint ? (
<div className="annotator-text-entry"> <Toolbar tone="dark" className="annotator-text-entry">
<input <Input
className="ui-input--dark ui-input--compact"
autoFocus autoFocus
value={textDraft} value={textDraft}
placeholder={t("textAnnotation")} placeholder={t("textAnnotation")}
@ -716,9 +750,10 @@ export function ImageAnnotator({ path, onSaved }: Props) {
} }
}} }}
/> />
<button <IconButton
aria-label={t("confirm")} label={t("confirm")}
title={t("confirm")} variant="toolbar-primary"
size="sm"
onClick={() => { onClick={() => {
if (!textDraft.trim()) return; if (!textDraft.trim()) return;
setAnnotations((current) => [ setAnnotations((current) => [
@ -737,8 +772,8 @@ export function ImageAnnotator({ path, onSaved }: Props) {
}} }}
> >
<Check size={14} /> <Check size={14} />
</button> </IconButton>
</div> </Toolbar>
) : null} ) : null}
</div> </div>
</div> </div>

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,7 @@ import { useEffect, useRef, useState } from "react";
import { useI18n } from "../i18n"; import { useI18n } from "../i18n";
import { api } from "../lib/api"; import { api } from "../lib/api";
import { decodeHexParam, messageFrom } from "../lib/utils"; import { decodeHexParam, messageFrom } from "../lib/utils";
import { IconButton } from "../ui/primitives";
interface PinnedPreview { interface PinnedPreview {
id: number; id: number;
@ -141,20 +142,22 @@ export function PinnedImage() {
)} )}
</div> </div>
<div className="pin-actions"> <div className="pin-actions">
<button <IconButton
type="button" label={t(enlarged ? "restorePin" : "enlargePin")}
title={t(enlarged ? "restorePin" : "enlargePin")} variant="glass-dark"
size="xs"
active={enlarged}
aria-pressed={enlarged} aria-pressed={enlarged}
onClick={() => void zoom()} onClick={() => void zoom()}
> >
{enlarged ? <Minimize2 size={13} /> : <Maximize2 size={13} />} {enlarged ? <Minimize2 size={13} /> : <Maximize2 size={13} />}
</button> </IconButton>
<button type="button" title={t("copy")} onClick={() => void copy()}> <IconButton label={t("copy")} variant="glass-dark" size="xs" onClick={() => void copy()}>
<Copy size={13} /> <Copy size={13} />
</button> </IconButton>
<button type="button" title={t("close")} onClick={() => void api.closePin()}> <IconButton label={t("close")} variant="glass-dark" size="xs" onClick={() => void api.closePin()}>
<X size={13} /> <X size={13} />
</button> </IconButton>
</div> </div>
</div> </div>
); );

View File

@ -54,6 +54,7 @@ import { FEEDBACK, outcomeMessage } from "../lib/feedback";
import type { FileInfo, RadialContext } from "../types"; import type { FileInfo, RadialContext } from "../types";
import { useI18n } from "../i18n"; import { useI18n } from "../i18n";
import { SharePanel } from "./SharePanel"; import { SharePanel } from "./SharePanel";
import { Button, IconButton } from "../ui/primitives";
const SIZE = 760; const SIZE = 760;
const CENTER = SIZE / 2; const CENTER = SIZE / 2;
@ -820,8 +821,9 @@ export function RadialMenu() {
const position = polar((OUTER + INNER) / 2 - 2, angle); const position = polar((OUTER + INNER) / 2 - 2, angle);
const Icon = wedge.icon; const Icon = wedge.icon;
return ( return (
<button <Button
key={`label-${wedge.id}`} key={`label-${wedge.id}`}
variant="plain"
className={`radial-label ${ring === "formats" ? "is-format" : ""} ${hovered === index ? "is-active" : ""}`} className={`radial-label ${ring === "formats" ? "is-format" : ""} ${hovered === index ? "is-active" : ""}`}
style={{ left: position.x, top: position.y }} style={{ left: position.x, top: position.y }}
onPointerEnter={() => { onPointerEnter={() => {
@ -840,7 +842,7 @@ export function RadialMenu() {
<Icon size={wedge.id === "convert" ? 23 : 22} strokeWidth={1.8} /> <Icon size={wedge.id === "convert" ? 23 : 22} strokeWidth={1.8} />
)} )}
<span>{wedge.label}</span> <span>{wedge.label}</span>
</button> </Button>
); );
})} })}
@ -896,9 +898,15 @@ export function RadialMenu() {
<CircleAlert size={24} strokeWidth={1.8} aria-hidden="true" /> <CircleAlert size={24} strokeWidth={1.8} aria-hidden="true" />
<strong>{t("actionFailed")}</strong> <strong>{t("actionFailed")}</strong>
<span className="radial-error-message">{error}</span> <span className="radial-error-message">{error}</span>
<button type="button" onClick={() => setError(null)} aria-label={t("close")}> <IconButton
label={t("close")}
variant="secondary"
size="xs"
className="radial-error-close"
onClick={() => setError(null)}
>
<X size={14} /> <X size={14} />
</button> </IconButton>
</div> </div>
) : null} ) : null}
</div> </div>

View File

@ -5,6 +5,7 @@ import { useI18n } from "../i18n";
import { api } from "../lib/api"; import { api } from "../lib/api";
import { formatDuration, messageFrom } from "../lib/utils"; import { formatDuration, messageFrom } from "../lib/utils";
import type { RecordingInfo } from "../types"; import type { RecordingInfo } from "../types";
import { Button } from "../ui/primitives";
export function RecorderHud() { export function RecorderHud() {
const { t } = useI18n(); const { t } = useI18n();
@ -63,10 +64,16 @@ export function RecorderHud() {
{error || t("record")} {error || t("record")}
</span> </span>
</div> </div>
<button type="button" className="recorder-stop" onClick={() => void stop()} disabled={stopping}> <Button
variant="danger"
size="sm"
className="recorder-stop"
onClick={() => void stop()}
disabled={stopping}
>
{stopping ? <LoaderCircle size={15} className="spin" /> : <Square size={14} fill="currentColor" />} {stopping ? <LoaderCircle size={15} className="spin" /> : <Square size={14} fill="currentColor" />}
{stopping ? t("processing") : t("stopRecording")} {stopping ? t("processing") : t("stopRecording")}
</button> </Button>
</div> </div>
); );
} }

View File

@ -8,6 +8,7 @@ import { useI18n } from "../i18n";
import { api } from "../lib/api"; import { api } from "../lib/api";
import { basename, decodeHexParam, messageFrom } from "../lib/utils"; import { basename, decodeHexParam, messageFrom } from "../lib/utils";
import type { CaptureResult } from "../types"; import type { CaptureResult } from "../types";
import { Button, IconButton, ProgressBar, Surface } from "../ui/primitives";
const THUMB_EXTENSIONS = ["png", "jpg", "jpeg", "webp", "gif", "bmp", "tiff", "tif"]; const THUMB_EXTENSIONS = ["png", "jpg", "jpeg", "webp", "gif", "bmp", "tiff", "tif"];
@ -110,7 +111,9 @@ export function ResultCard() {
const percent = ttl > 0 ? (remaining / ttl) * 100 : 0; const percent = ttl > 0 ? (remaining / ttl) * 100 : 0;
return ( return (
<div <Surface
variant="solid"
radius="lg"
className="result-card" className="result-card"
onMouseEnter={pause} onMouseEnter={pause}
onMouseLeave={resume} onMouseLeave={resume}
@ -136,25 +139,25 @@ export function ResultCard() {
{note ? <em>{note}</em> : null} {note ? <em>{note}</em> : null}
</div> </div>
<div className="result-card-actions"> <div className="result-card-actions">
<button title={t("copy")} onClick={() => void copy()}> <IconButton label={t("copy")} size="xs" onClick={() => void copy()}>
<Copy size={14} /> <Copy size={14} />
</button> </IconButton>
{info.kind === "image" ? ( {info.kind === "image" ? (
<button title={t("pin")} onClick={() => void pin()}> <IconButton label={t("pin")} size="xs" onClick={() => void pin()}>
<Images size={14} /> <Images size={14} />
</button> </IconButton>
) : null} ) : null}
<button title={t("sendTo")} onClick={() => void send()}> <IconButton label={t("sendTo")} size="xs" onClick={() => void send()}>
<Send size={14} /> <Send size={14} />
</button> </IconButton>
<button title={t("revealFile")} onClick={() => void reveal()}> <IconButton label={t("revealFile")} size="xs" onClick={() => void reveal()}>
<FolderSearch size={14} /> <FolderSearch size={14} />
</button> </IconButton>
<button className="result-card-open" onClick={() => void open()}> <Button variant="primary" size="xs" className="result-card-open" onClick={() => void open()}>
{t("edit")} {t("edit")}
</button> </Button>
</div> </div>
<div className="result-card-fuse" style={{ width: `${percent}%` }} /> <ProgressBar value={percent} size="xs" className="result-card-fuse" />
</div> </Surface>
); );
} }

View File

@ -12,6 +12,7 @@ import {
import { useI18n } from "../i18n"; import { useI18n } from "../i18n";
import { api } from "../lib/api"; import { api } from "../lib/api";
import type { HotkeyStatus, RuntimeInfo, WriteCheck } from "../types"; import type { HotkeyStatus, RuntimeInfo, WriteCheck } from "../types";
import { Badge, Button, Code, Surface } from "../ui/primitives";
type State = "checking" | "ok" | "problem" | "unknown"; type State = "checking" | "ok" | "problem" | "unknown";
@ -162,16 +163,16 @@ export function SetupPanel({
return ( return (
<div className="setup-scrim" role="dialog" aria-modal="true" aria-label={t("setupTitle")}> <div className="setup-scrim" role="dialog" aria-modal="true" aria-label={t("setupTitle")}>
<div className="setup-card"> <Surface variant="solid" radius="lg" className="setup-card">
<header className="setup-head"> <header className="setup-head">
<div> <div>
<h2>{t("setupTitle")}</h2> <h2>{t("setupTitle")}</h2>
<p>{t("setupIntro")}</p> <p>{t("setupIntro")}</p>
</div> </div>
<button className="setup-refresh" onClick={() => void refresh()}> <Button variant="outline" size="xs" onClick={() => void refresh()}>
<RefreshCw size={13} /> <RefreshCw size={13} />
{t("setupRecheck")} {t("setupRecheck")}
</button> </Button>
</header> </header>
<ul className="setup-list"> <ul className="setup-list">
@ -194,12 +195,21 @@ export function SetupPanel({
)} )}
</small> </small>
{row.action ? ( {row.action ? (
<button className="settings-link" onClick={row.action.run}> <Button variant="quiet" size="xs" onClick={row.action.run}>
{row.action.label} {row.action.label}
</button> </Button>
) : null} ) : null}
</span> </span>
<span className={`setup-state is-${row.state}`}> <Badge
tone={
row.state === "ok"
? "success"
: row.state === "problem"
? "danger"
: "neutral"
}
className="setup-state"
>
{row.state === "ok" ? ( {row.state === "ok" ? (
<Check size={16} /> <Check size={16} />
) : row.state === "problem" ? ( ) : row.state === "problem" ? (
@ -212,7 +222,7 @@ export function SetupPanel({
? "setupStateProblem" ? "setupStateProblem"
: "setupStateUnknown", : "setupStateUnknown",
)} )}
</span> </Badge>
</li> </li>
); );
})} })}
@ -221,18 +231,18 @@ export function SetupPanel({
{checks ? ( {checks ? (
<div className="setup-paths"> <div className="setup-paths">
{checks.map((check) => ( {checks.map((check) => (
<code key={check.kind}>{check.path}</code> <Code key={check.kind}>{check.path}</Code>
))} ))}
</div> </div>
) : null} ) : null}
<footer className="setup-foot"> <footer className="setup-foot">
<span>{t("setupFootnote")}</span> <span>{t("setupFootnote")}</span>
<button className="runtime-install" onClick={onDone}> <Button variant="outline" size="sm" onClick={onDone}>
{t("setupStart")} {t("setupStart")}
</button> </Button>
</footer> </footer>
</div> </Surface>
</div> </div>
); );
} }

View File

@ -5,6 +5,7 @@ import { useI18n } from "../i18n";
import { api } from "../lib/api"; import { api } from "../lib/api";
import { decodeHexParam, formatBytes } from "../lib/utils"; import { decodeHexParam, formatBytes } from "../lib/utils";
import type { ShareOffer } from "../types"; import type { ShareOffer } from "../types";
import { Badge, Button, ProgressBar, Surface } from "../ui/primitives";
function readOffer(): ShareOffer | null { function readOffer(): ShareOffer | null {
const raw = decodeHexParam(new URLSearchParams(window.location.search).get("offer")); const raw = decodeHexParam(new URLSearchParams(window.location.search).get("offer"));
@ -74,7 +75,7 @@ export function ShareNotice() {
const ratio = offer.timeoutSeconds > 0 ? left / offer.timeoutSeconds : 0; const ratio = offer.timeoutSeconds > 0 ? left / offer.timeoutSeconds : 0;
return ( return (
<div className="share-notice" data-tauri-drag-region> <Surface variant="solid" radius="lg" className="share-notice" data-tauri-drag-region>
<div className="share-notice-head" data-tauri-drag-region> <div className="share-notice-head" data-tauri-drag-region>
<span className="share-notice-glyph"> <span className="share-notice-glyph">
<Inbox size={16} /> <Inbox size={16} />
@ -82,27 +83,25 @@ export function ShareNotice() {
<span className="share-notice-kicker" data-tauri-drag-region> <span className="share-notice-kicker" data-tauri-drag-region>
{t("shareNoticeKicker", { peer: offer.peerName })} {t("shareNoticeKicker", { peer: offer.peerName })}
</span> </span>
<span className={`share-notice-count ${ratio < 0.25 ? "is-low" : ""}`}> <Badge tone={ratio < 0.25 ? "danger" : "accent"} className="share-notice-count">
{expired ? t("shareNoticeExpired") : `${left}s`} {expired ? t("shareNoticeExpired") : `${left}s`}
</span> </Badge>
</div> </div>
<div className="share-notice-file" title={offer.fileName}> <div className="share-notice-file" title={offer.fileName}>
<strong data-tauri-drag-region>{offer.fileName}</strong> <strong data-tauri-drag-region>{offer.fileName}</strong>
<small>{formatBytes(offer.size)}</small> <small>{formatBytes(offer.size)}</small>
</div> </div>
<div className="share-notice-actions"> <div className="share-notice-actions">
<button className="share-notice-decline" onClick={() => void answer(false)}> <Button variant="secondary" size="md" block onClick={() => void answer(false)}>
<X size={14} /> <X size={14} />
{t("shareNoticeDecline")} {t("shareNoticeDecline")}
</button> </Button>
<button className="share-notice-accept" onClick={() => void answer(true)}> <Button variant="primary" size="md" block onClick={() => void answer(true)}>
<Check size={14} /> <Check size={14} />
{t("shareNoticeAccept")} {t("shareNoticeAccept")}
</button> </Button>
</div> </div>
<div className="share-notice-bar"> <ProgressBar value={ratio * 100} size="xs" className="share-notice-bar" />
<span style={{ width: `${(ratio * 100).toFixed(1)}%` }} /> </Surface>
</div>
</div>
); );
} }

View File

@ -2,7 +2,6 @@ import { isTauri } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event"; import { listen } from "@tauri-apps/api/event";
import { import {
Apple, Apple,
Check,
CircleAlert, CircleAlert,
File as FileIcon, File as FileIcon,
GripVertical, GripVertical,
@ -19,6 +18,16 @@ import { api } from "../lib/api";
import { parseSharePaths, SHARE_PATHS_TYPE } from "../lib/dragOut"; import { parseSharePaths, SHARE_PATHS_TYPE } from "../lib/dragOut";
import { basename, dirname, formatBytes, messageFrom } from "../lib/utils"; import { basename, dirname, formatBytes, messageFrom } from "../lib/utils";
import type { SharePeer, ShareTransfer } from "../types"; import type { SharePeer, ShareTransfer } from "../types";
import {
Banner,
Button,
Checkbox,
EmptyState,
IconButton,
Kbd,
ProgressBar,
Surface,
} from "../ui/primitives";
interface SharePanelProps { interface SharePanelProps {
paths: string[]; paths: string[];
@ -197,7 +206,9 @@ export function SharePanel({ paths, onClose, onNotice }: SharePanelProps) {
if (!closeDisabled) onClose(); if (!closeDisabled) onClose();
}} }}
/> />
<div <Surface
variant="solid"
radius="xl"
className="share-panel" className="share-panel"
role="dialog" role="dialog"
aria-modal="true" aria-modal="true"
@ -210,20 +221,20 @@ export function SharePanel({ paths, onClose, onNotice }: SharePanelProps) {
<div className="share-head-copy"> <div className="share-head-copy">
<h2>{t("shareTitle")}</h2> <h2>{t("shareTitle")}</h2>
</div> </div>
<button <IconButton
className="home-icon-button" label={t("close")}
variant="ghost"
size="md"
onClick={() => { onClick={() => {
if (!closeDisabled) onClose(); if (!closeDisabled) onClose();
}} }}
aria-label={t("close")}
title={t("close")}
disabled={closeDisabled} disabled={closeDisabled}
> >
<X size={16} /> <X size={16} />
</button> </IconButton>
</header> </header>
<section className="share-files" aria-label={t("shareFiles")}> <Surface variant="inset" radius="md" className="share-files" aria-label={t("shareFiles")}>
<div className="share-files-head"> <div className="share-files-head">
<strong>{t("shareFiles")}</strong> <strong>{t("shareFiles")}</strong>
<span>{t("shareSelectionCount", { <span>{t("shareSelectionCount", {
@ -231,29 +242,28 @@ export function SharePanel({ paths, onClose, onNotice }: SharePanelProps) {
total: paths.length, total: paths.length,
})}</span> })}</span>
{paths.length > 1 ? ( {paths.length > 1 ? (
<label className="share-select-all"> <Checkbox
<input className="share-select-all"
type="checkbox" checked={allSelected}
checked={allSelected} onChange={toggleAll}
onChange={toggleAll} disabled={closeDisabled}
disabled={closeDisabled} >
/>
<span className="share-checkmark" aria-hidden="true">
{allSelected ? <Check size={10} /> : null}
</span>
{t("shareSelectAll")} {t("shareSelectAll")}
</label> </Checkbox>
) : null} ) : null}
</div> </div>
<div className="share-file-list" role="group" aria-label={t("shareFiles")}> <div className="share-file-list" role="group" aria-label={t("shareFiles")}>
{paths.map((path) => { {paths.map((path) => {
const checked = selectedPaths.includes(path); const checked = selectedPaths.includes(path);
return ( return (
<label <Checkbox
key={path} key={path}
className={`share-file-row ${checked ? "is-checked" : ""}`} className={`share-file-row ${checked ? "is-checked" : ""}`}
title={path} title={path}
draggable={!closeDisabled} draggable={!closeDisabled}
checked={checked}
onChange={() => togglePath(path)}
disabled={closeDisabled}
onDragStart={(event) => { onDragStart={(event) => {
const files = checked ? selectedPaths : [path]; const files = checked ? selectedPaths : [path];
event.dataTransfer.effectAllowed = "copy"; event.dataTransfer.effectAllowed = "copy";
@ -263,43 +273,36 @@ export function SharePanel({ paths, onClose, onNotice }: SharePanelProps) {
); );
}} }}
> >
<input
type="checkbox"
checked={checked}
onChange={() => togglePath(path)}
disabled={closeDisabled}
/>
<span className="share-checkmark" aria-hidden="true">
{checked ? <Check size={10} /> : null}
</span>
<FileIcon size={13} /> <FileIcon size={13} />
<span className="share-file-copy"> <span className="share-file-copy">
<strong>{basename(path)}</strong> <strong>{basename(path)}</strong>
<small>{dirname(path)}</small> <small>{dirname(path)}</small>
</span> </span>
<GripVertical className="share-file-grip" size={13} aria-hidden="true" /> <GripVertical className="share-file-grip" size={13} aria-hidden="true" />
</label> </Checkbox>
); );
})} })}
</div> </div>
</section> </Surface>
{peers.length === 0 ? ( {peers.length === 0 ? (
<div className="share-empty"> <EmptyState
<span className="share-empty-glyph"> className="share-empty"
{searching ? <LoaderCircle size={17} className="spin" /> : <Radar size={17} />} glyph={searching ? <LoaderCircle size={17} className="spin" /> : <Radar size={17} />}
</span> title={searching ? t("shareSearching") : t("shareNoPeers")}
<strong>{searching ? t("shareSearching") : t("shareNoPeers")}</strong> />
</div>
) : ( ) : (
<div className="share-grid"> <div className="share-grid">
{peers.map((peer) => { {peers.map((peer) => {
const active = busyPeer === peer.id; const active = busyPeer === peer.id;
const dropTarget = dragOverPeer === peer.id; const dropTarget = dragOverPeer === peer.id;
return ( return (
<button <Button
key={peer.id} key={peer.id}
className={`share-peer ${active ? "is-active" : ""} ${dropTarget ? "is-drop-target" : ""}`} variant="card"
size="lg"
active={active}
className={`share-peer ${dropTarget ? "is-drop-target" : ""}`}
onClick={() => void send(peer)} onClick={() => void send(peer)}
disabled={selectedPaths.length === 0 || (closeDisabled && !active)} disabled={selectedPaths.length === 0 || (closeDisabled && !active)}
title={peer.address} title={peer.address}
@ -334,28 +337,26 @@ export function SharePanel({ paths, onClose, onNotice }: SharePanelProps) {
<span className="share-peer-meta"> <span className="share-peer-meta">
{t(PLATFORM_LABEL[peer.platform] ?? "shareLinux")} {t(PLATFORM_LABEL[peer.platform] ?? "shareLinux")}
</span> </span>
</button> </Button>
); );
})} })}
</div> </div>
)} )}
{waitingFor ? ( {waitingFor ? (
<div className="share-progress"> <Surface variant="inset" radius="md" className="share-progress">
<div className="share-progress-head"> <div className="share-progress-head">
<span className="share-progress-wait"> <span className="share-progress-wait">
<LoaderCircle size={12} className="spin" /> <LoaderCircle size={12} className="spin" />
{t("shareWaiting", { peer: waitingFor })} {t("shareWaiting", { peer: waitingFor })}
</span> </span>
</div> </div>
<div className="share-bar is-indeterminate"> <ProgressBar indeterminate className="share-bar" />
<span /> </Surface>
</div>
</div>
) : null} ) : null}
{sending && progress && !waitingFor ? ( {sending && progress && !waitingFor ? (
<div className="share-progress"> <Surface variant="inset" radius="md" className="share-progress">
<div className="share-progress-head"> <div className="share-progress-head">
<span> <span>
{t("shareSendingTo", { {t("shareSendingTo", {
@ -367,32 +368,36 @@ export function SharePanel({ paths, onClose, onNotice }: SharePanelProps) {
{formatBytes(progress.sent)} / {formatBytes(progress.total)} {formatBytes(progress.sent)} / {formatBytes(progress.total)}
</small> </small>
</div> </div>
<div className="share-bar"> <ProgressBar value={ratio * 100} className="share-bar" />
<span style={{ width: `${(ratio * 100).toFixed(1)}%` }} /> </Surface>
</div>
</div>
) : null} ) : null}
{failure ? ( {failure ? (
<div className="share-error" role="alert"> <Banner
<CircleAlert size={13} /> tone="danger"
icon={<CircleAlert size={13} />}
inline
className="share-error"
role="alert"
>
{failure} {failure}
</div> </Banner>
) : null} ) : null}
<footer className="share-foot"> <footer className="share-foot">
<button <Button
className="share-reshow" variant="outline"
size="xs"
onClick={searchAgain} onClick={searchAgain}
disabled={closeDisabled} disabled={closeDisabled}
title={t("shareRefresh")} title={t("shareRefresh")}
> >
<RefreshCw size={12} className={searching ? "spin" : ""} /> <RefreshCw size={12} className={searching ? "spin" : ""} />
{searching ? t("shareSearching") : t("shareRefresh")} {searching ? t("shareSearching") : t("shareRefresh")}
</button> </Button>
<kbd>Esc</kbd> <Kbd>Esc</Kbd>
</footer> </footer>
</div> </Surface>
</> </>
); );
} }

View File

@ -13,6 +13,17 @@ import {
import { useI18n } from "../i18n"; import { useI18n } from "../i18n";
import { useUpdateFlow } from "../lib/useUpdate"; import { useUpdateFlow } from "../lib/useUpdate";
import { formatBytes } from "../lib/utils"; import { formatBytes } from "../lib/utils";
import {
Badge,
Banner,
Button,
Code,
ProgressBar,
Section,
SectionTitle,
Surface,
SwitchRow,
} from "../ui/primitives";
interface Props { interface Props {
/** Raw URL of the manifest, so the panel can name the feed it just queried. */ /** Raw URL of the manifest, so the panel can name the feed it just queried. */
@ -72,7 +83,7 @@ export function UpdatePanel({ feedUrl, autoCheck, onAutoCheckChange, system }: P
const failed = status?.state === "error" || status?.state === "unavailable"; const failed = status?.state === "error" || status?.state === "unavailable";
return ( return (
<section className="home-settings-section"> <Section>
{/* The two facts an update answer has to be read against come first: which {/* The two facts an update answer has to be read against come first: which
machine and which Shift version is asking, then where updates come from. machine and which Shift version is asking, then where updates come from.
Both precede the Updates heading so a screenshot of this panel already Both precede the Updates heading so a screenshot of this panel already
@ -84,11 +95,11 @@ export function UpdatePanel({ feedUrl, autoCheck, onAutoCheckChange, system }: P
{system ? ( {system ? (
<span className="update-system-host"> <span className="update-system-host">
<strong>{system.osVersion || system.platform}</strong> <strong>{system.osVersion || system.platform}</strong>
<small>{architectureLabel(system.architecture)}</small> <Badge>{architectureLabel(system.architecture)}</Badge>
<em>Shift {system.appVersion}</em> <em>Shift {system.appVersion}</em>
</span> </span>
) : ( ) : (
<span className="update-system-pending">{t("updateSystemPending")}</span> <Badge className="update-system-pending">{t("updateSystemPending")}</Badge>
)} )}
</div> </div>
<div className="update-meta-line"> <div className="update-meta-line">
@ -97,29 +108,35 @@ export function UpdatePanel({ feedUrl, autoCheck, onAutoCheckChange, system }: P
{/* Only a status backed by a manifest may claim anything about trust: an {/* Only a status backed by a manifest may claim anything about trust: an
errored check has no manifest to have verified. */} errored check has no manifest to have verified. */}
{status && status.state !== "error" ? ( {status && status.state !== "error" ? (
<span className={`update-trust is-${status.signed ? "signed" : "unsigned"}`}> <Badge
tone={status.signed ? "success" : "neutral"}
plain
className="update-trust"
>
<ShieldCheck size={13} /> <ShieldCheck size={13} />
{t(status.signed ? "updateSigned" : "updateUnsigned")} {t(status.signed ? "updateSigned" : "updateUnsigned")}
</span> </Badge>
) : null} ) : null}
<code title={feedUrl}>{feedUrl || t("updateFeedNone")}</code> <Code title={feedUrl}>{feedUrl || t("updateFeedNone")}</Code>
</div> </div>
</div> </div>
<div className="runtime-section-head"> <SectionTitle
<div className="home-section-title"> icon={<Sparkle size={17} />}
<Sparkle size={17} /> actions={
{t("updates")} <Button
</div> variant="quiet"
<button size="xs"
className="settings-link runtime-refresh" onClick={() => void check()}
onClick={() => void check()} disabled={checking || downloading}
disabled={checking || downloading} >
> <RefreshCw size={13} className={checking ? "spin" : ""} />
<RefreshCw size={13} className={checking ? "spin" : ""} /> {checking ? t("updateChecking") : t("updateCheckNow")}
{checking ? t("updateChecking") : t("updateCheckNow")} </Button>
</button> }
</div> >
{t("updates")}
</SectionTitle>
<div className="update-status-row"> <div className="update-status-row">
<span className={`update-state is-${status?.state ?? "idle"}`}> <span className={`update-state is-${status?.state ?? "idle"}`}>
@ -137,10 +154,10 @@ export function UpdatePanel({ feedUrl, autoCheck, onAutoCheckChange, system }: P
</span> </span>
{available && status ? ( {available && status ? (
<span className="update-arrow"> <span className="update-arrow">
<span className="update-new"> <Badge tone="success" className="update-new">
<Sparkle size={13} /> <Sparkle size={13} />
{status.availableVersion} {status.availableVersion}
</span> </Badge>
<small>{status.date}</small> <small>{status.date}</small>
</span> </span>
) : null} ) : null}
@ -149,96 +166,94 @@ export function UpdatePanel({ feedUrl, autoCheck, onAutoCheckChange, system }: P
{status?.notes ? <p className="update-notes">{status.notes}</p> : null} {status?.notes ? <p className="update-notes">{status.notes}</p> : null}
{status?.fileName ? ( {status?.fileName ? (
<div className="update-artifact"> <Surface variant="inset" radius="md" className="update-artifact">
<PackageOpen size={15} /> <PackageOpen size={15} />
<span className="update-artifact-name" title={status.fileName}> <span className="update-artifact-name" title={status.fileName}>
{status.fileName} {status.fileName}
</span> </span>
<span className="update-artifact-size">{formatBytes(status.size)}</span> <span className="update-artifact-size">{formatBytes(status.size)}</span>
</div> </Surface>
) : null} ) : null}
{percent !== null ? ( {percent !== null ? (
<div <ProgressBar
value={percent}
tone="success"
size="lg"
className="update-progress" className="update-progress"
role="progressbar" label={
aria-valuenow={percent} progress ? `${formatBytes(progress.downloaded)} / ${formatBytes(progress.total)}` : ""
aria-valuemin={0} }
aria-valuemax={100} />
>
<div className="update-progress-fill" style={{ width: `${percent}%` }} />
<span>
{progress ? `${formatBytes(progress.downloaded)} / ${formatBytes(progress.total)}` : ""}
</span>
</div>
) : null} ) : null}
{status?.sha256 ? ( {status?.sha256 ? (
<code className="update-hash" title={status.sha256}> <Code className="update-hash" title={status.sha256}>
<ShieldCheck size={13} /> <ShieldCheck size={13} />
SHA256 {verified ? status.sha256 : `${status.sha256.slice(0, 16)}…`} SHA256 {verified ? status.sha256 : `${status.sha256.slice(0, 16)}…`}
</code> </Code>
) : null} ) : null}
{status?.message && (failed || verified) ? ( {status?.message && (failed || verified) ? (
<div <Banner
className={`runtime-error ${verified ? "is-ok" : ""}`} tone={verified ? "success" : "danger"}
icon={verified ? <ShieldCheck size={15} /> : undefined}
compact
className="runtime-error"
role={verified ? "status" : "alert"} role={verified ? "status" : "alert"}
> >
<span>{verified ? t("updateVerified") : status.message}</span> {verified ? t("updateVerified") : status.message}
</div> </Banner>
) : null} ) : null}
{/* An install that could not run leaves the verified download in place, so it {/* An install that could not run leaves the verified download in place, so it
is reported beside the button instead of rewriting the status. */} is reported beside the button instead of rewriting the status. */}
{installError ? ( {installError ? (
<div className="runtime-error" role="alert"> <Banner tone="danger" compact className="runtime-error" role="alert">
<span>{installError}</span> {installError}
</div> </Banner>
) : null} ) : null}
<div className="update-actions"> <div className="update-actions">
{available && !verified ? ( {available && !verified ? (
<button <Button
className="update-action is-commit" variant="primary"
size="md"
onClick={() => void download()} onClick={() => void download()}
disabled={downloading} disabled={downloading}
> >
{downloading ? <LoaderCircle size={15} className="spin" /> : <Download size={15} />} {downloading ? <LoaderCircle size={15} className="spin" /> : <Download size={15} />}
{downloading ? t("updateDownloading") : t("updateDownload")} {downloading ? t("updateDownloading") : t("updateDownload")}
</button> </Button>
) : null} ) : null}
{verified ? ( {verified ? (
<button <Button
className="update-action is-commit" variant="primary"
size="md"
onClick={() => void install()} onClick={() => void install()}
disabled={installing} disabled={installing}
> >
{installing ? <LoaderCircle size={15} className="spin" /> : <Check size={15} />} {installing ? <LoaderCircle size={15} className="spin" /> : <Check size={15} />}
{installing ? t("updateInstalling") : t("updateInstall")} {installing ? t("updateInstalling") : t("updateInstall")}
</button> </Button>
) : null} ) : null}
{/* An install is a countdown to this process exiting, so the row drops the {/* An install is a countdown to this process exiting, so the row drops the
choice that only resets what is already decided. */} choice that only resets what is already decided. */}
{verified && !installing ? ( {verified && !installing ? (
<button className="update-action" onClick={() => void clear()}> <Button variant="secondary" size="md" onClick={() => void clear()}>
<X size={15} /> <X size={15} />
{t("updateDiscard")} {t("updateDiscard")}
</button> </Button>
) : null} ) : null}
</div> </div>
<label className="home-toggle-row home-toggle-divider"> <SwitchRow
<strong>{t("updateAutoCheck")}</strong> label={t("updateAutoCheck")}
<button checked={autoCheck}
className={`home-toggle ${autoCheck ? "is-on" : ""}`} onChange={onAutoCheckChange}
onClick={() => onAutoCheckChange(!autoCheck)} divider
aria-pressed={autoCheck} />
>
<span />
</button>
</label>
<p className="runtime-summary">{t("updateBody")}</p> <p className="runtime-summary">{t("updateBody")}</p>
</section> </Section>
); );
} }

View File

@ -1,6 +1,8 @@
import { StrictMode } from "react"; import { StrictMode } from "react";
import { createRoot } from "react-dom/client"; import { createRoot } from "react-dom/client";
import App from "./App"; import App from "./App";
import "./ui/tokens.css";
import "./ui/components.css";
import "./styles.css"; import "./styles.css";
createRoot(document.getElementById("root")!).render( createRoot(document.getElementById("root")!).render(

File diff suppressed because it is too large Load Diff

1166
src/ui/components.css 100644

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,478 @@
import {
forwardRef,
type ButtonHTMLAttributes,
type ElementType,
type HTMLAttributes,
type InputHTMLAttributes,
type LabelHTMLAttributes,
type ReactNode,
type TextareaHTMLAttributes,
} from "react";
import { Check, Search, X } from "lucide-react";
function cx(...parts: Array<string | false | null | undefined>) {
return parts.filter(Boolean).join(" ");
}
export type ButtonVariant =
| "primary"
| "secondary"
| "ghost"
| "quiet"
| "outline"
| "danger"
| "success"
| "toolbar"
| "toolbar-primary"
| "toolbar-danger"
| "inverse"
| "glass-dark"
| "plain"
| "card"
| "tab";
export type ButtonSize = "xs" | "sm" | "md" | "lg" | "xl";
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
variant?: ButtonVariant;
size?: ButtonSize;
iconOnly?: boolean;
active?: boolean;
block?: boolean;
}
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(
{
variant = "secondary",
size = "md",
iconOnly = false,
active = false,
block = false,
className,
type = "button",
...props
},
ref,
) {
return (
<button
ref={ref}
type={type}
className={cx(
"ui-button",
`ui-button--${variant}`,
`ui-button--${size}`,
iconOnly && "ui-button--icon",
block && "ui-button--block",
active && "is-active",
className,
)}
data-active={active || undefined}
{...props}
/>
);
});
export interface IconButtonProps extends Omit<ButtonProps, "children" | "iconOnly"> {
label: string;
children: ReactNode;
}
export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(function IconButton(
{ label, title, variant = "ghost", size = "sm", className, children, ...props },
ref,
) {
return (
<Button
ref={ref}
variant={variant}
size={size}
iconOnly
aria-label={label}
title={title ?? label}
className={className}
{...props}
>
{children}
</Button>
);
});
export type SurfaceVariant =
| "glass"
| "solid"
| "muted"
| "inset"
| "danger"
| "dark"
| "plain";
export type SurfaceRadius = "sm" | "md" | "lg" | "xl" | "hero";
export interface SurfaceProps extends HTMLAttributes<HTMLDivElement> {
variant?: SurfaceVariant;
radius?: SurfaceRadius;
as?: ElementType;
}
export function Surface({
variant = "glass",
radius = "lg",
as: Component = "div",
className,
...props
}: SurfaceProps) {
return (
<Component
className={cx(
"ui-surface",
`ui-surface--${variant}`,
`ui-surface--radius-${radius}`,
className,
)}
{...props}
/>
);
}
export interface SectionProps extends HTMLAttributes<HTMLElement> {}
export function Section({ className, ...props }: SectionProps) {
return <section className={cx("ui-section", className)} {...props} />;
}
export interface SectionTitleProps extends HTMLAttributes<HTMLDivElement> {
icon?: ReactNode;
actions?: ReactNode;
}
export function SectionTitle({ icon, actions, children, className, ...props }: SectionTitleProps) {
return (
<div className={cx("ui-section-title", className)} {...props}>
{icon}
<span className="ui-section-title__copy">{children}</span>
{actions ? <span className="ui-section-title__actions">{actions}</span> : null}
</div>
);
}
export type BadgeTone = "neutral" | "accent" | "success" | "danger" | "warning" | "info";
export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
tone?: BadgeTone;
plain?: boolean;
}
export function Badge({ tone = "neutral", plain = false, className, ...props }: BadgeProps) {
return (
<span
className={cx("ui-badge", `ui-badge--${tone}`, plain && "ui-badge--plain", className)}
{...props}
/>
);
}
export type BannerTone = "accent" | "success" | "danger" | "neutral";
export interface BannerProps extends HTMLAttributes<HTMLDivElement> {
tone?: BannerTone;
icon?: ReactNode;
action?: ReactNode;
compact?: boolean;
inline?: boolean;
}
export function Banner({
tone = "accent",
icon,
action,
compact = false,
inline = false,
children,
className,
...props
}: BannerProps) {
return (
<div
className={cx(
"ui-banner",
`ui-banner--${tone}`,
compact && "ui-banner--compact",
inline && "ui-banner--inline",
className,
)}
{...props}
>
{icon}
<span className="ui-banner__copy">{children}</span>
{action ? <span className="ui-banner__action">{action}</span> : null}
</div>
);
}
export interface SwitchRowProps {
label: ReactNode;
checked: boolean;
onChange: (checked: boolean) => void;
divider?: boolean;
disabled?: boolean;
className?: string;
}
export function SwitchRow({
label,
checked,
onChange,
divider = false,
disabled = false,
className,
}: SwitchRowProps) {
return (
<div className={cx("ui-switch-row", divider && "ui-switch-row--divider", className)}>
<span className="ui-switch-row__label">{label}</span>
<button
type="button"
role="switch"
aria-checked={checked}
className="ui-switch"
disabled={disabled}
onClick={() => onChange(!checked)}
/>
</div>
);
}
export interface SegmentedOption<T extends string> {
value: T;
label: ReactNode;
}
export interface SegmentedProps<T extends string> {
value: T;
options: Array<SegmentedOption<T>>;
onChange: (value: T) => void;
ariaLabel: string;
className?: string;
}
export function Segmented<T extends string>({
value,
options,
onChange,
ariaLabel,
className,
}: SegmentedProps<T>) {
return (
<div className={cx("ui-segmented", className)} role="radiogroup" aria-label={ariaLabel}>
{options.map((option) => (
<button
key={option.value}
type="button"
role="radio"
aria-checked={value === option.value}
className="ui-segmented__item"
onClick={() => onChange(option.value)}
>
{option.label}
</button>
))}
</div>
);
}
export const Input = forwardRef<HTMLInputElement, InputHTMLAttributes<HTMLInputElement>>(
function Input({ className, ...props }, ref) {
return <input ref={ref} className={cx("ui-input", className)} {...props} />;
},
);
export const Textarea = forwardRef<HTMLTextAreaElement, TextareaHTMLAttributes<HTMLTextAreaElement>>(
function Textarea({ className, ...props }, ref) {
return <textarea ref={ref} className={cx("ui-textarea", className)} {...props} />;
},
);
export interface SearchFieldProps {
value: string;
onChange: (value: string) => void;
placeholder: string;
clearLabel: string;
className?: string;
}
export function SearchField({
value,
onChange,
placeholder,
clearLabel,
className,
}: SearchFieldProps) {
return (
<label className={cx("ui-search", className)}>
<Search size={15} />
<input
className="ui-search__input"
value={value}
placeholder={placeholder}
onChange={(event) => onChange(event.target.value)}
/>
{value ? (
<IconButton
label={clearLabel}
variant="ghost"
size="xs"
onClick={() => onChange("")}
>
<X size={13} />
</IconButton>
) : null}
</label>
);
}
export interface ProgressBarProps {
value?: number;
indeterminate?: boolean;
tone?: "accent" | "success";
size?: "xs" | "sm" | "md" | "lg";
label?: ReactNode;
className?: string;
}
export function ProgressBar({
value = 0,
indeterminate = false,
tone = "accent",
size = "sm",
label,
className,
}: ProgressBarProps) {
return (
<div
className={cx(
"ui-progress",
`ui-progress--${size}`,
`ui-progress--${tone}`,
indeterminate && "ui-progress--indeterminate",
className,
)}
role="progressbar"
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={indeterminate ? undefined : Math.round(value)}
>
<span
className="ui-progress__fill"
style={indeterminate ? undefined : { width: `${Math.max(0, Math.min(100, value))}%` }}
/>
{label ? <span className="ui-progress__label">{label}</span> : null}
</div>
);
}
export interface EmptyStateProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
glyph?: ReactNode;
title?: ReactNode;
}
export function EmptyState({ glyph, title, children, className, ...props }: EmptyStateProps) {
return (
<div className={cx("ui-empty", className)} {...props}>
{glyph ? <span className="ui-empty__glyph">{glyph}</span> : null}
{title ? <strong className="ui-empty__title">{title}</strong> : null}
{children ? <p className="ui-empty__copy">{children}</p> : null}
</div>
);
}
export interface ToastProps extends HTMLAttributes<HTMLDivElement> {
tone?: "neutral" | "error";
size?: "sm" | "md";
}
export function Toast({ tone = "neutral", size = "md", className, ...props }: ToastProps) {
return (
<div className={cx("ui-toast", `ui-toast--${tone}`, `ui-toast--${size}`, className)} {...props} />
);
}
export interface ToolbarProps extends HTMLAttributes<HTMLDivElement> {
tone?: "light" | "dark";
variant?: "floating" | "bar";
}
export const Toolbar = forwardRef<HTMLDivElement, ToolbarProps>(function Toolbar(
{ tone = "light", variant = "floating", className, ...props },
ref,
) {
return (
<div
ref={ref}
className={cx(
"ui-toolbar",
`ui-toolbar--${variant}`,
tone === "dark" && "ui-toolbar--dark",
className,
)}
{...props}
/>
);
});
export function ToolbarDivider({ className }: { className?: string }) {
return <span className={cx("ui-toolbar__divider", className)} aria-hidden="true" />;
}
export function CheckboxMark({ checked }: { checked: boolean }) {
return (
<span className="ui-checkbox__box" data-checked={checked || undefined} aria-hidden="true">
{checked ? <Check size={11} strokeWidth={3} /> : null}
</span>
);
}
export interface CheckboxProps
extends Omit<LabelHTMLAttributes<HTMLLabelElement>, "onChange"> {
checked: boolean;
onChange: (checked: boolean) => void;
disabled?: boolean;
}
export const Checkbox = forwardRef<HTMLLabelElement, CheckboxProps>(function Checkbox(
{ checked, onChange, disabled = false, className, children, ...props },
ref,
) {
return (
<label ref={ref} className={cx("ui-checkbox", className)} {...props}>
<input
type="checkbox"
checked={checked}
disabled={disabled}
onChange={() => onChange(!checked)}
/>
<CheckboxMark checked={checked} />
{children}
</label>
);
});
export interface KbdProps {
children: ReactNode;
tone?: "light" | "dark";
size?: "sm" | "md";
}
export function Kbd({ children, tone = "light", size = "md" }: KbdProps) {
return (
<kbd className={cx("ui-kbd", `ui-kbd--${tone}`, `ui-kbd--${size}`)}>
{children}
</kbd>
);
}
export function Code({ children, className, ...props }: HTMLAttributes<HTMLElement>) {
return (
<code className={cx("ui-code", className)} {...props}>
{children}
</code>
);
}

123
src/ui/tokens.css 100644
View File

@ -0,0 +1,123 @@
:root {
color-scheme: light;
font-family:
-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "PingFang SC",
"Hiragino Sans GB", "Microsoft YaHei", sans-serif;
color: var(--ui-text);
background: transparent;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
--ui-font-sans:
-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "PingFang SC",
"Hiragino Sans GB", "Microsoft YaHei", sans-serif;
--ui-font-mono: "SFMono-Regular", "SF Mono", "Cascadia Code", ui-monospace, monospace;
--ui-text: #342019;
--ui-text-strong: #2d1a11;
--ui-text-soft: #6f5447;
--ui-text-muted: #92786a;
--ui-text-faint: #aa9081;
--ui-text-on-dark: #fff7f1;
--ui-text-on-accent: #fff8f2;
--ui-bg: #f5eee7;
--ui-bg-elevated: #fbf7f2;
--ui-surface: rgba(255, 252, 249, 0.78);
--ui-surface-strong: #fffbf7;
--ui-surface-solid: #fff;
--ui-surface-hover: #fff;
--ui-surface-muted: rgba(91, 55, 35, 0.055);
--ui-surface-inset: rgba(255, 255, 255, 0.62);
--ui-surface-dark: rgba(31, 26, 25, 0.9);
--ui-border: rgba(89, 51, 34, 0.1);
--ui-border-soft: rgba(89, 51, 34, 0.07);
--ui-border-strong: rgba(89, 51, 34, 0.18);
--ui-border-on-dark: rgba(255, 255, 255, 0.14);
--ui-accent: #f26a33;
--ui-accent-strong: #d94f1f;
--ui-accent-soft: #fff0e5;
--ui-accent-wash: rgba(242, 106, 51, 0.1);
--ui-accent-line: rgba(242, 106, 51, 0.24);
--ui-focus: rgba(242, 106, 51, 0.55);
--ui-focus-ring: 0 0 0 3px rgba(242, 106, 51, 0.14);
--ui-success: #14794a;
--ui-success-strong: #0f6439;
--ui-success-soft: #edf8f1;
--ui-danger: #b8442a;
--ui-danger-strong: #9c3d2f;
--ui-danger-soft: #fff0ed;
--ui-warning: #a84c29;
--ui-warning-soft: #fff1e7;
--ui-info: #4b6fa8;
--ui-info-soft: #eaf0fb;
--ui-shadow-xs: 0 2px 7px rgba(74, 43, 27, 0.08);
--ui-shadow-sm: 0 8px 24px rgba(74, 43, 27, 0.09);
--ui-shadow-md: 0 14px 38px rgba(74, 43, 27, 0.14);
--ui-shadow-lg: 0 28px 76px rgba(62, 33, 18, 0.22);
--ui-shadow-dark: 0 16px 44px rgba(0, 0, 0, 0.28);
--ui-radius-xs: 7px;
--ui-radius-sm: 10px;
--ui-radius-md: 13px;
--ui-radius-lg: 16px;
--ui-radius-xl: 22px;
--ui-radius-hero: 26px;
--ui-radius-pill: 999px;
--ui-space-1: 2px;
--ui-space-2: 4px;
--ui-space-3: 6px;
--ui-space-4: 8px;
--ui-space-5: 10px;
--ui-space-6: 12px;
--ui-space-7: 16px;
--ui-space-8: 20px;
--ui-space-9: 24px;
--ui-space-10: 32px;
--ui-control-xs: 26px;
--ui-control-sm: 32px;
--ui-control-md: 36px;
--ui-control-lg: 44px;
--ui-control-xl: 46px;
--ui-text-3xs: 11px;
--ui-text-2xs: 12.5px;
--ui-text-xs: 13.5px;
--ui-text-sm: 14.5px;
--ui-text-md: 16px;
--ui-text-lg: 18px;
--ui-text-xl: 21px;
--ui-text-hero: clamp(28px, 3vw, 38px);
--ui-dimmed: 0.55;
--ui-duration-fast: 140ms;
--ui-duration: 180ms;
--ui-ease: cubic-bezier(0.22, 0.68, 0.32, 1);
/* Compatibility aliases for view-level layout code while it is migrated. */
--ink: var(--ui-text);
--muted: var(--ui-text-muted);
--orange: var(--ui-accent);
--orange-deep: var(--ui-accent-strong);
--cream: #fff6ee;
--paper: var(--ui-bg-elevated);
--line: var(--ui-border);
--text-3xs: var(--ui-text-3xs);
--text-2xs: var(--ui-text-2xs);
--text-xs: var(--ui-text-xs);
--text-sm: var(--ui-text-sm);
--text-md: var(--ui-text-md);
--text-lg: var(--ui-text-lg);
--text-xl: var(--ui-text-xl);
--text-hero: var(--ui-text-hero);
--dimmed: var(--ui-dimmed);
--radius-sm: var(--ui-radius-md);
--radius-md: var(--ui-radius-lg);
}