Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/app-nav-badges-click-ui.md
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 5 additions & 7 deletions packages/app/src/components/AppNav/AppNav.components.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -388,13 +388,11 @@ export const AppNavLink = ({
</span>
{!isCollapsed && isBeta && (
<Badge
size="xs"
color="blue"
variant="light"
size="sm"
text="Beta"
state="info"
className={styles.navItemBadge}
>
Beta
</Badge>
/>
)}
{!isCollapsed && onToggle && (
<Tooltip
Expand Down
13 changes: 5 additions & 8 deletions packages/app/src/components/AppNav/AppNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import Link from 'next/link';
import Router, { useRouter } from 'next/router';
import Script from 'next/script';
import cx from 'classnames';
import { Badge } from '@clickhouse/click-ui';
import HyperDX from '@hyperdx/browser';
import { SavedSearchListApiResponse } from '@hyperdx/common-utils/dist/types';
import {
ActionIcon,
Anchor,
Badge,
Collapse,
Flex,
Group,
Expand Down Expand Up @@ -378,14 +378,11 @@ export default function AppNav({ fixed = false }: { fixed?: boolean }) {
fallback={
isUTC && (
<Badge
size="xs"
color="gray"
variant="light"
fw="normal"
size="sm"
text="UTC"
state="neutral"
title="Showing time in UTC"
>
UTC
</Badge>
/>
)
}
/>
Expand Down
14 changes: 5 additions & 9 deletions packages/app/src/components/AppNav/InstanceLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReactNode } from 'react';
import { Badge } from '@mantine/core';
import { Badge } from '@clickhouse/click-ui';

import { INSTANCE_LABEL } from '@/config';

Expand All @@ -12,11 +12,9 @@ export function InstanceLabel({ fallback = null }: { fallback?: ReactNode }) {
}
return (
<Badge
size="xs"
color="gray"
variant="light"
fw="normal"
tt="none"
size="sm"
text={INSTANCE_LABEL}
state="neutral"
title={INSTANCE_LABEL}
// Capped well under the sidebar's available width (wordmark + gap +
// collapse button) so a long label can't push the header's content past
Expand All @@ -25,8 +23,6 @@ export function InstanceLabel({ fallback = null }: { fallback?: ReactNode }) {
// min-width:0 alone doesn't prevent a maxed-out badge from wrapping the
// collapse button onto a second, clipped line.
style={{ minWidth: 0, maxWidth: 80 }}
>
{INSTANCE_LABEL}
</Badge>
/>
);
}
8 changes: 2 additions & 6 deletions packages/app/src/components/AppNav/WhatsNewDrawer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ReactMarkdown from 'react-markdown';
import { Badge } from '@clickhouse/click-ui';
import {
Anchor,
Badge,
Card,
Center,
Divider,
Expand Down Expand Up @@ -107,11 +107,7 @@ export const WhatsNewDrawer = ({
>
<Group gap="xs">
<Title order={4}>v{release.version}</Title>
{idx === 0 && (
<Badge variant="light" color="blue">
Latest
</Badge>
)}
{idx === 0 && <Badge text="Latest" state="info" />}
{release.date && (
<Text size="xs" c="dimmed">
{release.date}
Expand Down
11 changes: 5 additions & 6 deletions packages/app/src/components/AppNav/WhatsNewHighlightRow.tsx
Original file line number Diff line number Diff line change
@@ -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';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — Small component now mixes click-ui and Mantine, against the Click UI convention

WhatsNewHighlightRow is about 20 lines and now renders a click-ui Badge inside Mantine Group/Box/Text. The Click UI section of the repository conventions says: "Do not: Mix both libraries inside one small component". Fix: move the rest of the row to click-ui as well (Text exists there, and Container can replace the Group, set up to match the current layout as that section describes), or keep the Mantine Badge in this row until the whole row is migrated.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond


import type { WhatsNew } from './useWhatsNew';

Expand Down Expand Up @@ -32,11 +33,9 @@ export const WhatsNewHighlightRow = ({
<Box w={BADGE_COLUMN_WIDTH} flex="none">
<Badge
size="sm"
variant="light"
color={headline.kind === 'breaking' ? 'red' : 'blue'}
>
{headline.kind === 'breaking' ? 'Breaking' : 'New'}
</Badge>
text={headline.kind === 'breaking' ? 'Breaking' : 'New'}
state={headline.kind === 'breaking' ? 'danger' : 'info'}
/>
</Box>
{/* flex + miw=0 lets the headline wrap and clamp within the row rather than
forcing the container wider. */}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }) => (
<span data-testid="badge" data-state={state}>
{text}
</span>
),
}));

describe('WhatsNewHighlightRow', () => {
it.each([
['breaking', 'Breaking', 'danger'],
['feature', 'New', 'info'],
] as const)(
'renders a %s headline with the %s badge',
(kind, label, state) => {
renderWithMantine(
<WhatsNewHighlightRow headline={{ kind, text: 'A headline' }} />,
);

const badge = screen.getByTestId('badge');
expect(badge).toHaveTextContent(label);
expect(badge).toHaveAttribute('data-state', state);
expect(screen.getByTestId('whats-new-headline')).toHaveTextContent(
'A headline',
);
},
);
});
2 changes: 1 addition & 1 deletion packages/app/tests/e2e/core/navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
Loading