Repository navigation
feat: add click-ui; change bug report anchor to use Link component #3262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| '@hyperdx/app': patch | ||
| --- | ||
|
|
||
| feat: add `@clickhouse/click-ui` as a dependency and mount `ClickUIProvider` | ||
| next to `MantineProvider`. The provider follows the HyperDX color mode and does | ||
| not persist its own theme. The "open an issue on GitHub" link in error messages | ||
| is the first component to use click-ui (`Link`). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -406,6 +406,24 @@ The UI is built with **Mantine components**, but **colors and surfaces** should | |
|
|
||
| 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. | ||
|
|
||
| ## Click UI (incremental adoption) | ||
|
|
||
| `@clickhouse/click-ui` is a dependency of `packages/app`. `ThemeWrapper` mounts | ||
| `ClickUIProvider` inside `MantineProvider` with `persistTheme={false}`, so it | ||
| follows the HyperDX color mode and never writes its own theme to localStorage. | ||
| Storybook and `renderWithMantine` in tests get the provider for free. | ||
|
|
||
| - **Do**: Prefer a click-ui component over a new Mantine one when click-ui has | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — New 'prefer click-ui over Mantine' rule contradicts the existing 'Prefer Mantine components' rule in the same doc The base convention under "Mantine UI Components" says "Prefer Mantine components over custom-styled elements". The new bullet tells contributors to pick click-ui 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 |
||
| an equivalent for a simple primitive (`Link`, `Text`, `Title`, `Container`, | ||
| `Badge`, `Separator`, `Spacer`, `Icon`). Import from `@clickhouse/click-ui`. | ||
| - **Do not**: Mix both libraries inside one small component, and do not | ||
| replace working Mantine code outside the change you were asked to make. | ||
| - **Styling**: click-ui styles live in the `clickui` CSS cascade layer, so any | ||
| unlayered app or Mantine rule wins over them. Override `--click-*` variables | ||
| outside the layer if a token must change. | ||
| - **First use**: `packages/app/src/components/ContactSupportText.tsx` and the | ||
| `Click UI/Link` story in `packages/app/src/stories/ClickUI.stories.tsx`. | ||
|
|
||
| **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. | ||
|
|
||
| ## Refactoring | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import React from 'react'; | ||
| import { ClickUIProvider } from '@clickhouse/click-ui'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — Importing the click-ui barrel in the app-wide provider likely adds the whole library to every page's bundle
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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a real issue. From claude:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — Barrel import of click-ui in _app likely puts all of click-ui in the shared bundle ThemeWrapper is rendered by 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed. The What to do
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — All of click-ui is loaded on every page just to render one Link
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 { MantineProvider, MantineThemeOverride } from '@mantine/core'; | ||
| import { Notifications } from '@mantine/notifications'; | ||
|
|
||
|
|
@@ -36,8 +37,11 @@ export const ThemeWrapper = ({ | |
|
|
||
| return ( | ||
| <MantineProvider forceColorScheme={colorScheme} theme={mantineTheme}> | ||
| <Notifications zIndex={999999} /> | ||
| {children} | ||
| {/* HyperDX user preferences determine the color mode, so click-ui should not persist preferences to localstorage. */} | ||
| <ClickUIProvider theme={colorScheme} persistTheme={false}> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — ClickUIProvider adds a second, always-empty toast viewport to every page next to Mantine Notifications The PR's own test change (SpanLinkedFromSubpanel.test.tsx) shows ClickUIProvider renders an empty Radix toast viewport ( 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — ClickUIProvider adds a second, always-empty toast viewport to every page The updated SpanLinkedFromSubpanel test ("the providers add ... an empty toast viewport region") shows ClickUIProvider mounts a Radix Toast viewport. In 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — ClickUIProvider adds a second, always-empty toast viewport landmark next to Mantine Notifications The 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — ClickUIProvider adds a second, always-empty toast region to every page The updated SpanLinkedFromSubpanel test confirms the provider renders an empty toast viewport ( 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 |
||
| <Notifications zIndex={999999} /> | ||
| {children} | ||
| </ClickUIProvider> | ||
| </MantineProvider> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import React from 'react'; | ||
|
|
||
| // @clickhouse/click-ui's barrel export pulls in react-syntax-highlighter for | ||
| // CodeBlock, whose prism build depends on ESM-only hastscript that Jest cannot | ||
| // parse. Unit tests never render a click-ui CodeBlock, so this stub only needs | ||
| // the surface the click-ui module touches at import time. | ||
| function Highlighter({ children }: { children?: React.ReactNode }) { | ||
| return <pre>{children}</pre>; | ||
| } | ||
|
|
||
| Highlighter.registerLanguage = () => undefined; | ||
|
|
||
| export const Light = Highlighter; | ||
| export const Prism = Highlighter; | ||
| export const PrismLight = Highlighter; | ||
| export const createElement = () => null; | ||
| export default Highlighter; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // The link should look like normal font instead of click-ui's link font. | ||
| .inlineLink { | ||
| font: inherit; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,24 @@ | ||
| import { Link } from '@clickhouse/click-ui'; | ||
|
|
||
| import { IS_OSS } from '@/config'; | ||
|
|
||
| import styles from './ContactSupportText.module.scss'; | ||
|
|
||
| const GH_LINK = 'https://github.com/hyperdxio/hyperdx/issues'; | ||
|
|
||
| export const ContactSupportText = () => { | ||
| if (IS_OSS) { | ||
| return ( | ||
| <span> | ||
| Please open an issue on{' '} | ||
| <a href={GH_LINK} target="_blank"> | ||
| <Link | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — Global
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 |
||
| className={styles.inlineLink} | ||
| href={GH_LINK} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| GitHub | ||
| </a> | ||
| </Link> | ||
| . | ||
| </span> | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import React from 'react'; | ||
| /* Polyfills for browser APIs in Node.js test environment */ | ||
| import { TextDecoder, TextEncoder } from 'util'; | ||
| import { ClickUIProvider } from '@clickhouse/click-ui'; | ||
| import { MantineProvider } from '@mantine/core'; | ||
| import { Notifications } from '@mantine/notifications'; | ||
| import { render } from '@testing-library/react'; | ||
|
|
@@ -33,13 +34,17 @@ Object.defineProperty(window, 'matchMedia', { | |
| }), | ||
| }); | ||
|
|
||
| global.renderWithMantine = (ui: React.ReactElement) => { | ||
| return render( | ||
| <MantineProvider> | ||
| global.TestProviders = ({ children }: { children: React.ReactNode }) => ( | ||
| <MantineProvider> | ||
| <ClickUIProvider theme="dark" persistTheme={false}> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — Test providers hardcode a dark click-ui theme while Mantine renders in light
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 |
||
| <Notifications /> | ||
| {ui} | ||
| </MantineProvider>, | ||
| ); | ||
| {children} | ||
| </ClickUIProvider> | ||
| </MantineProvider> | ||
| ); | ||
|
|
||
| global.renderWithMantine = (ui: React.ReactElement) => { | ||
| return render(<TestProviders>{ui}</TestProviders>); | ||
| }; | ||
|
|
||
| if (!globalThis.structuredClone) { | ||
|
|
@@ -49,4 +54,6 @@ if (!globalThis.structuredClone) { | |
|
|
||
| declare global { | ||
| function renderWithMantine(ui: React.ReactElement): ReturnType<typeof render>; | ||
| // `var`, not `const`, so the global assignment above passes type-check | ||
| var TestProviders: React.FC<{ children: React.ReactNode }>; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { Link, Text } from '@clickhouse/click-ui'; | ||
| import { Stack } from '@mantine/core'; | ||
| import type { Meta, StoryObj } from '@storybook/nextjs'; | ||
|
|
||
| import { ContactSupportText } from '@/components/ContactSupportText'; | ||
|
|
||
| // Smoke test for the click-ui integration: the provider in ThemeWrapper must | ||
| // follow the Storybook theme toggle, and click-ui text must sit next to | ||
| // Mantine layout without either library's globals breaking the other. | ||
| const meta: Meta<typeof Link> = { | ||
| title: 'Click UI/Link', | ||
| component: Link, | ||
| parameters: { | ||
| layout: 'centered', | ||
| }, | ||
| argTypes: { | ||
| size: { | ||
| control: 'select', | ||
| options: ['xs', 'sm', 'md', 'lg'], | ||
| }, | ||
| weight: { | ||
| control: 'select', | ||
| options: ['normal', 'medium', 'semibold', 'bold', 'mono'], | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof Link>; | ||
|
|
||
| export const Playground: Story = { | ||
| args: { | ||
| children: 'Open the ClickHouse docs', | ||
| href: 'https://clickhouse.com/docs', | ||
| target: '_blank', | ||
| size: 'md', | ||
| weight: 'normal', | ||
| }, | ||
| }; | ||
|
|
||
| export const WithIcon: Story = { | ||
| args: { | ||
| children: 'View in ClickHouse', | ||
| href: 'https://clickhouse.com', | ||
| target: '_blank', | ||
| icon: 'popout', | ||
| }, | ||
| }; | ||
|
|
||
| export const InErrorMessage: Story = { | ||
| render: () => ( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — Remove the 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 |
||
| <Stack gap="xs"> | ||
| <Text> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — InErrorMessage story uses click-ui Text inside a Mantine Stack, which doesn't match real usage and breaks the doc's own 'don't mix libraries' rule In production, 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 |
||
| An error occurred. <ContactSupportText /> | ||
| </Text> | ||
|
Comment on lines
+52
to
+55
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Context Used: AGENTS.md (source) Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| </Stack> | ||
| ), | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔵 minor — New Click UI section splits the semantic-tokens section, so the chart-colors rule now sits under the Click UI heading
Move the
## Click UI (incremental adoption)block below the "Chart and visualization colors are a separate, more specific contract" paragraph. That paragraph belongs to "Semantic design tokens", and right now it reads as part of the Click UI guidance.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