feat(signage): venue badges, widgets' own look, widgets placed inside stacks, Save and leave, shared controls (owner review 5)
- Badges: the venue's list (setting signage.badges: names el/en, colours, an icon from a food and drink set) edited under Signage -> "Message & settings"; sent with the venue to screens and previews; several badges per product (MenuList.badges lists, a single one still read) in the shared multiple Dropdown; a board's badge colour / text colour override them (None = each own). - Widgets: colour, background plate, font, bold / italic / underline, text size, QR colours; widgets in a stack's part get every setting, vertical alignment, and a custom box inside their place, picked (stack, then widget) and dragged on the preview (selection by path "2.1.0"). - Menu slides: vertical alignment of the list (board_valign); "Where the list sits" is now "Horizontal alignment". - Message of the day: one component in the settings tab, on the Overview and from its widget. - Leaving a slide with changes: "Save and leave" (ConfirmDialog altLabel). - @xenia/ui: ColourField (with colour.js helpers), FieldRow (framed only while wrapped), Slider, IconPicker, Segmented multiple; native selects on the Overview and signage replaced by Dropdown, the device settings' colour input by ColourField. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -40,7 +40,11 @@
|
||||
"clear": "Καθαρισμός",
|
||||
"all": "Όλα",
|
||||
"noOptions": "Δεν βρέθηκε τίποτα",
|
||||
"selected": "{{count}} επιλεγμένα"
|
||||
"selected": "{{count}} επιλεγμένα",
|
||||
"colourOwn": "Δικό σας χρώμα",
|
||||
"colourCode": "Κωδικός χρώματος",
|
||||
"opacity": "Αδιαφάνεια",
|
||||
"noIcon": "Χωρίς εικονίδιο"
|
||||
},
|
||||
"override": {
|
||||
"title": "Έγκριση υπευθύνου",
|
||||
|
||||
@@ -1434,7 +1434,7 @@
|
||||
"which": "Προϊόντα",
|
||||
"layout": "Διάταξη",
|
||||
"width": "Πλάτος λίστας",
|
||||
"place": "Θέση λίστας",
|
||||
"place": "Οριζόντια στοίχιση",
|
||||
"placeHint": "Σε όλο το πλάτος η λίστα γεμίζει την οθόνη: στενέψτε την για να τη μετακινήσετε.",
|
||||
"hiddenTag": "κρυμμένο",
|
||||
"pageSecondsHint": "Όταν η λίστα δεν χωράει στην οθόνη, χωρίζεται σε σελίδες που εναλλάσσονται: κάθε σελίδα μένει τόσα δευτερόλεπτα.",
|
||||
@@ -1443,7 +1443,9 @@
|
||||
"rename": "Άλλο όνομα σε αυτόν τον πίνακα",
|
||||
"renameBack": "Πίσω στο όνομα του καταλόγου",
|
||||
"catalogueName": "Το όνομα του καταλόγου (αυτό βλέπουν οι σερβιτόροι)",
|
||||
"catalogueNameIs": "Κατάλογος: {{name}}"
|
||||
"catalogueNameIs": "Κατάλογος: {{name}}",
|
||||
"vplace": "Κάθετη στοίχιση",
|
||||
"vplaceHint": "Πού μπαίνει μια σύντομη λίστα: πάνω, στη μέση ή κάτω."
|
||||
},
|
||||
"badges": {
|
||||
"new": "Νέο",
|
||||
@@ -1488,7 +1490,7 @@
|
||||
"bottom-bar": "Μπάρα κάτω"
|
||||
},
|
||||
"ownText": "Δικό του κείμενο (προαιρετικό)",
|
||||
"ownTextHint": "Κενό: το μήνυμα ημέρας του καταστήματος (Προβολή → Οθόνες).",
|
||||
"ownTextHint": "Κενό: το μήνυμα της ημέρας του καταστήματος (το ίδιο σε κάθε οθόνη).",
|
||||
"dateLong": "Τρίτη, 17 Νοεμβρίου 2026",
|
||||
"dateShort": "17/11/2026",
|
||||
"seconds": "Με δευτερόλεπτα",
|
||||
@@ -1539,14 +1541,29 @@
|
||||
"removeSlide": "Αφαίρεση της διαφάνειας από αυτό το τμήμα",
|
||||
"removeWidget": "Αφαίρεση αυτού του widget",
|
||||
"before": "Μετακίνηση πριν",
|
||||
"after": "Μετακίνηση μετά"
|
||||
}
|
||||
"after": "Μετακίνηση μετά",
|
||||
"pickHint": "Στην προεπισκόπηση, διαλέξτε τη στοίβα και μετά πατήστε ένα widget της για να το μετακινήσετε ή να αλλάξετε το μέγεθός του μέσα στο τμήμα του."
|
||||
},
|
||||
"inPart": "Στη θέση του",
|
||||
"fillsPlace": "Στοιχισμένο στη θέση του",
|
||||
"backInPlace": "Πίσω σε στοίχιση",
|
||||
"vertical": "Κάθετη στοίχιση",
|
||||
"look": "Κείμενο και χρώματα",
|
||||
"plateOnly": "Φόντο πίσω του",
|
||||
"colour": "Χρώμα",
|
||||
"asSlide": "Όπως η διαφάνεια",
|
||||
"plate": "Φόντο πίσω του",
|
||||
"noPlate": "Κανένα",
|
||||
"textSize": "Μέγεθος κειμένου",
|
||||
"qrColour": "Χρώμα κωδικού QR",
|
||||
"qrBackground": "Φόντο κωδικού QR",
|
||||
"changeMessage": "Αλλαγή μηνύματος"
|
||||
},
|
||||
"tabs": {
|
||||
"playlists": "Λίστες",
|
||||
"screens": "Οθόνες",
|
||||
"schedules": "Προγράμματα",
|
||||
"settings": "Μήνυμα και καιρός",
|
||||
"settings": "Μήνυμα & ρυθμίσεις",
|
||||
"slides": "Διαφάνειες"
|
||||
},
|
||||
"screens": {
|
||||
@@ -1638,7 +1655,8 @@
|
||||
"noForecast": "Καμία πρόγνωση: ο διακομιστής δεν φτάνει την υπηρεσία καιρού (χωρίς internet;). Το στοιχείο κρύβεται στο μεταξύ.",
|
||||
"waiting": "Καμία πρόγνωση ακόμα.",
|
||||
"refresh": "Ενημέρωση τώρα",
|
||||
"forget": "Αφαίρεση πόλης"
|
||||
"forget": "Αφαίρεση πόλης",
|
||||
"messagePlaceholder": "π.χ. Σήμερα: φρέσκο χταπόδι στα κάρβουνα"
|
||||
},
|
||||
"discardTitle": "Αλλαγές χωρίς αποθήκευση",
|
||||
"discardYes": "Έξοδος χωρίς αποθήκευση",
|
||||
@@ -1696,7 +1714,7 @@
|
||||
"rounded": "Στρογγυλεμένο",
|
||||
"round": "Στρογγυλό"
|
||||
},
|
||||
"hint": "Κάθε πεδίο αλλάζει μόνο τον εαυτό του. Οι επικεφαλίδες και οι τιμές ξεκινούν με το μέγεθος και τη γραμματοσειρά των ονομάτων («Όπως τα ονόματα»). Το χρώμα των σημάτων χρωματίζει και τις τελείες σελίδας. Τα ονόματα με δεξιά στοίχιση τελειώνουν όλα στο ίδιο σημείο, με ίσες τελείες πριν από τις τιμές.",
|
||||
"hint": "Κάθε πεδίο αλλάζει μόνο τον εαυτό του. Οι επικεφαλίδες και οι τιμές ξεκινούν με το μέγεθος και τη γραμματοσειρά των ονομάτων («Όπως τα ονόματα»). Τα σήματα έχουν τα δικά τους χρώματα (Προβολή → Μήνυμα & ρυθμίσεις), εκτός αν διαλέξετε εδώ χρώματα για όλα. Τα ονόματα με δεξιά στοίχιση τελειώνουν όλα στο ίδιο σημείο, με ίσες τελείες πριν από τις τιμές.",
|
||||
"f": {
|
||||
"heading": {
|
||||
"size": "Μέγεθος επικεφαλίδων",
|
||||
@@ -1723,6 +1741,9 @@
|
||||
"size": "Μέγεθος τελειών",
|
||||
"colour": "Χρώμα τελειών",
|
||||
"line": "Γραμμή τελειών"
|
||||
},
|
||||
"widget": {
|
||||
"style": "Στυλ"
|
||||
}
|
||||
},
|
||||
"badgeColour": "Χρώμα σημάτων",
|
||||
@@ -1730,12 +1751,23 @@
|
||||
"badgeTextAuto": "Αυτόματο",
|
||||
"reset": "Επαναφορά εμφάνισης",
|
||||
"resetTitle": "Επαναφορά της εμφάνισης αυτού του μενού;",
|
||||
"resetBody": "Κάθε μέγεθος, χρώμα, γραμματοσειρά, στυλ, στοίχιση και διάστιχο γυρίζει στην αρχή. Τα προϊόντα, η σειρά και τα ονόματά τους μένουν. Η «Αναίρεση αλλαγών» τα φέρνει πίσω μέχρι να αποθηκεύσετε."
|
||||
"resetBody": "Κάθε μέγεθος, χρώμα, γραμματοσειρά, στυλ, στοίχιση και διάστιχο γυρίζει στην αρχή. Τα προϊόντα, η σειρά και τα ονόματά τους μένουν. Η «Αναίρεση αλλαγών» τα φέρνει πίσω μέχρι να αποθηκεύσετε.",
|
||||
"pageDots": "Χρώμα τελειών σελίδας",
|
||||
"badgeOwn": "Του κάθε σήματος"
|
||||
},
|
||||
"colourPick": {
|
||||
"custom": "Δικό σας χρώμα",
|
||||
"code": "Κωδικός χρώματος",
|
||||
"opacity": "Αδιαφάνεια"
|
||||
"saveAndLeave": "Αποθήκευση και έξοδος",
|
||||
"badgesSettings": {
|
||||
"title": "Σήματα για πίνακες μενού",
|
||||
"hint": "Τα σήματα που μπορείτε να βάλετε σε προϊόντα στους πίνακες μενού και στα widgets μενού: τα ονόματα, τα χρώματα και τα εικονίδιά τους. Τα χρώματά τους είναι τα προεπιλεγμένα: ένας πίνακας μπορεί να δώσει σε όλα τα σήματά του δικό του χρώμα.",
|
||||
"nameEl": "Όνομα στα ελληνικά",
|
||||
"nameEn": "Όνομα στα αγγλικά",
|
||||
"colour": "Φόντο",
|
||||
"text": "Κείμενο",
|
||||
"icon": "Εικονίδιο",
|
||||
"add": "Προσθήκη σήματος",
|
||||
"removeTitle": "Αφαίρεση του σήματος «{{name}}»;",
|
||||
"removeBody": "Οι πίνακες που το χρησιμοποιούν σταματούν να το δείχνουν. Τίποτα δεν αλλάζει μέχρι να αποθηκεύσετε.",
|
||||
"needName": "Κάθε σήμα χρειάζεται όνομα (στα ελληνικά ή στα αγγλικά)."
|
||||
}
|
||||
},
|
||||
"overview": {
|
||||
@@ -2104,6 +2136,10 @@
|
||||
"putOnTab": "Σε καρτέλες",
|
||||
"tabOutsideShifts": "Πληρωμές καρτελών σε κάποιον χωρίς βάρδια",
|
||||
"tabOutsideShiftsTip": "Καταγράφονται ως εισπράξεις αυτού του ατόμου (π.χ. του ιδιοκτήτη)· δεν είναι στο συρτάρι καμίας βάρδιας, οπότε δεν μετρούν στο αναμενόμενο του συρταριού."
|
||||
},
|
||||
"tvMessage": {
|
||||
"title": "Μήνυμα της ημέρας",
|
||||
"hint": "Σε όλες τις τηλεοράσεις μαζί, στα widgets που το δείχνουν."
|
||||
}
|
||||
},
|
||||
"products": {
|
||||
|
||||
@@ -40,7 +40,11 @@
|
||||
"clear": "Clear",
|
||||
"all": "All",
|
||||
"noOptions": "Nothing found",
|
||||
"selected": "{{count}} selected"
|
||||
"selected": "{{count}} selected",
|
||||
"colourOwn": "Your own colour",
|
||||
"colourCode": "Colour code",
|
||||
"opacity": "Opacity",
|
||||
"noIcon": "No icon"
|
||||
},
|
||||
"override": {
|
||||
"title": "Manager approval",
|
||||
|
||||
@@ -1434,7 +1434,7 @@
|
||||
"which": "Products",
|
||||
"layout": "Layout",
|
||||
"width": "Width of the list",
|
||||
"place": "Where the list sits",
|
||||
"place": "Horizontal alignment",
|
||||
"placeHint": "At the full width the list fills the screen: make it narrower to place it.",
|
||||
"hiddenTag": "hidden",
|
||||
"pageSecondsHint": "When the list doesn't fit on the screen it is split into pages that take turns: each page stays this many seconds.",
|
||||
@@ -1443,7 +1443,9 @@
|
||||
"rename": "Name it differently on this board",
|
||||
"renameBack": "Back to the catalogue's name",
|
||||
"catalogueName": "The catalogue's name (the waiters see this one)",
|
||||
"catalogueNameIs": "Catalogue: {{name}}"
|
||||
"catalogueNameIs": "Catalogue: {{name}}",
|
||||
"vplace": "Vertical alignment",
|
||||
"vplaceHint": "Where a short list sits: at the top, in the middle or at the bottom."
|
||||
},
|
||||
"badges": {
|
||||
"new": "New",
|
||||
@@ -1488,7 +1490,7 @@
|
||||
"bottom-bar": "Bar at the bottom"
|
||||
},
|
||||
"ownText": "Its own text (optional)",
|
||||
"ownTextHint": "Empty: the venue's message of the day (Signage → Screens).",
|
||||
"ownTextHint": "Empty: the venue's message of the day (the same on every screen).",
|
||||
"dateLong": "Tuesday, 17 November 2026",
|
||||
"dateShort": "17/11/2026",
|
||||
"seconds": "With seconds",
|
||||
@@ -1539,14 +1541,29 @@
|
||||
"removeSlide": "Take the slide out of this part",
|
||||
"removeWidget": "Remove this widget",
|
||||
"before": "Move before",
|
||||
"after": "Move after"
|
||||
}
|
||||
"after": "Move after",
|
||||
"pickHint": "On the preview, pick the stack, then click a widget in it to move or size it inside its part."
|
||||
},
|
||||
"inPart": "In its place",
|
||||
"fillsPlace": "Aligned in its place",
|
||||
"backInPlace": "Back to aligned",
|
||||
"vertical": "Vertical alignment",
|
||||
"look": "Text and colours",
|
||||
"plateOnly": "Background plate",
|
||||
"colour": "Colour",
|
||||
"asSlide": "As the slide",
|
||||
"plate": "Background plate",
|
||||
"noPlate": "None",
|
||||
"textSize": "Text size",
|
||||
"qrColour": "QR code colour",
|
||||
"qrBackground": "QR code background",
|
||||
"changeMessage": "Change the message"
|
||||
},
|
||||
"tabs": {
|
||||
"playlists": "Playlists",
|
||||
"screens": "Screens",
|
||||
"schedules": "Schedules",
|
||||
"settings": "Message and weather",
|
||||
"settings": "Message & settings",
|
||||
"slides": "Slides"
|
||||
},
|
||||
"screens": {
|
||||
@@ -1638,7 +1655,8 @@
|
||||
"noForecast": "No forecast: the server can't reach the weather service (no internet?). The widget is hidden meanwhile.",
|
||||
"waiting": "No forecast yet.",
|
||||
"refresh": "Fetch now",
|
||||
"forget": "Remove the town"
|
||||
"forget": "Remove the town",
|
||||
"messagePlaceholder": "e.g. Today: fresh grilled octopus"
|
||||
},
|
||||
"discardTitle": "Unsaved changes",
|
||||
"discardYes": "Leave without saving",
|
||||
@@ -1696,7 +1714,7 @@
|
||||
"rounded": "Rounded",
|
||||
"round": "Round"
|
||||
},
|
||||
"hint": "Each field changes only itself. Headings and prices start in the names' size and font (\"As the names\"). The badges' colour also colours the page dots. Names aligned right all end at the same point, with equal dots before the prices.",
|
||||
"hint": "Each field changes only itself. Headings and prices start in the names' size and font (\"As the names\"). Badges take their own colours (Signage → Message & settings) unless you pick colours here for all of them. Names aligned right all end at the same point, with equal dots before the prices.",
|
||||
"f": {
|
||||
"heading": {
|
||||
"size": "Headings size",
|
||||
@@ -1723,6 +1741,9 @@
|
||||
"size": "Dots size",
|
||||
"colour": "Dots colour",
|
||||
"line": "Dots line"
|
||||
},
|
||||
"widget": {
|
||||
"style": "Style"
|
||||
}
|
||||
},
|
||||
"badgeColour": "Badges colour",
|
||||
@@ -1730,12 +1751,23 @@
|
||||
"badgeTextAuto": "Automatic",
|
||||
"reset": "Reset the look",
|
||||
"resetTitle": "Reset the look of this menu?",
|
||||
"resetBody": "Every size, colour, font, style, alignment and spacing goes back to the start. The products, their order and names stay. \"Undo changes\" brings it back until you save."
|
||||
"resetBody": "Every size, colour, font, style, alignment and spacing goes back to the start. The products, their order and names stay. \"Undo changes\" brings it back until you save.",
|
||||
"pageDots": "Page dots colour",
|
||||
"badgeOwn": "Each badge's own"
|
||||
},
|
||||
"colourPick": {
|
||||
"custom": "Your own colour",
|
||||
"code": "Colour code",
|
||||
"opacity": "Opacity"
|
||||
"saveAndLeave": "Save and leave",
|
||||
"badgesSettings": {
|
||||
"title": "Badges for menu boards",
|
||||
"hint": "The badges you can put on products on menu boards and menu widgets: their names, colours and icons. Their colours are the defaults: a board can still give all its badges a colour of its own.",
|
||||
"nameEl": "Name in Greek",
|
||||
"nameEn": "Name in English",
|
||||
"colour": "Background",
|
||||
"text": "Text",
|
||||
"icon": "Icon",
|
||||
"add": "Add a badge",
|
||||
"removeTitle": "Remove the badge \"{{name}}\"?",
|
||||
"removeBody": "Boards that use it stop showing it. Nothing changes until you save.",
|
||||
"needName": "Every badge needs a name (in Greek or in English)."
|
||||
}
|
||||
},
|
||||
"overview": {
|
||||
@@ -2104,6 +2136,10 @@
|
||||
"putOnTab": "Put on tabs",
|
||||
"tabOutsideShifts": "Paid on tabs to someone with no shift",
|
||||
"tabOutsideShiftsTip": "Recorded as received by that person (e.g. the owner); it isn't in any shift's drawer, so it isn't in the drawer's expected amount."
|
||||
},
|
||||
"tvMessage": {
|
||||
"title": "Message of the day",
|
||||
"hint": "On every TV at once, on the widgets that show it."
|
||||
}
|
||||
},
|
||||
"products": {
|
||||
|
||||
@@ -44,5 +44,9 @@ export function useUiLabels() {
|
||||
noOptions: t('ui.noOptions'),
|
||||
selected: count => t('ui.selected', { count }),
|
||||
pinProgress: (count, total) => t('ui.pinProgress', { count, total }),
|
||||
colourOwn: t('ui.colourOwn'),
|
||||
colourCode: t('ui.colourCode'),
|
||||
opacity: t('ui.opacity'),
|
||||
noIcon: t('ui.noIcon'),
|
||||
}), [t, language]) // eslint-disable-line react-hooks/exhaustive-deps
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ function EmbeddedSlide({ slide, media, venue, now }) {
|
||||
const pages = slide.kind === 'menu' && size ? boardPages(slide, 0, size.w || 16, size.h || 9) : null
|
||||
const page = pages ? pageAt(pages.length, slide.content?.page_seconds, now.getTime()) : 0
|
||||
return (
|
||||
<div ref={ref} style={{ position: 'absolute', inset: 0, overflow: 'hidden', containerType: 'size' }} data-testid="signage-embedded" data-kind={slide.kind} data-id={slide.id}>
|
||||
<div ref={ref} style={{ position: 'absolute', inset: 0, overflow: 'hidden', containerType: 'size' }} data-testid="signage-embedded" data-embedded="" data-kind={slide.kind} data-id={slide.id}>
|
||||
{size && <SlideView slide={{ ...slide, video_to_end: false }} media={media} venue={venue} now={now} pages={pages} page={page} />}
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
// same on any TV.
|
||||
import { Cloud, CloudFog, CloudLightning, CloudMoon, CloudRain, CloudSnow, CloudSun, Moon, Sun } from 'lucide-react'
|
||||
import { QRCodeSVG } from 'qrcode.react'
|
||||
import { BADGE_ICONS } from './badges'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { cellWidgets, fitUnit, FONTS, menuLook, menuPages, pageAt, priceChars, textWidth, visibleGroups, weatherIcon, widgetAlign } from './logic'
|
||||
import { badgeColours, badgeName, cellWidgets, fitUnit, FONTS, itemBadges, menuLook, menuPages, pageAt, priceChars, textWidth, visibleGroups, weatherIcon, widgetAlign } from './logic'
|
||||
|
||||
/** A slide's background: a colour, or a photo (cover / contain) with a darkening layer. */
|
||||
export function Background({ bg, media }) {
|
||||
@@ -63,12 +64,15 @@ export function MenuSlide({ slide, media, venue, now, page, pages, extras, embed
|
||||
data-testid="signage-menu" data-page={page} data-pages={pages.length}>
|
||||
{/* the list: the whole width, or narrower and placed left / centre / right (2026-11-21) */}
|
||||
<div style={{ flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column', width: `${c.board_width || 100}%`,
|
||||
alignSelf: BOARD_ALIGN[c.board_align] || 'flex-start' }} data-testid="signage-menu-board" data-align={c.board_align || 'left'}>
|
||||
alignSelf: BOARD_ALIGN[c.board_align] || 'flex-start', justifyContent: VSELF[c.board_valign] || 'flex-start' }}
|
||||
data-testid="signage-menu-board" data-align={c.board_align || 'left'} data-valign={c.board_valign || 'top'}>
|
||||
{c.title && <h1 style={{ fontSize: `${7 * scale}cqmin`, fontWeight: 800, margin: '0 0 2cqmin', color: c.heading_style?.colour || accent, lineHeight: 1.1,
|
||||
textAlign: c.board_align || 'left' }}>{c.title}</h1>}
|
||||
<div style={{ columnCount: c.columns || 2, columnGap: '5cqmin', fontSize: `${3.2 * scale}cqmin`, flex: 1, minHeight: 0, overflow: 'hidden', columnFill: 'auto', ...listSpacing(c) }}
|
||||
{/* top: the list takes the height (columns fill one after the other); middle / bottom: as tall as it is, placed (owner review 5) */}
|
||||
<div style={{ columnCount: c.columns || 2, columnGap: '5cqmin', fontSize: `${3.2 * scale}cqmin`, flex: (c.board_valign || 'top') === 'top' ? 1 : '0 1 auto',
|
||||
minHeight: 0, overflow: 'hidden', columnFill: 'auto', ...listSpacing(c) }}
|
||||
data-testid="signage-menu-list">
|
||||
<MenuGroups c={c} groups={groups} />
|
||||
<MenuGroups c={c} groups={groups} badges={venue?.badges} />
|
||||
</div>
|
||||
{pages.length > 1 && (
|
||||
<div style={{ display: 'flex', gap: '1cqmin', justifyContent: 'center', paddingTop: '1cqmin' }} aria-hidden="true">
|
||||
@@ -96,8 +100,9 @@ const listSpacing = c => {
|
||||
return { lineHeight: look.lineHeight, letterSpacing: look.letterSpacing }
|
||||
}
|
||||
|
||||
export function MenuGroups({ c, groups }) {
|
||||
const { t } = useTranslation('terminal')
|
||||
export function MenuGroups({ c, groups, badges }) {
|
||||
const { t, i18n } = useTranslation('terminal')
|
||||
const lang = c.language || (String(i18n.language || '').startsWith('el') ? 'el' : 'en')
|
||||
const { formatMoney } = useFormat()
|
||||
const look = menuLook(c)
|
||||
const priceW = `${(priceChars(groups, formatMoney) * 0.62).toFixed(2)}em`
|
||||
@@ -121,10 +126,16 @@ export function MenuGroups({ c, groups }) {
|
||||
<div style={{ display: 'flex', alignItems: 'baseline', gap: '0.3em' }}>
|
||||
<span style={{ ...look.item, textDecoration: it.available ? look.item.textDecoration : 'line-through',
|
||||
...(nameFills ? { flex: 1, minWidth: 0, textAlign: look.itemAlign } : {}) }} data-testid="signage-menu-name">{it.name}</span>
|
||||
{it.badge && (
|
||||
<span style={{ ...look.badge, fontSize: '0.55em', fontWeight: 800, padding: '0.1em 0.5em', borderRadius: '99em',
|
||||
textTransform: 'uppercase', letterSpacing: '0.05em', whiteSpace: 'nowrap', lineHeight: 1.4 }} data-testid="signage-badge">{t(`signage.badges.${it.badge}`)}</span>
|
||||
)}
|
||||
{itemBadges(it, badges).map(d => {
|
||||
const Icon = BADGE_ICONS[d.icon]
|
||||
return (
|
||||
<span key={d.key} style={{ ...badgeColours(d, c), fontSize: '0.55em', fontWeight: 800, padding: '0.1em 0.55em', borderRadius: '99em',
|
||||
textTransform: 'uppercase', letterSpacing: '0.05em', whiteSpace: 'nowrap', lineHeight: 1.4, display: 'inline-flex', alignItems: 'center', gap: '0.3em',
|
||||
alignSelf: 'center' }} data-testid="signage-badge" data-key={d.key}>
|
||||
{Icon && <Icon style={{ width: '1.15em', height: '1.15em', flexShrink: 0 }} strokeWidth={2.5} aria-hidden="true" />}{badgeName(d, lang)}
|
||||
</span>
|
||||
)
|
||||
})}
|
||||
{!it.available && <span style={{ fontSize: '0.6em', whiteSpace: 'nowrap' }} data-testid="signage-sold-out">{t('signage.soldOut')}</span>}
|
||||
{it.price != null && <>
|
||||
<span style={{ ...look.dots, ...(nameFills ? { flex: '0 0 2em' } : { flex: 1, minWidth: '0.6em' }) }} data-testid="signage-menu-dots" />
|
||||
@@ -154,6 +165,12 @@ const CORNER = {
|
||||
'bottom-right': { bottom: '3cqmin', right: '3cqmin', alignItems: 'flex-end' },
|
||||
}
|
||||
const SELF = { left: 'flex-start', center: 'center', right: 'flex-end' }
|
||||
const VSELF = { top: 'flex-start', middle: 'center', bottom: 'flex-end', auto: 'center' }
|
||||
/** A widget's own colour and the plate behind it (owner review 5); `pad`: a plate that hugs it. */
|
||||
const plate = (w, pad) => ({
|
||||
...(w.colour ? { color: w.colour } : {}),
|
||||
...(w.background_colour ? { background: w.background_colour, borderRadius: '1.2cqmin', ...(pad ? { padding: '0.8cqmin 1.6cqmin' } : {}) } : {}),
|
||||
})
|
||||
// a menu or a stack in a corner or a bar has no box of its own: it gets one of this size (cqmin)
|
||||
const BOXED = { menu: [48, 56], stack: [60, 36] }
|
||||
|
||||
@@ -179,7 +196,7 @@ export function Widgets({ widgets, media, venue, now, colour, extras, embed }) {
|
||||
style={{ ...pos, display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '3cqmin', padding: '2cqmin 4cqmin',
|
||||
background: 'rgba(0,0,0,0.35)', color: colour || '#fff', minHeight: '9cqmin' }}>
|
||||
{bar(where).map(([w, i, body]) => (
|
||||
<div key={i} data-widget={i} style={{ display: 'flex', flexDirection: 'column', alignItems: SELF[widgetAlign(w)], textAlign: widgetAlign(w) }}>{body}</div>
|
||||
<div key={i} data-widget={i} style={{ display: 'flex', flexDirection: 'column', alignItems: SELF[widgetAlign(w)], textAlign: widgetAlign(w), ...plate(w, true) }}>{body}</div>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
@@ -188,7 +205,7 @@ export function Widgets({ widgets, media, venue, now, colour, extras, embed }) {
|
||||
return (
|
||||
<div key={i} data-widget={i} className="absolute" data-testid="signage-w-box"
|
||||
style={{ left: `${w.box.x}%`, top: `${w.box.y}%`, width: `${w.box.w}%`, height: `${w.box.h}%`, containerType: 'size', color: colour || '#fff' }}>
|
||||
<div style={{ width: '100%', height: '100%', display: 'flex', alignItems: 'center', justifyContent: SELF[widgetAlign(w)], textAlign: widgetAlign(w) }}>
|
||||
<div style={{ width: '100%', height: '100%', display: 'flex', alignItems: VSELF[w.vertical] || 'center', justifyContent: SELF[widgetAlign(w)], textAlign: widgetAlign(w), ...plate(w) }}>
|
||||
{body}
|
||||
</div>
|
||||
</div>
|
||||
@@ -196,7 +213,7 @@ export function Widgets({ widgets, media, venue, now, colour, extras, embed }) {
|
||||
}
|
||||
const own = w.align && w.align !== 'auto' ? { alignItems: SELF[w.align], textAlign: w.align } : {}
|
||||
return (
|
||||
<div key={i} data-widget={i} className="absolute" style={{ ...CORNER[w.position], ...own, display: 'flex', flexDirection: 'column', color: colour || '#fff' }}>
|
||||
<div key={i} data-widget={i} className="absolute" style={{ ...CORNER[w.position], ...own, display: 'flex', flexDirection: 'column', color: colour || '#fff', ...plate(w, true) }}>
|
||||
{body}
|
||||
</div>
|
||||
)
|
||||
@@ -216,10 +233,17 @@ function widgetBody(w, ctx, fit, path) {
|
||||
const { media, venue, now, fmt, extras } = ctx
|
||||
const { formatDate, formatTime } = fmt
|
||||
const x = extras[path] || {}
|
||||
const s = SIZE[w.size] || 1
|
||||
const unit = (height, width) => (fit ? fitUnit(height, width) : n => `${+(n * s).toFixed(3)}cqmin`)
|
||||
const text = (u, size, weight = 700) => ({ fontSize: u(size), fontWeight: weight, lineHeight: 1.15,
|
||||
textShadow: '0 0.2cqmin 0.8cqmin rgba(0,0,0,0.35)', whiteSpace: fit ? 'nowrap' : undefined })
|
||||
const ts = (w.text_size || 100) / 100 // its own text size (owner review 5)
|
||||
const s = (SIZE[w.size] || 1) * ts
|
||||
// in a box of its own the box sets the size: its text size can only make it smaller there
|
||||
const unit = (height, width) => {
|
||||
if (!fit) return n => `${+(n * s).toFixed(3)}cqmin`
|
||||
const f = fitUnit(height, width)
|
||||
return n => f(n * Math.min(1, ts))
|
||||
}
|
||||
const text = (u, size, weight = 700) => ({ fontSize: u(size), fontWeight: w.bold === false ? 400 : w.bold ? Math.max(weight, 800) : weight, lineHeight: 1.15,
|
||||
textShadow: w.background_colour ? undefined : '0 0.2cqmin 0.8cqmin rgba(0,0,0,0.35)', whiteSpace: fit ? 'nowrap' : undefined,
|
||||
...(w.font ? { fontFamily: FONTS[w.font] } : {}), ...(w.italic ? { fontStyle: 'italic' } : {}), ...(w.underline ? { textDecoration: 'underline' } : {}) })
|
||||
const line = (str, testid, weight) => {
|
||||
const u = unit(3.4 * 1.15, textWidth(str.length, 3.4))
|
||||
return <span style={text(u, 3.4, weight)} data-testid={testid}>{str}</span>
|
||||
@@ -257,15 +281,15 @@ function widgetBody(w, ctx, fit, path) {
|
||||
const u = unit(16 + caption, Math.max(16, w.qr_caption ? textWidth(w.qr_caption.length, 2.4) : 0))
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: u(0.8) }} data-testid="signage-w-qr" data-link={link}>
|
||||
<div style={{ background: '#fff', padding: u(1), borderRadius: u(1), lineHeight: 0 }}>
|
||||
<QRCodeSVG value={link} size={256} style={{ width: u(14), height: u(14) }} />
|
||||
<div style={{ background: w.qr_background || '#fff', padding: u(1), borderRadius: u(1), lineHeight: 0 }}>
|
||||
<QRCodeSVG value={link} size={256} fgColor={w.qr_colour || '#000000'} bgColor={w.qr_background || '#ffffff'} style={{ width: u(14), height: u(14) }} />
|
||||
</div>
|
||||
{w.qr_caption && <span style={text(u, 2.4)}>{w.qr_caption}</span>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
if (w.kind === 'weather') return weatherBody(w, venue?.weather, unit, text, formatDate)
|
||||
if (w.kind === 'menu') return boxed(<MenuWidget board={w.board || {}} menu={x.menu} now={now} />, 'menu')
|
||||
if (w.kind === 'menu') return boxed(<MenuWidget board={w.board || {}} menu={x.menu} now={now} badges={venue?.badges} />, 'menu')
|
||||
if (w.kind === 'stack') return boxed(<Stack w={w} path={path} ctx={ctx} />, 'stack')
|
||||
return null
|
||||
}
|
||||
@@ -311,7 +335,7 @@ function weatherBody(w, wx, unit, text, formatDate) {
|
||||
* A menu widget (2026-11-21): a board's list in the widget's box (inside an element with
|
||||
* `container-type: size`), its pages turning on the clock; the text sized so a page fills the box.
|
||||
*/
|
||||
function MenuWidget({ board: b, menu, now }) {
|
||||
function MenuWidget({ board: b, menu, now, badges }) {
|
||||
const groups = visibleGroups(menu?.groups)
|
||||
const per = b.page_size || 8
|
||||
const headings = b.category_titles !== false
|
||||
@@ -328,7 +352,7 @@ function MenuWidget({ board: b, menu, now }) {
|
||||
data-testid="signage-w-menu" data-page={page} data-pages={pages.length}>
|
||||
{b.title && <div style={{ fontSize: '1.5em', fontWeight: 800, color: b.heading_style?.colour || accent, lineHeight: 1.15, marginBottom: '0.3em' }}>{b.title}</div>}
|
||||
<div style={{ columnCount: cols, columnGap: '1.2em', columnFill: 'auto', ...listSpacing(b) }} data-testid="signage-menu-list">
|
||||
<MenuGroups c={b} groups={pages[page] || []} />
|
||||
<MenuGroups c={b} groups={pages[page] || []} badges={badges} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
@@ -354,11 +378,21 @@ function Stack({ w, path, ctx }) {
|
||||
<div key={j} style={{ flex: `${c.share || 1} 1 0%`, minWidth: 0, minHeight: 0, position: 'relative', overflow: 'hidden', containerType: 'size',
|
||||
display: 'flex', flexDirection: across }} data-testid="signage-stack-cell" data-share={c.share}>
|
||||
{ws.map((cw, k) => {
|
||||
const wp = `${cp}.${k}`
|
||||
const own = cw.position === 'custom' && cw.box
|
||||
const align = cw.align && cw.align !== 'auto' ? cw.align : 'center'
|
||||
const body = widgetBody(cw, ctx, true, wp)
|
||||
return (
|
||||
<div key={k} style={{ flex: '1 1 0%', minWidth: 0, minHeight: 0, overflow: 'hidden', containerType: 'size',
|
||||
display: 'flex', alignItems: 'center', justifyContent: SELF[align], textAlign: align }} data-testid="signage-stack-place">
|
||||
{widgetBody(cw, ctx, true, `${cp}.${k}`)}
|
||||
<div key={k} style={{ flex: '1 1 0%', minWidth: 0, minHeight: 0, overflow: 'hidden', containerType: 'size', position: 'relative',
|
||||
...(own ? {} : { display: 'flex', alignItems: VSELF[cw.vertical] || 'center', justifyContent: SELF[align], textAlign: align }) }}
|
||||
data-testid="signage-stack-place" data-place={wp}>
|
||||
{body && (own ? (
|
||||
<div data-widget={wp} style={{ position: 'absolute', left: `${cw.box.x}%`, top: `${cw.box.y}%`, width: `${cw.box.w}%`, height: `${cw.box.h}%`,
|
||||
containerType: 'size', display: 'flex', alignItems: VSELF[cw.vertical] || 'center', justifyContent: SELF[align], textAlign: align, ...plate(cw) }}
|
||||
data-testid="signage-w-box">{body}</div>
|
||||
) : (
|
||||
<div data-widget={wp} style={{ display: 'flex', maxWidth: '100%', maxHeight: '100%', ...(cw.kind === 'menu' || cw.kind === 'stack' ? { width: '100%', height: '100%' } : {}), ...plate(cw, true) }}>{body}</div>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// The icons a menu badge can have (owner review 5, 2026-11-21): the same names as the server's
|
||||
// list (local_backend/services/signage_badges.py ICONS), drawn on the TV and offered in the editor.
|
||||
import {
|
||||
Apple, Award, Beef, Beer, CakeSlice, Carrot, ChefHat, Cherry, Citrus, Clock, Coffee, Croissant, Crown, CupSoda, Drumstick, Egg,
|
||||
Fish, Flame, Gift, GlassWater, Hamburger, Heart, IceCreamCone, Leaf, Martini, Milk, Nut, Percent, Pizza, Salad, Sandwich, Shrimp,
|
||||
Snowflake, Soup, Sparkles, Sprout, Star, Tag, ThumbsUp, Vegan, Wheat, WheatOff, Wine, Zap,
|
||||
} from 'lucide-react'
|
||||
|
||||
export const BADGE_ICONS = {
|
||||
sparkles: Sparkles, 'chef-hat': ChefHat, tag: Tag, star: Star, flame: Flame, sprout: Sprout, leaf: Leaf, vegan: Vegan, wheat: Wheat,
|
||||
'wheat-off': WheatOff, fish: Fish, shrimp: Shrimp, beef: Beef, drumstick: Drumstick, egg: Egg, milk: Milk, nut: Nut, carrot: Carrot,
|
||||
salad: Salad, pizza: Pizza, hamburger: Hamburger, sandwich: Sandwich, soup: Soup, croissant: Croissant, 'ice-cream-cone': IceCreamCone,
|
||||
'cake-slice': CakeSlice, coffee: Coffee, 'cup-soda': CupSoda, wine: Wine, beer: Beer, martini: Martini, 'glass-water': GlassWater,
|
||||
citrus: Citrus, cherry: Cherry, apple: Apple, heart: Heart, award: Award, 'thumbs-up': ThumbsUp, clock: Clock, percent: Percent,
|
||||
gift: Gift, crown: Crown, zap: Zap, snowflake: Snowflake,
|
||||
}
|
||||
@@ -2,5 +2,6 @@
|
||||
// player (terminal/src/apps/signage) and in the manager's live previews. Sizes are container
|
||||
// units (cqmin): put a slide inside an element with `container-type: size` (frameStyle() does).
|
||||
export * from './logic.js'
|
||||
export { BADGE_ICONS } from './badges.js'
|
||||
export { Background, BlankSlide, MenuSlide, TextSlide, Widgets } from './Slides.jsx'
|
||||
export { SlideView } from './SlideView.jsx'
|
||||
|
||||
@@ -321,8 +321,8 @@ const DOTS = { dotted: 'dotted', dashed: 'dashed', solid: 'solid' }
|
||||
* board's text size): headings, names and prices each their own size, colour, font, bold / italic /
|
||||
* underline and alignment (empty: the board's text size and font, the text colour for names and the
|
||||
* accent colour for headings and prices); the dots between name and price; line and letter spacing
|
||||
* (auto: 1.25 and normal; set on the list, never inherited from the page); photos' size and shape;
|
||||
* the badges' colours (2026-11-21: their text the venue's, or white / black to read on them).
|
||||
* (auto: 1.25 and normal; set on the list, never inherited from the page); photos' size and shape.
|
||||
* Badges: badgeColours (owner review 5).
|
||||
*/
|
||||
export function menuLook(c = {}) {
|
||||
const base = c.text_size || 100
|
||||
@@ -346,8 +346,6 @@ export function menuLook(c = {}) {
|
||||
dots: d.style === 'none'
|
||||
? { borderBottom: 'none' }
|
||||
: { borderBottom: `${+(0.08 * (d.size || 100) / 100).toFixed(3)}em ${DOTS[d.style] || 'dotted'} ${d.colour || 'currentColor'}`, opacity: d.colour ? 1 : 0.35 },
|
||||
// badges: the accent (also the page dots), their text the venue's or one that reads on it
|
||||
badge: { background: accent, color: c.badge_text_colour || readableOn(accent) },
|
||||
title: c.heading_style?.colour || accent,
|
||||
lineHeight: c.line_height || 1.25,
|
||||
letterSpacing: c.letter_spacing != null ? `${c.letter_spacing}em` : 'normal',
|
||||
@@ -358,6 +356,39 @@ export function menuLook(c = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The badges a venue has until it edits its own (owner review 5; the server's DEFAULTS in
|
||||
* services/signage_badges.py): a screen that hasn't heard of the venue's list draws these.
|
||||
*/
|
||||
export const DEFAULT_BADGES = [
|
||||
{ key: 'new', names: { el: 'Νέο', en: 'New' }, colour: '#22c55e', text_colour: null, icon: 'sparkles' },
|
||||
{ key: 'chef', names: { el: 'Πρόταση σεφ', en: "Chef's pick" }, colour: '#f59e0b', text_colour: null, icon: 'chef-hat' },
|
||||
{ key: 'offer', names: { el: 'Προσφορά', en: 'Offer' }, colour: '#ef4444', text_colour: null, icon: 'tag' },
|
||||
{ key: 'popular', names: { el: 'Δημοφιλές', en: 'Popular' }, colour: '#f472b6', text_colour: null, icon: 'star' },
|
||||
{ key: 'spicy', names: { el: 'Καυτερό', en: 'Spicy' }, colour: '#dc2626', text_colour: null, icon: 'flame' },
|
||||
{ key: 'vegetarian', names: { el: 'Χορτοφαγικό', en: 'Vegetarian' }, colour: '#16a34a', text_colour: null, icon: 'sprout' },
|
||||
{ key: 'vegan', names: { el: 'Vegan', en: 'Vegan' }, colour: '#15803d', text_colour: null, icon: 'vegan' },
|
||||
]
|
||||
|
||||
/** A product's badges as their definitions (unknown keys left out; one badge stored as `badge` too). */
|
||||
export function itemBadges(it, defs) {
|
||||
const list = defs?.length ? defs : DEFAULT_BADGES
|
||||
const keys = it?.badges?.length ? it.badges : it?.badge ? [it.badge] : []
|
||||
return keys.map(k => list.find(d => d.key === k)).filter(Boolean)
|
||||
}
|
||||
|
||||
/** A badge's colours on a board: the board's own for all its badges, else the badge's; text that reads. */
|
||||
export function badgeColours(def, c = {}) {
|
||||
const background = c.badge_colour || def?.colour || '#f59e0b'
|
||||
return { background, color: c.badge_text_colour || def?.text_colour || readableOn(background) }
|
||||
}
|
||||
|
||||
/** A badge's name in a language (the board's, else the screen's), else in the other one. */
|
||||
export function badgeName(def, lang) {
|
||||
const n = def?.names || {}
|
||||
return n[lang] || n.el || n.en || def?.key || ''
|
||||
}
|
||||
|
||||
/** A stack part's widgets (a part stored before owner review 4 has one `widget`). */
|
||||
export function cellWidgets(c) {
|
||||
return c?.widgets?.length ? c.widgets : c?.widget ? [c.widget] : []
|
||||
|
||||
@@ -202,7 +202,17 @@ test('owner review 4: a part\'s widgets (one stored as `widget` too), badges tha
|
||||
assert.equal(readableOn('#1e3a8acc'), '#ffffff')
|
||||
assert.equal(readableOn('#f59e0b'), '#111111')
|
||||
assert.equal(readableOn('#fff'), '#111111')
|
||||
assert.deepEqual(menuLook({ accent_colour: '#1e3a8a' }).badge, { background: '#1e3a8a', color: '#ffffff' })
|
||||
assert.deepEqual(menuLook({ accent_colour: '#1e3a8a', badge_text_colour: '#fde68a' }).badge, { background: '#1e3a8a', color: '#fde68a' })
|
||||
assert.equal(menuLook({ accent_colour: '#123456', heading_style: { colour: '#ff0000' } }).title, '#ff0000')
|
||||
})
|
||||
|
||||
test('owner review 5: the venue badges, several per product; a board with its own badge colours', async () => {
|
||||
const { badgeColours, badgeName, DEFAULT_BADGES, itemBadges } = await import('../src/logic.js')
|
||||
const mine = [{ key: 'gf', names: { en: 'Gluten free' }, colour: '#0ea5e9', text_colour: null, icon: 'wheat-off' }, DEFAULT_BADGES[1]]
|
||||
assert.deepEqual(itemBadges({ badges: ['chef', 'gf', 'gone'] }, mine).map(d => d.key), ['chef', 'gf'])
|
||||
assert.deepEqual(itemBadges({ badge: 'new' }, null).map(d => d.key), ['new']) // stored before: one badge; no list yet: the defaults
|
||||
assert.deepEqual(badgeColours(mine[0]), { background: '#0ea5e9', color: '#111111' })
|
||||
assert.deepEqual(badgeColours(mine[0], { badge_colour: '#1e3a8a' }), { background: '#1e3a8a', color: '#ffffff' })
|
||||
assert.deepEqual(badgeColours(mine[0], { badge_text_colour: '#fde68a' }), { background: '#0ea5e9', color: '#fde68a' })
|
||||
assert.equal(badgeName(mine[0], 'el'), 'Gluten free')
|
||||
assert.equal(badgeName(DEFAULT_BADGES[1], 'el'), 'Πρόταση σεφ')
|
||||
})
|
||||
|
||||
@@ -465,6 +465,77 @@
|
||||
box-shadow: var(--x-shadow-popover); outline: none;
|
||||
animation: x-fade-in var(--x-duration-fast) var(--x-ease);
|
||||
}
|
||||
/* ── FieldRow (2026-11-21): fields that wrap, framed while wrapped ─────────────── */
|
||||
.x-field-row {
|
||||
display: grid; gap: var(--x-space-3); align-items: end;
|
||||
grid-template-columns: repeat(auto-fill, minmax(min(var(--x-field-min, 10.5rem), 100%), 1fr));
|
||||
padding: var(--x-space-3); border: var(--x-border-width) solid transparent; border-radius: var(--x-radius-control);
|
||||
transition: background-color var(--x-duration-fast) var(--x-ease), border-color var(--x-duration-fast) var(--x-ease);
|
||||
}
|
||||
.x-field-row--wrapped { border-color: var(--x-line); background: var(--x-surface); }
|
||||
.x-field-row--wrapped.x-field-row--shade { background: var(--x-surface-2); }
|
||||
|
||||
/* ── Slider (2026-11-21): framed like a field, its value beside it ──────────────── */
|
||||
.x-slider {
|
||||
min-height: var(--x-control-md); display: flex; align-items: center; gap: var(--x-space-3); padding: 0 var(--x-space-3);
|
||||
border: var(--x-border-width) solid var(--x-line); border-radius: var(--x-radius-control); background: var(--x-surface);
|
||||
}
|
||||
.x-slider__input { flex: 1; min-width: 0; accent-color: var(--x-accent); }
|
||||
.x-slider__value { width: 3rem; text-align: right; font-size: var(--x-text-label); color: var(--x-ink-2); font-variant-numeric: tabular-nums; }
|
||||
|
||||
/* ── ColourField (2026-11-21): a colour as a field; its panel over the page ──────── */
|
||||
.x-swatch {
|
||||
display: block; flex-shrink: 0; width: 24px; height: 24px; border-radius: 999px; border: var(--x-border-width) solid var(--x-line-strong);
|
||||
background: linear-gradient(var(--x-swatch), var(--x-swatch)), repeating-conic-gradient(#d1d5db 0 25%, #ffffff 0 50%) 0 0 / 8px 8px;
|
||||
}
|
||||
.x-colour {
|
||||
width: 100%; min-width: 0; min-height: var(--x-control-md); display: flex; align-items: center; gap: var(--x-space-2); padding: 0 var(--x-space-3);
|
||||
border: var(--x-border-width) solid var(--x-line); border-radius: var(--x-radius-control); background: var(--x-surface);
|
||||
color: var(--x-ink); font: inherit; font-size: var(--x-text-label); cursor: pointer; text-align: left;
|
||||
transition: border-color var(--x-duration-fast) var(--x-ease);
|
||||
}
|
||||
.x-colour:hover { border-color: var(--x-line-strong); }
|
||||
.x-colour:focus-visible { outline: none; box-shadow: var(--x-focus-ring); }
|
||||
.x-colour__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--x-ink-2); }
|
||||
.x-colour__value--code { font-family: var(--x-font-mono, ui-monospace, monospace); }
|
||||
.x-colour__panel { display: grid; gap: var(--x-space-3); padding: var(--x-space-3); width: 17.5rem; }
|
||||
.x-colour__auto {
|
||||
min-height: var(--x-control-md); padding: 0 var(--x-space-3); text-align: left; font: inherit; font-size: var(--x-text-label); cursor: pointer;
|
||||
border: var(--x-border-width) solid var(--x-line); border-radius: var(--x-radius-control); background: var(--x-surface); color: var(--x-ink);
|
||||
}
|
||||
.x-colour__auto:hover { background: var(--x-surface-2); }
|
||||
.x-colour__auto--on { border-color: var(--x-accent); background: var(--x-accent-soft); color: var(--x-accent-ink); }
|
||||
.x-colour__presets { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--x-space-2); justify-items: center; }
|
||||
.x-colour__preset { padding: 0; border: 0; background: none; border-radius: 999px; cursor: pointer; transition: transform var(--x-duration-fast) var(--x-ease); }
|
||||
.x-colour__preset .x-swatch { width: 32px; height: 32px; }
|
||||
.x-colour__preset:hover { transform: scale(1.1); }
|
||||
.x-colour__preset:focus-visible { outline: none; box-shadow: var(--x-focus-ring); }
|
||||
.x-colour__preset--on { box-shadow: 0 0 0 2px var(--x-surface), 0 0 0 4px var(--x-accent); }
|
||||
.x-colour__own { display: grid; gap: var(--x-space-2); border-top: var(--x-border-width) solid var(--x-line); padding-top: var(--x-space-3); }
|
||||
.x-colour__heading { font-size: var(--x-text-overline, 11px); font-weight: var(--x-weight-semibold); text-transform: uppercase; letter-spacing: 0.04em; color: var(--x-ink-3); }
|
||||
.x-colour__row { display: flex; align-items: center; gap: var(--x-space-2); }
|
||||
.x-colour__picker {
|
||||
width: 40px; height: var(--x-control-md); flex-shrink: 0; padding: 2px; cursor: pointer;
|
||||
border: var(--x-border-width) solid var(--x-line); border-radius: var(--x-radius-control); background: var(--x-surface);
|
||||
}
|
||||
.x-colour__code { flex: 1; min-width: 0; font-family: var(--x-font-mono, ui-monospace, monospace); }
|
||||
.x-colour__opacity { display: grid; gap: 4px; font-size: var(--x-text-caption); color: var(--x-ink-2); }
|
||||
.x-colour__opacity-row { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
|
||||
.x-colour__opacity input { accent-color: var(--x-accent); }
|
||||
|
||||
/* ── IconPicker (2026-11-21) ──────────────────────────────────────────────────── */
|
||||
.x-icon-pick__current { width: 24px; height: 24px; display: grid; place-items: center; color: var(--x-ink); flex-shrink: 0; }
|
||||
.x-icon-pick { display: grid; gap: var(--x-space-2); padding: var(--x-space-3); width: 20rem; }
|
||||
.x-icon-pick__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--x-space-1); }
|
||||
.x-icon-pick__item, .x-icon-pick__none {
|
||||
display: grid; place-items: center; min-height: 36px; border: var(--x-border-width) solid transparent; border-radius: var(--x-radius-control);
|
||||
background: none; color: var(--x-ink-2); cursor: pointer; font: inherit; font-size: var(--x-text-label);
|
||||
}
|
||||
.x-icon-pick__none { border-color: var(--x-line); }
|
||||
.x-icon-pick__item:hover, .x-icon-pick__none:hover { background: var(--x-surface-2); color: var(--x-ink); }
|
||||
.x-icon-pick__item:focus-visible, .x-icon-pick__none:focus-visible { outline: none; box-shadow: var(--x-focus-ring); }
|
||||
.x-icon-pick__item--on { border-color: var(--x-accent); background: var(--x-accent-soft); color: var(--x-accent-ink); }
|
||||
|
||||
/* ── Popover (2026-11-21): a small panel under a button, kept inside the window ── */
|
||||
.x-popover {
|
||||
position: fixed; z-index: var(--x-z-popover); box-sizing: border-box;
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
import { useCallback, useRef, useState } from 'react'
|
||||
import { cx } from '../internal/cx.js'
|
||||
import { Field, Input } from './Field.jsx'
|
||||
import { Popover } from './Popover.jsx'
|
||||
import { useLabels } from './labels.js'
|
||||
import { COLOUR_PRESETS, joinAlpha, splitAlpha, typedColour } from './colour.js'
|
||||
|
||||
/**
|
||||
* The one colour field of the product (2026-11-21): its swatch and code, as tall as the fields
|
||||
* beside it; a click opens a small panel over the page (Popover) with the ready colours, then the
|
||||
* picker, the opacity and the code typed by hand. Stores #rrggbb, or #rrggbbaa when see-through.
|
||||
* <ColourField label="Text colour" value={c} onChange={setC} />
|
||||
* auto: { label, on, pick } — a first choice that leaves the colour to something else ("Automatic",
|
||||
* "Each badge's own"); `on` shows it chosen (the field then reads its label).
|
||||
* opacity: false hides the opacity (a colour that can't be see-through).
|
||||
*/
|
||||
export function ColourField({ label, hint, value, onChange, presets = COLOUR_PRESETS, auto, opacity = true, className, testId }) {
|
||||
const labels = useLabels()
|
||||
const [open, setOpen] = useState(false)
|
||||
const [typed, setTyped] = useState(null)
|
||||
const btn = useRef(null)
|
||||
const v = (value || '#000000').toLowerCase()
|
||||
const { rgb, alpha } = splitAlpha(v)
|
||||
const close = useCallback(() => { setOpen(false); setTyped(null) }, [])
|
||||
const tid = s => (testId ? `${testId}-${s}` : undefined)
|
||||
return (
|
||||
<>
|
||||
<Field label={label} hint={hint} className={className}>
|
||||
<button ref={btn} type="button" className="x-colour" onClick={() => setOpen(o => !o)} aria-expanded={open} aria-haspopup="dialog" data-testid={tid('open')}>
|
||||
<Swatch colour={v} />
|
||||
<span className={cx('x-colour__value', !auto?.on && 'x-colour__value--code')}>{auto?.on ? auto.label : v}</span>
|
||||
</button>
|
||||
</Field>
|
||||
<Popover open={open} anchor={btn} onClose={close} aria-label={label} className="x-colour__panel" data-testid={tid('panel')}>
|
||||
{auto && (
|
||||
<button type="button" className={cx('x-colour__auto', auto.on && 'x-colour__auto--on')} aria-pressed={!!auto.on}
|
||||
onClick={() => { auto.pick(); close() }} data-testid={tid('auto')}>{auto.label}</button>
|
||||
)}
|
||||
<div className="x-colour__presets">
|
||||
{presets.map(c => {
|
||||
const chosen = !auto?.on && rgb === c.toLowerCase()
|
||||
return (
|
||||
<button key={c} type="button" className={cx('x-colour__preset', chosen && 'x-colour__preset--on')} aria-label={c} aria-pressed={chosen} title={c}
|
||||
onClick={() => { onChange(opacity ? joinAlpha(c.toLowerCase(), alpha) : c.toLowerCase()); close() }} data-testid={tid('preset')}>
|
||||
<Swatch colour={c} />
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
<div className="x-colour__own">
|
||||
<span className="x-colour__heading">{labels.colourOwn}</span>
|
||||
<div className="x-colour__row">
|
||||
<input type="color" className="x-colour__picker" value={rgb} aria-label={label} data-testid={testId}
|
||||
onChange={e => { setTyped(null); onChange(opacity ? joinAlpha(e.target.value, alpha) : e.target.value) }} />
|
||||
<Input value={typed ?? v} maxLength={9} spellCheck={false} aria-label={labels.colourCode} className="x-colour__code" data-testid={tid('code')}
|
||||
onChange={e => { setTyped(e.target.value); const c = typedColour(e.target.value); if (c && (opacity || c.length === 7)) onChange(c) }}
|
||||
onBlur={() => setTyped(null)} />
|
||||
</div>
|
||||
{opacity && (
|
||||
<label className="x-colour__opacity">
|
||||
<span className="x-colour__opacity-row"><span>{labels.opacity}</span><span>{alpha}%</span></span>
|
||||
<input type="range" min={0} max={100} step={5} value={alpha} data-testid={tid('opacity')}
|
||||
onChange={e => { setTyped(null); onChange(joinAlpha(rgb, Number(e.target.value))) }} />
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
</Popover>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
/** A colour's swatch over a checkerboard, so a see-through colour shows as one. */
|
||||
export function Swatch({ colour, className }) {
|
||||
return <span className={cx('x-swatch', className)} aria-hidden="true" style={{ '--x-swatch': colour }} />
|
||||
}
|
||||
@@ -8,15 +8,19 @@ import { useLabels } from './labels.js'
|
||||
* (2026-11-21). tone 'danger' for deleting / throwing work away.
|
||||
* <ConfirmDialog open title="Delete this slide?" confirmLabel="Delete" tone="danger"
|
||||
* onConfirm={remove} onCancel={close}>It goes from the playlist.</ConfirmDialog>
|
||||
* altLabel / onAlt: a third choice, the main one (2026-11-21: unsaved changes → "Save and leave"
|
||||
* beside "Leave without saving"); the confirm button is then the secondary danger one.
|
||||
*/
|
||||
export function ConfirmDialog({ open, title, children, confirmLabel, cancelLabel, tone = 'primary', onConfirm, onCancel, busy = false, testId }) {
|
||||
export function ConfirmDialog({ open, title, children, confirmLabel, cancelLabel, tone = 'primary', onConfirm, onCancel, altLabel, onAlt, busy = false, testId }) {
|
||||
const labels = useLabels()
|
||||
const alt = altLabel && onAlt
|
||||
return (
|
||||
<Dialog open={open} size="sm" title={title} onClose={onCancel}
|
||||
<Dialog open={open} size={alt ? 'md' : 'sm'} title={title} onClose={onCancel}
|
||||
footer={<>
|
||||
<Button variant="secondary" onClick={onCancel} data-testid={testId ? `${testId}-cancel` : 'confirm-cancel'}>{cancelLabel ?? labels.cancel}</Button>
|
||||
<Button variant={tone === 'danger' ? 'danger' : 'primary'} loading={busy} onClick={onConfirm}
|
||||
<Button variant={alt ? 'secondary' : tone === 'danger' ? 'danger' : 'primary'} tone={alt && tone === 'danger' ? 'danger' : undefined} loading={busy && !alt} onClick={onConfirm}
|
||||
data-testid={testId ? `${testId}-ok` : 'confirm-ok'}>{confirmLabel ?? labels.submit}</Button>
|
||||
{alt && <Button variant="primary" loading={busy} onClick={onAlt} data-testid={testId ? `${testId}-alt` : 'confirm-alt'}>{altLabel}</Button>}
|
||||
</>}>
|
||||
{children && <div className="x-confirm__body">{children}</div>}
|
||||
</Dialog>
|
||||
@@ -27,6 +31,7 @@ export function ConfirmDialog({ open, title, children, confirmLabel, cancelLabel
|
||||
* The same as a hook that answers with a promise:
|
||||
* const [confirm, confirmDialog] = useConfirm()
|
||||
* if (!(await confirm({ title, body, confirmLabel, tone: 'danger' }))) return
|
||||
* With altLabel the promise answers 'alt' for the third choice (truthy: check it first).
|
||||
* …render {confirmDialog} somewhere in the component.
|
||||
*/
|
||||
export function useConfirm() {
|
||||
@@ -35,6 +40,7 @@ export function useConfirm() {
|
||||
const answer = value => { ask?.resolve(value); setAsk(null) }
|
||||
const dialog = ask ? (
|
||||
<ConfirmDialog open title={ask.title} confirmLabel={ask.confirmLabel} cancelLabel={ask.cancelLabel} tone={ask.tone} testId={ask.testId}
|
||||
altLabel={ask.altLabel} onAlt={ask.altLabel ? () => answer('alt') : undefined}
|
||||
onConfirm={() => answer(true)} onCancel={() => answer(false)}>{ask.body}</ConfirmDialog>
|
||||
) : null
|
||||
return [confirm, dialog]
|
||||
|
||||
@@ -45,13 +45,20 @@ export function FilterChip({ pressed = false, tone = 'neutral', count, size = 'm
|
||||
* A few mutually exclusive views (List / Map). options: [{ value, label, icon?, ariaLabel? }]
|
||||
* (ariaLabel: the name of an option shown as an icon only). fill: as wide as its column, the options sharing it.
|
||||
* <Segmented value={view} onChange={setView} options={[…]} aria-label="View" />
|
||||
* multiple (2026-11-21): toggles that go together (bold / italic / underline); value is an array.
|
||||
*/
|
||||
export function Segmented({ options = [], value, onChange, size = 'md', fill = false, className, ...rest }) {
|
||||
export function Segmented({ options = [], value, onChange, size = 'md', fill = false, multiple = false, className, ...rest }) {
|
||||
const on = v => (multiple ? (value || []).includes(v) : v === value)
|
||||
const pick = v => {
|
||||
if (!multiple) return onChange?.(v)
|
||||
const list = value || []
|
||||
return onChange?.(list.includes(v) ? list.filter(x => x !== v) : [...list, v])
|
||||
}
|
||||
return (
|
||||
<div role="group" className={cx('x-segmented', `x-segmented--${size}`, fill && 'x-segmented--fill', className)} {...rest}>
|
||||
{options.map(o => (
|
||||
<button key={o.value} type="button" aria-pressed={o.value === value} className={cx('x-segmented__item', o.value === value && 'x-segmented__item--on')}
|
||||
onClick={() => onChange?.(o.value)} data-testid={o.testId} aria-label={o.ariaLabel} title={o.ariaLabel}>
|
||||
<button key={o.value} type="button" aria-pressed={on(o.value)} className={cx('x-segmented__item', on(o.value) && 'x-segmented__item--on')}
|
||||
onClick={() => pick(o.value)} data-testid={o.testId} aria-label={o.ariaLabel} title={o.ariaLabel}>
|
||||
{o.icon}{o.label}
|
||||
</button>
|
||||
))}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Children, useLayoutEffect, useRef, useState } from 'react'
|
||||
import { cx } from '../internal/cx.js'
|
||||
|
||||
/**
|
||||
* A row of fields that wraps (2026-11-21): each field keeps its least width (`min`) and the ones
|
||||
* that don't fit go to a second line, in columns that line up from row to row. While a row is
|
||||
* wrapped it is framed and (with `shade`, every other row) tinted, so its two lines read as one
|
||||
* set; a row that fits on one line looks like any other row.
|
||||
* <FieldRow><Field …/><Field …/></FieldRow>
|
||||
* <FieldRow shade>…</FieldRow> (alternate rows)
|
||||
*/
|
||||
export function FieldRow({ min = '10.5rem', shade = false, className, style, children, ...rest }) {
|
||||
const ref = useRef(null)
|
||||
const [wrapped, setWrapped] = useState(false)
|
||||
const count = Children.count(children)
|
||||
useLayoutEffect(() => {
|
||||
const el = ref.current
|
||||
if (!el) return undefined
|
||||
const check = () => {
|
||||
const kids = [...el.children].filter(k => k.offsetParent !== null || k.getClientRects().length)
|
||||
setWrapped(kids.length > 1 && kids.some(k => k.offsetTop > kids[0].offsetTop + 2))
|
||||
}
|
||||
check()
|
||||
const ro = new ResizeObserver(check)
|
||||
ro.observe(el)
|
||||
return () => ro.disconnect()
|
||||
}, [count])
|
||||
return (
|
||||
<div ref={ref} className={cx('x-field-row', wrapped && 'x-field-row--wrapped', wrapped && shade && 'x-field-row--shade', className)}
|
||||
style={{ ...style, '--x-field-min': min }} data-wrapped={wrapped ? 'true' : undefined} {...rest}>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import { useRef, useState } from 'react'
|
||||
import { cx } from '../internal/cx.js'
|
||||
import { Field } from './Field.jsx'
|
||||
import { Popover } from './Popover.jsx'
|
||||
import { useLabels } from './labels.js'
|
||||
|
||||
/**
|
||||
* Pick an icon from a set (2026-11-21): a field showing the icon chosen; a click opens a grid of
|
||||
* the set over the page (Popover), with "No icon" first.
|
||||
* <IconPicker label="Icon" icons={{ flame: Flame, leaf: Leaf }} value={key} onChange={setKey} />
|
||||
* icons: { key: a component taking `size` }. value null = no icon.
|
||||
*/
|
||||
export function IconPicker({ label, icons = {}, value, onChange, className, testId }) {
|
||||
const labels = useLabels()
|
||||
const [open, setOpen] = useState(false)
|
||||
const btn = useRef(null)
|
||||
const Current = value ? icons[value] : null
|
||||
const pick = k => { onChange?.(k); setOpen(false) }
|
||||
const tid = s => (testId ? `${testId}-${s}` : undefined)
|
||||
return (
|
||||
<>
|
||||
<Field label={label} className={className}>
|
||||
<button ref={btn} type="button" className="x-colour" onClick={() => setOpen(o => !o)} aria-expanded={open} aria-haspopup="dialog" data-testid={tid('open')}>
|
||||
<span className="x-icon-pick__current" aria-hidden="true">{Current ? <Current size={18} /> : null}</span>
|
||||
<span className="x-colour__value">{value || labels.noIcon}</span>
|
||||
</button>
|
||||
</Field>
|
||||
<Popover open={open} anchor={btn} onClose={() => setOpen(false)} aria-label={label} className="x-icon-pick" data-testid={tid('panel')}>
|
||||
<button type="button" className={cx('x-icon-pick__none', !value && 'x-icon-pick__item--on')} onClick={() => pick(null)} data-testid={tid('none')}>{labels.noIcon}</button>
|
||||
<div className="x-icon-pick__grid">
|
||||
{Object.entries(icons).map(([k, Icon]) => (
|
||||
<button key={k} type="button" className={cx('x-icon-pick__item', value === k && 'x-icon-pick__item--on')} aria-label={k} aria-pressed={value === k} title={k}
|
||||
onClick={() => pick(k)} data-testid={tid(k)}>
|
||||
<Icon size={20} aria-hidden="true" />
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</Popover>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Field } from './Field.jsx'
|
||||
|
||||
/**
|
||||
* A slider with its label and its value, framed and as tall as the fields beside it (2026-11-21).
|
||||
* <Slider label="Text size" value={size} min={50} max={250} step={10} suffix="%" onChange={setSize} />
|
||||
* onChange receives the number.
|
||||
*/
|
||||
export function Slider({ label, value, min = 0, max = 100, step = 1, onChange, suffix = '', className, testId }) {
|
||||
return (
|
||||
<Field label={label} className={className}>
|
||||
<span className="x-slider">
|
||||
<input type="range" min={min} max={max} step={step} value={value} onChange={e => onChange?.(Number(e.target.value))}
|
||||
className="x-slider__input" aria-label={label} data-testid={testId} />
|
||||
<span className="x-slider__value">{value}{suffix}</span>
|
||||
</span>
|
||||
</Field>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// A colour's helpers for ColourField (2026-11-21): pure, unit-tested (tests/colour.test.mjs).
|
||||
|
||||
/** Twelve ready colours, two rows of six (a venue's colours: data, not the theme's). */
|
||||
export const COLOUR_PRESETS = [
|
||||
'#ffffff', '#d1d5db', '#6b7280', '#111827', '#000000', '#fde68a',
|
||||
'#f59e0b', '#ef4444', '#f472b6', '#a78bfa', '#38bdf8', '#22c55e',
|
||||
]
|
||||
|
||||
/** A colour as its #rrggbb and its opacity (0–100 %): #rrggbbaa is see-through. */
|
||||
export function splitAlpha(hex) {
|
||||
const h = String(hex || '#000000').toLowerCase()
|
||||
const rgb = /^#[0-9a-f]{6}/.test(h) ? h.slice(0, 7) : '#000000'
|
||||
const alpha = /^#[0-9a-f]{8}$/.test(h) ? Math.round((parseInt(h.slice(7, 9), 16) / 255) * 100) : 100
|
||||
return { rgb, alpha }
|
||||
}
|
||||
|
||||
/** #rrggbb with an opacity: #rrggbb when it is solid, #rrggbbaa otherwise. */
|
||||
export function joinAlpha(rgb, alpha) {
|
||||
const a = Math.max(0, Math.min(100, Math.round(alpha)))
|
||||
return a >= 100 ? rgb : `${rgb}${Math.round((a / 100) * 255).toString(16).padStart(2, '0')}`
|
||||
}
|
||||
|
||||
/** A colour typed by hand: #rgb, #rrggbb or #rrggbbaa (the # optional) → #rrggbb(aa), or null. */
|
||||
export function typedColour(text) {
|
||||
let h = String(text || '').trim().toLowerCase().replace(/^#/, '')
|
||||
if (/^[0-9a-f]{3}$/.test(h)) h = h.split('').map(x => x + x).join('')
|
||||
return /^[0-9a-f]{6}([0-9a-f]{2})?$/.test(h) ? `#${h}` : null
|
||||
}
|
||||
@@ -21,6 +21,10 @@ export const DEFAULT_LABELS = {
|
||||
all: 'All',
|
||||
noOptions: 'Nothing found',
|
||||
selected: n => `${n} selected`,
|
||||
colourOwn: 'Your own colour',
|
||||
colourCode: 'Colour code',
|
||||
opacity: 'Opacity',
|
||||
noIcon: 'No icon',
|
||||
pinProgress: (n, total) => `${n} of ${total} digits entered`,
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,11 @@ export { Spinner } from './components/Spinner.jsx'
|
||||
export { Field, Input, Textarea, Select } from './components/Field.jsx'
|
||||
export { Dropdown } from './components/Dropdown.jsx'
|
||||
export { Popover } from './components/Popover.jsx'
|
||||
export { ColourField, Swatch } from './components/ColourField.jsx'
|
||||
export { COLOUR_PRESETS, joinAlpha, splitAlpha, typedColour } from './components/colour.js'
|
||||
export { FieldRow } from './components/FieldRow.jsx'
|
||||
export { Slider } from './components/Slider.jsx'
|
||||
export { IconPicker } from './components/IconPicker.jsx'
|
||||
export { Page, PageHeader, Pane, Toolbar, ToolbarSpacer } from './components/Page.jsx'
|
||||
export { SearchInput, FilterChip, Segmented, Tabs } from './components/Controls.jsx'
|
||||
export { Switch } from './components/Switch.jsx'
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { test } from 'node:test'
|
||||
import { COLOUR_PRESETS, joinAlpha, splitAlpha, typedColour } from '../src/components/colour.js'
|
||||
|
||||
test('a colour with its opacity: #rrggbbaa, typed by hand', () => {
|
||||
assert.equal(COLOUR_PRESETS.length, 12)
|
||||
assert.deepEqual(splitAlpha('#FF0000'), { rgb: '#ff0000', alpha: 100 })
|
||||
assert.deepEqual(splitAlpha('#ff000080'), { rgb: '#ff0000', alpha: 50 })
|
||||
assert.equal(joinAlpha('#ff0000', 100), '#ff0000')
|
||||
assert.equal(joinAlpha('#ff0000', 50), '#ff000080')
|
||||
assert.equal(joinAlpha('#ff0000', 0), '#ff000000')
|
||||
assert.equal(typedColour('abc'), '#aabbcc')
|
||||
assert.equal(typedColour(' #11223344 '), '#11223344')
|
||||
assert.equal(typedColour('#12345'), null)
|
||||
})
|
||||
Reference in New Issue
Block a user