@seriousgaming/sdk-tools 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundling/ui-bundler.d.ts +12 -0
- package/dist/cli-25RWY5BQ.js +41 -0
- package/dist/cli-272KBNJH.js +97 -0
- package/dist/cli-2BH7FX27.js +52 -0
- package/dist/cli-2GOFEW26.js +81 -0
- package/dist/cli-3E3MD5U4.js +21 -0
- package/dist/cli-3HE4AVZG.js +115 -0
- package/dist/cli-4AKVLEC4.js +1387 -0
- package/dist/cli-4BV45LBH.js +126 -0
- package/dist/cli-4LKXZQ2B.js +48 -0
- package/dist/cli-4UWFQNGF.js +54 -0
- package/dist/cli-4YB3ROVR.js +78 -0
- package/dist/cli-57RXC3HQ.js +36 -0
- package/dist/cli-5JEGTVTG.js +96 -0
- package/dist/cli-6AMT3BUO.js +97 -0
- package/dist/cli-6RRVEGFB.js +80 -0
- package/dist/cli-6WXLXJVX.js +36 -0
- package/dist/cli-7OGYADZ3.js +97 -0
- package/dist/cli-AK7OIPWY.js +229 -0
- package/dist/cli-B4TN6PJP.js +124 -0
- package/dist/cli-B6YHEKIJ.js +248 -0
- package/dist/cli-BPYMTOUL.js +89 -0
- package/dist/cli-BWX5E7TQ.js +23 -0
- package/dist/cli-BYJWFFCF.js +37 -0
- package/dist/cli-C3NVCKO6.js +43 -0
- package/dist/cli-C47GJATR.js +42 -0
- package/dist/cli-C5QOJJWX.js +46 -0
- package/dist/cli-C6TH5S7K.js +6417 -0
- package/dist/cli-DL2CVMRF.js +89 -0
- package/dist/cli-DMW2OQIJ.js +76 -0
- package/dist/cli-DZW3XD5F.js +143 -0
- package/dist/cli-E2NLWIFE.js +1331 -0
- package/dist/cli-E33CJRRQ.js +36 -0
- package/dist/cli-E6DJIMYD.js +142 -0
- package/dist/cli-EEFJKIGL.js +151 -0
- package/dist/cli-EVFS55WN.js +185 -0
- package/dist/cli-F2D4GGUA.js +549 -0
- package/dist/cli-FBTRTIZJ.js +226 -0
- package/dist/cli-FWFRKQNE.js +11 -0
- package/dist/cli-FYINNRML.js +760 -0
- package/dist/cli-G522CPRL.js +88 -0
- package/dist/cli-G6KELFSX.js +2847 -0
- package/dist/cli-G6UE5NL4.js +90 -0
- package/dist/cli-GBFM76BF.js +16 -0
- package/dist/cli-GDQ6ILJY.js +101 -0
- package/dist/cli-GFBGYFYD.js +50 -0
- package/dist/cli-GGPDQNM3.js +35 -0
- package/dist/cli-GTSGLN3Z.js +307 -0
- package/dist/cli-GUXKQMJ7.js +13641 -0
- package/dist/cli-GXD36NF2.js +60 -0
- package/dist/cli-HCRTYQQS.js +16 -0
- package/dist/cli-HYY64SUD.js +185 -0
- package/dist/cli-I355WTAF.js +463 -0
- package/dist/cli-IDKYF5XB.js +59 -0
- package/dist/cli-ILKCQNM6.js +8 -0
- package/dist/cli-IRZ5KB7D.js +36 -0
- package/dist/cli-IUS2YCD3.js +31 -0
- package/dist/cli-J4DKUUTK.js +138 -0
- package/dist/cli-JFU22EJ2.js +187 -0
- package/dist/cli-JMZLT65J.js +226 -0
- package/dist/cli-JZM7XTNV.js +89 -0
- package/dist/cli-K2B6WHKA.js +81 -0
- package/dist/cli-KL3756X6.js +126 -0
- package/dist/cli-KNOOKGYW.js +88 -0
- package/dist/cli-LFGRFIEO.js +226 -0
- package/dist/cli-LFM7GJHI.js +0 -0
- package/dist/cli-LMDJCHHD.js +304 -0
- package/dist/cli-LXYPE3L5.js +99 -0
- package/dist/cli-M6BCQRID.js +153 -0
- package/dist/cli-MBNMPVDC.js +367 -0
- package/dist/cli-MJUYJIEP.js +13 -0
- package/dist/cli-MMN4BPO4.js +145 -0
- package/dist/cli-MYJGMA6U.js +40 -0
- package/dist/cli-N6H6T2E2.js +616 -0
- package/dist/cli-O5KP4OVN.js +61 -0
- package/dist/cli-O6PWMJTZ.js +25 -0
- package/dist/cli-ORIG557O.js +141 -0
- package/dist/cli-PFFCNGHI.js +243 -0
- package/dist/cli-PNLYX6R6.js +131 -0
- package/dist/cli-PQBXVLEU.js +649 -0
- package/dist/cli-PTT5RGKO.js +62 -0
- package/dist/cli-Q2XJF5AS.js +127 -0
- package/dist/cli-QEVDDBNO.js +60 -0
- package/dist/cli-QEVE5HUM.js +167 -0
- package/dist/cli-QUIJCBYB.js +391 -0
- package/dist/cli-QUNIRH7A.js +57 -0
- package/dist/cli-QVASWX2A.js +187 -0
- package/dist/cli-QWQMPCL6.js +253 -0
- package/dist/cli-R4PCG5YX.js +131 -0
- package/dist/cli-RA673NGF.js +53 -0
- package/dist/cli-RN6IWTL2.js +36 -0
- package/dist/cli-ROT3DRKU.js +145 -0
- package/dist/cli-RZITKPJX.js +367 -0
- package/dist/cli-S5IVGDDD.js +32 -0
- package/dist/cli-S5QDONIQ.js +218 -0
- package/dist/cli-SIPDUBFL.js +36 -0
- package/dist/cli-SMFSZF2G.js +4009 -0
- package/dist/cli-SRHBXZCN.js +159 -0
- package/dist/cli-TCY5LJ7E.js +88 -0
- package/dist/cli-TDSQSCX4.js +131 -0
- package/dist/cli-TIDQ4WUE.js +257 -0
- package/dist/cli-TLLA6KAP.js +79 -0
- package/dist/cli-TPU4TUR6.js +132 -0
- package/dist/cli-U2UE7I7J.js +30 -0
- package/dist/cli-UELGBQG7.js +101 -0
- package/dist/cli-UHSZBKYO.js +97 -0
- package/dist/cli-UJ4UCL2Z.js +38 -0
- package/dist/cli-UKQYZYFK.js +31 -0
- package/dist/cli-UMFFURZ7.js +81 -0
- package/dist/cli-UNAJ2OTE.js +15 -0
- package/dist/cli-UNJ5X6BU.js +89 -0
- package/dist/cli-UTJU4IYG.js +117 -0
- package/dist/cli-V4GHRWOV.js +1837 -0
- package/dist/cli-VCI3CG36.js +73 -0
- package/dist/cli-VCKOC2EV.js +256 -0
- package/dist/cli-VL2P354N.js +46 -0
- package/dist/cli-WAE26SVW.js +72 -0
- package/dist/cli-WOGIAU2E.js +100 -0
- package/dist/cli-WU43JT4T.js +52 -0
- package/dist/cli-XCO2VQOH.js +122 -0
- package/dist/cli-XSVGKI3R.js +39 -0
- package/dist/cli-YOTGR3NB.js +82 -0
- package/dist/cli-YVVXUD2G.js +197 -0
- package/dist/cli-ZISJ36MM.js +89 -0
- package/dist/cli-ZTWOE3ZT.js +65 -0
- package/dist/cli-ZVSFYDPQ.js +205 -0
- package/dist/cli-ZWPYIXNI.js +68 -0
- package/dist/cli.js +171 -42385
- package/dist/client/build-surfaces.d.ts +33 -0
- package/dist/client/dev-server.d.ts +6 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/playwright.d.ts +62 -0
- package/dist/client.js +339 -56
- package/dist/core/session.d.ts +15 -1
- package/dist/dev/console/assets/{index-BvB-LFQZ.js → index-CuMOOH9m.js} +21 -21
- package/dist/dev/console/index.html +1 -1
- package/dist/dev/public-origins.d.ts +61 -0
- package/dist/dev/shell.d.ts +51 -4
- package/dist/dev/surfaces.d.ts +7 -0
- package/dist/docs/ai-agents.md +5 -0
- package/dist/docs/api/index.md +14 -12
- package/dist/docs/api/sdk-tools-client.md +29 -0
- package/dist/docs/api/sdk-tools-playwright.md +104 -0
- package/dist/docs/changelog-0.x.md +2 -2
- package/dist/docs/changelog.md +56 -4
- package/dist/docs/cli-and-dev-server.md +79 -0
- package/dist/docs/cli-error-codes.md +39 -36
- package/dist/docs/cli-reference.md +93 -32
- package/dist/docs/environment-variables.md +16 -5
- package/dist/docs/guides/ai-facilitation.md +2 -0
- package/dist/docs/guides/capabilities.md +2 -0
- package/dist/docs/guides/designing-a-game.md +31 -4
- package/dist/docs/guides/designing-screens.md +133 -0
- package/dist/docs/guides/endpoints.md +2 -0
- package/dist/docs/guides/engine-testing.md +5 -1
- package/dist/docs/guides/engine.md +2 -0
- package/dist/docs/guides/file-handling.md +3 -1
- package/dist/docs/guides/games.md +3 -1
- package/dist/docs/guides/global-settings.md +2 -0
- package/dist/docs/guides/guide.md +2 -0
- package/dist/docs/guides/hooks.md +2 -0
- package/dist/docs/guides/index.md +9 -0
- package/dist/docs/guides/internationalization.md +2 -0
- package/dist/docs/guides/llm-integration.md +4 -2
- package/dist/docs/guides/multi-team-games.md +3 -1
- package/dist/docs/guides/patterns.md +2 -0
- package/dist/docs/guides/presentation.md +1 -1
- package/dist/docs/guides/production-constraints.md +2 -0
- package/dist/docs/guides/scenario-editor.md +2 -0
- package/dist/docs/guides/scenarios.md +6 -2
- package/dist/docs/guides/session-game-flow.md +365 -0
- package/dist/docs/guides/session-hooks.md +205 -0
- package/dist/docs/guides/session.md +27 -565
- package/dist/docs/guides/settings.md +2 -0
- package/dist/docs/guides/setup.md +3 -1
- package/dist/docs/guides/speech-generation.md +2 -0
- package/dist/docs/guides/starter-game.md +63 -23
- package/dist/docs/guides/testing.md +35 -18
- package/dist/docs/guides/tick-controller.md +3 -1
- package/dist/docs/guides/type-safety.md +2 -0
- package/dist/docs/guides/ui-files-and-llms.md +328 -0
- package/dist/docs/guides/ui-participants.md +281 -0
- package/dist/docs/guides/ui-styling.md +263 -0
- package/dist/docs/guides/ui-ticks.md +247 -0
- package/dist/docs/guides/ui.md +11 -1092
- package/dist/docs/guides/upgrading.md +2 -0
- package/dist/docs/guides/validators.md +2 -0
- package/dist/docs/guides/waiting-room.md +1 -1
- package/dist/docs/index.md +2 -1
- package/dist/docs/page-index.md +146 -0
- package/dist/docs/recipes/adapt-a-game-for-walkthroughs.md +1 -1
- package/dist/docs/recipes/adapt-ui-for-observers.md +1 -1
- package/dist/docs/recipes/create-presentation.md +11 -0
- package/dist/docs/recipes/create-scenario-editor.md +1 -0
- package/dist/docs/recipes/create-session-ui.md +2 -1
- package/dist/docs/recipes/create-setup.md +1 -0
- package/dist/docs/recipes/create-user-interface.md +1 -0
- package/dist/docs/recipes/create-waiting-room-ui.md +1 -0
- package/dist/docs/recipes/design-state-for-concurrent-writes.md +1 -1
- package/dist/docs/recipes/e2e-testing.md +19 -20
- package/dist/docs/recipes/fix-duplicate-packages.md +2 -2
- package/dist/docs/recipes/index.md +3 -0
- package/dist/docs/recipes/screenshot-a-surface.md +80 -0
- package/dist/docs/recipes/test-a-multi-role-game.md +1 -1
- package/dist/docs/recipes/use-request-tick.md +2 -2
- package/dist/execution/config-resolver.d.ts +4 -1
- package/dist/playwright.js +32232 -0
- package/dist/runtime/manifest-version.d.ts +1 -1
- package/dist/runtime.js +1 -1
- package/dist/templates/package/CLAUDE.md.template +14 -5
- package/dist/templates/package/DESIGN.md.liquid +39 -7
- package/dist/templates/package/README.md.liquid +1 -1
- package/dist/templates/package/claude/rules/workflow-create-user-interface.md +1 -1
- package/dist/templates/package/claude/rules/workflow-test-engine-or-ui.md +1 -1
- package/dist/templates/package/global-setup.ts.template +7 -18
- package/dist/templates/package/playwright.config.ts.liquid +8 -11
- package/dist/templates/package/pnpm-workspace.yaml.template +13 -0
- package/dist/templates/starter-game/capabilities/pacing/capability.sdk.json +18 -0
- package/dist/templates/starter-game/package.json +2 -0
- package/dist/templates/starter-game/playwright.config.ts +8 -11
- package/dist/templates/starter-game/presentation/defaults.ts +52 -0
- package/dist/templates/starter-game/presentation/index.html +20 -0
- package/dist/templates/starter-game/presentation/presentation.sdk.json +10 -0
- package/dist/templates/starter-game/presentation/src/App.tsx +55 -0
- package/dist/templates/starter-game/presentation/src/Band.tsx +40 -0
- package/dist/templates/starter-game/presentation/src/Slides.tsx +415 -0
- package/dist/templates/starter-game/presentation/src/WeatherIcon.tsx +21 -0
- package/dist/templates/starter-game/presentation/src/i18n.ts +88 -0
- package/dist/templates/starter-game/presentation/src/main.tsx +15 -0
- package/dist/templates/starter-game/presentation/src/stalls.test.ts +196 -0
- package/dist/templates/starter-game/presentation/src/stalls.ts +199 -0
- package/dist/templates/starter-game/presentation/types.ts +94 -0
- package/dist/templates/starter-game/seriousgaming.sdk.json +2 -1
- package/dist/templates/starter-game/session/defaults.ts +6 -0
- package/dist/templates/starter-game/session/index.html +1 -1
- package/dist/templates/starter-game/session/session.sdk.json +2 -2
- package/dist/templates/starter-game/session/src/App.test.tsx +436 -115
- package/dist/templates/starter-game/session/src/App.tsx +372 -222
- package/dist/templates/starter-game/session/src/JoinCodes.tsx +184 -0
- package/dist/templates/starter-game/session/src/ManagePanel.tsx +188 -0
- package/dist/templates/starter-game/session/src/Results.tsx +340 -0
- package/dist/templates/starter-game/session/src/SessionBar.tsx +179 -0
- package/dist/templates/starter-game/session/src/SessionPanels.tsx +105 -0
- package/dist/templates/starter-game/session/src/SidePanel.tsx +89 -0
- package/dist/templates/starter-game/session/src/StallCard.tsx +253 -0
- package/dist/templates/starter-game/session/src/TopBar.tsx +36 -0
- package/dist/templates/starter-game/session/src/i18n.ts +91 -24
- package/dist/templates/starter-game/session/src/status.ts +28 -0
- package/dist/templates/starter-game/session/types.ts +8 -2
- package/dist/templates/starter-game/shared/Awning.tsx +31 -0
- package/dist/templates/starter-game/shared/HostLogo.test.tsx +38 -0
- package/dist/templates/starter-game/shared/HostLogo.tsx +48 -0
- package/dist/templates/starter-game/shared/StallIcons.tsx +83 -0
- package/dist/templates/starter-game/shared/days.ts +11 -0
- package/dist/templates/starter-game/shared/format.test.ts +13 -0
- package/dist/templates/starter-game/{ui/src → shared}/format.ts +1 -1
- package/dist/templates/starter-game/testing/e2e/game.spec.ts +43 -9
- package/dist/templates/starter-game/testing/e2e/global-setup.ts +7 -18
- package/dist/templates/starter-game/ui/defaults.ts +3 -0
- package/dist/templates/starter-game/ui/src/App.test.tsx +197 -29
- package/dist/templates/starter-game/ui/src/App.tsx +176 -99
- package/dist/templates/starter-game/ui/src/DayBar.test.tsx +50 -7
- package/dist/templates/starter-game/ui/src/DayBar.tsx +96 -38
- package/dist/templates/starter-game/ui/src/DaysTable.tsx +69 -0
- package/dist/templates/starter-game/ui/src/FirstDay.tsx +37 -0
- package/dist/templates/starter-game/ui/src/Header.tsx +257 -0
- package/dist/templates/starter-game/ui/src/Lesson.tsx +63 -0
- package/dist/templates/starter-game/ui/src/MakeRow.tsx +98 -71
- package/dist/templates/starter-game/ui/src/Notices.tsx +59 -0
- package/dist/templates/starter-game/ui/src/PastDay.tsx +88 -0
- package/dist/templates/starter-game/ui/src/Section.tsx +26 -26
- package/dist/templates/starter-game/ui/src/ThemeToggle.tsx +25 -11
- package/dist/templates/starter-game/ui/src/TodayPanel.test.tsx +37 -33
- package/dist/templates/starter-game/ui/src/TodayPanel.tsx +66 -52
- package/dist/templates/starter-game/ui/src/WeatherCard.tsx +47 -0
- package/dist/templates/starter-game/ui/src/WeekOver.tsx +145 -0
- package/dist/templates/starter-game/ui/src/YesterdayPanel.tsx +65 -114
- package/dist/templates/starter-game/ui/src/days.ts +58 -0
- package/dist/templates/starter-game/ui/src/i18n.ts +86 -32
- package/dist/templates/starter-game/ui/src/test-helpers.ts +1 -0
- package/dist/templates/starter-game/ui/src/theme.ts +8 -8
- package/dist/templates/starter-game/ui/types.ts +6 -0
- package/dist/templates/starter-game/ui/ui.sdk.json +1 -1
- package/dist/templates/starter-game/validators/daylimit/defaults.ts +13 -0
- package/dist/templates/starter-game/validators/daylimit/logic/logic.test.ts +20 -0
- package/dist/templates/starter-game/validators/daylimit/logic/logic.ts +23 -0
- package/dist/templates/starter-game/validators/daylimit/types.ts +23 -0
- package/dist/templates/starter-game/validators/daylimit/validator.sdk.json +10 -0
- package/dist/templates/starter-game/waiting_room/src/App.test.tsx +83 -5
- package/dist/templates/starter-game/waiting_room/src/App.tsx +262 -119
- package/dist/templates/starter-game/waiting_room/src/i18n.ts +8 -4
- package/dist/utils/error-codes.d.ts +12 -0
- package/dist/utils/prompt.d.ts +5 -5
- package/dist/utils/resource-scan.d.ts +39 -0
- package/package.json +15 -4
- package/dist/templates/starter-game/session/src/Section.tsx +0 -37
- package/dist/templates/starter-game/session/src/TeamDoor.tsx +0 -96
- package/dist/templates/starter-game/session/src/format.ts +0 -8
- package/dist/templates/starter-game/ui/src/HistoryPanel.test.tsx +0 -74
- package/dist/templates/starter-game/ui/src/HistoryPanel.tsx +0 -120
- package/dist/templates/starter-game/ui/src/HostLogo.test.tsx +0 -25
- package/dist/templates/starter-game/ui/src/HostLogo.tsx +0 -38
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import CloseIcon from '@mui/icons-material/Close';
|
|
2
|
+
import { Box, IconButton, Typography } from '@mui/material';
|
|
3
|
+
import { useId, type ReactNode } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
title: string;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A column of its own beside the stalls, rather than a dialog over them.
|
|
14
|
+
*
|
|
15
|
+
* On the platform this surface sits in a frame under the host's bar, and a
|
|
16
|
+
* backdrop would dim only the frame, which reads as broken rather than as
|
|
17
|
+
* paused. A column also leaves the cards where they were, which matters to a
|
|
18
|
+
* facilitator who is pointing at one of them while they talk.
|
|
19
|
+
*/
|
|
20
|
+
export default function SidePanel({ title, onClose, children }: Props) {
|
|
21
|
+
const { t } = useTranslation();
|
|
22
|
+
const headingId = useId();
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Box
|
|
26
|
+
component="aside"
|
|
27
|
+
aria-labelledby={headingId}
|
|
28
|
+
sx={(theme) => ({
|
|
29
|
+
width: { xs: '100%', md: 360 },
|
|
30
|
+
flex: 'none',
|
|
31
|
+
boxSizing: 'border-box',
|
|
32
|
+
bgcolor: 'background.paper',
|
|
33
|
+
borderInlineStart: { xs: 0, md: `1px solid ${theme.palette.divider}` },
|
|
34
|
+
boxShadow: { md: '-12px 0 32px rgba(0, 0, 0, 0.06)' },
|
|
35
|
+
px: 3,
|
|
36
|
+
py: 2.5,
|
|
37
|
+
display: 'flex',
|
|
38
|
+
flexDirection: 'column',
|
|
39
|
+
gap: 2.5,
|
|
40
|
+
overflowY: 'auto',
|
|
41
|
+
minHeight: 0,
|
|
42
|
+
})}
|
|
43
|
+
>
|
|
44
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
|
45
|
+
<Typography
|
|
46
|
+
id={headingId}
|
|
47
|
+
component="h2"
|
|
48
|
+
noWrap
|
|
49
|
+
sx={{ flex: 1, minWidth: 0, fontSize: '1.15rem', fontWeight: 600 }}
|
|
50
|
+
>
|
|
51
|
+
{title}
|
|
52
|
+
</Typography>
|
|
53
|
+
<IconButton aria-label={t('panel.close')} onClick={onClose} edge="end">
|
|
54
|
+
<CloseIcon />
|
|
55
|
+
</IconButton>
|
|
56
|
+
</Box>
|
|
57
|
+
{children}
|
|
58
|
+
</Box>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A labelled group inside a panel. */
|
|
63
|
+
export function PanelGroup({
|
|
64
|
+
label,
|
|
65
|
+
divided = false,
|
|
66
|
+
children,
|
|
67
|
+
}: {
|
|
68
|
+
label: string;
|
|
69
|
+
divided?: boolean;
|
|
70
|
+
children: ReactNode;
|
|
71
|
+
}) {
|
|
72
|
+
return (
|
|
73
|
+
<Box
|
|
74
|
+
component="section"
|
|
75
|
+
aria-label={label}
|
|
76
|
+
sx={{
|
|
77
|
+
display: 'flex',
|
|
78
|
+
flexDirection: 'column',
|
|
79
|
+
gap: 1,
|
|
80
|
+
...(divided && { borderTop: 1, borderColor: 'divider', pt: 2 }),
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
<Typography component="h3" sx={{ fontWeight: 600, fontSize: '0.875rem' }}>
|
|
84
|
+
{label}
|
|
85
|
+
</Typography>
|
|
86
|
+
{children}
|
|
87
|
+
</Box>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { Avatar, AvatarGroup, Box, Button, Card, Chip, Popover, Typography } from '@mui/material';
|
|
2
|
+
import { alpha, type Theme } from '@mui/material/styles';
|
|
3
|
+
import type { Participant, TeamLinks } from '@seriousgaming/sdk/ui';
|
|
4
|
+
import { useRef, useState } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
|
|
7
|
+
import { initials, type StallStatus } from './status';
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
teamId: string;
|
|
11
|
+
name: string;
|
|
12
|
+
status: StallStatus;
|
|
13
|
+
people: Participant[];
|
|
14
|
+
jar: string;
|
|
15
|
+
links: TeamLinks | undefined;
|
|
16
|
+
showLinks: boolean;
|
|
17
|
+
selected: boolean;
|
|
18
|
+
onManage: () => void;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// The host's roles, in turn, so two people at one stall rarely share a colour
|
|
22
|
+
// and a rebrand recolours them with everything else.
|
|
23
|
+
const AVATAR_ROLES = ['primary', 'secondary', 'success', 'info'] as const;
|
|
24
|
+
|
|
25
|
+
const chipColours = (theme: Theme, status: StallStatus) => {
|
|
26
|
+
const role =
|
|
27
|
+
status.kind === 'waiting'
|
|
28
|
+
? theme.palette.warning
|
|
29
|
+
: status.kind === 'finished'
|
|
30
|
+
? theme.palette.success
|
|
31
|
+
: theme.palette.primary;
|
|
32
|
+
return {
|
|
33
|
+
bgcolor: alpha(role.main, 0.14),
|
|
34
|
+
color: theme.palette.mode === 'dark' ? role.light : role.dark,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* One stall, always in three rows: who it is and where it has got to, who is
|
|
40
|
+
* there and what it has made, and the ways in.
|
|
41
|
+
*
|
|
42
|
+
* Three rows whatever the stall is doing is what keeps a grid of eight calm:
|
|
43
|
+
* a card that grew a fourth line when something happened would push its row
|
|
44
|
+
* out of line with its neighbours, and the eye goes to the misalignment rather
|
|
45
|
+
* than to the stall.
|
|
46
|
+
*/
|
|
47
|
+
export default function StallCard({
|
|
48
|
+
teamId,
|
|
49
|
+
name,
|
|
50
|
+
status,
|
|
51
|
+
people,
|
|
52
|
+
jar,
|
|
53
|
+
links,
|
|
54
|
+
showLinks,
|
|
55
|
+
selected,
|
|
56
|
+
onManage,
|
|
57
|
+
}: Props) {
|
|
58
|
+
const { t } = useTranslation();
|
|
59
|
+
const copyButton = useRef<HTMLButtonElement>(null);
|
|
60
|
+
const [copied, setCopied] = useState(false);
|
|
61
|
+
const [byHand, setByHand] = useState(false);
|
|
62
|
+
|
|
63
|
+
const label =
|
|
64
|
+
status.kind === 'playing'
|
|
65
|
+
? t('stall.playing', { day: status.day })
|
|
66
|
+
: status.kind === 'waiting'
|
|
67
|
+
? t('stall.waiting', { day: status.day })
|
|
68
|
+
: t('stall.finished');
|
|
69
|
+
|
|
70
|
+
const copyJoinLink = () => {
|
|
71
|
+
if (!links) return;
|
|
72
|
+
// Called straight from the click, never after an await: Safari and
|
|
73
|
+
// Firefox only allow the write inside the gesture. Where it is refused
|
|
74
|
+
// anyway, the link is shown to copy by hand, which is worse than
|
|
75
|
+
// copying and better than a button that does nothing.
|
|
76
|
+
try {
|
|
77
|
+
navigator.clipboard.writeText(links.joinUrl).then(
|
|
78
|
+
() => {
|
|
79
|
+
setCopied(true);
|
|
80
|
+
window.setTimeout(() => setCopied(false), 2000);
|
|
81
|
+
},
|
|
82
|
+
() => setByHand(true)
|
|
83
|
+
);
|
|
84
|
+
} catch {
|
|
85
|
+
setByHand(true);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<Card
|
|
91
|
+
component="article"
|
|
92
|
+
variant="outlined"
|
|
93
|
+
data-testid={`team-${teamId}`}
|
|
94
|
+
aria-label={name}
|
|
95
|
+
sx={(theme) => ({
|
|
96
|
+
borderRadius: 4,
|
|
97
|
+
p: 2,
|
|
98
|
+
display: 'grid',
|
|
99
|
+
gridTemplateRows: 'auto auto auto',
|
|
100
|
+
rowGap: 1.75,
|
|
101
|
+
...(selected && {
|
|
102
|
+
borderColor: theme.palette.primary.main,
|
|
103
|
+
boxShadow: `0 0 0 1px ${theme.palette.primary.main}`,
|
|
104
|
+
}),
|
|
105
|
+
})}
|
|
106
|
+
>
|
|
107
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5, minWidth: 0 }}>
|
|
108
|
+
<Typography
|
|
109
|
+
component="h3"
|
|
110
|
+
noWrap
|
|
111
|
+
sx={{ flex: 1, minWidth: 0, fontWeight: 600, fontSize: '1.05rem' }}
|
|
112
|
+
>
|
|
113
|
+
{name}
|
|
114
|
+
</Typography>
|
|
115
|
+
<Chip
|
|
116
|
+
size="small"
|
|
117
|
+
label={label}
|
|
118
|
+
sx={(theme) => ({
|
|
119
|
+
fontWeight: 600,
|
|
120
|
+
flexShrink: 0,
|
|
121
|
+
...chipColours(theme, status),
|
|
122
|
+
})}
|
|
123
|
+
/>
|
|
124
|
+
</Box>
|
|
125
|
+
|
|
126
|
+
<Box
|
|
127
|
+
sx={{
|
|
128
|
+
display: 'flex',
|
|
129
|
+
alignItems: 'center',
|
|
130
|
+
justifyContent: 'space-between',
|
|
131
|
+
gap: 1.5,
|
|
132
|
+
height: 32,
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
{people.length === 0 ? (
|
|
136
|
+
<Typography variant="body2" color="text.secondary" noWrap>
|
|
137
|
+
{t('stall.nobody')}
|
|
138
|
+
</Typography>
|
|
139
|
+
) : (
|
|
140
|
+
<AvatarGroup
|
|
141
|
+
max={6}
|
|
142
|
+
sx={{
|
|
143
|
+
'& .MuiAvatar-root': {
|
|
144
|
+
width: 28,
|
|
145
|
+
height: 28,
|
|
146
|
+
fontSize: '0.7rem',
|
|
147
|
+
fontWeight: 600,
|
|
148
|
+
},
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
{people.map((person, index) => {
|
|
152
|
+
const name = person.connected
|
|
153
|
+
? person.name
|
|
154
|
+
: t('stall.away', { name: person.name });
|
|
155
|
+
const role = AVATAR_ROLES[index % AVATAR_ROLES.length] ?? 'primary';
|
|
156
|
+
return (
|
|
157
|
+
<Avatar
|
|
158
|
+
key={person.id}
|
|
159
|
+
alt={name}
|
|
160
|
+
title={name}
|
|
161
|
+
aria-label={name}
|
|
162
|
+
role="img"
|
|
163
|
+
sx={(theme) => ({
|
|
164
|
+
bgcolor: person.connected
|
|
165
|
+
? theme.palette[role].main
|
|
166
|
+
: theme.palette.action.disabledBackground,
|
|
167
|
+
color: person.connected
|
|
168
|
+
? theme.palette[role].contrastText
|
|
169
|
+
: theme.palette.text.secondary,
|
|
170
|
+
})}
|
|
171
|
+
>
|
|
172
|
+
{initials(person.name)}
|
|
173
|
+
</Avatar>
|
|
174
|
+
);
|
|
175
|
+
})}
|
|
176
|
+
</AvatarGroup>
|
|
177
|
+
)}
|
|
178
|
+
<Typography
|
|
179
|
+
variant="body2"
|
|
180
|
+
color="text.secondary"
|
|
181
|
+
noWrap
|
|
182
|
+
sx={{ fontVariantNumeric: 'tabular-nums' }}
|
|
183
|
+
>
|
|
184
|
+
{t('stall.jar')}{' '}
|
|
185
|
+
<Box component="strong" sx={{ color: 'text.primary' }}>
|
|
186
|
+
{jar}
|
|
187
|
+
</Box>
|
|
188
|
+
</Typography>
|
|
189
|
+
</Box>
|
|
190
|
+
|
|
191
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, mx: -1, mb: -0.75 }}>
|
|
192
|
+
{/* `target="_blank"` rather than navigating this frame: a
|
|
193
|
+
session surface owns the canvas, and replacing it with a
|
|
194
|
+
stall's screen would leave the facilitator no way back.
|
|
195
|
+
Observing admits nobody, so the stall never sees a fourth
|
|
196
|
+
person appear. */}
|
|
197
|
+
{showLinks && links && (
|
|
198
|
+
<>
|
|
199
|
+
<Button
|
|
200
|
+
component="a"
|
|
201
|
+
href={links.observeUrl}
|
|
202
|
+
target="_blank"
|
|
203
|
+
rel="noopener"
|
|
204
|
+
sx={{ whiteSpace: 'nowrap' }}
|
|
205
|
+
>
|
|
206
|
+
{t('stall.observe')}
|
|
207
|
+
</Button>
|
|
208
|
+
<Button
|
|
209
|
+
ref={copyButton}
|
|
210
|
+
aria-label={t('stall.copyLabel', { team: name })}
|
|
211
|
+
onClick={copyJoinLink}
|
|
212
|
+
sx={{ whiteSpace: 'nowrap' }}
|
|
213
|
+
>
|
|
214
|
+
{copied ? t('stall.copied') : t('stall.copy')}
|
|
215
|
+
</Button>
|
|
216
|
+
<Popover
|
|
217
|
+
open={byHand}
|
|
218
|
+
anchorEl={copyButton.current}
|
|
219
|
+
onClose={() => setByHand(false)}
|
|
220
|
+
anchorOrigin={{ vertical: 'bottom', horizontal: 'left' }}
|
|
221
|
+
>
|
|
222
|
+
<Box sx={{ p: 2, maxWidth: 360 }}>
|
|
223
|
+
<Typography variant="body2" sx={{ mb: 1 }}>
|
|
224
|
+
{t('stall.copyByHand')}
|
|
225
|
+
</Typography>
|
|
226
|
+
<Typography
|
|
227
|
+
variant="body2"
|
|
228
|
+
sx={{
|
|
229
|
+
fontFamily: 'monospace',
|
|
230
|
+
userSelect: 'all',
|
|
231
|
+
wordBreak: 'break-all',
|
|
232
|
+
}}
|
|
233
|
+
>
|
|
234
|
+
{links.joinUrl}
|
|
235
|
+
</Typography>
|
|
236
|
+
</Box>
|
|
237
|
+
</Popover>
|
|
238
|
+
</>
|
|
239
|
+
)}
|
|
240
|
+
<Box sx={{ flex: 1 }} />
|
|
241
|
+
<Button
|
|
242
|
+
color="inherit"
|
|
243
|
+
aria-label={t('stall.manageLabel', { team: name })}
|
|
244
|
+
aria-expanded={selected}
|
|
245
|
+
onClick={onManage}
|
|
246
|
+
sx={{ whiteSpace: 'nowrap' }}
|
|
247
|
+
>
|
|
248
|
+
{t('stall.manage')}
|
|
249
|
+
</Button>
|
|
250
|
+
</Box>
|
|
251
|
+
</Card>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Box, Typography } from '@mui/material';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
|
|
4
|
+
import { Awning } from '../../shared/Awning';
|
|
5
|
+
import HostLogo from '../../shared/HostLogo';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The host's colour, its logo where it sent one, and the game's name, with the
|
|
9
|
+
* awning underneath. The session's own controls sit on the band below, so this
|
|
10
|
+
* stays the same on every screen of the game.
|
|
11
|
+
*/
|
|
12
|
+
export default function TopBar() {
|
|
13
|
+
const { t } = useTranslation();
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Box component="header">
|
|
17
|
+
<Box
|
|
18
|
+
sx={{
|
|
19
|
+
bgcolor: 'primary.main',
|
|
20
|
+
color: 'primary.contrastText',
|
|
21
|
+
height: 56,
|
|
22
|
+
px: { xs: 2, md: 4 },
|
|
23
|
+
display: 'flex',
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
gap: 2.5,
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
<HostLogo height={28} />
|
|
29
|
+
<Typography variant="h6" component="h1" noWrap sx={{ fontWeight: 700 }}>
|
|
30
|
+
{t('game')}
|
|
31
|
+
</Typography>
|
|
32
|
+
</Box>
|
|
33
|
+
<Awning />
|
|
34
|
+
</Box>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -4,38 +4,105 @@ import { initReactI18next } from 'react-i18next';
|
|
|
4
4
|
const resources = {
|
|
5
5
|
en: {
|
|
6
6
|
translation: {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
game: 'Lemonade Stand',
|
|
8
|
+
bar: {
|
|
9
|
+
label: 'Session',
|
|
10
|
+
limitLead: 'Stalls can play up to',
|
|
11
|
+
limitGroup: 'Day limit',
|
|
12
|
+
limitDay: 'Day {{day}}',
|
|
13
|
+
limitOf: 'of {{last}}',
|
|
14
|
+
hold: 'Hold at day {{day}}',
|
|
15
|
+
open: 'Open day {{day}}',
|
|
16
|
+
waitingOpen: 'Waiting room open',
|
|
17
|
+
waitingClosed: 'Waiting room closed',
|
|
18
|
+
waitingHint:
|
|
10
19
|
'Holds every player on the holding screen. Nothing about the session changes, so you can park it for a discussion and pick up where the stalls were.',
|
|
11
20
|
guide: 'Facilitator guide',
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
21
|
+
slides: 'Slides',
|
|
22
|
+
},
|
|
23
|
+
tabs: {
|
|
24
|
+
label: 'Facilitator views',
|
|
25
|
+
teams: 'Teams',
|
|
26
|
+
results: 'Results',
|
|
27
|
+
},
|
|
28
|
+
tools: {
|
|
29
|
+
joinCodes: 'Show join codes',
|
|
30
|
+
more: 'More',
|
|
31
|
+
notice: 'Notice to the room',
|
|
32
|
+
print: 'Print join sheets',
|
|
33
|
+
addStall: 'Add a stall',
|
|
34
|
+
startAgain: 'Start the session again',
|
|
35
|
+
},
|
|
36
|
+
readOnly: 'This session is read only, so the controls here will be refused.',
|
|
37
|
+
noStalls: 'No stalls yet. They appear here as soon as the session has one.',
|
|
38
|
+
stall: {
|
|
39
|
+
playing: 'Playing day {{day}}',
|
|
40
|
+
waiting: 'Waiting for day {{day}}',
|
|
41
|
+
finished: 'Finished',
|
|
42
|
+
jar: 'In the jar',
|
|
43
|
+
nobody: 'Nobody yet',
|
|
44
|
+
away: '{{name}} (away)',
|
|
45
|
+
observe: 'Observe',
|
|
46
|
+
copy: 'Copy join link',
|
|
47
|
+
copyLabel: 'Copy the join link for {{team}}',
|
|
48
|
+
copied: 'Copied',
|
|
49
|
+
copyByHand: 'Copy this link by hand',
|
|
50
|
+
manage: 'Manage',
|
|
51
|
+
manageLabel: 'Manage {{team}}',
|
|
52
|
+
},
|
|
53
|
+
panel: {
|
|
54
|
+
close: 'Close',
|
|
55
|
+
name: 'Stall name',
|
|
16
56
|
people: 'People',
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
purse: 'In the jar',
|
|
22
|
-
wayIn: 'Way in',
|
|
23
|
-
controls: '',
|
|
24
|
-
unchanged: 'Same as yesterday',
|
|
25
|
-
changed: 'Changed',
|
|
57
|
+
nobody: 'Nobody has joined this stall yet.',
|
|
58
|
+
move: 'Move',
|
|
59
|
+
moveLabel: 'Move {{name}} to another stall',
|
|
60
|
+
moveTo: 'Move to {{team}}',
|
|
26
61
|
undo: 'Undo',
|
|
27
|
-
|
|
62
|
+
undoNothing: 'Nothing to undo until this stall has played a day.',
|
|
63
|
+
undoDay: 'Undo day {{day}}',
|
|
64
|
+
undoAsk: 'Take {{team}} back to the start of day {{day}}?',
|
|
65
|
+
keep: 'Keep it',
|
|
28
66
|
noticeHint: 'One note, shown on every stall’s screen and in the waiting room.',
|
|
29
67
|
noticeLabel: 'Message',
|
|
30
68
|
send: 'Send',
|
|
69
|
+
startAgainAsk:
|
|
70
|
+
'Take every stall back to the start of day 1? Everything they have made so far is lost.',
|
|
71
|
+
startAgain: 'Start again',
|
|
31
72
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
73
|
+
results: {
|
|
74
|
+
after: 'After day {{day}}',
|
|
75
|
+
show: 'Show day {{day}}',
|
|
76
|
+
fullScreen: 'Full screen',
|
|
77
|
+
exitFullScreen: 'Leave full screen',
|
|
78
|
+
empty: 'Results appear here once a stall has played its first day.',
|
|
79
|
+
jarAverage: 'In the jar, average stall',
|
|
80
|
+
profitAverage: 'Profit on day {{day}}, average stall',
|
|
81
|
+
turnedAway: 'Turned away on day {{day}}',
|
|
82
|
+
people_one: '{{count}} person',
|
|
83
|
+
people_other: '{{count}} people',
|
|
84
|
+
range: '{{low}} to {{high}}',
|
|
85
|
+
played: '{{played}} of {{total}} stalls have played day {{day}}',
|
|
86
|
+
caption: 'Every stall after day {{day}}',
|
|
87
|
+
stall: 'Stall',
|
|
88
|
+
jar: 'In the jar',
|
|
89
|
+
profit: 'Profit, day {{day}}',
|
|
90
|
+
sold: 'Sold',
|
|
91
|
+
turned: 'Turned away',
|
|
92
|
+
poured: 'Poured away',
|
|
93
|
+
notYet: 'Not played yet',
|
|
94
|
+
none: '–',
|
|
95
|
+
},
|
|
96
|
+
codes: {
|
|
97
|
+
position: 'Stall {{position}} of {{total}}',
|
|
98
|
+
goTo: 'Go to',
|
|
99
|
+
pin: 'Session PIN',
|
|
100
|
+
fallback: 'Link not working?',
|
|
101
|
+
fallbackLead: 'Try',
|
|
102
|
+
previous: 'Previous stall',
|
|
103
|
+
next: 'Next stall',
|
|
104
|
+
done: 'Done',
|
|
105
|
+
missing: 'The join links have not arrived yet.',
|
|
39
106
|
},
|
|
40
107
|
},
|
|
41
108
|
},
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LAST_DAY } from '../../shared/days';
|
|
2
|
+
|
|
3
|
+
export type StallStatus =
|
|
4
|
+
| { kind: 'playing'; day: number }
|
|
5
|
+
| { kind: 'waiting'; day: number }
|
|
6
|
+
| { kind: 'finished' };
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Where a stall is in its week, from the two numbers that decide it.
|
|
10
|
+
*
|
|
11
|
+
* There is no 'ready' here, and nothing on a player's screen to say so: the
|
|
12
|
+
* stalls open their own days, so the only things a facilitator needs to know
|
|
13
|
+
* are which day each one is on and whether the day limit is holding it.
|
|
14
|
+
*/
|
|
15
|
+
export function stallStatus(completedTicks: number, lastOpenDay: number): StallStatus {
|
|
16
|
+
if (completedTicks >= LAST_DAY) return { kind: 'finished' };
|
|
17
|
+
if (completedTicks >= lastOpenDay) return { kind: 'waiting', day: completedTicks + 1 };
|
|
18
|
+
return { kind: 'playing', day: completedTicks + 1 };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Initials for an avatar: the first letter of the first and last words. */
|
|
22
|
+
export function initials(name: string) {
|
|
23
|
+
const words = name.trim().split(/\s+/).filter(Boolean);
|
|
24
|
+
if (words.length === 0) return '?';
|
|
25
|
+
const first = words.at(0)?.charAt(0) ?? '';
|
|
26
|
+
const last = words.length > 1 ? (words.at(-1)?.charAt(0) ?? '') : '';
|
|
27
|
+
return (first + last).toUpperCase();
|
|
28
|
+
}
|
|
@@ -56,6 +56,12 @@ export interface Context {
|
|
|
56
56
|
*/
|
|
57
57
|
Message: string;
|
|
58
58
|
};
|
|
59
|
+
pacing: {
|
|
60
|
+
/**
|
|
61
|
+
* The last day a stall may open. The facilitator lowers it to hold the room at a day, and raises it to let them on; the default opens all ten
|
|
62
|
+
*/
|
|
63
|
+
LastOpenDay: number;
|
|
64
|
+
};
|
|
59
65
|
}
|
|
60
66
|
export interface DayLine {
|
|
61
67
|
Made: number;
|
|
@@ -76,9 +82,9 @@ export interface DayLine {
|
|
|
76
82
|
|
|
77
83
|
export type TeamContext = Pick<Context, 'plan' | 'results' | 'roles'>;
|
|
78
84
|
|
|
79
|
-
export type SharedContext = Pick<Context, 'briefing'>;
|
|
85
|
+
export type SharedContext = Pick<Context, 'briefing' | 'pacing'>;
|
|
80
86
|
|
|
81
|
-
export type SharedWrites = Pick<Context, 'briefing'>;
|
|
87
|
+
export type SharedWrites = Pick<Context, 'briefing' | 'pacing'>;
|
|
82
88
|
|
|
83
89
|
export type TeamWrites = Record<string, never>;
|
|
84
90
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Box, useTheme } from '@mui/material';
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The scalloped edge of a stall's awning, under the top bar of every screen.
|
|
6
|
+
*
|
|
7
|
+
* This is the game's one drawn motif: the host's theme supplies the colour, so
|
|
8
|
+
* it changes with the brand, and everything else on screen comes from the icon
|
|
9
|
+
* set. One shape used everywhere is what makes the screens recognisably this
|
|
10
|
+
* game's without competing with the host's identity.
|
|
11
|
+
*/
|
|
12
|
+
export function Awning({ depth = 12, scallop = 20 }: { depth?: number; scallop?: number }) {
|
|
13
|
+
const theme = useTheme();
|
|
14
|
+
const id = useId();
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Box aria-hidden sx={{ height: depth, mt: '-1px', lineHeight: 0 }}>
|
|
18
|
+
<svg width="100%" height={depth} preserveAspectRatio="none">
|
|
19
|
+
<defs>
|
|
20
|
+
<pattern id={id} width={scallop} height={depth} patternUnits="userSpaceOnUse">
|
|
21
|
+
<path
|
|
22
|
+
d={`M0 0 H${scallop} V2 Q${scallop / 2} ${depth} 0 2 Z`}
|
|
23
|
+
fill={theme.palette.primary.main}
|
|
24
|
+
/>
|
|
25
|
+
</pattern>
|
|
26
|
+
</defs>
|
|
27
|
+
<rect width="100%" height={depth} fill={`url(#${id})`} />
|
|
28
|
+
</svg>
|
|
29
|
+
</Box>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createMockBrand,
|
|
3
|
+
createMockUserInterfaceTheme,
|
|
4
|
+
renderUserInterface,
|
|
5
|
+
} from '@seriousgaming/sdk/ui/testing';
|
|
6
|
+
import { screen } from '@testing-library/react';
|
|
7
|
+
import { describe, expect, it } from 'vitest';
|
|
8
|
+
|
|
9
|
+
import HostLogo from './HostLogo';
|
|
10
|
+
|
|
11
|
+
describe('the host logo', () => {
|
|
12
|
+
// The logo sits on the top bar, which is the host's primary colour with
|
|
13
|
+
// light text on it, so the artwork drawn for a dark background is the one
|
|
14
|
+
// that reads.
|
|
15
|
+
it("shows the host's logo drawn for the bar, named for the host", () => {
|
|
16
|
+
const brand = createMockBrand({ name: 'Northwind' });
|
|
17
|
+
renderUserInterface(<HostLogo />, { theme: createMockUserInterfaceTheme({ brand }) });
|
|
18
|
+
|
|
19
|
+
const logo = screen.getByRole('img', { name: 'Northwind' });
|
|
20
|
+
expect(logo).toHaveAttribute('src', brand.logo?.onDark);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('falls back to the only variant the host sent', () => {
|
|
24
|
+
const brand = createMockBrand({ name: 'Northwind' });
|
|
25
|
+
const onLight = brand.logo?.onLight;
|
|
26
|
+
renderUserInterface(<HostLogo />, {
|
|
27
|
+
theme: createMockUserInterfaceTheme({ brand: { ...brand, logo: { onLight } } }),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
expect(screen.getByRole('img', { name: 'Northwind' })).toHaveAttribute('src', onLight);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('shows nothing when the host sends no logo', () => {
|
|
34
|
+
renderUserInterface(<HostLogo />);
|
|
35
|
+
|
|
36
|
+
expect(screen.queryByTestId('host-logo')).not.toBeInTheDocument();
|
|
37
|
+
});
|
|
38
|
+
});
|