import * as plugins from '../plugins.js';
import {
DeesElement,
property,
html,
customElement,
type TemplateResult,
css,
cssManager,
unsafeCSS,
} from '@design.estate/dees-element';
import type { IStatusHistoryPoint } from '../interfaces/index.js';
import { fonts, colors, shadows, borderRadius, spacing, commonStyles, getStatusColor } from '../styles/shared.styles.js';
import './internal/uplinternal-miniheading.js';
import { demoFunc } from './upl-statuspage-statusdetails.demo.js';
declare global {
interface HTMLElementTagNameMap {
'upl-statuspage-statusdetails': UplStatuspageStatusdetails;
}
}
@customElement('upl-statuspage-statusdetails')
export class UplStatuspageStatusdetails extends DeesElement {
public static demo = demoFunc;
@property({ type: Array })
public historyData: IStatusHistoryPoint[] = [];
@property({ type: String })
public serviceId: string = '';
@property({ type: String })
public serviceName: string = 'Service';
@property({ type: Boolean })
public loading: boolean = false;
@property({ type: Number })
public hoursToShow: number = 48;
constructor() {
super();
}
public static styles = [
plugins.domtools.elementBasic.staticStyles,
commonStyles,
css`
:host {
position: relative;
display: block;
background: transparent;
font-family: ${unsafeCSS(fonts.base)};
color: ${colors.text.primary};
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 ${unsafeCSS(spacing.lg)} ${unsafeCSS(spacing.lg)} ${unsafeCSS(spacing.lg)};
}
.mainbox {
background: ${colors.background.card};
border: 1px solid ${colors.border.default};
border-radius: ${unsafeCSS(borderRadius.md)};
padding: ${unsafeCSS(spacing.md)};
box-shadow: ${unsafeCSS(shadows.sm)};
}
.mainbox .barContainer {
position: relative;
display: flex;
gap: 2px;
padding: ${unsafeCSS(spacing.sm)};
background: ${colors.background.secondary};
border-radius: ${unsafeCSS(borderRadius.base)};
overflow: hidden;
}
.mainbox .barContainer .bar {
flex: 1;
height: 48px;
border-radius: ${unsafeCSS(borderRadius.sm)};
cursor: pointer;
transition: all 0.2s ease;
position: relative;
opacity: 0.9;
}
.mainbox .barContainer .bar:hover {
opacity: 1;
transform: scaleY(1.05);
}
.mainbox .barContainer .bar.operational {
background: ${colors.status.operational};
}
.mainbox .barContainer .bar.degraded {
background: ${colors.status.degraded};
}
.mainbox .barContainer .bar.partial_outage {
background: ${colors.status.partial};
}
.mainbox .barContainer .bar.major_outage {
background: ${colors.status.major};
}
.mainbox .barContainer .bar.maintenance {
background: ${colors.status.maintenance};
}
.mainbox .barContainer .bar.no-data {
background: ${colors.border.muted};
opacity: 0.3;
}
.timeIndicator {
position: absolute;
width: 2px;
height: calc(100% - ${unsafeCSS(spacing.md)});
background: ${colors.text.primary};
top: ${unsafeCSS(spacing.sm)};
transition: left 0.3s;
opacity: 0.5;
pointer-events: none;
}
.time-labels {
display: flex;
justify-content: space-between;
padding: ${unsafeCSS(spacing.sm)} ${unsafeCSS(spacing.sm)} 0;
font-size: 12px;
color: ${colors.text.secondary};
font-family: ${unsafeCSS(fonts.mono)};
}
.tooltip {
position: absolute;
background: ${cssManager.bdTheme('#1a1a1a', '#ffffff')};
color: ${cssManager.bdTheme('#ffffff', '#1a1a1a')};
padding: ${unsafeCSS(spacing.sm)} ${unsafeCSS(spacing.md)};
border-radius: ${unsafeCSS(borderRadius.base)};
font-size: 13px;
pointer-events: none;
opacity: 0;
transition: opacity 0.2s;
z-index: 10;
white-space: nowrap;
box-shadow: ${unsafeCSS(shadows.lg)};
border: 1px solid ${colors.border.default};
}
.tooltip.visible {
opacity: 0.95;
}
.tooltip strong {
font-weight: 600;
display: block;
margin-bottom: ${unsafeCSS(spacing.xs)};
color: ${cssManager.bdTheme('#ffffff', '#1a1a1a')};
}
.tooltip div {
line-height: 1.4;
}
.loading-skeleton {
display: flex;
padding: ${unsafeCSS(spacing.sm)};
gap: 2px;
background: ${colors.background.secondary};
border-radius: ${unsafeCSS(borderRadius.base)};
}
.loading-skeleton .skeleton-bar {
flex: 1;
height: 48px;
background: ${cssManager.bdTheme(
'linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%)',
'linear-gradient(90deg, #1f1f1f 25%, #262626 50%, #1f1f1f 75%)'
)};
background-size: 200% 100%;
animation: loading 1.5s infinite;
border-radius: ${unsafeCSS(borderRadius.sm)};
}
@keyframes loading {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}
.status-legend {
display: flex;
gap: ${unsafeCSS(spacing.lg)};
justify-content: center;
margin-top: ${unsafeCSS(spacing.lg)};
font-size: 13px;
flex-wrap: wrap;
}
.legend-item {
display: flex;
align-items: center;
gap: ${unsafeCSS(spacing.xs)};
}
.legend-color {
width: 12px;
height: 12px;
border-radius: ${unsafeCSS(borderRadius.sm)};
}
@media (max-width: 640px) {
.container {
padding: 0 ${unsafeCSS(spacing.md)} ${unsafeCSS(spacing.md)} ${unsafeCSS(spacing.md)};
}
.mainbox {
padding: ${unsafeCSS(spacing.sm)};
}
.time-labels {
font-size: 11px;
}
.status-legend {
gap: ${unsafeCSS(spacing.md)};
font-size: 12px;
}
}
`,
];
public render(): TemplateResult {
const now = Date.now();
const currentHour = new Date().getHours();
const timeIndicatorPosition = this.calculateTimeIndicatorPosition();
return html`