Skip to content

Commit 6ab92fd

Browse files
authored
feat(react): add Card variant prop, type fixes, and Pro app (#85)
* fix(react): fix NativeSelect children type and Table optional dataIndex - NativeSelect children type now accepts arrays of ReactElements - Table ColumnType.dataIndex is now optional for action columns - Updated getValue helper to handle undefined dataIndex gracefully * feat(card): add variant prop with outlined, elevated, and filled styles - Add CardVariant type: 'outlined' | 'elevated' | 'filled' - outlined: border (default, same as bordered=true) - elevated: box-shadow using --ty-shadow-card token - filled: subtle background using --ty-color-fill token - variant takes precedence over deprecated bordered prop - Full backward compatibility: existing bordered prop still works - Added Variant demo and updated docs (EN + CN) * feat(pro): add Tiny Design Pro app with UI block examples Next.js 15 static site with 20 block categories and 25 blocks showcasing @tiny-design/react components. Features include: - Live preview with responsive viewport toggle (desktop/tablet/mobile) - Source code view with syntax highlighting and copy button - Light/dark theme support with anti-FOUC script - Static export for GitHub Pages deployment at /tiny-design/pro/ * feat(docs): add Pro nav link and update deploy workflow - Add "Pro" link with "New" badge to docs header navigation - Update deploy-site.yml to build and merge pro app output into the combined GitHub Pages deployment at /tiny-design/pro/ * chore: update pnpm-lock.yaml * chore: add changeset for card variant and type fixes * fix(icon): add missing semicolons in svg-icons demo * refactor(pro): use react-runner for block previews Replace direct component imports with react-runner's useRunner hook. Blocks are now rendered from their raw source strings, making the source code the single source of truth for both preview and code view. This removes the duplicate dynamic import per block. * fix(pro): exclude ?raw imports from SWC transform in webpack config Existing Next.js oneOf rules were compiling TSX before the asset/source loader could read the original text. Now ?raw queries are excluded from all oneOf sub-rules so the raw source is preserved as-is. * fix(pro): strip Next.js HMR code from raw source in dev mode In dev mode, Next.js appends import.meta.webpackHot HMR code to asset/source modules, causing react-runner's sucrase transform to fail with "Cannot use import.meta outside a module". Strip the appended IIFE wrapper before passing the source to useRunner. * fix(pro): fix hydration mismatch in theme toggle icon Defer theme-dependent icon rendering until after mount to prevent server/client mismatch when localStorage theme differs from default. * fix: build issue * feat: update pro page * chore: update styles * fix: build issues * chore: fix file path
1 parent e89a0ca commit 6ab92fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+4121
-36
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tiny-design/react": minor
3+
---
4+
5+
Add `variant` prop to Card component (`outlined`, `elevated`, `filled`). Fix NativeSelect children type to accept arrays. Make Table ColumnType `dataIndex` optional for action columns.

.github/workflows/deploy-site.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ jobs:
4343
- name: Copy 404.html for SPA routing
4444
run: cp apps/docs/build/index.html apps/docs/build/404.html
4545

46+
- name: Build pro site
47+
run: pnpm --filter @tiny-design/pro build
48+
env:
49+
NEXT_PUBLIC_BASE_PATH: /tiny-design/pro
50+
51+
- name: Merge pro into docs output
52+
run: cp -r apps/pro/out/ apps/docs/build/pro/
53+
4654
- name: Upload artifact
4755
uses: actions/upload-pages-artifact@v3
4856
with:

apps/docs/src/containers/theme-editor/components/preview-panel.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ export const PreviewPanel = (): React.ReactElement => {
126126
</Flex>
127127
<Table columns={tableColumns} dataSource={tableData} pagination={false} bordered />
128128
<Card title="Card Title" style={{ marginTop: 16 }}>
129-
<p>Card content with some text to show how typography looks in a card component.</p>
129+
<Card.Content>
130+
<p>Card content with some text to show how typography looks in a card component.</p>
131+
<p>Card content with some text to show how typography looks in a card component.</p>
132+
</Card.Content>
130133
</Card>
131134
<Flex gap="sm" wrap="wrap" style={{ marginTop: 16 }}>
132135
<Tag>Default</Tag>

apps/docs/src/locale/en_US.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const en_US: SiteLocale = {
77
guide: 'Guide',
88
theme: 'Theme',
99
components: 'Components',
10+
pro: 'Pro',
1011
},
1112
home: {
1213
subtitle: 'A Friendly UI Component Set for React',

apps/docs/src/locale/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type SiteLocale = {
55
guide: string;
66
theme: string;
77
components: string;
8+
pro: string;
89
};
910
home: {
1011
subtitle: string;

apps/docs/src/locale/zh_CN.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const zh_CN: SiteLocale = {
77
guide: '指南',
88
theme: '主题',
99
components: '组件',
10+
pro: 'Pro',
1011
},
1112
home: {
1213
subtitle: '一套友好的 React UI 组件库',

apps/pro/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.next/
2+
out/

apps/pro/next-env.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
/// <reference path="./.next/types/routes.d.ts" />
4+
5+
// NOTE: This file should not be edited
6+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

apps/pro/next.config.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import type { NextConfig } from 'next';
2+
import path from 'path';
3+
import { fileURLToPath } from 'url';
4+
5+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
6+
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || '';
7+
8+
const nextConfig: NextConfig = {
9+
output: 'export',
10+
basePath,
11+
trailingSlash: true,
12+
images: { unoptimized: true },
13+
sassOptions: {
14+
includePaths: [
15+
path.resolve(__dirname, 'node_modules'),
16+
path.resolve(__dirname, '../../node_modules'),
17+
path.resolve(__dirname, '../../packages/react/src'),
18+
],
19+
},
20+
webpack(config) {
21+
// Source alias: resolve to package source (same pattern as docs app)
22+
config.resolve.alias['@tiny-design/react'] = path.resolve(
23+
__dirname,
24+
'../../packages/react/src'
25+
);
26+
config.resolve.alias['@tiny-design/icons'] = path.resolve(
27+
__dirname,
28+
'../../packages/icons/src'
29+
);
30+
31+
// ?raw imports: embed original file contents as strings at build time.
32+
// We must exclude ?raw from existing oneOf rules so Next.js/SWC doesn't
33+
// compile the TSX before we read it as plain text.
34+
const rawQuery = /raw/;
35+
36+
for (const rule of config.module.rules) {
37+
if (rule && typeof rule === 'object' && rule.oneOf) {
38+
for (const oneOfRule of rule.oneOf) {
39+
if (oneOfRule && typeof oneOfRule === 'object') {
40+
// Add resourceQuery exclusion to each sub-rule
41+
if (!oneOfRule.resourceQuery) {
42+
oneOfRule.resourceQuery = { not: [rawQuery] };
43+
} else if (oneOfRule.resourceQuery instanceof RegExp) {
44+
oneOfRule.resourceQuery = {
45+
and: [oneOfRule.resourceQuery],
46+
not: [rawQuery],
47+
};
48+
}
49+
}
50+
}
51+
}
52+
}
53+
54+
config.module.rules.push({
55+
resourceQuery: rawQuery,
56+
type: 'asset/source',
57+
});
58+
59+
return config;
60+
},
61+
};
62+
63+
export default nextConfig;

apps/pro/package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "@tiny-design/pro",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev --port 3001",
7+
"build": "next build",
8+
"start": "next start"
9+
},
10+
"dependencies": {
11+
"@tiny-design/icons": "workspace:*",
12+
"@tiny-design/react": "workspace:*",
13+
"@tiny-design/tokens": "workspace:*",
14+
"classnames": "^2.5.0",
15+
"next": "^15.3.4",
16+
"prism-react-renderer": "^2.3.0",
17+
"react": "^18.2.0",
18+
"react-dom": "^18.2.0",
19+
"react-runner": "^1.0.5",
20+
"sass": "^1.49.9"
21+
},
22+
"devDependencies": {
23+
"@types/node": "^22.0.0",
24+
"@types/react": "^18.2.0",
25+
"@types/react-dom": "^18.2.0",
26+
"typescript": "^5.4.0"
27+
}
28+
}

0 commit comments

Comments
 (0)