Files
catalog/ts_web/elements/upl-statuspage-header.ts
2025-06-29 19:55:58 +00:00

220 lines
6.2 KiB
TypeScript

import { DeesElement, property, html, customElement, type TemplateResult, css, cssManager, unsafeCSS } from '@design.estate/dees-element';
import * as domtools from '@design.estate/dees-domtools';
import { fonts } from '../styles/shared.styles.js';
import { demoFunc } from './upl-statuspage-header.demo.js';
declare global {
interface HTMLElementTagNameMap {
'upl-statuspage-header': UplStatuspageHeader;
}
}
@customElement('upl-statuspage-header')
export class UplStatuspageHeader extends DeesElement {
// STATIC
public static demo = demoFunc;
// INSTANCE
@property({ type: String })
public pageTitle: string = "Statuspage Title";
@property({ type: Boolean })
public showReportButton: boolean = true;
@property({ type: Boolean })
public showSubscribeButton: boolean = true;
@property({ type: String })
public brandColor: string = '';
@property({ type: String })
public logoUrl: string = '';
@property({ type: Boolean })
public customStyles: boolean = false;
@property({ type: Boolean })
public loading: boolean = false;
constructor() {
super();
}
public static styles = [
domtools.elementBasic.staticStyles,
css`
:host {
display: block;
background: ${cssManager.bdTheme('#ffffff', '#0a0a0a')};
font-family: ${unsafeCSS(fonts.base)};
color: ${cssManager.bdTheme('#0a0a0a', '#fafafa')};
border-bottom: 1px solid ${cssManager.bdTheme('#e5e7eb', '#262626')};
}
.mainbox {
margin: auto;
max-width: 1200px;
padding: 0 24px;
}
.mainbox .actions {
display: flex;
justify-content: flex-end;
gap: 8px;
padding: 24px 0;
}
.mainbox .actions .actionButton {
background: transparent;
font-size: 14px;
font-weight: 500;
border: 1px solid ${cssManager.bdTheme('#e5e7eb', '#262626')};
padding: 8px 16px;
border-radius: 6px;
cursor: pointer;
user-select: none;
transition: all 0.2s ease;
display: inline-flex;
align-items: center;
justify-content: center;
min-height: 36px;
color: ${cssManager.bdTheme('#0a0a0a', '#fafafa')};
}
.mainbox .actions .actionButton:hover {
background: ${cssManager.bdTheme('#f9fafb', '#262626')};
border-color: ${cssManager.bdTheme('#d1d5db', '#404040')};
transform: translateY(-1px);
}
.mainbox .actions .actionButton:active {
transform: translateY(0);
}
.header-content {
padding: 48px 0 64px 0;
text-align: center;
}
h1 {
margin: 0;
font-size: 48px;
font-weight: 700;
letter-spacing: -0.02em;
line-height: 1.1;
color: ${cssManager.bdTheme('#0a0a0a', '#fafafa')};
}
.subtitle {
margin: 16px 0 0 0;
font-size: 16px;
font-weight: 400;
color: ${cssManager.bdTheme('#6b7280', '#a1a1aa')};
letter-spacing: 0.02em;
text-transform: uppercase;
}
.logo {
display: block;
margin: 0 auto 32px;
max-width: 180px;
height: auto;
filter: ${cssManager.bdTheme('none', 'brightness(0) invert(1)')};
}
.loading-skeleton {
height: 200px;
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: 6px;
margin: 24px 0;
}
@keyframes loading {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}
/* Primary button variant */
.actionButton.primary {
background: ${cssManager.bdTheme('#0a0a0a', '#fafafa')};
color: ${cssManager.bdTheme('#ffffff', '#0a0a0a')};
border-color: ${cssManager.bdTheme('#0a0a0a', '#fafafa')};
}
.actionButton.primary:hover {
background: ${cssManager.bdTheme('#262626', '#f4f4f5')};
border-color: ${cssManager.bdTheme('#262626', '#f4f4f5')};
}
`
]
public render(): TemplateResult {
if (this.loading) {
return html`
<div class="mainbox">
<div class="loading-skeleton"></div>
</div>
`;
}
return html`
${domtools.elementBasic.styles}
<style>
${this.customStyles && this.brandColor ? `
.mainbox .actions .actionButton {
border-color: ${this.brandColor};
color: ${this.brandColor};
}
.mainbox .actions .actionButton:hover {
background: ${this.brandColor}10;
border-color: ${this.brandColor};
}
.mainbox .actions .actionButton.primary {
background: ${this.brandColor};
border-color: ${this.brandColor};
color: white;
}
.mainbox .actions .actionButton.primary:hover {
background: ${this.brandColor}dd;
border-color: ${this.brandColor}dd;
}
` : ''}
</style>
<div class="mainbox">
<div class="actions">
${this.showReportButton ? html`
<div class="actionButton" @click=${this.dispatchReportNewIncident}>Report Issue</div>
` : ''}
${this.showSubscribeButton ? html`
<div class="actionButton primary" @click=${this.dispatchStatusSubscribe}>Subscribe</div>
` : ''}
</div>
<div class="header-content">
${this.logoUrl ? html`
<img src="${this.logoUrl}" alt="Logo" class="logo">
` : ''}
<h1>${this.pageTitle}</h1>
<div class="subtitle">System Status</div>
</div>
</div>
`;
}
public dispatchReportNewIncident() {
this.dispatchEvent(new CustomEvent('reportNewIncident', {
}))
}
public dispatchStatusSubscribe() {
this.dispatchEvent(new CustomEvent('statusSubscribe', {
}))
}
}