Skip to content
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

2189-Add-spacing-around-and-graysacale-in-check-names #2340

Merged
merged 2 commits into from
Oct 31, 2024
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
10 changes: 6 additions & 4 deletions src/components/Canary/CanaryCards.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";
import { GetName } from "./data";
import { Title, StatusList } from "./renderers";
import { HealthCheck } from "../../api/types/health";
import { GetName } from "./data";
import { CanaryCheckName, StatusList } from "./renderers";

type CanaryCardProps = {
checks: HealthCheck[];
Expand All @@ -23,7 +22,10 @@ export function CanaryCards({ checks, onClick }: CanaryCardProps) {
>
<div className="flex-1 py-2 text-sm">
<span className="truncate font-medium text-gray-900 hover:text-gray-600">
<Title title={GetName(check)} icon={check.icon || check.type} />
<CanaryCheckName
title={GetName(check)}
icon={check.icon || check.type}
/>
</span>
<div className="float-right mr-2">
<StatusList check={check} />
Expand Down
10 changes: 8 additions & 2 deletions src/components/Canary/Columns/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import dayjs from "dayjs";
import { Status } from "../../Status";
import { GetName } from "../data";
import style from "../index.module.css";
import { Duration, Percentage, StatusList, Title, empty } from "../renderers";
import {
CanaryCheckName,
Duration,
empty,
Percentage,
StatusList
} from "../renderers";
import { removeNamespacePrefix } from "../utils";
import {
getHealthPercentageScore,
Expand Down Expand Up @@ -131,7 +137,7 @@ export function TitleCell({
// paddingLeft: `${row.depth * 1.1}rem`
// }}
>
<Title
<CanaryCheckName
title={title}
icon={rowValues.icon || rowValues.type}
isDeleted={!!row.original.deleted_at}
Expand Down
41 changes: 38 additions & 3 deletions src/components/Canary/renderers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,52 @@ export function Percentage({ val, upper, lower }: PercentageProps) {
);
}

type TitleProps = {
type CanaryCheckNameProps = {
icon?: string;
title: string;
isDeleted?: boolean;
};

export function Title({ icon, title, isDeleted }: TitleProps) {
export function CanaryCheckName({
icon,
title,
isDeleted
}: CanaryCheckNameProps) {
const hasSlash = title.includes("/");

if (hasSlash) {
const parts = title.split("/");
return (
<>
{icon && <Icon name={icon} className="h-6 w-auto pr-1" />}
{parts.map((part, idx) => {
// if not last part
if (idx !== parts.length - 1) {
return (
<>
<span key={part} className="text-sm text-gray-500">
{part}
</span>
<span className="text-light px-0.5 text-gray-500">/</span>
</>
);
}
// last part
return (
<span key={part} className="text-sm">
{part}
</span>
);
})}
{isDeleted && <TbTrash />}
</>
);
}

return (
<>
{icon && <Icon name={icon} className="h-6 w-auto" />}
<span className="pl-1 text-sm">{title}</span> {isDeleted && <TbTrash />}
<span className="pl-1 text-sm">{title} </span> {isDeleted && <TbTrash />}
</>
);
}
Expand Down
Loading