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

278 lines
7.3 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';
import * as sharedStyles 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 })
accessor pageTitle: string = "Statuspage Title";
2025-06-29 19:55:58 +00:00
@property({ type: Boolean })
accessor showReportButton: boolean = true;
2025-06-29 19:55:58 +00:00
@property({ type: Boolean })
accessor showSubscribeButton: boolean = true;
2025-06-29 19:55:58 +00:00
@property({ type: String })
accessor logoUrl: string = '';
2025-06-29 19:55:58 +00:00
@property({ type: Boolean })
accessor loading: boolean = false;
2025-06-29 19:55:58 +00:00
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 {
display: block;
background: ${sharedStyles.colors.background.primary};
font-family: ${unsafeCSS(sharedStyles.fonts.base)};
color: ${sharedStyles.colors.text.primary};
border-bottom: 1px solid ${sharedStyles.colors.border.default};
position: sticky;
top: 0;
z-index: 40;
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.header-container {
max-width: 1200px;
margin: 0 auto;
padding: 0 ${unsafeCSS(sharedStyles.spacing.lg)};
}
.header-nav {
display: flex;
align-items: center;
justify-content: space-between;
height: 64px;
}
.header-left {
display: flex;
align-items: center;
gap: ${unsafeCSS(sharedStyles.spacing.lg)};
}
.header-actions {
display: flex;
align-items: center;
gap: ${unsafeCSS(sharedStyles.spacing.sm)};
}
.actionButton {
font-family: ${unsafeCSS(sharedStyles.fonts.base)};
font-size: 13px;
font-weight: 500;
padding: 0 14px;
border-radius: ${unsafeCSS(sharedStyles.borderRadius.base)};
cursor: pointer;
user-select: none;
transition: all ${unsafeCSS(sharedStyles.durations.normal)} ${unsafeCSS(sharedStyles.easings.default)};
display: inline-flex;
align-items: center;
justify-content: center;
height: 36px;
background: transparent;
border: 1px solid ${sharedStyles.colors.border.default};
color: ${sharedStyles.colors.text.primary};
letter-spacing: -0.01em;
}
.actionButton:hover {
background: ${sharedStyles.colors.background.secondary};
border-color: ${sharedStyles.colors.border.muted};
box-shadow: ${unsafeCSS(sharedStyles.shadows.xs)};
}
.actionButton:active {
transform: scale(0.98);
transition-duration: ${unsafeCSS(sharedStyles.durations.fast)};
}
.actionButton:focus-visible {
outline: 2px solid ${sharedStyles.colors.accent.focus};
outline-offset: 2px;
}
.site-title {
font-size: 18px;
font-weight: 600;
letter-spacing: -0.02em;
color: ${sharedStyles.colors.text.primary};
}
.logo {
height: 28px;
width: auto;
filter: ${cssManager.bdTheme('none', 'brightness(0) invert(1)')};
transition: opacity ${unsafeCSS(sharedStyles.durations.normal)} ${unsafeCSS(sharedStyles.easings.default)};
}
.logo:hover {
opacity: 0.8;
}
.page-info {
padding: ${unsafeCSS(sharedStyles.spacing.lg)} 0 ${unsafeCSS(sharedStyles.spacing.xl)} 0;
}
.page-title {
font-size: 48px;
font-weight: 700;
letter-spacing: -0.03em;
line-height: 1.1;
color: ${sharedStyles.colors.text.primary};
margin: 0 0 16px 0;
}
.page-subtitle {
font-size: 18px;
color: ${sharedStyles.colors.text.secondary};
margin: 0;
line-height: 1.5;
}
/* Primary button variant */
.actionButton.primary {
background: ${sharedStyles.colors.accent.primary};
color: ${sharedStyles.colors.background.primary};
border-color: transparent;
}
.actionButton.primary:hover {
background: ${sharedStyles.colors.accent.hover};
box-shadow: ${unsafeCSS(sharedStyles.shadows.sm)};
}
.loading-skeleton {
height: 64px;
background: ${sharedStyles.colors.background.secondary};
border-bottom: 1px solid ${sharedStyles.colors.border.default};
position: relative;
overflow: hidden;
}
.loading-skeleton::after {
content: '';
position: absolute;
inset: 0;
background: ${cssManager.bdTheme(
'linear-gradient(90deg, transparent 0%, rgba(0,0,0,0.04) 50%, transparent 100%)',
'linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.04) 50%, transparent 100%)'
)};
animation: loading 1.5s ${unsafeCSS(sharedStyles.easings.default)} infinite;
}
@keyframes loading {
0% { transform: translateX(-100%); }
100% { transform: translateX(200%); }
}
@media (max-width: 768px) {
2025-06-29 22:58:33 +00:00
.header-container {
padding: 0 ${unsafeCSS(sharedStyles.spacing.md)};
2021-09-23 14:30:02 +02:00
}
2025-06-29 22:58:33 +00:00
.header-nav {
height: 56px;
2025-06-29 22:58:33 +00:00
}
.header-left {
gap: ${unsafeCSS(sharedStyles.spacing.md)};
2021-09-23 14:30:02 +02:00
}
2025-06-29 22:58:33 +00:00
.site-title {
font-size: 16px;
2021-09-23 14:30:02 +02:00
}
2025-06-29 22:58:33 +00:00
.logo {
height: 24px;
2025-06-29 19:55:58 +00:00
}
}
@media (max-width: 640px) {
.actionButton {
font-size: 12px;
padding: 0 12px;
height: 32px;
2025-06-29 22:58:33 +00:00
}
2025-06-29 22:58:33 +00:00
.page-title {
font-size: 32px;
2025-06-29 19:55:58 +00:00
}
2025-06-29 22:58:33 +00:00
.page-subtitle {
font-size: 16px;
2025-06-29 19:55:58 +00:00
}
.header-actions {
gap: 6px;
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
}