Files
catalog/ts_web/elements/upl-statuspage-statusbar.ts

225 lines
6.2 KiB
TypeScript
Raw Normal View History

2025-06-29 19:55:58 +00:00
import { DeesElement, property, html, customElement, type TemplateResult, cssManager, css, unsafeCSS } from '@design.estate/dees-element';
import * as domtools from '@design.estate/dees-domtools';
2025-06-29 19:55:58 +00:00
import type { IOverallStatus } from '../interfaces/index.js';
2025-06-29 22:36:12 +00:00
import { fonts, colors } from '../styles/shared.styles.js';
2025-06-29 19:55:58 +00:00
import { demoFunc } from './upl-statuspage-statusbar.demo.js';
2021-09-23 14:30:02 +02:00
declare global {
interface HTMLElementTagNameMap {
'upl-statuspage-statusbar': UplStatuspageStatusbar;
}
}
@customElement('upl-statuspage-statusbar')
export class UplStatuspageStatusbar extends DeesElement {
2025-06-29 19:55:58 +00:00
public static demo = demoFunc;
@property({ type: Object })
public overallStatus: IOverallStatus = {
status: 'operational',
message: 'All Systems Operational',
lastUpdated: Date.now(),
affectedServices: 0,
totalServices: 0
};
@property({ type: Boolean })
public loading: boolean = false;
@property({ type: Boolean })
public expandable: boolean = true;
2021-09-23 14:30:02 +02:00
constructor() {
super();
}
2023-01-05 13:37:28 +01:00
public static styles = [
cssManager.defaultStyles,
css`
:host {
2025-06-29 19:55:58 +00:00
padding: 0;
2021-09-23 14:30:02 +02:00
display: block;
2025-06-29 19:55:58 +00:00
background: transparent;
font-family: ${unsafeCSS(fonts.base)};
2021-09-23 14:30:02 +02:00
}
2025-06-29 19:55:58 +00:00
.statusbar-container {
2021-09-23 14:30:02 +02:00
margin: auto;
2025-06-29 19:55:58 +00:00
max-width: 1200px;
2025-06-29 22:58:33 +00:00
padding: 24px 24px;
2025-06-29 19:55:58 +00:00
position: relative;
}
.statusbar-inner {
display: flex;
align-items: center;
2025-06-29 22:49:47 +00:00
justify-content: space-between;
min-height: 56px;
padding: 16px 20px;
border-radius: 6px;
cursor: ${cssManager.bdTheme('default', 'default')};
2025-06-29 19:55:58 +00:00
transition: all 0.2s ease;
position: relative;
overflow: hidden;
font-weight: 500;
2025-06-29 22:49:47 +00:00
font-size: 14px;
background: ${cssManager.bdTheme('#ffffff', '#0a0a0a')};
border: 1px solid ${cssManager.bdTheme('#e5e7eb', '#27272a')};
box-shadow: ${cssManager.bdTheme('0 1px 2px 0 rgba(0, 0, 0, 0.05)', 'none')};
2025-06-29 19:55:58 +00:00
}
.statusbar-inner:hover {
2025-06-29 22:49:47 +00:00
background: ${cssManager.bdTheme('#f9fafb', '#0f0f0f')};
2025-06-29 19:55:58 +00:00
}
2025-06-29 22:49:47 +00:00
.status-indicator {
width: 8px;
height: 8px;
border-radius: 50%;
flex-shrink: 0;
2025-06-29 19:55:58 +00:00
}
2025-06-29 22:49:47 +00:00
.statusbar-inner.operational .status-indicator {
2025-06-29 22:36:12 +00:00
background: ${colors.status.operational};
2025-06-29 19:55:58 +00:00
}
2025-06-29 22:49:47 +00:00
.statusbar-inner.degraded .status-indicator {
2025-06-29 22:36:12 +00:00
background: ${colors.status.degraded};
2025-06-29 19:55:58 +00:00
}
2025-06-29 22:49:47 +00:00
.statusbar-inner.partial_outage .status-indicator {
2025-06-29 22:36:12 +00:00
background: ${colors.status.partial};
2025-06-29 19:55:58 +00:00
}
2025-06-29 22:49:47 +00:00
.statusbar-inner.major_outage .status-indicator {
2025-06-29 22:36:12 +00:00
background: ${colors.status.major};
2025-06-29 19:55:58 +00:00
}
2025-06-29 22:49:47 +00:00
.statusbar-inner.maintenance .status-indicator {
2025-06-29 22:36:12 +00:00
background: ${colors.status.maintenance};
2025-06-29 19:55:58 +00:00
}
.status-content {
display: flex;
align-items: center;
2025-06-29 22:49:47 +00:00
gap: 12px;
flex: 1;
2025-06-29 19:55:58 +00:00
}
.status-main {
display: flex;
align-items: center;
2025-06-29 22:49:47 +00:00
gap: 12px;
color: ${cssManager.bdTheme('#0a0a0a', '#fafafa')};
2025-06-29 19:55:58 +00:00
}
2025-06-29 22:49:47 +00:00
.status-details {
font-size: 13px;
color: ${cssManager.bdTheme('#6b7280', '#a1a1aa')};
2025-06-29 19:55:58 +00:00
}
.loading-skeleton {
2025-06-29 22:49:47 +00:00
background: ${cssManager.bdTheme('#ffffff', '#0a0a0a')};
border: 1px solid ${cssManager.bdTheme('#e5e7eb', '#27272a')};
border-radius: 6px;
height: 56px;
position: relative;
overflow: hidden;
}
.loading-skeleton::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
2025-06-29 19:55:58 +00:00
background: ${cssManager.bdTheme(
2025-06-29 22:49:47 +00:00
'linear-gradient(90deg, transparent 0%, rgba(0,0,0,0.03) 50%, transparent 100%)',
'linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.03) 50%, transparent 100%)'
2025-06-29 19:55:58 +00:00
)};
animation: loading 1.5s infinite;
}
@keyframes loading {
0% {
2025-06-29 22:49:47 +00:00
transform: translateX(-100%);
2025-06-29 19:55:58 +00:00
}
100% {
2025-06-29 22:49:47 +00:00
transform: translateX(200%);
2025-06-29 19:55:58 +00:00
}
}
.last-updated {
2025-06-29 22:49:47 +00:00
font-size: 12px;
2025-06-29 19:55:58 +00:00
color: ${cssManager.bdTheme('#6b7280', '#9ca3af')};
2025-06-29 22:49:47 +00:00
white-space: nowrap;
2025-06-29 19:55:58 +00:00
}
@media (max-width: 640px) {
2025-06-29 22:58:33 +00:00
.statusbar-container {
padding: 16px 16px;
}
2025-06-29 19:55:58 +00:00
.statusbar-inner {
2025-06-29 22:49:47 +00:00
font-size: 13px;
2025-06-29 19:55:58 +00:00
padding: 12px 16px;
2025-06-29 22:49:47 +00:00
min-height: 48px;
}
.status-content {
gap: 10px;
2025-06-29 19:55:58 +00:00
}
2025-06-29 22:49:47 +00:00
.status-indicator {
width: 6px;
height: 6px;
}
.last-updated {
font-size: 11px;
2025-06-29 19:55:58 +00:00
}
2021-09-23 14:30:02 +02:00
}
2023-01-05 13:37:28 +01:00
`,
]
2021-09-23 14:30:02 +02:00
2023-01-05 13:37:28 +01:00
public render(): TemplateResult {
2025-06-29 19:55:58 +00:00
const formatLastUpdated = () => {
const date = new Date(this.overallStatus.lastUpdated);
2025-06-29 22:49:47 +00:00
const now = new Date();
const diff = now.getTime() - date.getTime();
const minutes = Math.floor(diff / 60000);
if (minutes < 1) return 'Just now';
if (minutes < 60) return `${minutes}m ago`;
const hours = Math.floor(minutes / 60);
if (hours < 24) return `${hours}h ago`;
return date.toLocaleDateString();
2025-06-29 19:55:58 +00:00
};
2023-01-05 13:37:28 +01:00
return html`
2025-06-29 19:55:58 +00:00
<div class="statusbar-container">
${this.loading ? html`
<div class="loading-skeleton"></div>
` : html`
2025-06-29 22:49:47 +00:00
<div class="statusbar-inner ${this.overallStatus.status}">
2025-06-29 19:55:58 +00:00
<div class="status-content">
2025-06-29 22:49:47 +00:00
<div class="status-indicator"></div>
2025-06-29 19:55:58 +00:00
<div class="status-main">
<span>${this.overallStatus.message}</span>
2025-06-29 22:49:47 +00:00
${this.overallStatus.affectedServices > 0 ? html`
<span class="status-details">
· ${this.overallStatus.affectedServices} of ${this.overallStatus.totalServices} services affected
</span>
` : ''}
2025-06-29 19:55:58 +00:00
</div>
</div>
2025-06-29 22:49:47 +00:00
<div class="last-updated">
${formatLastUpdated()}
</div>
2025-06-29 19:55:58 +00:00
</div>
`}
2021-09-23 14:30:02 +02:00
</div>
`;
}
}