diff --git a/.changeset/app-nav-badges-click-ui.md b/.changeset/app-nav-badges-click-ui.md new file mode 100644 index 0000000000..67a0fd2e73 --- /dev/null +++ b/.changeset/app-nav-badges-click-ui.md @@ -0,0 +1,6 @@ +--- +'@hyperdx/app': patch +--- + +feat: use the click-ui `Badge` for the sidebar "Beta", "UTC", and instance +label badges, and for the "Latest", "New", and "Breaking" badges in What's new. diff --git a/packages/app/src/components/AppNav/AppNav.components.tsx b/packages/app/src/components/AppNav/AppNav.components.tsx index b50d2b3b1e..13d457f20e 100644 --- a/packages/app/src/components/AppNav/AppNav.components.tsx +++ b/packages/app/src/components/AppNav/AppNav.components.tsx @@ -1,9 +1,9 @@ import React from 'react'; import Link from 'next/link'; import cx from 'classnames'; +import { Badge } from '@clickhouse/click-ui'; import { Avatar, - Badge, Button, Group, Menu, @@ -388,13 +388,11 @@ export const AppNavLink = ({ {!isCollapsed && isBeta && ( - Beta - + /> )} {!isCollapsed && onToggle && ( - UTC - + /> ) } /> diff --git a/packages/app/src/components/AppNav/InstanceLabel.tsx b/packages/app/src/components/AppNav/InstanceLabel.tsx index eaf755891e..0cdddcaed7 100644 --- a/packages/app/src/components/AppNav/InstanceLabel.tsx +++ b/packages/app/src/components/AppNav/InstanceLabel.tsx @@ -1,5 +1,5 @@ import { ReactNode } from 'react'; -import { Badge } from '@mantine/core'; +import { Badge } from '@clickhouse/click-ui'; import { INSTANCE_LABEL } from '@/config'; @@ -12,11 +12,9 @@ export function InstanceLabel({ fallback = null }: { fallback?: ReactNode }) { } return ( - {INSTANCE_LABEL} - + /> ); } diff --git a/packages/app/src/components/AppNav/WhatsNewDrawer.tsx b/packages/app/src/components/AppNav/WhatsNewDrawer.tsx index 7dca8c64e7..65849620e3 100644 --- a/packages/app/src/components/AppNav/WhatsNewDrawer.tsx +++ b/packages/app/src/components/AppNav/WhatsNewDrawer.tsx @@ -1,7 +1,7 @@ import ReactMarkdown from 'react-markdown'; +import { Badge } from '@clickhouse/click-ui'; import { Anchor, - Badge, Card, Center, Divider, @@ -107,11 +107,7 @@ export const WhatsNewDrawer = ({ > v{release.version} - {idx === 0 && ( - - Latest - - )} + {idx === 0 && } {release.date && ( {release.date} diff --git a/packages/app/src/components/AppNav/WhatsNewHighlightRow.tsx b/packages/app/src/components/AppNav/WhatsNewHighlightRow.tsx index ba31c9f886..b031a1c20b 100644 --- a/packages/app/src/components/AppNav/WhatsNewHighlightRow.tsx +++ b/packages/app/src/components/AppNav/WhatsNewHighlightRow.tsx @@ -1,4 +1,5 @@ -import { Badge, Box, Group, Text } from '@mantine/core'; +import { Badge } from '@clickhouse/click-ui'; +import { Box, Group, Text } from '@mantine/core'; import type { WhatsNew } from './useWhatsNew'; @@ -32,11 +33,9 @@ export const WhatsNewHighlightRow = ({ - {headline.kind === 'breaking' ? 'Breaking' : 'New'} - + text={headline.kind === 'breaking' ? 'Breaking' : 'New'} + state={headline.kind === 'breaking' ? 'danger' : 'info'} + /> {/* flex + miw=0 lets the headline wrap and clamp within the row rather than forcing the container wider. */} diff --git a/packages/app/src/components/AppNav/__tests__/WhatsNewHighlightRow.test.tsx b/packages/app/src/components/AppNav/__tests__/WhatsNewHighlightRow.test.tsx new file mode 100644 index 0000000000..c6a77e3074 --- /dev/null +++ b/packages/app/src/components/AppNav/__tests__/WhatsNewHighlightRow.test.tsx @@ -0,0 +1,35 @@ +import { screen } from '@testing-library/react'; + +import { WhatsNewHighlightRow } from '@/components/AppNav/WhatsNewHighlightRow'; + +// click-ui encodes state only in hashed CSS module class names, so the mock +// exposes the props as attributes to assert on. +jest.mock('@clickhouse/click-ui', () => ({ + ...jest.requireActual('@clickhouse/click-ui'), + Badge: ({ text, state }: { text: React.ReactNode; state?: string }) => ( + + {text} + + ), +})); + +describe('WhatsNewHighlightRow', () => { + it.each([ + ['breaking', 'Breaking', 'danger'], + ['feature', 'New', 'info'], + ] as const)( + 'renders a %s headline with the %s badge', + (kind, label, state) => { + renderWithMantine( + , + ); + + const badge = screen.getByTestId('badge'); + expect(badge).toHaveTextContent(label); + expect(badge).toHaveAttribute('data-state', state); + expect(screen.getByTestId('whats-new-headline')).toHaveTextContent( + 'A headline', + ); + }, + ); +}); diff --git a/packages/app/tests/e2e/core/navigation.spec.ts b/packages/app/tests/e2e/core/navigation.spec.ts index e3af50a459..485169926c 100644 --- a/packages/app/tests/e2e/core/navigation.spec.ts +++ b/packages/app/tests/e2e/core/navigation.spec.ts @@ -388,7 +388,7 @@ test.describe('Navigation', { tag: ['@core'] }, () => { await expect(headlines).toHaveCount(2); // Both measurements below are font-metric dependent, and the fallback font - // is wider than the webfont — "BREAKING" genuinely does overflow the column + // is wider than the webfont — "Breaking" genuinely does overflow the column // mid-swap. Wait for the swap so this measures the shipped typeface. await page.evaluate(() => document.fonts.ready.then(() => undefined));