Skip to content

Commit 6628726

Browse files
committed
add shop promo to header
1 parent 887075b commit 6628726

File tree

4 files changed

+90
-0
lines changed

4 files changed

+90
-0
lines changed

webui/src/assets/vars.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
--color-background-mute: #2e2e31;
44
--color-background-soft: rgb(40,43,51);
55
--color-background-light: #393a40;
6+
7+
--color-background-promo: #323743;
8+
--color-border-promo: rgba(211, 212, 213, 0.25);
69

710
--color-border: #282b33;
811

@@ -105,6 +108,9 @@
105108
--color-background-light: #e5e9f0;
106109
--color-border: #e2e8f0;
107110

111+
--color-background-promo: #fff;
112+
--color-border-promo: #dee2e6;
113+
108114
--color-refresh-background: rgb(8, 109, 215);
109115

110116
--color-text: rgb(3,6,11);

webui/src/components/Header.vue

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import { parseMarkdown } from '@/composables/markdown';
88
import { Modal } from 'bootstrap';
99
import type { AppInfoResponse } from '@/types/dashboard';
1010
import { useDashboard } from '@/composables/dashboard';
11+
import { usePromo } from '@/composables/promo';
1112
1213
const isDashboard = import.meta.env.VITE_DASHBOARD === 'true'
1314
const useDemo = import.meta.env.VITE_USE_DEMO === 'true'
15+
const promo = usePromo()
1416
let appInfo: AppInfoResponse | null = null
1517
const query = ref('')
1618
const tooltipDark = 'Switch to light mode';
@@ -196,6 +198,15 @@ function navigateAndClose(params: Record<string, string>) {
196198

197199
<template>
198200
<header>
201+
<!-- Promotion banner -->
202+
<div class="promo-banner" v-if="promo.activePromotion.value">
203+
<strong>Shop discount!</strong>
204+
Get <strong>{{ promo.activePromotion.value.discount }}% off</strong> Mokapi Gear —
205+
<span class="d-none d-md-inline">
206+
support Mokapi with code in your heart and style on your sleeve.
207+
</span>
208+
<a href="https://mokapi.myspreadshop.net" class="promo-link ms-2">Visit shop →</a>
209+
</div>
199210
<nav class="navbar navbar-expand-lg">
200211
<div class="container-fluid">
201212
<a class="navbar-brand" href="./"><img src="/logo-header.svg" height="30" alt="Mokapi home"/></a>
@@ -356,6 +367,29 @@ header {
356367
header .container-fluid {
357368
padding: 0;
358369
}
370+
.promo-banner {
371+
background-color: var(--color-background-promo);
372+
border-bottom: 1px solid var(--color-border-promo);
373+
color: var(--color-text);
374+
text-align: center;
375+
padding: 0.5rem 1rem;
376+
font-size: 0.95rem;
377+
margin-bottom: 5px;
378+
}
379+
380+
.promo-banner strong {
381+
font-weight: 600;
382+
}
383+
384+
.promo-link {
385+
color: var(--color-doc-link);
386+
text-decoration: none;
387+
font-weight: 500;
388+
}
389+
390+
.promo-link:hover {
391+
text-decoration: underline;
392+
}
359393
.navbar {
360394
background-color: var(--color-background);
361395
}

webui/src/composables/promo.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { computed } from 'vue'
2+
import { promotions, type Promotion } from '@/config/promo'
3+
4+
export function usePromo() {
5+
const now = new Date()
6+
7+
const activePromotion = computed<Promotion | undefined>(() =>
8+
promotions.find(p =>
9+
p.enabled &&
10+
now >= new Date(p.validFrom) &&
11+
now <= new Date(p.validUntil)
12+
)
13+
)
14+
return {
15+
activePromotion,
16+
}
17+
}

webui/src/config/promo.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
export interface Promotion {
2+
enabled: boolean
3+
discount: number
4+
validFrom: string
5+
validUntil: string
6+
}
7+
8+
export const promotions: Promotion[] = [
9+
{
10+
enabled: true,
11+
discount: 25,
12+
validFrom: '2025-12-29',
13+
validUntil: '2026-01-06',
14+
},
15+
{
16+
enabled: true,
17+
discount: 20,
18+
validFrom: '2026-01-13',
19+
validUntil: '2026-01-18',
20+
},
21+
{
22+
enabled: true,
23+
discount: 20,
24+
validFrom: '2026-01-20',
25+
validUntil: '2026-01-25',
26+
},
27+
{
28+
enabled: true,
29+
discount: 30,
30+
validFrom: '2026-01-30',
31+
validUntil: '2026-02-01',
32+
},
33+
]

0 commit comments

Comments
 (0)