mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
feat: use official Pi agent logo (#1335)
* feat: add official Pi agent logo * fix: honor selected theme for Pi logo
This commit is contained in:
@@ -3,8 +3,7 @@ import { render } from '@testing-library/react'
|
|||||||
import { AGENT_FLAVORS } from '@hapi/protocol'
|
import { AGENT_FLAVORS } from '@hapi/protocol'
|
||||||
import { AgentFlavorIcon } from './AgentFlavorIcon'
|
import { AgentFlavorIcon } from './AgentFlavorIcon'
|
||||||
|
|
||||||
// Flavors backed by a @lobehub/icons brand logo. 'pi' has no logo in the
|
// Flavors backed by a @lobehub/icons brand logo.
|
||||||
// package and intentionally falls back to the letter badge.
|
|
||||||
const LOGO_FLAVORS = AGENT_FLAVORS.filter((f) => f !== 'pi')
|
const LOGO_FLAVORS = AGENT_FLAVORS.filter((f) => f !== 'pi')
|
||||||
|
|
||||||
function getWrapper(container: HTMLElement): HTMLElement {
|
function getWrapper(container: HTMLElement): HTMLElement {
|
||||||
@@ -29,13 +28,15 @@ describe('AgentFlavorIcon', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('keeps the "Pi" letter badge for the pi flavor (no brand logo available)', () => {
|
it('renders the Pi logo with transparent, theme-aware coloring', () => {
|
||||||
const { container } = render(<AgentFlavorIcon flavor="pi" />)
|
const { container } = render(<AgentFlavorIcon flavor="pi" />)
|
||||||
const badge = getWrapper(container)
|
const badge = getWrapper(container)
|
||||||
expect(container.querySelector('svg')).toBeNull()
|
const svg = container.querySelector('svg')
|
||||||
expect(badge.textContent).toBe('Pi')
|
expect(svg).not.toBeNull()
|
||||||
expect(badge.className).toContain('bg-[#5b21b6]')
|
expect(badge.textContent).toBe('')
|
||||||
expect(badge.className).toContain('text-white')
|
expect(badge.className).not.toContain('rounded-sm')
|
||||||
|
expect(badge.className).toContain('text-[var(--app-fg)]')
|
||||||
|
expect(svg?.getAttribute('viewBox')).toBe('0 0 800 800')
|
||||||
})
|
})
|
||||||
|
|
||||||
it.each([null, undefined, '', ' ', 'mystery-cli'])(
|
it.each([null, undefined, '', ' ', 'mystery-cli'])(
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ const FLAVOR_LOGOS: Record<string, IconType> = {
|
|||||||
opencode: OpenCodeMono,
|
opencode: OpenCodeMono,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Letter-badge fallback for flavors without a brand logo in @lobehub/icons
|
function PiLogo() {
|
||||||
// (pi) and for anything unrecognized.
|
return (
|
||||||
const FLAVOR_BADGES: Record<string, { label: string; colors: string }> = {
|
<svg viewBox="0 0 800 800" width="100%" height="100%" fill="currentColor">
|
||||||
pi: {
|
<path fillRule="evenodd" d="M165.29 165.29h352.07V400H400v117.36H282.65v117.36H165.29zM282.65 282.65V400H400V282.65z" />
|
||||||
label: 'Pi',
|
<path d="M517.36 400h117.36v234.72H517.36z" />
|
||||||
colors: 'bg-[#5b21b6] text-white',
|
</svg>
|
||||||
},
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const UNKNOWN_FLAVOR_BADGE = {
|
const UNKNOWN_FLAVOR_BADGE = {
|
||||||
@@ -54,7 +54,18 @@ export function AgentFlavorIcon({ flavor, className }: { flavor?: string | null;
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const badge = FLAVOR_BADGES[normalized] ?? UNKNOWN_FLAVOR_BADGE
|
if (normalized === 'pi') {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
aria-hidden="true"
|
||||||
|
className={`inline-flex items-center justify-center leading-none text-[var(--app-fg)] ${sizeClass}`}
|
||||||
|
>
|
||||||
|
<PiLogo />
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const badge = UNKNOWN_FLAVOR_BADGE
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
|
|||||||
Reference in New Issue
Block a user