Skip to content

Commit 32e2ae9

Browse files
feat: add click-ui; change bug report anchor to use Link component
1 parent 51e47b1 commit 32e2ae9

14 files changed

Lines changed: 1357 additions & 88 deletions

‎.changeset/add-click-ui.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@hyperdx/app': patch
3+
---
4+
5+
feat: add `@clickhouse/click-ui` as a dependency and mount `ClickUIProvider`
6+
next to `MantineProvider`. The provider follows the HyperDX color mode and does
7+
not persist its own theme. The "open an issue on GitHub" link in error messages
8+
is the first component to use click-ui (`Link`).

‎agent_docs/code_style.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,24 @@ The UI is built with **Mantine components**, but **colors and surfaces** should
406406

407407
Mantine theme overrides in `packages/app/src/theme/**` may map Mantine’s scale to our palette; that does not replace using **`var(--color-...)`** in new styling where you need explicit color control.
408408

409+
## Click UI (incremental adoption)
410+
411+
`@clickhouse/click-ui` is a dependency of `packages/app`. `ThemeWrapper` mounts
412+
`ClickUIProvider` inside `MantineProvider` with `persistTheme={false}`, so it
413+
follows the HyperDX color mode and never writes its own theme to localStorage.
414+
Storybook and `renderWithMantine` in tests get the provider for free.
415+
416+
- **Do**: Prefer a click-ui component over a new Mantine one when click-ui has
417+
an equivalent for a simple primitive (`Link`, `Text`, `Title`, `Container`,
418+
`Badge`, `Separator`, `Spacer`, `Icon`). Import from `@clickhouse/click-ui`.
419+
- **Do not**: Mix both libraries inside one small component, and do not
420+
replace working Mantine code outside the change you were asked to make.
421+
- **Styling**: click-ui styles live in the `clickui` CSS cascade layer, so any
422+
unlayered app or Mantine rule wins over them. Override `--click-*` variables
423+
outside the layer if a token must change.
424+
- **First use**: `packages/app/src/components/ContactSupportText.tsx` and the
425+
`Click UI/Link` story in `packages/app/src/stories/ClickUI.stories.tsx`.
426+
409427
**Chart and visualization colors are a separate, more specific contract** — they have their own categorical, semantic, and heatmap palettes wired through `packages/app/src/utils.ts` helpers. Don't hard-code series colors or reuse `--color-text-*` for charts. See [`data_viz_colors.md`](./data_viz_colors.md) before touching anything that renders data.
410428

411429
## Refactoring

‎packages/app/jest.config.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ module.exports = {
2525
'^ky$': '<rootDir>/src/__mocks__/ky-universal.ts',
2626
'^react-markdown$': '<rootDir>/src/__mocks__/react-markdown.tsx',
2727
'^remark-gfm$': '<rootDir>/src/__mocks__/remark-gfm.ts',
28+
'^react-syntax-highlighter$':
29+
'<rootDir>/src/__mocks__/react-syntax-highlighter.tsx',
30+
// @clickhouse/click-ui depends on ESM-only lodash-es; lodash has the same API.
31+
'^lodash-es$': 'lodash',
32+
'^lodash-es/(.*)$': 'lodash/$1',
2833
},
2934
setupFilesAfterEnv: ['<rootDir>/src/setupTests.tsx'],
3035
// Coverage floors are scoped to hooks/ and utils/ only — the genuinely

‎packages/app/next.config.mjs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ const nextConfig = {
9494
// when running dev and E2E simultaneously (e.g. NEXT_DIST_DIR=.next-e2e)
9595
...(process.env.NEXT_DIST_DIR ? { distDir: process.env.NEXT_DIST_DIR } : {}),
9696
reactCompiler: true,
97+
// click-ui ships per-component CSS imports from node_modules, which Next
98+
// rejects as global CSS unless the package is transpiled.
99+
transpilePackages: ['@clickhouse/click-ui'],
97100
basePath: basePath,
98101
env: {
99102
// Ensures bundler-time replacements for client/server code that references this env var

‎packages/app/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"storybook:build": "storybook build"
2727
},
2828
"dependencies": {
29+
"@clickhouse/click-ui": "^0.12.0",
2930
"@codemirror/autocomplete": "^6.0.0",
3031
"@codemirror/lang-json": "^6.0.1",
3132
"@codemirror/lang-sql": "^6.7.0",

‎packages/app/src/ThemeWrapper.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import { ClickUIProvider } from '@clickhouse/click-ui';
23
import { MantineProvider, MantineThemeOverride } from '@mantine/core';
34
import { Notifications } from '@mantine/notifications';
45

@@ -36,8 +37,11 @@ export const ThemeWrapper = ({
3637

3738
return (
3839
<MantineProvider forceColorScheme={colorScheme} theme={mantineTheme}>
39-
<Notifications zIndex={999999} />
40-
{children}
40+
{/* HyperDX user preferences determine the color mode, so click-ui should not persist preferences to localstorage. */}
41+
<ClickUIProvider theme={colorScheme} persistTheme={false}>
42+
<Notifications zIndex={999999} />
43+
{children}
44+
</ClickUIProvider>
4145
</MantineProvider>
4246
);
4347
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react';
2+
3+
// @clickhouse/click-ui's barrel export pulls in react-syntax-highlighter for
4+
// CodeBlock, whose prism build depends on ESM-only hastscript that Jest cannot
5+
// parse. Unit tests never render a click-ui CodeBlock, so this stub only needs
6+
// the surface the click-ui module touches at import time.
7+
function Highlighter({ children }: { children?: React.ReactNode }) {
8+
return <pre>{children}</pre>;
9+
}
10+
11+
Highlighter.registerLanguage = () => undefined;
12+
13+
export const Light = Highlighter;
14+
export const Prism = Highlighter;
15+
export const PrismLight = Highlighter;
16+
export const createElement = () => null;
17+
export default Highlighter;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// The link should look like normal font instead of click-ui's link font.
2+
.inlineLink {
3+
font: inherit;
4+
}

‎packages/app/src/components/ContactSupportText.tsx‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
1+
import { Link } from '@clickhouse/click-ui';
2+
13
import { IS_OSS } from '@/config';
24

5+
import styles from './ContactSupportText.module.scss';
6+
37
const GH_LINK = 'https://github.com/hyperdxio/hyperdx/issues';
48

59
export const ContactSupportText = () => {
610
if (IS_OSS) {
711
return (
812
<span>
913
Please open an issue on{' '}
10-
<a href={GH_LINK} target="_blank">
14+
<Link
15+
className={styles.inlineLink}
16+
href={GH_LINK}
17+
target="_blank"
18+
rel="noopener noreferrer"
19+
>
1120
GitHub
12-
</a>
21+
</Link>
1322
.
1423
</span>
1524
);

‎packages/app/src/components/__tests__/DBTimeChart.test.tsx‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import React from 'react';
2-
import { MantineProvider } from '@mantine/core';
3-
import { Notifications } from '@mantine/notifications';
42
import { screen, waitFor } from '@testing-library/react';
53
import userEvent from '@testing-library/user-event';
64

@@ -307,8 +305,7 @@ describe('DBTimeChart', () => {
307305
// survive — this also guards against dateRange being reintroduced into
308306
// queryShapeIdentity, which would make live-range ticks re-cap the chart.
309307
rerender(
310-
<MantineProvider>
311-
<Notifications />
308+
<TestProviders>
312309
<DBTimeChart
313310
config={{
314311
...groupByConfig,
@@ -318,7 +315,7 @@ describe('DBTimeChart', () => {
318315
],
319316
}}
320317
/>
321-
</MantineProvider>,
318+
</TestProviders>,
322319
);
323320

324321
// The opt-in survives: no series are re-hidden, so the affordance stays
@@ -349,10 +346,9 @@ describe('DBTimeChart', () => {
349346
// Change the query shape (a positive seriesLimit below GROUP_COUNT keeps
350347
// series hidden), which should reset the opt-in and re-show the affordance.
351348
rerender(
352-
<MantineProvider>
353-
<Notifications />
349+
<TestProviders>
354350
<DBTimeChart config={{ ...groupByConfig, seriesLimit: 5 }} />
355-
</MantineProvider>,
351+
</TestProviders>,
356352
);
357353

358354
expect(

0 commit comments

Comments
 (0)