Files
xenia-pos-local/waiter_pwa/src/components/ConnectivityBar.jsx
T
bonaminandClaude Opus 5.5 beb53c65bb feat(waiter): the look on the shared tokens; the venue's colour (platform-v2 step 4.6)
- The waiter's --bg/--text/--accent… are made of @xenia/ui tokens: light / dark (user
  menu) and the venue's accent reach every screen; the 751 colour literals in
  waiter_pwa/src became tokens (by hue family and lightness), hex-alpha suffixes became
  fade() (color-mix), fixing 'var(--accent)18' tints that never showed.
- @xenia/ui: new `special` (violet: offers, discounts, deals; contrast-tested) and
  `on-colour` tokens.
- Setting venue.theme (teal | amber | blue | violet | rose, default amber), bootstrap
  venue.theme, manager Settings → Venue → Colour; the waiter sets data-venue-theme and
  the theme before the first render.
- Guard tests/no-colours.test.mjs; tests/e2e/waiter_look.mjs (every page light + dark,
  side-by-side compare page); waiter e2e +3; backend test_venue_theme.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:08:39 +02:00

77 lines
2.2 KiB
React

import useConnectionStore from '../store/connectionStore'
import { fade } from '../logic/colour'
/**
* A 3px bar pinned to the very top of the screen (above the header).
* Always visible — color signals connection state at a glance:
*
* liveAlive=true → solid green (live connection up)
* online only → solid blue (HTTP reachable, live connection not up yet)
* reconnecting → amber, animated sweep
* offline → red, animated sweep
* offline >5min → flashing red
*/
export default function ConnectivityBar() {
const { status, liveAlive, flashing } = useConnectionStore()
const isOnline = status === 'online'
const isReconnecting = status === 'reconnecting'
const color = isOnline
? (liveAlive ? 'var(--x-success)' : 'var(--x-info)')
: isReconnecting
? 'var(--x-warning)'
: 'var(--x-danger)'
const animated = !isOnline
return (
<>
<style>{`
@keyframes connectivity-sweep {
0% { background-position: -200% center; }
100% { background-position: 300% center; }
}
@keyframes connectivity-flash {
0%, 100% { opacity: 1; }
50% { opacity: 0.15; }
}
.connectivity-bar {
position: relative;
height: 3px;
flex-shrink: 0;
overflow: hidden;
}
.connectivity-bar--sweep {
background: linear-gradient(
90deg,
var(--cb-color) 0%,
var(--cb-color) 30%,
color-mix(in srgb, var(--cb-color) 20%, transparent) 50%,
var(--cb-color) 70%,
var(--cb-color) 100%
);
background-size: 200% 100%;
animation: connectivity-sweep 1.8s ease-in-out infinite;
}
.connectivity-bar--flash {
animation: connectivity-flash 0.7s ease-in-out infinite;
}
`}</style>
<div
className={[
'connectivity-bar',
animated && !flashing ? 'connectivity-bar--sweep' : '',
flashing ? 'connectivity-bar--flash' : '',
].join(' ')}
style={{
'--cb-color': color,
backgroundColor: color,
boxShadow: `0 0 6px 1px ${fade(color, 0.6)}`,
}}
/>
</>
)
}