дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-28 21:42:27 +02:00
When the system WebKit predates Safari 15.4 (macOS 11, and 12 before 12.3) and Safari's update has staged a newer WebKit, main re-execs once with DYLD_FRAMEWORK_PATH pointing at the staged frameworks and clears it again in the second process, so child processes keep the system frameworks. macOS 12.3+ and 13+ keep the system engine without a restart; an unreadable system version also keeps it. - Entitlements: allow-dyld-environment-variables only; library validation stays on (the staged framework is Apple-signed). - Bundle and link minimum back to 11.0 so Launch Services opens the app on Big Sur; .cargo/config.toml sets MACOSX_DEPLOYMENT_TARGET as a default a developer can override. - The staged copy is checked with a stat before the system version is read, so current macOS never spawns defaults at startup. - Debug builds skip the bindings export when the build checkout is absent. - Boot error page, install and contributor docs describe the Big Sur case. Tested by the contributor on macOS 11.7.11 (Safari 16.6.1 staged) and 26.5; by us on macOS 15.7.8 (no re-exec). Co-authored-by: qq471754603 <[email protected]>
55 рядки
4.7 KiB
Plaintext
55 рядки
4.7 KiB
Plaintext
---
|
|
title: "UI guidelines"
|
|
description: "Rules for frontend UI code: design tokens, CSS Modules, icons, the UI primitives, accessibility and WebKit compatibility."
|
|
---
|
|
|
|
The visual style is dark, low-contrast greys and one cool accent. Consistency comes from a small set of rules that apply to every component.
|
|
|
|
## Design tokens
|
|
|
|
[`src/styles/tokens.css`](https://github.com/l0ng-ai/openidea/blob/main/src/styles/tokens.css) is the source of truth for colours and metrics (spacing, sizes, radii, font weights). `:root` holds the dark theme; `[data-theme="light"]` and `[data-theme="dark-hc"]` (high contrast) override it. Themes from plugins and colour-scheme settings set the same variables at runtime.
|
|
|
|
- **Use only tokens in components.** No hex, `rgb()` or named colour literals in a component's CSS or inline styles: `color: var(--fg-muted)`, not `color: #8c8c8c`.
|
|
- **Need a new colour or metric?** Add a token to `tokens.css` for every theme variant, with a name that says what it is for, not what it looks like.
|
|
- **Tokens are part of the theme API.** The token reference in `plugins/themes.md` is generated from `tokens.css` (`pnpm gen:theme-docs`), and `scripts/theme/theme.test.ts` fails when it is stale. Run the generator after adding or renaming a token.
|
|
|
|
## CSS Modules
|
|
|
|
Style components with CSS Modules: `Thing.module.css` next to `Thing.tsx`, imported as `styles` and combined with `clsx`. `src/styles/global.css` is only for document-level rules. Don't add global class names from a feature.
|
|
|
|
## Icons
|
|
|
|
- Icons are inline SVG from [`src/ui/icons.tsx`](https://github.com/l0ng-ai/openidea/blob/main/src/ui/icons.tsx): `<Icon name="folder" />`, or the `icon` prop of `Button` and actions.
|
|
- **Never use emoji** as icons or decoration, in the UI or in user-visible text.
|
|
- An `Icon` without `label` is decorative and rendered `aria-hidden`. Give it a `label` when the icon alone carries meaning.
|
|
- The SVGs live in `src/ui/expui/<group>/` (vendored new-UI icons, with `_dark` and `@20x20` variants) and `src/ui/openidea/<group>/` (the project's own, drawn in the same style), and are registered by name in `icons.tsx`. Names are the contract used by `Action.icon` and contributions. Add new icons there; don't inline ad-hoc SVG in a feature. Monochrome icons are drawn in `currentColor`, so they follow the theme.
|
|
|
|
## UI primitives
|
|
|
|
Build from the primitives in `src/ui/` before writing your own: `Button`, `BarButton`, `Input`, `Checkbox`, `Select`, `Dialog`, `Popup`, `Menu`, `Tooltip`, `List`, `Tree`, `Tabs`, `Splitter`, `Scrollbar`, `Spinner`, `Kbd`, and `T` for translated text. They already handle focus, keyboard navigation, theming and translation of their labels. Workbench-level pieces (tool windows, status items, overlays) come from [contributions](/en/contribute/architecture/frontend#contributions), not from custom layout.
|
|
|
|
Toolbar icon actions use `IconButton`: its full hit target uses `--bg-toolbar-hover` on hover, while pressed and selected states use their corresponding toolbar tokens. Keep semantic icon colours and the keyboard focus ring intact.
|
|
|
|
## Accessibility
|
|
|
|
- Use real `<button>` and `<input>` elements (or the primitives that render them), never clickable `<div>`s.
|
|
- Every icon-only button has an `aria-label`. `aria-label` is one of the props the text catalog translates, so write it in English like any other label.
|
|
- Everything a user can do is an [action](/en/contribute/architecture/frontend#actions) with a stable id, so it is reachable from the keyboard and Find Action, not only by mouse.
|
|
- Keep focus visible and predictable: dialogs and popups return focus to where it came from.
|
|
|
|
## Text
|
|
|
|
User-visible text is written in English at the call site and goes through the text catalog; Chinese is required for every string. See [Localization](/en/contribute/guidelines/i18n).
|
|
|
|
## WebKit compatibility
|
|
|
|
On macOS and Linux the app runs in WebKit, and the supported floor is Safari 15.4, the engine of macOS 12 (the app's minimum). On macOS 11 and on macOS 12 before 12.3, `src-tauri/src/macos_webview.rs` loads the newer WebKit staged by a Safari update, provided that update is installed. `pnpm build` runs `scripts/check-webkit.ts` on the bundle, and `src/platform/webkitCompatibility.test.ts` checks application regexes. Avoid:
|
|
|
|
- regex lookbehind (`(?<=…)`, `(?<!…)`), which needs Safari 16.4, and the regex `v` flag;
|
|
- import attributes;
|
|
- newer runtime APIs in startup code, such as `Promise.withResolvers`, `Object.groupBy`, `Map.groupBy`, `Array.fromAsync`, `String.prototype.isWellFormed`.
|
|
|
|
## Verifying UI changes
|
|
|
|
Run the app (`pnpm tauri dev`) and check the change in both the dark and light themes. PRs that change what users see need before/after screenshots, and multi-step interactions a recording; see [Contribution workflow](/en/contribute/workflow).
|