fix(web): polish main nav and deployment tooltip styles (#37800)

This commit is contained in:
Stephen Zhou 2026-06-23 16:10:28 +08:00 committed by GitHub
parent a554891bbd
commit 0fcaf92d67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 81 additions and 2 deletions

View File

@ -0,0 +1,15 @@
import { render, screen } from '@testing-library/react'
import { SkipNav } from '../skip-nav'
describe('SkipNav', () => {
it('keeps the shadow hidden until the link is visible', () => {
render(<SkipNav>Skip to main content</SkipNav>)
const link = screen.getByRole('link', { name: 'Skip to main content' })
expect(link).not.toHaveClass('shadow-lg')
expect(link).not.toHaveClass('shadow-shadow-shadow-5')
expect(link).toHaveClass('focus-visible:shadow-lg')
expect(link).toHaveClass('focus-visible:shadow-shadow-shadow-5')
})
})

View File

@ -26,7 +26,7 @@ export function SkipNav({
href={MAIN_CONTENT_HREF}
onClick={handleClick}
className={cn(
'fixed top-2 left-2 z-60 inline-flex h-9 -translate-y-[calc(100%+0.75rem)] items-center justify-center rounded-lg border-[0.5px] border-components-button-secondary-border bg-components-button-secondary-bg px-3 system-sm-medium text-components-button-secondary-text shadow-lg shadow-shadow-shadow-5 outline-hidden transition-transform duration-150 focus-visible:translate-y-0 focus-visible:ring-2 focus-visible:ring-state-accent-solid motion-reduce:transition-none',
'fixed top-2 left-2 z-60 inline-flex h-9 -translate-y-[calc(100%+0.75rem)] items-center justify-center rounded-lg border-[0.5px] border-components-button-secondary-border bg-components-button-secondary-bg px-3 system-sm-medium text-components-button-secondary-text outline-hidden transition-transform duration-150 focus-visible:translate-y-0 focus-visible:shadow-lg focus-visible:ring-2 focus-visible:shadow-shadow-shadow-5 focus-visible:ring-state-accent-solid motion-reduce:transition-none',
className,
)}
{...props}

View File

@ -0,0 +1,64 @@
import type { Release } from '@dify/contracts/enterprise/types.gen'
import { ReleaseSource } from '@dify/contracts/enterprise/types.gen'
import { act, fireEvent, render, screen } from '@testing-library/react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { ReleaseMetaTooltip } from '../instance-card-sections'
function createRelease(overrides: Partial<Release> = {}): Release {
return {
id: 'release-1',
appInstanceId: 'app-instance-1',
displayName: 'Initial release',
description: '',
source: ReleaseSource.RELEASE_SOURCE_SOURCE_APP,
sourceAppId: 'source-app-1',
gateCommitId: 'commit-1',
requiredSlots: [],
createdBy: {
id: 'user-1',
displayName: 'Ada',
},
createdAt: '2026-01-01T00:00:00.000Z',
...overrides,
}
}
function closestWithClass(element: HTMLElement, className: string) {
let current: HTMLElement | null = element
while (current) {
if (current.classList.contains(className))
return current
current = current.parentElement
}
return null
}
describe('ReleaseMetaTooltip', () => {
beforeEach(() => {
vi.useFakeTimers()
})
afterEach(() => {
vi.useRealTimers()
})
it('should use compact typography for the release metadata preview', async () => {
render(
<ReleaseMetaTooltip release={createRelease()} deployed>
<a href="/deployments/app-instance-1/releases">
Initial release · 14 days ago
</a>
</ReleaseMetaTooltip>,
)
await act(async () => {
fireEvent.mouseEnter(screen.getByRole('link', { name: 'Initial release · 14 days ago' }))
await vi.advanceTimersByTimeAsync(700)
})
const previewValue = screen.getByText('Initial release')
expect(closestWithClass(previewValue, 'min-w-48')).toHaveClass('system-xs-regular')
})
})

View File

@ -50,7 +50,7 @@ export function ReleaseMetaTooltip({ release, deployed, children }: {
<PreviewCard>
<PreviewCardTrigger render={children} />
<PreviewCardContent popupClassName="px-3 py-2">
<div className="flex min-w-48 flex-col gap-1">
<div className="flex min-w-48 flex-col gap-1 system-xs-regular">
{rows.map(row => (
<div key={row.label} className="flex justify-between gap-4">
<span className="shrink-0 text-text-tertiary">{row.label}</span>