Skip to content

Commit 9c640b6

Browse files
authored
ref(docs): Adjust OTel badge color based on value (#251)
1 parent f053b1d commit 9c640b6

File tree

4 files changed

+49
-5
lines changed

4 files changed

+49
-5
lines changed

docs/src/components/AttributeCard.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
import PiiBadge from './PiiBadge.astro';
3+
import OtelBadge from './OtelBadge.astro';
34
import TypeBadge from './TypeBadge.astro';
45
import type { Attribute } from '../content.config';
56
import { parseAttributeId } from '../utils/category';
@@ -41,7 +42,7 @@ const rawJson = JSON.stringify(attribute, null, 2);
4142
<TypeBadge type={attribute.type} />
4243
<PiiBadge pii={attribute.pii.key} reason={attribute.pii.reason} />
4344
{attribute.is_in_otel != null && (
44-
<span class="badge badge-otel" title="Defined in OpenTelemetry Semantic Conventions">OTel: {attribute.is_in_otel ? 'True' : 'False'}</span>
45+
<OtelBadge isInOtel={attribute.is_in_otel} />
4546
)}
4647
{attribute.has_dynamic_suffix && (
4748
<span class="badge badge-dynamic" title="This attribute has a dynamic suffix">Dynamic</span>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
interface Props {
3+
isInOtel: boolean;
4+
}
5+
6+
const { isInOtel } = Astro.props;
7+
8+
const labels = {
9+
true: 'OTel: True',
10+
false: 'OTel: False',
11+
};
12+
13+
const colorClasses = {
14+
true: 'bg-otel-true-soft text-otel-true',
15+
false: 'bg-otel-false-soft text-otel-false',
16+
};
17+
18+
const valueKey = isInOtel ? 'true' : 'false';
19+
---
20+
21+
<span
22+
class:list={[
23+
"inline-flex items-center px-2 py-1 text-xs font-medium rounded-sm uppercase tracking-wide",
24+
colorClasses[valueKey]
25+
]}
26+
title="Defined in OpenTelemetry Semantic Conventions"
27+
>
28+
{labels[valueKey]}
29+
</span>

docs/src/styles/global.css

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
--color-pii-maybe-soft: rgba(234, 179, 8, 0.15);
3636
--color-pii-false: #22c55e;
3737
--color-pii-false-soft: rgba(34, 197, 94, 0.15);
38+
39+
--color-otel-true: #22c55e;
40+
--color-otel-true-soft: rgba(34, 197, 94, 0.15);
41+
--color-otel-false: #64748b;
42+
--color-otel-false-soft: rgba(100, 116, 139, 0.2);
3843
}
3944

4045
.dark {
@@ -73,6 +78,11 @@
7378
--color-pii-maybe-soft: rgba(212, 167, 44, 0.15);
7479
--color-pii-false: #50a060;
7580
--color-pii-false-soft: rgba(80, 160, 96, 0.15);
81+
82+
--color-otel-true: #50a060;
83+
--color-otel-true-soft: rgba(80, 160, 96, 0.15);
84+
--color-otel-false: #6b7280;
85+
--color-otel-false-soft: rgba(107, 114, 128, 0.2);
7686
}
7787

7888
@tailwind base;
@@ -207,10 +217,6 @@
207217
@apply bg-error-soft text-error;
208218
}
209219

210-
.badge-otel {
211-
@apply bg-info-soft text-info;
212-
}
213-
214220
.badge-dynamic {
215221
@apply bg-warning-soft text-warning;
216222
}

docs/tailwind.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ export default {
5959
false: 'var(--color-pii-false)',
6060
'false-soft': 'var(--color-pii-false-soft)',
6161
},
62+
63+
// OTEL indicator colors
64+
otel: {
65+
true: 'var(--color-otel-true)',
66+
'true-soft': 'var(--color-otel-true-soft)',
67+
false: 'var(--color-otel-false)',
68+
'false-soft': 'var(--color-otel-false-soft)',
69+
},
6270
},
6371
fontFamily: {
6472
sans: ['DM Sans', 'system-ui', '-apple-system', 'BlinkMacSystemFont', 'sans-serif'],

0 commit comments

Comments
 (0)