mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-12-04 22:21:21 +09:00
36 lines
1.2 KiB
React
36 lines
1.2 KiB
React
import { useState } from 'react';
|
|
import { EngineIcon } from '../icons/DatabaseBrands';
|
|
import { hasBrandIcon } from '../icons/databaseBrandData';
|
|
import { engineMeta } from './engineHelpers';
|
|
|
|
// The engine icon, resolved in three steps: the brand glyph we ship, then the
|
|
// template's own `icon` URL, then a generic database glyph. Never an emoji —
|
|
// the design mock uses them, this panel does not.
|
|
//
|
|
// A remote icon that 404s falls through to the glyph rather than leaving a
|
|
// broken image in the catalog grid.
|
|
export function EngineGlyph({ entry, size = 16 }) {
|
|
const [broken, setBroken] = useState(false);
|
|
|
|
const id = entry?.id || entry?.template_id;
|
|
if (hasBrandIcon(id)) return <EngineIcon engine={id} size={size} />;
|
|
|
|
if (entry?.icon && !broken) {
|
|
return (
|
|
<img
|
|
className="dbx-eng-img"
|
|
src={entry.icon}
|
|
alt=""
|
|
width={size}
|
|
height={size}
|
|
onError={() => setBroken(true)}
|
|
/>
|
|
);
|
|
}
|
|
|
|
const protocol = engineMeta(entry).protocol;
|
|
return <EngineIcon engine={hasBrandIcon(protocol) ? protocol : 'database'} size={size} />;
|
|
}
|
|
|
|
export default EngineGlyph;
|