Skip to content

Commit cba6be1

Browse files
committed
add new status badge to link with incident.io
1 parent 1cf1388 commit cba6be1

File tree

3 files changed

+83
-15
lines changed

3 files changed

+83
-15
lines changed

docusaurus.config.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -167,21 +167,7 @@ const config = {
167167
},
168168
footer: {
169169
style: 'light',
170-
links: [
171-
{
172-
html: `
173-
<iframe
174-
src="https://29next.instatus.com/embed-status/f343a721/dark-sm"
175-
width="230"
176-
height="61"
177-
frameBorder="0"
178-
scrolling="no"
179-
style="border: none;"
180-
>
181-
</iframe>
182-
`,
183-
},
184-
],
170+
links: [],
185171
copyright: `Copyright © ${new Date().getFullYear()} Next Commerce`,
186172
},
187173
prism: {

src/components/IncidentStatusBadge.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import React, { useEffect, useState } from 'react';
2+
3+
const STATUS_URL = 'https://status.nextcommerce.com/api/v1/summary';
4+
const STATUS_PAGE_URL = 'https://status.nextcommerce.com/';
5+
6+
const getStatus = (data) => {
7+
const { ongoing_incidents, in_progress_maintenances, scheduled_maintenances } = data;
8+
9+
if (ongoing_incidents.length > 0) {
10+
return { text: 'Active incident in progress', color: '#FFA500' }; // orange
11+
}
12+
13+
if (in_progress_maintenances.length > 0) {
14+
return { text: 'Performing scheduled maintenance', color: '#FFA500' }; // orange
15+
}
16+
17+
if (scheduled_maintenances.length > 0) {
18+
return { text: 'Upcoming schedule maintenance', color: '#007BFF' }; // blue
19+
}
20+
21+
return { text: 'All systems normal', color: '#00d97e' }; // green
22+
};
23+
24+
const dotStyle = (color) => ({
25+
height: '10px',
26+
width: '10px',
27+
backgroundColor: color,
28+
borderRadius: '50%',
29+
display: 'inline-block',
30+
marginRight: '0.5em',
31+
boxShadow: `0 0 3px 2px ${color}`, // glow effect
32+
});
33+
34+
const badgeStyle = {
35+
display: 'inline-flex',
36+
alignItems: 'center',
37+
padding: '0.4em 0.8em',
38+
borderRadius: '9px',
39+
border: '1px solid #e0e0e060',
40+
fontSize: '0.875rem',
41+
fontWeight: 500,
42+
backgroundColor: '#2b2b2b',
43+
textDecoration: 'none',
44+
color: '#fff',
45+
boxShadow: '0 1px 2px rgba(0, 0, 0, 0.05)',
46+
};
47+
48+
const IncidentStatusBadge = () => {
49+
const [status, setStatus] = useState(null);
50+
51+
useEffect(() => {
52+
fetch(STATUS_URL)
53+
.then((res) => res.json())
54+
.then((data) => setStatus(getStatus(data)))
55+
.catch((err) => console.error('Failed to load status:', err));
56+
}, []);
57+
58+
if (!status) return null;
59+
60+
return (
61+
<a href={STATUS_PAGE_URL} target="_blank" rel="noopener noreferrer" style={badgeStyle}>
62+
<span style={dotStyle(status.color)}></span>
63+
{status.text}
64+
</a>
65+
);
66+
};
67+
68+
export default IncidentStatusBadge;

src/theme/Footer/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
import Footer from '@theme-original/Footer';
3+
import IncidentStatusBadge from '../../components/IncidentStatusBadge';
4+
5+
export default function FooterWrapper(props) {
6+
return (
7+
<>
8+
<div style={{ backgroundColor: '#000', textAlign: 'center', padding: '2em' }}>
9+
<IncidentStatusBadge />
10+
</div>
11+
<Footer {...props}></Footer>
12+
</>
13+
);
14+
}

0 commit comments

Comments
 (0)