diff --git a/frontend/package.json.md5 b/frontend/package.json.md5 index 7396e243..bed8925b 100755 --- a/frontend/package.json.md5 +++ b/frontend/package.json.md5 @@ -1 +1 @@ -d0464f9da25e9356e61652e638c99ffe \ No newline at end of file +0295a42fd931778d85157816d79d29e5 \ No newline at end of file diff --git a/frontend/src/components/DatabaseIcons.test.tsx b/frontend/src/components/DatabaseIcons.test.tsx index e9b3a402..4d5fa5e3 100644 --- a/frontend/src/components/DatabaseIcons.test.tsx +++ b/frontend/src/components/DatabaseIcons.test.tsx @@ -1,10 +1,22 @@ +import React from 'react'; import { describe, expect, it } from 'vitest'; +import { renderToStaticMarkup } from 'react-dom/server'; -import { DB_ICON_TYPES, getDbIconLabel } from './DatabaseIcons'; +import { DB_ICON_TYPES, getDbIcon, getDbIconLabel } from './DatabaseIcons'; describe('DatabaseIcons', () => { it('includes InterSystems IRIS in the selectable database icons', () => { expect(DB_ICON_TYPES).toContain('iris'); expect(getDbIconLabel('iris')).toBe('InterSystems IRIS'); }); + + it('wraps database icons in a consistent frame for sidebar sizing', () => { + const mysqlMarkup = renderToStaticMarkup(<>{getDbIcon('mysql', undefined, 22)}); + const jvmMarkup = renderToStaticMarkup(<>{getDbIcon('jvm', undefined, 22)}); + + expect(mysqlMarkup).toContain('data-db-icon-frame="true"'); + expect(jvmMarkup).toContain('data-db-icon-frame="true"'); + expect(mysqlMarkup).toContain('width:22px'); + expect(jvmMarkup).toContain('width:22px'); + }); }); diff --git a/frontend/src/components/DatabaseIcons.tsx b/frontend/src/components/DatabaseIcons.tsx index 0def9b27..a54a0f52 100644 --- a/frontend/src/components/DatabaseIcons.tsx +++ b/frontend/src/components/DatabaseIcons.tsx @@ -7,6 +7,25 @@ export interface DbIconProps { color?: string; } +const IconFrame: React.FC<{ + size: number; + children: React.ReactNode; +}> = ({ size, children }) => ( + + {children} + +); + // ─── 默认色表 ─────────────────────────────────────────────── const DB_DEFAULT_COLORS: Record = { @@ -49,20 +68,22 @@ const BRAND_SVG_TYPES = new Set([ const BrandSvgIcon: React.FC<{ type: string; size: number; color?: string }> = ({ type, size, color }) => { const bgColor = color || getDbDefaultColor(type); return ( - - {type} - + + + {type} + + ); }; @@ -72,16 +93,19 @@ const BrandSvgIcon: React.FC<{ type: string; size: number; color?: string }> = ( const ColorBadge: React.FC<{ size: number; color: string; label: string }> = ({ size, color, label }) => { const textSize = label.length <= 2 ? size * 0.48 : size * 0.38; return ( - - - 2 ? -0.5 : 0} - > - {label} - - + + + + 2 ? -0.5 : 0} + > + {label} + + + ); }; @@ -161,11 +185,13 @@ const JVMIcon: React.FC = ({ size = 16, color }) => ( const CustomIcon: React.FC = ({ size = 16, color }) => { const c = color || DB_DEFAULT_COLORS.custom; return ( - - - - - + + + + + + + ); };