Skip to content

Commit b9a8ed0

Browse files
authored
feat: add ReleaseLifecycle badge (#575)
* feat: add respective light/dark colors * feat: refactor for colors and theme * feat: add border
1 parent a239fc9 commit b9a8ed0

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

main/snippets/ReleaseLifecycle.jsx

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
export const ReleaseLifecycle = ({ releaseLifecycle = 'GA' }) => {
2+
const lifecycleMap = {
3+
ea: 'Early Access',
4+
ga: 'Generally Available',
5+
deprecated: 'Deprecated',
6+
planned: 'Planned',
7+
beta: 'Beta',
8+
};
9+
10+
// Color theme configuration for different lifecycle stages
11+
const LIFECYCLE_THEMES = {
12+
info: {
13+
light: {
14+
bg: 'lab(91.896% .077188 -6.94053)',
15+
text: 'lab(36.091% 25.9241 -68.0384)',
16+
},
17+
dark: {
18+
bg: 'lab(16.0426% 6.71726 -27.2409)',
19+
text: 'lab(72.6029% 4.08953 -41.9669)',
20+
},
21+
},
22+
secondary: {
23+
light: {
24+
bg: 'lab(90.8548% 11.3355 8.01476)',
25+
text: 'lab(47.5286% 56.4238 43.4706)',
26+
},
27+
dark: {
28+
bg: 'lab(16.3609% 37.191 25.6346)',
29+
text: 'lab(71.881% 41.5 29.4839)',
30+
},
31+
},
32+
danger: {
33+
light: {
34+
bg: 'lab(94.7916% -.0000298023 0)',
35+
text: 'lab(54.3656% 0 -.0000119209)',
36+
},
37+
dark: { bg: 'lab(13.232% 0 0)', text: 'lab(51.6164% 0 0)' },
38+
},
39+
};
40+
41+
// Map lifecycle stages to their corresponding themes
42+
const LIFECYCLE_THEME_MAP = {
43+
ea: 'info',
44+
ga: 'info',
45+
beta: 'info',
46+
deprecated: 'secondary',
47+
planned: 'danger',
48+
};
49+
50+
const lifecycle = releaseLifecycle.toLocaleLowerCase();
51+
const lifecycleText = lifecycleMap[lifecycle];
52+
53+
if (!lifecycleText) {
54+
return null;
55+
}
56+
57+
const theme = LIFECYCLE_THEMES[LIFECYCLE_THEME_MAP[lifecycle]];
58+
59+
return (
60+
<div>
61+
<div className="api-section-heading flex flex-col gap-y-4 w-full">
62+
<div className="flex items-baseline border-b pb-2.5 border-gray-100 dark:border-gray-800 w-full">
63+
<h4 className="api-section-heading-title flex-1 mb-0">
64+
Release Lifecycle
65+
</h4>
66+
</div>
67+
</div>
68+
<div
69+
className="flex font-mono text-sm group/param-head param-head break-all relative mt-2.5"
70+
id="releaselifecycle-lifecycle"
71+
>
72+
<div className="flex-1 flex flex-col content-start py-0.5 mr-5">
73+
<div className="flex items-center flex-wrap gap-2">
74+
<div className="absolute -top-1.5">
75+
<a
76+
href="#releaselifecycle-lifecycle"
77+
className="-ml-10 flex items-center opacity-0 border-0 group-hover/param-head:opacity-100 focus:opacity-100 focus:outline-0 py-2 [.expandable-content_&]:-ml-[2.1rem] group/link"
78+
aria-label="Navigate to header"
79+
>
80+
<div className="w-6 h-6 rounded-md flex items-center justify-center shadow-sm text-gray-400 dark:text-white/50 dark:bg-background-dark dark:brightness-[1.35] dark:ring-1 dark:hover:brightness-150 bg-white ring-1 ring-gray-400/30 dark:ring-gray-700/25 hover:ring-gray-400/60 dark:hover:ring-white/20 group-focus/link:border-2 group-focus/link:border-primary dark:group-focus/link:border-primary-light">
81+
<svg
82+
xmlns="http://www.w3.org/2000/svg"
83+
fill="gray"
84+
height="12px"
85+
viewBox="0 0 576 512"
86+
>
87+
<path d="M0 256C0 167.6 71.6 96 160 96h72c13.3 0 24 10.7 24 24s-10.7 24-24 24H160C98.1 144 48 194.1 48 256s50.1 112 112 112h72c13.3 0 24 10.7 24 24s-10.7 24-24 24H160C71.6 416 0 344.4 0 256zm576 0c0 88.4-71.6 160-160 160H344c-13.3 0-24-10.7-24-24s10.7-24 24-24h72c61.9 0 112-50.1 112-112s-50.1-112-112-112H344c-13.3 0-24-10.7-24-24s10.7-24 24-24h72c88.4 0 160 71.6 160 160zM184 232H392c13.3 0 24 10.7 24 24s-10.7 24-24 24H184c-13.3 0-24-10.7-24-24s10.7-24 24-24z"></path>
88+
</svg>
89+
</div>
90+
</a>
91+
</div>
92+
<span
93+
className="inline-flex items-center w-fit font-medium gap-1 py-0.5 px-2 text-sm tracking-[-0.1px] rounded-lg border"
94+
style={{
95+
backgroundColor: `light-dark(${theme.light.bg}, ${theme.dark.bg})`,
96+
color: `light-dark(${theme.light.text}, ${theme.dark.text})`,
97+
borderColor: `light-dark(color-mix(in oklab, ${theme.light.text} 25%, transparent), color-mix(in oklab, ${theme.dark.text} 25%, transparent))`,
98+
}}
99+
>
100+
{lifecycleText}
101+
</span>
102+
</div>
103+
</div>
104+
</div>
105+
</div>
106+
);
107+
};

0 commit comments

Comments
 (0)