-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #423 from duyet/chore/ui-update
feat: add column Markdown format
- Loading branch information
Showing
14 changed files
with
782 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { MarkdownFormat } from './markdown-format' | ||
|
||
describe('<MarkdownFormat />', () => { | ||
it('renders basic markdown text', () => { | ||
cy.mount(<MarkdownFormat value="Hello **World**" />) | ||
cy.get('strong').should('contain', 'World') | ||
}) | ||
|
||
it('renders empty string when value is null or undefined', () => { | ||
cy.mount(<MarkdownFormat value={null} />) | ||
cy.get('span').should('have.text', '') | ||
|
||
cy.mount(<MarkdownFormat value={undefined} />) | ||
cy.get('span').should('have.text', '') | ||
}) | ||
|
||
it('applies default classes', () => { | ||
cy.mount(<MarkdownFormat value="Test" />) | ||
cy.get('span') | ||
.should('have.class', 'truncate') | ||
.and('have.class', 'text-wrap') | ||
}) | ||
|
||
it('applies custom className from options', () => { | ||
cy.mount( | ||
<MarkdownFormat value="Test" options={{ className: 'text-red-500' }} /> | ||
) | ||
cy.get('span') | ||
.should('have.class', 'text-red-500') | ||
.and('have.class', 'truncate') | ||
.and('have.class', 'text-wrap') | ||
}) | ||
|
||
it('handles non-string values by converting to string', () => { | ||
cy.mount(<MarkdownFormat value={123} />) | ||
cy.get('span').should('contain', '123') | ||
|
||
cy.mount(<MarkdownFormat value={true} />) | ||
cy.get('span').should('contain', 'true') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { cn } from '@/lib/utils' | ||
import Markdown from 'react-markdown' | ||
|
||
export interface MarkdownFormatOptions { | ||
className?: string | ||
} | ||
|
||
interface MarkdownFormatProps { | ||
value: any | ||
options?: MarkdownFormatOptions | ||
} | ||
|
||
export function MarkdownFormat({ value, options }: MarkdownFormatProps) { | ||
return ( | ||
<span className={cn('truncate text-wrap', options?.className)}> | ||
<Markdown>{`${!!value ? value : ''}`}</Markdown> | ||
</span> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use client' | ||
|
||
import { cn } from '@/lib/utils' | ||
|
||
export interface CardMetricProps { | ||
current: number | ||
target: number | ||
currentReadable?: string | ||
targetReadable?: string | ||
className?: string | ||
} | ||
|
||
export function CardMetric({ | ||
current, | ||
target, | ||
currentReadable, | ||
targetReadable, | ||
className, | ||
}: CardMetricProps) { | ||
const percent = (current / target) * 100 | ||
|
||
return ( | ||
<div className={cn('flex flex-col gap-4', className)}> | ||
<div className="text-xl md:text-3xl">{currentReadable || current}</div> | ||
|
||
<div> | ||
<div className="mt-2 flex flex-row items-center justify-between gap-2"> | ||
<span | ||
className="truncate text-muted-foreground" | ||
title={`${percent}%`} | ||
> | ||
{currentReadable || current} | ||
</span> | ||
<hr className="shrink grow border-dotted" /> | ||
<span className="text-nowrap">{targetReadable || target}</span> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
245ca28
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.
Successfully deployed to the following URLs:
clickhouse-monitoring – ./
clickhouse-monitor.vercel.app
clickhouse-monitoring-git-main-duyet-team.vercel.app
clickhouse.duyet.net
clickhouse-monitoring-duyet-team.vercel.app
clickhouse-dashboard.vercel.app
clickhouse-monitoring.vercel.app