Skip to content

Commit 09a7d01

Browse files
committed
更新组件样式和布局,优化响应式设计,增强可读性和一致性
1 parent 19f7ad4 commit 09a7d01

File tree

8 files changed

+120
-75
lines changed

8 files changed

+120
-75
lines changed

examples/showcase/pages/layout/grid.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,23 @@
4444
"children": [
4545
{
4646
"type": "div",
47-
"className": "h-24 bg-red-100 dark:bg-red-900 rounded"
47+
"className": "h-24 bg-card border rounded shadow-sm flex items-center justify-center text-muted-foreground",
48+
"children": { "type": "text", "value": "1" }
4849
},
4950
{
5051
"type": "div",
51-
"className": "h-24 bg-green-100 dark:bg-green-900 rounded"
52+
"className": "h-24 bg-secondary/50 border rounded shadow-sm flex items-center justify-center text-secondary-foreground",
53+
"children": { "type": "text", "value": "2" }
5254
},
5355
{
5456
"type": "div",
55-
"className": "h-24 bg-blue-100 dark:bg-blue-900 rounded"
57+
"className": "h-24 bg-primary/10 border rounded shadow-sm flex items-center justify-center text-primary",
58+
"children": { "type": "text", "value": "3" }
5659
},
5760
{
5861
"type": "div",
59-
"className": "h-24 bg-yellow-100 dark:bg-yellow-900 rounded"
62+
"className": "h-24 bg-muted border rounded shadow-sm flex items-center justify-center text-muted-foreground",
63+
"children": { "type": "text", "value": "4" }
6064
}
6165
]
6266
}

packages/components/src/renderers/data-display/tree-view.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,19 @@ ComponentRegistry.register('tree-view',
107107

108108
return (
109109
<div className={cn(
110-
'relative border border-slate-800/60 rounded-lg p-3 bg-slate-950/40 backdrop-blur-md overflow-hidden',
111-
'shadow-[0_0_20px_-10px_rgba(6,182,212,0.15)]',
110+
'relative border border-border/60 rounded-lg p-3 bg-card/40 backdrop-blur-md overflow-hidden',
111+
'shadow-lg shadow-primary/5',
112112
className
113113
)}
114114
{...props}
115115
>
116116
{/* Background Grid */}
117-
<div className="absolute inset-0 bg-[linear-gradient(to_right,#8080800a_1px,transparent_1px),linear-gradient(to_bottom,#8080800a_1px,transparent_1px)] bg-[size:24px_24px] pointer-events-none" />
117+
<div className="absolute inset-0 bg-[linear-gradient(to_right,hsl(var(--border)/0.1)_1px,transparent_1px),linear-gradient(to_bottom,hsl(var(--border)/0.1)_1px,transparent_1px)] bg-[size:24px_24px] pointer-events-none" />
118118

119119
{schema.title && (
120-
<div className="flex items-center gap-2 mb-3 pb-2 border-b border-cyan-900/30 relative z-10">
121-
<CircuitBoard className="w-4 h-4 text-cyan-500" />
122-
<h3 className="text-xs font-bold font-mono uppercase tracking-widest text-cyan-400">{schema.title}</h3>
120+
<div className="flex items-center gap-2 mb-3 pb-2 border-b border-primary/20 relative z-10">
121+
<CircuitBoard className="w-4 h-4 text-primary" />
122+
<h3 className="text-xs font-bold font-mono uppercase tracking-widest text-primary">{schema.title}</h3>
123123
</div>
124124
)}
125125
<div className="space-y-1 relative z-10">

packages/components/src/renderers/form/file-upload.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,27 +127,27 @@ ComponentRegistry.register('file-upload',
127127
{files.map((file, index) => (
128128
<div
129129
key={index}
130-
className="relative group/file overflow-hidden flex items-center justify-between p-3 border border-slate-800 bg-slate-900/80 rounded-sm text-sm transition-all hover:border-cyan-500/30 hover:shadow-[0_0_15px_-5px_rgba(6,182,212,0.3)] animate-in slide-in-from-bottom-2 fade-in"
130+
className="relative group/file overflow-hidden flex items-center justify-between p-3 border border-border bg-card/80 rounded-sm text-sm transition-all hover:border-primary/30 hover:shadow-lg hover:shadow-primary/10 animate-in slide-in-from-bottom-2 fade-in"
131131
>
132-
<div className="absolute left-0 top-0 bottom-0 w-[2px] bg-cyan-500/50 group-hover/file:bg-cyan-400 group-hover/file:shadow-[0_0_8px_cyan]" />
132+
<div className="absolute left-0 top-0 bottom-0 w-[2px] bg-primary/50 group-hover/file:bg-primary group-hover/file:shadow-[0_0_8px_hsl(var(--primary))]" />
133133

134134
<div className="flex items-center gap-3 z-10">
135-
<CheckCircle2 className="w-4 h-4 text-green-500 shadow-[0_0_5px_rgba(34,197,94,0.5)] rounded-full" />
136-
<span className="truncate max-w-[200px] text-slate-300 group-hover/file:text-cyan-100 font-mono text-xs">{file.name}</span>
135+
<CheckCircle2 className="w-4 h-4 text-emerald-500 rounded-full" />
136+
<span className="truncate max-w-[200px] text-muted-foreground group-hover/file:text-foreground font-mono text-xs transition-colors">{file.name}</span>
137137
</div>
138138

139139
<Button
140140
type="button"
141141
variant="ghost"
142142
size="sm"
143-
className="h-6 w-6 p-0 hover:bg-red-950/50 hover:text-red-400 hover:shadow-[0_0_10px_red]"
143+
className="h-6 w-6 p-0 hover:bg-destructive/10 hover:text-destructive"
144144
onClick={() => handleRemoveFile(index)}
145145
>
146146
<X className="h-3 w-3" />
147147
</Button>
148148

149-
{/* Scanning Effect */}
150-
<div className="absolute inset-0 bg-linear-to-r from-transparent via-cyan-500/5 to-transparent -translate-x-full group-hover/file:animate-[shimmer_1s_infinite] pointer-events-none" />
149+
{/* Scanning Effect - Fixed gradient syntax */}
150+
<div className="absolute inset-0 bg-gradient-to-r from-transparent via-primary/5 to-transparent -translate-x-full group-hover/file:animate-[shimmer_1s_infinite] pointer-events-none" />
151151
</div>
152152
))}
153153
</div>

packages/components/src/renderers/layout/grid.tsx

Lines changed: 77 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,67 @@ import type { GridSchema } from '@object-ui/types';
33
import { renderChildren } from '../../lib/utils';
44
import { cn } from '../../lib/utils';
55

6+
// Helper maps to ensure Tailwind classes are scanned and included
7+
const GRID_COLS: Record<number, string> = {
8+
1: 'grid-cols-1', 2: 'grid-cols-2', 3: 'grid-cols-3', 4: 'grid-cols-4',
9+
5: 'grid-cols-5', 6: 'grid-cols-6', 7: 'grid-cols-7', 8: 'grid-cols-8',
10+
9: 'grid-cols-9', 10: 'grid-cols-10', 11: 'grid-cols-11', 12: 'grid-cols-12'
11+
};
12+
13+
const GRID_COLS_SM: Record<number, string> = {
14+
1: 'sm:grid-cols-1', 2: 'sm:grid-cols-2', 3: 'sm:grid-cols-3', 4: 'sm:grid-cols-4',
15+
5: 'sm:grid-cols-5', 6: 'sm:grid-cols-6', 7: 'sm:grid-cols-7', 8: 'sm:grid-cols-8',
16+
9: 'sm:grid-cols-9', 10: 'sm:grid-cols-10', 11: 'sm:grid-cols-11', 12: 'sm:grid-cols-12'
17+
};
18+
19+
const GRID_COLS_MD: Record<number, string> = {
20+
1: 'md:grid-cols-1', 2: 'md:grid-cols-2', 3: 'md:grid-cols-3', 4: 'md:grid-cols-4',
21+
5: 'md:grid-cols-5', 6: 'md:grid-cols-6', 7: 'md:grid-cols-7', 8: 'md:grid-cols-8',
22+
9: 'md:grid-cols-9', 10: 'md:grid-cols-10', 11: 'md:grid-cols-11', 12: 'md:grid-cols-12'
23+
};
24+
25+
const GRID_COLS_LG: Record<number, string> = {
26+
1: 'lg:grid-cols-1', 2: 'lg:grid-cols-2', 3: 'lg:grid-cols-3', 4: 'lg:grid-cols-4',
27+
5: 'lg:grid-cols-5', 6: 'lg:grid-cols-6', 7: 'lg:grid-cols-7', 8: 'lg:grid-cols-8',
28+
9: 'lg:grid-cols-9', 10: 'lg:grid-cols-10', 11: 'lg:grid-cols-11', 12: 'lg:grid-cols-12'
29+
};
30+
31+
const GRID_COLS_XL: Record<number, string> = {
32+
1: 'xl:grid-cols-1', 2: 'xl:grid-cols-2', 3: 'xl:grid-cols-3', 4: 'xl:grid-cols-4',
33+
5: 'xl:grid-cols-5', 6: 'xl:grid-cols-6', 7: 'xl:grid-cols-7', 8: 'xl:grid-cols-8',
34+
9: 'xl:grid-cols-9', 10: 'xl:grid-cols-10', 11: 'xl:grid-cols-11', 12: 'xl:grid-cols-12'
35+
};
36+
37+
const GAPS: Record<number, string> = {
38+
0: 'gap-0', 1: 'gap-1', 2: 'gap-2', 3: 'gap-3', 4: 'gap-4',
39+
5: 'gap-5', 6: 'gap-6', 8: 'gap-8', 10: 'gap-10', 12: 'gap-12'
40+
};
41+
642
ComponentRegistry.register('grid',
7-
({ schema, className, ...props }: { schema: GridSchema; className?: string; [key: string]: any }) => {
8-
const gridCols = schema.columns || 2;
9-
const gap = schema.gap || 4;
43+
({ schema, className, ...props }: { schema: GridSchema & { smColumns?: number, mdColumns?: number, lgColumns?: number, xlColumns?: number }; className?: string; [key: string]: any }) => {
44+
// Determine columns configuration
45+
// Supports direct number or responsive object logic if schema allows,
46+
// but here we primarily handle the flat properties supported by the designer inputs
47+
const baseCols = typeof schema.columns === 'number' ? schema.columns : 2;
48+
const smCols = schema.smColumns;
49+
const mdCols = schema.mdColumns;
50+
const lgCols = schema.lgColumns;
51+
const xlCols = schema.xlColumns;
52+
53+
const gap = schema.gap ?? 4;
1054

1155
// Generate Tailwind grid classes
1256
const gridClass = cn(
1357
'grid',
14-
// Grid columns classes
15-
gridCols === 1 && 'grid-cols-1',
16-
gridCols === 2 && 'grid-cols-2',
17-
gridCols === 3 && 'grid-cols-3',
18-
gridCols === 4 && 'grid-cols-4',
19-
gridCols === 5 && 'grid-cols-5',
20-
gridCols === 6 && 'grid-cols-6',
21-
gridCols === 7 && 'grid-cols-7',
22-
gridCols === 8 && 'grid-cols-8',
23-
gridCols === 9 && 'grid-cols-9',
24-
gridCols === 10 && 'grid-cols-10',
25-
gridCols === 11 && 'grid-cols-11',
26-
gridCols === 12 && 'grid-cols-12',
27-
// Gap classes
28-
gap === 0 && 'gap-0',
29-
gap === 1 && 'gap-1',
30-
gap === 2 && 'gap-2',
31-
gap === 3 && 'gap-3',
32-
gap === 4 && 'gap-4',
33-
gap === 5 && 'gap-5',
34-
gap === 6 && 'gap-6',
35-
gap === 7 && 'gap-7',
36-
gap === 8 && 'gap-8',
58+
// Base columns
59+
GRID_COLS[baseCols] || 'grid-cols-2',
3760
// Responsive columns
38-
schema.mdColumns && `md:grid-cols-${schema.mdColumns}`,
39-
schema.lgColumns && `lg:grid-cols-${schema.lgColumns}`,
61+
smCols && GRID_COLS_SM[smCols],
62+
mdCols && GRID_COLS_MD[mdCols],
63+
lgCols && GRID_COLS_LG[lgCols],
64+
xlCols && GRID_COLS_XL[xlCols],
65+
// Gap
66+
GAPS[gap] || 'gap-4',
4067
className
4168
);
4269

@@ -67,33 +94,47 @@ ComponentRegistry.register('grid',
6794
{
6895
name: 'columns',
6996
type: 'number',
70-
label: 'Columns',
97+
label: 'Base Columns (Mobile)',
7198
defaultValue: 2,
72-
description: 'Number of columns (1-12)'
99+
description: 'Number of columns on mobile devices'
100+
},
101+
{
102+
name: 'smColumns',
103+
type: 'number',
104+
label: 'SM Columns (Tablet)',
105+
description: 'Columns at sm breakpoint (>640px)'
73106
},
74107
{
75108
name: 'mdColumns',
76109
type: 'number',
77-
label: 'MD Breakpoint Columns',
78-
description: 'Columns at md breakpoint (optional)'
110+
label: 'MD Columns (Laptop)',
111+
description: 'Columns at md breakpoint (>768px)'
79112
},
80113
{
81114
name: 'lgColumns',
82115
type: 'number',
83-
label: 'LG Breakpoint Columns',
84-
description: 'Columns at lg breakpoint (optional)'
116+
label: 'LG Columns (Desktop)',
117+
description: 'Columns at lg breakpoint (>1024px)'
118+
},
119+
{
120+
name: 'xlColumns',
121+
type: 'number',
122+
label: 'XL Columns (Wide)',
123+
description: 'Columns at xl breakpoint (>1280px)'
85124
},
86125
{
87126
name: 'gap',
88127
type: 'number',
89128
label: 'Gap',
90129
defaultValue: 4,
91-
description: 'Gap between items (0-8)'
130+
description: 'Gap between items (0-12)'
92131
},
93132
{ name: 'className', type: 'string', label: 'CSS Class' }
94133
],
95134
defaultProps: {
96-
columns: 2,
135+
columns: 1,
136+
mdColumns: 2,
137+
lgColumns: 4,
97138
gap: 4,
98139
children: [
99140
{ type: 'card', title: 'Card 1', description: 'First card' },

packages/plugin-charts/src/ChartImpl.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ export default function ChartImpl({
1919
xAxisKey = 'name',
2020
height = 400,
2121
className = '',
22-
// Default to Cyan-500 for the tech feel
23-
color = '#06b6d4',
22+
// Default to standard primary color
23+
color = 'hsl(var(--primary))',
2424
}: ChartImplProps) {
2525
return (
26-
<div className={`p-4 rounded-xl border border-slate-800 bg-slate-950/40 backdrop-blur-sm shadow-xl ${className}`}>
26+
<div className={`p-4 rounded-xl border border-border bg-card/40 backdrop-blur-sm shadow-lg shadow-background/5 ${className}`}>
2727
<ResponsiveContainer width="100%" height={height}>
2828
<BarChart data={data} margin={{ top: 20, right: 30, left: 20, bottom: 5 }}>
2929
<defs>
@@ -43,30 +43,30 @@ export default function ChartImpl({
4343
</feMerge>
4444
</filter>
4545
</defs>
46-
<CartesianGrid strokeDasharray="3 3" stroke="#1e293b" vertical={false} />
46+
<CartesianGrid strokeDasharray="3 3" stroke="hsl(var(--border))" vertical={false} />
4747
<XAxis
4848
dataKey={xAxisKey}
49-
tick={{ fill: '#94a3b8', fontSize: 12, fontFamily: 'monospace' }}
49+
tick={{ fill: 'hsl(var(--muted-foreground))', fontSize: 12, fontFamily: 'monospace' }}
5050
tickLine={false}
51-
axisLine={{ stroke: '#334155' }}
51+
axisLine={{ stroke: 'hsl(var(--border))' }}
5252
dy={10}
5353
/>
5454
<YAxis
55-
tick={{ fill: '#94a3b8', fontSize: 12, fontFamily: 'monospace' }}
55+
tick={{ fill: 'hsl(var(--muted-foreground))', fontSize: 12, fontFamily: 'monospace' }}
5656
tickLine={false}
5757
axisLine={false}
5858
/>
5959
<Tooltip
60-
cursor={{ fill: '#1e293b', opacity: 0.4 }}
60+
cursor={{ fill: 'hsl(var(--muted))', opacity: 0.2 }}
6161
contentStyle={{
62-
backgroundColor: '#020617',
63-
borderColor: '#1e293b',
64-
color: '#f8fafc',
62+
backgroundColor: 'hsl(var(--popover))',
63+
borderColor: 'hsl(var(--border))',
64+
color: 'hsl(var(--popover-foreground))',
6565
borderRadius: '8px',
6666
fontFamily: 'monospace',
67-
boxShadow: '0 0 20px rgba(6, 182, 212, 0.15)'
67+
boxShadow: '0 4px 6px -1px rgb(0 0 0 / 0.1)'
6868
}}
69-
itemStyle={{ color: '#22d3ee' }}
69+
itemStyle={{ color: 'hsl(var(--primary))' }}
7070
/>
7171
<Legend wrapperStyle={{ paddingTop: '20px', fontFamily: 'monospace' }} />
7272
<Bar

packages/plugin-charts/src/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ ComponentRegistry.register(
5454
{ name: 'dataKey', type: 'string', label: 'Data Key', defaultValue: 'value' },
5555
{ name: 'xAxisKey', type: 'string', label: 'X-Axis Key', defaultValue: 'name' },
5656
{ name: 'height', type: 'number', label: 'Height', defaultValue: 400 },
57-
{ name: 'color', type: 'color', label: 'Color', defaultValue: '#06b6d4' },
57+
{ name: 'color', type: 'color', label: 'Color' },
5858
],
5959
defaultProps: {
6060
data: [
@@ -67,7 +67,6 @@ ComponentRegistry.register(
6767
dataKey: 'value',
6868
xAxisKey: 'name',
6969
height: 400,
70-
color: '#06b6d4',
7170
},
7271
}
7372
);

packages/plugin-kanban/src/KanbanImpl.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ function SortableCard({ card }: { card: KanbanCard }) {
6161

6262
return (
6363
<div ref={setNodeRef} style={style} {...attributes} {...listeners}>
64-
<Card className="mb-2 cursor-grab active:cursor-grabbing border-slate-800 bg-slate-950/60 hover:border-cyan-500/40 hover:shadow-lg hover:shadow-cyan-900/10 transition-all duration-300 group">
64+
<Card className="mb-2 cursor-grab active:cursor-grabbing border-border bg-card/60 hover:border-primary/40 hover:shadow-lg hover:shadow-primary/10 transition-all duration-300 group">
6565
<CardHeader className="p-4">
66-
<CardTitle className="text-sm font-medium font-mono tracking-tight text-slate-200 group-hover:text-cyan-400 transition-colors">{card.title}</CardTitle>
66+
<CardTitle className="text-sm font-medium font-mono tracking-tight text-foreground group-hover:text-primary transition-colors">{card.title}</CardTitle>
6767
{card.description && (
68-
<CardDescription className="text-xs text-slate-500 font-mono">
68+
<CardDescription className="text-xs text-muted-foreground font-mono">
6969
{card.description}
7070
</CardDescription>
7171
)}
@@ -107,15 +107,15 @@ function KanbanColumn({
107107
<div
108108
ref={setNodeRef}
109109
className={cn(
110-
"flex flex-col w-80 flex-shrink-0 rounded-lg border border-slate-800 bg-slate-950/20 backdrop-blur-sm shadow-xl",
110+
"flex flex-col w-80 flex-shrink-0 rounded-lg border border-border bg-card/20 backdrop-blur-sm shadow-xl",
111111
column.className
112112
)}
113113
>
114-
<div className="p-4 border-b border-cyan-900/20 bg-slate-900/40">
114+
<div className="p-4 border-b border-border/50 bg-muted/20">
115115
<div className="flex items-center justify-between">
116-
<h3 className="font-mono text-sm font-semibold tracking-wider text-cyan-400/90 uppercase">{column.title}</h3>
116+
<h3 className="font-mono text-sm font-semibold tracking-wider text-primary/90 uppercase">{column.title}</h3>
117117
<div className="flex items-center gap-2">
118-
<span className="font-mono text-xs text-cyan-700/70">
118+
<span className="font-mono text-xs text-muted-foreground">
119119
{safeCards.length}
120120
{column.limit && ` / ${column.limit}`}
121121
</span>

packages/runner/tailwind.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export default {
44
content: [
55
"./index.html",
66
"./src/**/*.{ts,tsx}",
7+
78
// ⚠️ 核心配置:
89
// 指向 Monorepo 中的包源码,确保 Tailwind 能提取出 Object UI 组件内的 className
910
"../../packages/components/src/**/*.{ts,tsx}",

0 commit comments

Comments
 (0)