Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ on:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
check:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
node-version-file: .node-version
- uses: pnpm/action-setup@v4
- run: pnpm install --frozen-lockfile
- run: pnpm check
- run: pnpm build
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24.21.0
22 changes: 22 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"semi": false,
"singleQuote": true,
"arrowParens": "avoid",
"quoteProps": "consistent",
"singleAttributePerLine": true,
"htmlWhitespaceSensitivity": "strict",
"ignorePatterns": [
"docs/content/**",
"docs/.nuxt/**",
"docs/.data/**",
"dist/**",
"public/**",
"**/generated/**",
"**/fixtures/**",
".agents/**",
"docs/plans/**",
"AGENTS.md",
"pnpm-lock.yaml",
"skills-lock.json"
]
}
14 changes: 14 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"plugins": ["typescript", "unicorn", "oxc", "vue"],
"categories": {
"correctness": "error"
},
"ignorePatterns": [
"docs/content/**",
"docs/.nuxt/**",
"docs/.data/**",
"dist/**",
"**/generated/**",
".agents/**"
]
}
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ git subtree pull --prefix=vendor/ui https://github.com/0froq/ui.git main --squas

用户定了之后再改代码,让它在库里和项目里都能运行。不要把项目文件原样复制进 `vendor/ui`。指向页面组件、项目 store、路由、项目类名和项目色值的地方,改成 props、slot,或库里已有的函数;样式改读 `--ui-*`。调用处仍由项目传入文案和数据。改完后,原来的页面还要能渲染。外观如果用了 token 契约里没有的颜色或字体,而且不能改写成那十二个变量,停下来告诉用户缺哪一个,不要给这个组件单开一套变量。

写库里的代码之前,读 `vendor/ui/AGENTS.md` 的「代码规范」,并对照同一层已有文件。规范一节还没有细则时,以同一目录里已有组件为准,并让库的 eslint 通过。不要另起一套写法。
写库里的代码之前,读 `vendor/ui/AGENTS.md` 的「代码规范」,并对照同一层已有文件。规范一节还没有细则时,以同一目录里已有组件为准,并让库的 `pnpm lint` 通过。不要另起一套写法。

1. 定名字和 props。库里已有同一种控件就沿用现有名字,例如 `Choice`、`Toggle`。新控件不要带项目名。props 只保留交互需要的,例如 `v-model`、`options`、`label`。项目专属参数留在本项目里包一层。
2. 行为。不依赖 DOM 结构的逻辑放进 `vendor/ui/src/core/`,不要引用 Vue。需要 Vue、但不关心样子的逻辑放进 `vendor/ui/src/vue/`,并从 `vendor/ui/src/vue/index.ts` 导出。已有 `useChoice` 或其他函数能用就用,不要复制一份。有动效时用 `vendor/ui/src/core` 里的 `prefersReducedMotion`。
Expand Down Expand Up @@ -161,7 +161,7 @@ git subtree pull --prefix=vendor/ui https://github.com/0froq/ui.git main --squas

抽进库的代码要符合这一节。移植前先读这里,再对照同一层已有文件。

eslint 使用 `@antfu/eslint-config`。Vue 单行和多行都是每个属性单独一行。改完在库仓库里跑 `pnpm lint`,或在项目里对 `vendor/ui` 跑同一套配置。不要为了迁就项目原来的格式去关规则。
库仓库使用 Oxlint 与 Oxfmt(Vite+ `vp lint` / `vp fmt`)。Vue 单行和多行都是每个属性单独一行。改完在库仓库里跑 `pnpm lint` 与 `pnpm fmt:check`,或在项目里对 `vendor/ui` 跑同一套配置。不要为了迁就项目原来的格式去关规则。

### 细则

Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) froq

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
58 changes: 35 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,26 @@ docs/ Docs site. It depends on this package. Component and docs change

Everything below is exported from `@froq/ui`.

| Component | Role |
| --- | --- |
| Button / CopyButton | Native button. Async clipboard, stable width |
| TextInput / TextArea / Select / Checkbox | Native fields. Attributes and events reach the control |
| FormField / NumberInput / DateInput / Slider / FileUpload / RadioGroup | Label, error, native value. Validation stays with the caller |
| Choice / ChoiceCircle / Toggle | Controlled choice and switch. Custom radio does not submit a form value |
| ToggleGroup | Single or multiple. Arrow keys move focus. A selected value can be cleared |
| Combobox | Search and multiple selection. Remote requests stay with the caller |
| Calendar / DatePicker | One month. ISO dates, locale, range, disabled dates |
| Navigation / Sidebar | Flat links and collapsible groups. Routing stays with the caller |
| Breadcrumb / Pagination | Path and page links. No router and no data fetching |
| Collapsible / Accordion / Tabs | Controlled panels. Content stays mounted |
| Skeleton / Progress / Spinner / Alert | Loading, progress, wait, inline notice |
| Banner | Site notice. Actions slot. The caller owns dismissal |
| Toast / ToastRegion | Temporary notice and a shared region. The queue stays with the caller |
| IconButton / EmptyState | Named icon button. Empty content and an actions slot |
| Badge / Avatar / Separator / Card / AspectRatio / Table | Mark, image, rule, surface, ratio, native table |
| Dialog / AlertDialog / Drawer / Popover / Menu / Tooltip | Dialog, confirm, side panel, anchored layer, menu, tip |
| ContextMenu / HoverCard | Context menu and link preview. The preview is not required content |
| Paper | Paper texture |
| Component | Role |
| ---------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| Button / CopyButton | Native button. Async clipboard, stable width |
| TextInput / TextArea / Select / Checkbox | Native fields. Attributes and events reach the control |
| FormField / NumberInput / DateInput / Slider / FileUpload / RadioGroup | Label, error, native value. Validation stays with the caller |
| Choice / ChoiceCircle / Toggle | Controlled choice and switch. Custom radio does not submit a form value |
| ToggleGroup | Single or multiple. Arrow keys move focus. A selected value can be cleared |
| Combobox | Search and multiple selection. Remote requests stay with the caller |
| Calendar / DatePicker | One month. ISO dates, locale, range, disabled dates |
| Navigation / Sidebar | Flat links and collapsible groups. Routing stays with the caller |
| Breadcrumb / Pagination | Path and page links. No router and no data fetching |
| Collapsible / Accordion / Tabs | Controlled panels. Content stays mounted |
| Skeleton / Progress / Spinner / Alert | Loading, progress, wait, inline notice |
| Banner | Site notice. Actions slot. The caller owns dismissal |
| Toast / ToastRegion | Temporary notice and a shared region. The queue stays with the caller |
| IconButton / EmptyState | Named icon button. Empty content and an actions slot |
| Badge / Avatar / Separator / Card / AspectRatio / Table | Mark, image, rule, surface, ratio, native table |
| Dialog / AlertDialog / Drawer / Popover / Menu / Tooltip | Dialog, confirm, side panel, anchored layer, menu, tip |
| ContextMenu / HoverCard | Context menu and link preview. The preview is not required content |
| Paper | Paper texture |

Each component has a demo, an English note, and a Chinese note.
The docs site discovers them from the source.
Expand All @@ -64,6 +64,14 @@ Set `data-theme="light"` or `data-theme="dark"` on the scope, or an ancestor, to
`@froq/ui/tokens.css` is enough when a project wants the tokens without the components.
`pnpm check:tokens` fails if a variable is missing, or if a component reads one outside this list.

## Install

```bash
pnpm add @froq/ui
```

Requires Node `^24.21.0 || >=26.0.0` for development of this repo; consumers may use any Node version their bundler supports.

## Use

```ts
Expand Down Expand Up @@ -162,9 +170,13 @@ pnpm dev # docs at http://localhost:3000
pnpm generate # static files in dist/
pnpm deploy # generate, then cf deploy
pnpm preview:deploy # generate, then cf previews deploy
pnpm check # lint, types, token contract
pnpm check # oxlint, oxfmt, types, token contract
pnpm lint:fix # oxlint --fix
pnpm fmt # oxfmt
```

Node **24.21.0** (`.node-version`, `mise.toml`). Lint and format use [Vite+](https://github.com/voidzero-dev/vite-plus) (`vp`) with `.oxlintrc.json` and `.oxfmtrc.json`.

## Docs site

https://ui.froq.me
Expand All @@ -174,7 +186,7 @@ The static output is `dist/` at the repo root.
It deploys to the Cloudflare Worker `ui`.
The Worker config is `cloudflare.config.ts`; the assets directory is in `wrangler.config.ts`.

Workers Builds (GitHub connection, no API token in the repo): `NODE_VERSION=22`, build `pnpm generate`, production `pnpm exec cf deploy`, preview `pnpm exec cf previews deploy`.
Workers Builds (GitHub connection, no API token in the repo): `NODE_VERSION=24.21.0`, build `pnpm generate`, production `pnpm exec cf deploy`, preview `pnpm exec cf previews deploy`.

The docs live in the `docs/` subpackage, so root `cf deploy` does not run generate on its own.
That is why `deploy` is `pnpm generate && cf deploy`.
Expand All @@ -188,7 +200,7 @@ CI installs from the lockfile.

## License

This package has no root license file.
MIT. See [LICENSE](LICENSE).
The handwriting strokes in `src/core/signature/` are SIL OFL 1.1.
Copyright 2010 The Allura Project Authors.
See `OFL.txt` and `NOTICE.md` beside that data.
56 changes: 56 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Release `@froq/ui`

## 0.1.0 (first npm publish)

First public release on npm under the `@froq` scope. The package ships TypeScript and Vue source; consumers compile it with Vite or Nuxt (`build.transpile: ['@froq/ui']`). Runtime peer: `vue` ^3.5.0 (optional for `@froq/ui/core` only).

### After merge: publish to npm

Maintainer only. Do not publish from CI or cloud agents.

1. Confirm [main](https://github.com/0froq/ui) is green and `package.json` `version` is **0.1.0**.
2. Use Node **24.21.0** (`.node-version` / `mise.toml`) and pnpm **12.11.2** (`packageManager` in `package.json`).
3. From the repo root:

```bash
pnpm install --frozen-lockfile
pnpm check
pnpm pack --pack-destination /tmp
tar -tzf /tmp/froq-ui-0.1.0.tgz | head
```

4. Log in as the **froq** npm user (org **`@froq`**):

```bash
npm whoami
# expect: froq
```

5. Publish (public scoped package):

```bash
npm publish --access public
```

6. Tag the release in git (optional but recommended):

```bash
git tag v0.1.0
git push origin v0.1.0
```

7. Update [ui.froq.me](https://ui.froq.me) changelog if the docs site should mention the npm install path (`pnpm add @froq/ui`).

### Publish readiness checklist

| Item | Status |
| ------------------------------------------------ | ------------------------------------------------ |
| `name` is `@froq/ui` | yes |
| `private` is false | yes |
| `publishConfig.access` is `public` | yes |
| `files` includes publishable `src/` | yes |
| `exports` for `.`, `./core`, `./vue`, CSS | yes |
| Runtime deps use registry ranges (no `catalog:`) | yes |
| `engines.node` ^24.21.0 \|\| >=26.0.0 | yes |
| Not yet on npm (first publish) | confirm before publish |
| Root `LICENSE` / license field | MIT; signature assets remain SIL OFL 1.1 in tree |
5 changes: 2 additions & 3 deletions docs/app/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ useHead({
htmlAttrs: {
lang,
},
titleTemplate: (title) => {
if (!title || title === 'froq/ui')
return 'froq/ui'
titleTemplate: title => {
if (!title || title === 'froq/ui') return 'froq/ui'
return `${title} — froq/ui`
},
})
Expand Down
Loading
Loading