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

221 lines
5.7 KiB
TypeScript
Raw Normal View History

2025-06-29 19:55:58 +00:00
import { DeesElement, property, html, customElement, type TemplateResult, css, cssManager, unsafeCSS } from '@design.estate/dees-element';
import * as domtools from '@design.estate/dees-domtools';
2025-06-29 22:36:12 +00:00
import { fonts, shadows } from '../styles/shared.styles.js';
2025-06-29 19:55:58 +00:00
import { demoFunc } from './upl-statuspage-header.demo.js';
2021-09-23 14:30:02 +02:00
declare global {
interface HTMLElementTagNameMap {
'upl-statuspage-header': UplStatuspageHeader;
}
}
@customElement('upl-statuspage-header')
export class UplStatuspageHeader extends DeesElement {
2021-09-24 13:53:07 +02:00
// STATIC
2025-06-29 19:55:58 +00:00
public static demo = demoFunc;
2021-09-23 14:30:02 +02:00
2021-09-24 13:53:07 +02:00
// INSTANCE
2025-06-29 19:55:58 +00:00
@property({ type: String })
2021-09-24 13:53:07 +02:00
public pageTitle: string = "Statuspage Title";
2021-09-23 14:30:02 +02:00
2025-06-29 19:55:58 +00:00
@property({ type: Boolean })
public showReportButton: boolean = true;
@property({ type: Boolean })
public showSubscribeButton: boolean = true;
@property({ type: String })
public logoUrl: string = '';
@property({ type: Boolean })
public loading: boolean = false;
2021-09-23 14:30:02 +02:00
constructor() {
super();
}
2021-09-24 13:53:07 +02:00
public static styles = [
domtools.elementBasic.staticStyles,
css`
:host {
2021-09-23 14:30:02 +02:00
display: block;
2025-06-29 22:58:33 +00:00
background: ${cssManager.bdTheme('#ffffff', '#0a0a0a')};
2025-06-29 19:55:58 +00:00
font-family: ${unsafeCSS(fonts.base)};
color: ${cssManager.bdTheme('#0a0a0a', '#fafafa')};
2025-06-29 22:58:33 +00:00
border-bottom: 1px solid ${cssManager.bdTheme('#e5e7eb', '#27272a')};
position: sticky;
top: 0;
z-index: 40;
2021-09-23 14:30:02 +02:00
}
2025-06-29 22:58:33 +00:00
.header-container {
2025-06-29 19:55:58 +00:00
max-width: 1200px;
2025-06-29 22:58:33 +00:00
margin: 0 auto;
2025-06-29 19:55:58 +00:00
padding: 0 24px;
2021-09-23 14:30:02 +02:00
}
2025-06-29 22:58:33 +00:00
.header-nav {
display: flex;
align-items: center;
justify-content: space-between;
height: 64px;
}
.header-left {
2021-09-23 14:30:02 +02:00
display: flex;
2025-06-29 22:58:33 +00:00
align-items: center;
gap: 24px;
}
.header-actions {
display: flex;
align-items: center;
2025-06-29 19:55:58 +00:00
gap: 8px;
2021-09-23 14:30:02 +02:00
}
2025-06-29 22:58:33 +00:00
.actionButton {
2025-06-29 19:55:58 +00:00
font-size: 14px;
font-weight: 500;
2025-06-29 22:58:33 +00:00
padding: 8px 12px;
2025-06-29 19:55:58 +00:00
border-radius: 6px;
2021-09-23 14:30:02 +02:00
cursor: pointer;
user-select: none;
2025-06-29 19:55:58 +00:00
transition: all 0.2s ease;
display: inline-flex;
align-items: center;
justify-content: center;
2025-06-29 22:58:33 +00:00
height: 36px;
background: transparent;
border: none;
2025-06-29 19:55:58 +00:00
color: ${cssManager.bdTheme('#0a0a0a', '#fafafa')};
2021-09-23 14:30:02 +02:00
}
2025-06-29 22:58:33 +00:00
.actionButton:hover {
background: ${cssManager.bdTheme('#f4f4f5', '#27272a')};
2021-09-23 14:30:02 +02:00
}
2025-06-29 22:58:33 +00:00
.site-title {
font-size: 20px;
font-weight: 600;
letter-spacing: -0.02em;
color: ${cssManager.bdTheme('#0a0a0a', '#fafafa')};
2021-09-23 14:30:02 +02:00
}
2025-06-29 22:58:33 +00:00
.logo {
height: 24px;
width: auto;
filter: ${cssManager.bdTheme('none', 'brightness(0) invert(1)')};
2025-06-29 19:55:58 +00:00
}
2025-06-29 22:58:33 +00:00
.page-info {
padding: 48px 0 64px 0;
}
.page-title {
2025-06-29 19:55:58 +00:00
font-size: 48px;
font-weight: 700;
letter-spacing: -0.02em;
line-height: 1.1;
color: ${cssManager.bdTheme('#0a0a0a', '#fafafa')};
2025-06-29 22:58:33 +00:00
margin: 0 0 16px 0;
2025-06-29 19:55:58 +00:00
}
2025-06-29 22:58:33 +00:00
.page-subtitle {
font-size: 20px;
color: ${cssManager.bdTheme('#6b7280', '#a1a1aa')};
margin: 0;
line-height: 1.5;
2025-06-29 19:55:58 +00:00
}
/* Primary button variant */
.actionButton.primary {
background: ${cssManager.bdTheme('#0a0a0a', '#fafafa')};
color: ${cssManager.bdTheme('#ffffff', '#0a0a0a')};
2025-06-29 22:58:33 +00:00
border: 1px solid ${cssManager.bdTheme('#0a0a0a', '#fafafa')};
2025-06-29 19:55:58 +00:00
}
.actionButton.primary:hover {
2025-06-29 22:36:12 +00:00
background: ${cssManager.bdTheme('#262626', '#e5e7eb')};
2025-06-29 22:58:33 +00:00
border-color: ${cssManager.bdTheme('#262626', '#e5e7eb')};
}
.loading-skeleton {
height: 64px;
background: ${cssManager.bdTheme('#f9fafb', '#0a0a0a')};
border-bottom: 1px solid ${cssManager.bdTheme('#e5e7eb', '#27272a')};
}
@media (max-width: 640px) {
.header-nav {
height: 56px;
}
.site-title {
font-size: 18px;
}
.actionButton {
font-size: 13px;
padding: 6px 10px;
height: 32px;
}
.page-title {
font-size: 36px;
}
.page-subtitle {
font-size: 18px;
}
2021-09-23 14:30:02 +02:00
}
2021-09-24 13:53:07 +02:00
`
]
public render(): TemplateResult {
2025-06-29 19:55:58 +00:00
if (this.loading) {
return html`
2025-06-29 22:58:33 +00:00
<div class="loading-skeleton"></div>
2025-06-29 19:55:58 +00:00
`;
}
2021-09-24 13:53:07 +02:00
return html`
2025-06-29 22:58:33 +00:00
<header>
<div class="header-container">
<nav class="header-nav">
<div class="header-left">
${this.logoUrl ? html`
<img src="${this.logoUrl}" alt="${this.pageTitle}" class="logo">
` : ''}
<h1 class="site-title">${this.pageTitle}</h1>
</div>
<div class="header-actions">
${this.showReportButton ? html`
<button class="actionButton" @click=${this.dispatchReportNewIncident}>
Report Issue
</button>
` : ''}
${this.showSubscribeButton ? html`
<button class="actionButton primary" @click=${this.dispatchStatusSubscribe}>
Subscribe
</button>
` : ''}
</div>
</nav>
2021-09-23 14:30:02 +02:00
</div>
2025-06-29 22:58:33 +00:00
</header>
2021-09-23 14:30:02 +02:00
`;
}
2021-09-24 13:53:07 +02:00
public dispatchReportNewIncident() {
this.dispatchEvent(new CustomEvent('reportNewIncident', {
}))
}
public dispatchStatusSubscribe() {
this.dispatchEvent(new CustomEvent('statusSubscribe', {
}))
}
2021-09-23 14:30:02 +02:00
}