@toyonix/web-kit 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +68 -2
- package/config/eslint.js +68 -0
- package/config/prettier.js +20 -0
- package/config/tsconfig.base.json +22 -0
- package/dist/css/base.css +58 -0
- package/dist/css/components.css +915 -0
- package/dist/css/fonts/LICENSE-Newsreader.txt +93 -0
- package/dist/css/fonts/LICENSE-Space-Grotesk.txt +93 -0
- package/dist/css/fonts/LICENSE-Space-Mono.txt +93 -0
- package/dist/css/fonts/newsreader-latin-ext-opsz-italic.woff2 +0 -0
- package/dist/css/fonts/newsreader-latin-ext-opsz-normal.woff2 +0 -0
- package/dist/css/fonts/newsreader-latin-opsz-italic.woff2 +0 -0
- package/dist/css/fonts/newsreader-latin-opsz-normal.woff2 +0 -0
- package/dist/css/fonts/space-grotesk-latin-400-normal.woff2 +0 -0
- package/dist/css/fonts/space-grotesk-latin-500-normal.woff2 +0 -0
- package/dist/css/fonts/space-grotesk-latin-700-normal.woff2 +0 -0
- package/dist/css/fonts/space-grotesk-latin-ext-400-normal.woff2 +0 -0
- package/dist/css/fonts/space-grotesk-latin-ext-500-normal.woff2 +0 -0
- package/dist/css/fonts/space-grotesk-latin-ext-700-normal.woff2 +0 -0
- package/dist/css/fonts/space-mono-latin-400-normal.woff2 +0 -0
- package/dist/css/fonts/space-mono-latin-700-normal.woff2 +0 -0
- package/dist/css/fonts/space-mono-latin-ext-400-normal.woff2 +0 -0
- package/dist/css/fonts/space-mono-latin-ext-700-normal.woff2 +0 -0
- package/dist/css/fonts.css +141 -0
- package/dist/css/index.css +10 -0
- package/dist/css/tailwind.css +46 -0
- package/dist/css/tokens.css +66 -0
- package/dist/env.d.ts +28 -0
- package/dist/env.js +62 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/next/index.d.ts +36 -0
- package/dist/next/index.js +103 -0
- package/dist/react/Alert.d.ts +8 -0
- package/dist/react/Alert.js +16 -0
- package/dist/react/AppLink.d.ts +11 -0
- package/dist/react/AppLink.js +12 -0
- package/dist/react/AppShell.d.ts +20 -0
- package/dist/react/AppShell.js +94 -0
- package/dist/react/Badge.d.ts +10 -0
- package/dist/react/Badge.js +29 -0
- package/dist/react/Button.d.ts +16 -0
- package/dist/react/Button.js +36 -0
- package/dist/react/Card.d.ts +21 -0
- package/dist/react/Card.js +61 -0
- package/dist/react/CodeBlock.d.ts +8 -0
- package/dist/react/CodeBlock.js +16 -0
- package/dist/react/Dialog.d.ts +16 -0
- package/dist/react/Dialog.js +33 -0
- package/dist/react/DropdownMenu.d.ts +12 -0
- package/dist/react/DropdownMenu.js +36 -0
- package/dist/react/Table.d.ts +5 -0
- package/dist/react/Table.js +15 -0
- package/dist/react/Tabs.d.ts +9 -0
- package/dist/react/Tabs.js +26 -0
- package/dist/react/ThemeScript.d.ts +9 -0
- package/dist/react/ThemeScript.js +15 -0
- package/dist/react/ThemeToggle.d.ts +5 -0
- package/dist/react/ThemeToggle.js +22 -0
- package/dist/react/Tooltip.d.ts +13 -0
- package/dist/react/Tooltip.js +21 -0
- package/dist/react/cx.d.ts +4 -0
- package/dist/react/cx.js +7 -0
- package/dist/react/form.d.ts +19 -0
- package/dist/react/form.js +76 -0
- package/dist/react/index.d.ts +21 -0
- package/dist/react/index.js +21 -0
- package/dist/react/layout.d.ts +7 -0
- package/dist/react/layout.js +29 -0
- package/dist/react/typography.d.ts +23 -0
- package/dist/react/typography.js +46 -0
- package/dist/react/use-registry.d.ts +9 -0
- package/dist/react/use-registry.js +41 -0
- package/dist/react/use-theme.d.ts +18 -0
- package/dist/react/use-theme.js +46 -0
- package/dist/registry/build.d.ts +28 -0
- package/dist/registry/build.js +91 -0
- package/dist/registry/index.d.ts +49 -0
- package/dist/registry/index.js +84 -0
- package/dist/slugs.d.ts +15 -0
- package/dist/slugs.js +37 -0
- package/dist/storage/index.d.ts +39 -0
- package/dist/storage/index.js +123 -0
- package/dist/theme.d.ts +19 -0
- package/dist/theme.js +26 -0
- package/package.json +111 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ToYoNiX
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,69 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @toyonix/web-kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Shared design system, components, and tooling for toyonix static sites (Next.js static export on
|
|
4
|
+
GitHub Pages). New sites should start from the `web-starter` template, which wires all of this up.
|
|
5
|
+
|
|
6
|
+
## Setup
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
// next.config.ts
|
|
10
|
+
import { withWebKit } from "@toyonix/web-kit/next";
|
|
11
|
+
export default withWebKit({}); // static export, basePath from the repo name
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```css
|
|
15
|
+
/* app/globals.css */
|
|
16
|
+
@import "tailwindcss";
|
|
17
|
+
@import "@toyonix/web-kit/tailwind.css";
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
// app/layout.tsx
|
|
22
|
+
import { AppShell, ThemeScript } from "@toyonix/web-kit/react";
|
|
23
|
+
import { getRegistrySnapshot } from "@toyonix/web-kit/registry";
|
|
24
|
+
import "./globals.css";
|
|
25
|
+
|
|
26
|
+
export default async function RootLayout({ children }: { children: React.ReactNode }) {
|
|
27
|
+
return (
|
|
28
|
+
<html lang="en" suppressHydrationWarning>
|
|
29
|
+
<head>
|
|
30
|
+
<ThemeScript />
|
|
31
|
+
</head>
|
|
32
|
+
<body>
|
|
33
|
+
<AppShell registry={await getRegistrySnapshot()}>{children}</AppShell>
|
|
34
|
+
</body>
|
|
35
|
+
</html>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Configs: `export { default } from "@toyonix/web-kit/eslint"` (eslint.config.mjs),
|
|
41
|
+
`export { default } from "@toyonix/web-kit/prettier"` (prettier.config.mjs), and
|
|
42
|
+
`"extends": "@toyonix/web-kit/tsconfig.json"`.
|
|
43
|
+
|
|
44
|
+
## Entry points
|
|
45
|
+
|
|
46
|
+
| Import | What |
|
|
47
|
+
| -------------------------------------------------------- | --------------------------------------------------------------- |
|
|
48
|
+
| `@toyonix/web-kit` | `withBasePath`, `appHref`, `getAppId`, slugs, theme helpers |
|
|
49
|
+
| `@toyonix/web-kit/react` | `AppShell`, `ThemeScript`, `useTheme`, components |
|
|
50
|
+
| `@toyonix/web-kit/storage` | namespaced `storage.app` / `storage.session` / `storage.shared` |
|
|
51
|
+
| `@toyonix/web-kit/registry` | registry types, `getRegistrySnapshot`, `fetchRegistry` |
|
|
52
|
+
| `@toyonix/web-kit/registry/build` | `buildRegistry` (root site only, Node) |
|
|
53
|
+
| `@toyonix/web-kit/next` | `withWebKit` for next.config |
|
|
54
|
+
| `@toyonix/web-kit/css` | all CSS without Tailwind (works in plain HTML) |
|
|
55
|
+
| `@toyonix/web-kit/tailwind.css` | all CSS + Tailwind theme mapped to the tokens |
|
|
56
|
+
| `@toyonix/web-kit/eslint`, `/prettier`, `/tsconfig.json` | shared configs |
|
|
57
|
+
|
|
58
|
+
## Rules for sites
|
|
59
|
+
|
|
60
|
+
- Use tokens (`bg-surface`, `text-accent-text`, `var(--tx-accent)`), never hard-coded colors.
|
|
61
|
+
Tailwind's default palette is removed on purpose.
|
|
62
|
+
- Use `storage` for localStorage/sessionStorage/IndexedDB names; every app shares one origin.
|
|
63
|
+
- In-app links: `next/link`. Links to other toyonix apps: `<AppLink app="gen">` or `appHref()`.
|
|
64
|
+
- Don't copy kit components into a site. If something is missing, add it to the kit.
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
MIT. Bundled fonts (Newsreader, Space Grotesk, Space Mono) are under the SIL Open Font License
|
|
69
|
+
1.1; see `dist/css/fonts/LICENSE-*.txt`.
|
package/config/eslint.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// @toyonix/web-kit/eslint: shared ESLint flat config for toyonix sites.
|
|
2
|
+
//
|
|
3
|
+
// // eslint.config.mjs
|
|
4
|
+
// export { default } from "@toyonix/web-kit/eslint";
|
|
5
|
+
//
|
|
6
|
+
// Next core-web-vitals + TypeScript (including type-aware rules), plus the platform rules:
|
|
7
|
+
// storage only through the kit (spec §6) and no deep imports into the kit.
|
|
8
|
+
import { defineConfig, globalIgnores } from "eslint/config";
|
|
9
|
+
import nextVitals from "eslint-config-next/core-web-vitals";
|
|
10
|
+
import nextTs from "eslint-config-next/typescript";
|
|
11
|
+
import tseslint from "typescript-eslint";
|
|
12
|
+
|
|
13
|
+
const STORAGE_MESSAGE =
|
|
14
|
+
"All toyonix apps share one origin. Use `storage` from @toyonix/web-kit/storage so keys stay namespaced.";
|
|
15
|
+
const COOKIE_MESSAGE =
|
|
16
|
+
"All toyonix apps share one origin. If you really need a cookie, set Path=cookiePath() from @toyonix/web-kit/storage and disable this rule on that line.";
|
|
17
|
+
|
|
18
|
+
/** The toyonix platform rules on their own, for composing a custom config. */
|
|
19
|
+
export const platformRules = defineConfig({
|
|
20
|
+
name: "toyonix/platform",
|
|
21
|
+
rules: {
|
|
22
|
+
// toyonix sites use the App Router; this rule only knows pages/ and warns when it is missing.
|
|
23
|
+
"@next/next/no-html-link-for-pages": "off",
|
|
24
|
+
"no-restricted-globals": [
|
|
25
|
+
"error",
|
|
26
|
+
...["localStorage", "sessionStorage", "indexedDB"].map((name) => ({ name, message: STORAGE_MESSAGE })),
|
|
27
|
+
],
|
|
28
|
+
"no-restricted-properties": [
|
|
29
|
+
"error",
|
|
30
|
+
...["localStorage", "sessionStorage", "indexedDB"].flatMap((property) =>
|
|
31
|
+
["window", "globalThis", "self"].map((object) => ({ object, property, message: STORAGE_MESSAGE })),
|
|
32
|
+
),
|
|
33
|
+
{ object: "document", property: "cookie", message: COOKIE_MESSAGE },
|
|
34
|
+
],
|
|
35
|
+
"no-restricted-imports": [
|
|
36
|
+
"error",
|
|
37
|
+
{
|
|
38
|
+
patterns: [
|
|
39
|
+
{
|
|
40
|
+
group: ["@toyonix/web-kit/dist/*", "@toyonix/web-kit/src/*"],
|
|
41
|
+
message:
|
|
42
|
+
"Import from @toyonix/web-kit's public entry points only; internals change without notice.",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export default defineConfig([
|
|
51
|
+
...nextVitals,
|
|
52
|
+
...nextTs,
|
|
53
|
+
{
|
|
54
|
+
name: "toyonix/type-aware",
|
|
55
|
+
files: ["**/*.{ts,tsx,mts,cts}"],
|
|
56
|
+
extends: [tseslint.configs.recommendedTypeCheckedOnly],
|
|
57
|
+
languageOptions: { parserOptions: { projectService: true } },
|
|
58
|
+
},
|
|
59
|
+
platformRules,
|
|
60
|
+
globalIgnores([
|
|
61
|
+
"**/.next/**",
|
|
62
|
+
"**/out/**",
|
|
63
|
+
"**/build/**",
|
|
64
|
+
"**/dist/**",
|
|
65
|
+
"**/coverage/**",
|
|
66
|
+
"**/next-env.d.ts",
|
|
67
|
+
]),
|
|
68
|
+
]);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// @toyonix/web-kit/prettier: shared Prettier config for toyonix sites.
|
|
2
|
+
//
|
|
3
|
+
// // prettier.config.mjs
|
|
4
|
+
// export { default } from "@toyonix/web-kit/prettier";
|
|
5
|
+
//
|
|
6
|
+
// The Tailwind plugin sorts class names; it reads the theme from app/globals.css by default.
|
|
7
|
+
import * as tailwind from "prettier-plugin-tailwindcss";
|
|
8
|
+
|
|
9
|
+
/** Builds the config, e.g. when the Tailwind entry stylesheet lives somewhere other than app/globals.css. */
|
|
10
|
+
export function createPrettierConfig({ tailwindStylesheet = "./app/globals.css" } = {}) {
|
|
11
|
+
/** @type {import("prettier").Config & { tailwindStylesheet?: string }} */
|
|
12
|
+
const config = {
|
|
13
|
+
printWidth: 110,
|
|
14
|
+
plugins: [tailwind],
|
|
15
|
+
tailwindStylesheet,
|
|
16
|
+
};
|
|
17
|
+
return config;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default createPrettierConfig();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"display": "@toyonix/web-kit site base",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"target": "ES2022",
|
|
6
|
+
"lib": ["DOM", "DOM.Iterable", "ES2023"],
|
|
7
|
+
"module": "ESNext",
|
|
8
|
+
"moduleResolution": "Bundler",
|
|
9
|
+
"jsx": "react-jsx",
|
|
10
|
+
"strict": true,
|
|
11
|
+
"noUncheckedIndexedAccess": true,
|
|
12
|
+
"noImplicitOverride": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"esModuleInterop": true,
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
"allowJs": false,
|
|
18
|
+
"noEmit": true,
|
|
19
|
+
"incremental": true,
|
|
20
|
+
"plugins": [{ "name": "next" }]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Element defaults. Loaded in the `base` cascade layer, so Tailwind utilities and app CSS
|
|
3
|
+
* always win. Sizes and margins are left to components (.tx-display, .tx-prose, …) so plain
|
|
4
|
+
* elements stay predictable.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
*,
|
|
8
|
+
*::before,
|
|
9
|
+
*::after {
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
html {
|
|
14
|
+
-webkit-text-size-adjust: 100%;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
body {
|
|
18
|
+
margin: 0;
|
|
19
|
+
background-color: var(--tx-bg);
|
|
20
|
+
color: var(--tx-text);
|
|
21
|
+
font-family: var(--tx-font-sans);
|
|
22
|
+
font-size: 16px;
|
|
23
|
+
line-height: 1.6;
|
|
24
|
+
-webkit-font-smoothing: antialiased;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
h1,
|
|
28
|
+
h2,
|
|
29
|
+
h3,
|
|
30
|
+
h4 {
|
|
31
|
+
font-family: var(--tx-font-heading);
|
|
32
|
+
font-weight: var(--tx-heading-weight);
|
|
33
|
+
letter-spacing: var(--tx-heading-tracking);
|
|
34
|
+
text-transform: var(--tx-heading-transform);
|
|
35
|
+
line-height: 1.15;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
a {
|
|
39
|
+
color: var(--tx-accent-text);
|
|
40
|
+
text-underline-offset: 3px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
code,
|
|
44
|
+
kbd,
|
|
45
|
+
pre,
|
|
46
|
+
samp {
|
|
47
|
+
font-family: var(--tx-font-mono);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
::selection {
|
|
51
|
+
background: var(--tx-accent);
|
|
52
|
+
color: var(--tx-accent-contrast);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
:focus-visible {
|
|
56
|
+
outline: var(--tx-border-width) solid var(--tx-ring);
|
|
57
|
+
outline-offset: 2px;
|
|
58
|
+
}
|