Skip to content

Commit 8d93e96

Browse files
further break apart and use tailwind for style
1 parent 935c49f commit 8d93e96

File tree

8 files changed

+232
-323
lines changed

8 files changed

+232
-323
lines changed

vscode/react/src/components/tablediff/ColumnStatsSection.tsx

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { SectionToggle } from './SectionToggle'
2-
import { type TableDiffData, type SampleValue, themeColors } from './types'
2+
import { type TableDiffData, type SampleValue } from './types'
3+
import { twColors, twMerge } from './tailwind-utils'
34

45
interface ColumnStatsSectionProps {
56
columnStats: TableDiffData['row_diff']['column_stats']
@@ -14,9 +15,8 @@ interface StatHeaderProps {
1415
const StatHeader = ({ stat }: StatHeaderProps) => (
1516
<th
1617
key={stat}
17-
className="text-left py-2 px-1 font-medium w-16"
18+
className={twMerge('text-left py-2 px-1 font-medium w-16', twColors.textMuted)}
1819
title={stat}
19-
style={{ color: themeColors.muted }}
2020
>
2121
{stat.length > 6 ? stat.slice(0, 6) + '..' : stat}
2222
</th>
@@ -28,9 +28,8 @@ interface StatCellProps {
2828

2929
const StatCell = ({ value }: StatCellProps) => (
3030
<td
31-
className="py-2 px-1 font-mono text-xs truncate"
31+
className={twMerge('py-2 px-1 font-mono text-xs truncate', twColors.textMuted)}
3232
title={String(value)}
33-
style={{ color: themeColors.muted }}
3433
>
3534
{typeof value === 'number'
3635
? value.toFixed(1)
@@ -47,17 +46,11 @@ interface ColumnStatRowProps {
4746

4847
const ColumnStatRow = ({ columnName, statsValue }: ColumnStatRowProps) => (
4948
<tr
50-
className="transition-colors"
51-
style={{
52-
borderBottom: `1px solid ${themeColors.border}`,
53-
}}
54-
onMouseEnter={e => {
55-
e.currentTarget.style.backgroundColor =
56-
'var(--vscode-list-hoverBackground)'
57-
}}
58-
onMouseLeave={e => {
59-
e.currentTarget.style.backgroundColor = 'transparent'
60-
}}
49+
className={twMerge(
50+
'transition-colors border-b',
51+
twColors.borderPanel,
52+
twColors.bgHover
53+
)}
6154
>
6255
<td
6356
className="py-2 pr-2 font-mono truncate"
@@ -94,32 +87,21 @@ export function ColumnStatsSection({
9487
id="columnStats"
9588
title="Column Statistics"
9689
badge={`${Object.keys(columnStats).length} columns`}
97-
badgeStyle={{
98-
backgroundColor: 'var(--vscode-input-background)',
99-
color: 'var(--vscode-symbolIcon-classForeground, #9b59b6)',
100-
borderColor: 'var(--vscode-symbolIcon-classForeground, #9b59b6)',
101-
}}
90+
badgeClassName={twMerge(
91+
'px-2 py-1 text-xs rounded border',
92+
twColors.bgInput,
93+
'text-[var(--vscode-symbolIcon-classForeground,#9b59b6)]',
94+
'border-[var(--vscode-symbolIcon-classForeground,#9b59b6)]'
95+
)}
10296
expanded={expanded}
10397
onToggle={onToggle}
10498
>
10599
<div className="px-8 py-3">
106100
<div className="overflow-auto max-h-80">
107101
<table className="w-full text-xs table-fixed">
108-
<thead
109-
className="sticky top-0 z-10"
110-
style={{
111-
backgroundColor: 'var(--vscode-editor-background)',
112-
}}
113-
>
114-
<tr
115-
style={{
116-
borderBottom: `1px solid ${themeColors.border}`,
117-
}}
118-
>
119-
<th
120-
className="text-left py-2 pr-2 font-medium w-28"
121-
style={{ color: themeColors.muted }}
122-
>
102+
<thead className={twMerge('sticky top-0 z-10', twColors.bgEditor)}>
103+
<tr className={twMerge('border-b', twColors.borderPanel)}>
104+
<th className={twMerge('text-left py-2 pr-2 font-medium w-28', twColors.textMuted)}>
123105
Column
124106
</th>
125107
{statKeys.map(stat => (

vscode/react/src/components/tablediff/RowStatsSection.tsx

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { SectionToggle } from './SectionToggle'
2-
import { type TableDiffData, themeColors } from './types'
2+
import { type TableDiffData } from './types'
3+
import { twColors, twMerge } from './tailwind-utils'
34

45
interface RowStatsSectionProps {
56
rowDiff: TableDiffData['row_diff']
@@ -28,60 +29,52 @@ export function RowStatsSection({
2829
id="rows"
2930
title="Row Statistics"
3031
badge={`${formatPercentage(fullMatchPct)} match rate`}
31-
badgeStyle={{
32-
backgroundColor: 'var(--vscode-input-background)',
33-
color: themeColors.info,
34-
borderColor: themeColors.info,
35-
}}
32+
badgeClassName={twMerge(
33+
'px-2 py-1 text-xs rounded border',
34+
twColors.bgInput,
35+
twColors.textInfo,
36+
twColors.borderInfo
37+
)}
3638
expanded={expanded}
3739
onToggle={onToggle}
3840
>
3941
<div className="px-8 py-3 space-y-3">
4042
<div className="grid grid-cols-2 gap-4 text-xs">
4143
<div className="space-y-1">
4244
<div className="flex justify-between">
43-
<span style={{ color: themeColors.success }}>✓ Full Matches</span>
45+
<span className={twColors.textSuccess}>✓ Full Matches</span>
4446
<span className="font-medium">{formatCount(fullMatchCount)}</span>
4547
</div>
4648
<div className="flex justify-between">
47-
<span style={{ color: themeColors.info }}>~ Partial Matches</span>
49+
<span className={twColors.textInfo}>~ Partial Matches</span>
4850
<span className="font-medium">
4951
{formatCount(partialMatchCount)}
5052
</span>
5153
</div>
5254
</div>
5355
<div className="space-y-1">
5456
<div className="flex justify-between">
55-
<span style={{ color: themeColors.warning }}>+ Source Only</span>
57+
<span className={twColors.textWarning}>+ Source Only</span>
5658
<span className="font-medium">{formatCount(sOnlyCount)}</span>
5759
</div>
5860
<div className="flex justify-between">
59-
<span style={{ color: themeColors.error }}>- Target Only</span>
61+
<span className={twColors.textError}>- Target Only</span>
6062
<span className="font-medium">{formatCount(tOnlyCount)}</span>
6163
</div>
6264
</div>
6365
</div>
6466
{/* Match rate progress bar */}
6567
<div className="mt-3 space-y-1">
66-
<div
67-
className="flex items-center gap-2 text-xs"
68-
style={{ color: themeColors.muted }}
69-
>
68+
<div className={twMerge('flex items-center gap-2 text-xs', twColors.textMuted)}>
7069
<span>Match Rate</span>
7170
<span className="font-medium">
7271
{formatPercentage(fullMatchPct)}
7372
</span>
7473
</div>
75-
<div
76-
className="h-2 rounded-full overflow-hidden"
77-
style={{ backgroundColor: 'var(--vscode-input-background)' }}
78-
>
74+
<div className={twMerge('h-2 rounded-full overflow-hidden', twColors.bgInput)}>
7975
<div
80-
className="h-full transition-all duration-300"
81-
style={{
82-
width: `${fullMatchPct * 100}%`,
83-
backgroundColor: themeColors.success,
84-
}}
76+
className={twMerge('h-full transition-all duration-300', twColors.textSuccess.replace('text-', 'bg-'))}
77+
style={{ width: `${fullMatchPct * 100}%` }}
8578
/>
8679
</div>
8780
</div>

0 commit comments

Comments
 (0)