Skip to content

Commit

Permalink
feat: make the label value clickable if it's a link
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadshaheer committed Sep 12, 2024
1 parent 381a4de commit d0d8898
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
font-weight: 400;
line-height: 18px;
letter-spacing: -0.005em;
&,
&:hover {
color: var(--text-vanilla-400);
}
}
&__key {
background: var(--bg-ink-400);
Expand All @@ -20,13 +24,15 @@
&__value {
background: var(--bg-slate-400);
}
color: var(--text-vanilla-400);
}

.lightMode {
.key-value-label {
border-color: var(--bg-vanilla-400);
color: var(--text-ink-400);
&__key,
&__value {
color: var(--text-ink-400);
}
&__key {
background: var(--bg-vanilla-300);
}
Expand Down
23 changes: 19 additions & 4 deletions frontend/src/periscope/components/KeyValueLabel/KeyValueLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import './KeyValueLabel.styles.scss';

import { Tooltip } from 'antd';
import { useMemo } from 'react';

import TrimmedText from '../TrimmedText/TrimmedText';

Expand All @@ -15,19 +16,33 @@ export default function KeyValueLabel({
badgeValue,
maxCharacters = 20,
}: KeyValueLabelProps): JSX.Element | null {
const isUrl = useMemo(() => /^https?:\/\//.test(badgeValue), [badgeValue]);

if (!badgeKey || !badgeValue) {
return null;
}

return (
<div className="key-value-label">
<div className="key-value-label__key">
<TrimmedText text={badgeKey} maxCharacters={maxCharacters} />
</div>
<Tooltip title={badgeValue}>
<div className="key-value-label__value">
{isUrl ? (
<a
href={badgeValue}
target="_blank"
rel="noopener noreferrer"
className="key-value-label__value"
>
<TrimmedText text={badgeValue} maxCharacters={maxCharacters} />
</div>
</Tooltip>
</a>
) : (
<Tooltip title={badgeValue}>
<div className="key-value-label__value">
<TrimmedText text={badgeValue} maxCharacters={maxCharacters} />
</div>
</Tooltip>
)}
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions signoz-core-ui
Submodule signoz-core-ui added at f8c925

0 comments on commit d0d8898

Please sign in to comment.