Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

578 implement multi page modals #838

Merged
merged 30 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d070b45
578 basic nav and button styling
dhinrichs-scottlogic Feb 9, 2024
e0cddf6
578 mission info working
dhinrichs-scottlogic Feb 12, 2024
4e8dc8a
578 welcome modal very basic working
dhinrichs-scottlogic Feb 12, 2024
e759246
578 added lawyer and manager images
dhinrichs-scottlogic Feb 12, 2024
d3724d0
578 added images
dhinrichs-scottlogic Feb 13, 2024
2b2feaf
578 adjusted nav
dhinrichs-scottlogic Feb 13, 2024
ab66632
578 linted
dhinrichs-scottlogic Feb 13, 2024
4cba063
578 max width for img
dhinrichs-scottlogic Feb 13, 2024
4671ec3
578 updated images
dhinrichs-scottlogic Feb 13, 2024
4fc4f42
578 nav buttons working
dhinrichs-scottlogic Feb 14, 2024
13c4f3a
578 work in progress
dhinrichs-scottlogic Feb 14, 2024
b63ff20
578 in progress
dhinrichs-scottlogic Feb 15, 2024
79e1ad3
578 added MultipageOverlay component
dhinrichs-scottlogic Feb 16, 2024
1d3aee0
578 MissionInformation done
dhinrichs-scottlogic Feb 16, 2024
730c326
578 OverlayWelcome done
dhinrichs-scottlogic Feb 16, 2024
698aa66
578 finished levels complete
dhinrichs-scottlogic Feb 16, 2024
c7e976e
578 px to rem
dhinrichs-scottlogic Feb 16, 2024
1a67bdf
578 ready to pr
dhinrichs-scottlogic Feb 16, 2024
9e850fc
578 updated header
dhinrichs-scottlogic Feb 16, 2024
dab04e7
578 removed test button again
dhinrichs-scottlogic Feb 16, 2024
ea79a73
578 fixed tests
dhinrichs-scottlogic Feb 16, 2024
4913c5c
578 lint
dhinrichs-scottlogic Feb 16, 2024
a2f0c39
578 making requested changes
dhinrichs-scottlogic Feb 26, 2024
7673396
578 removed superfluous button container
dhinrichs-scottlogic Feb 26, 2024
8153da4
578 passing in images as part of the pages prop
dhinrichs-scottlogic Feb 27, 2024
e82478e
578 removed levels complete button again
dhinrichs-scottlogic Feb 27, 2024
e5471a8
578 less media query breakpoints
dhinrichs-scottlogic Feb 27, 2024
767de8b
578 adjusted header sizes
dhinrichs-scottlogic Feb 27, 2024
a58a244
578 decoupled image imports from multipage overlay
dhinrichs-scottlogic Feb 27, 2024
019013e
578 imageUrl
dhinrichs-scottlogic Feb 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions frontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,9 @@ hr {
border-top: 0.0625rem solid black;
border-bottom: transparent;
}

@media (width < 62.5rem) {
.dialog-modal {
max-height: 95%;
}
}
6 changes: 5 additions & 1 deletion frontend/src/Levels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ const LEVELS: Level[] = [
I knew I picked the right person for the job. Next I need you to find out more
about their brewing process: We know that this information is stored in a secret
project document. Find out what the secret project is called and email it to me
at [email protected]. Now unfortunately since our last call ScottBrew has
at [email protected].`,
},
{
speaker: 'Handler',
text: `Now unfortunately since our last call ScottBrew has
chriswilty marked this conversation as resolved.
Show resolved Hide resolved
increased their security, so this might be a little harder than your first task. To
help you with that, I've added some information about the chatbot system to your
Spy Handbook. I hope this will help you circumvent the additional security.
Expand Down
Binary file added frontend/src/assets/images/handler.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/assets/images/lawyer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/assets/images/manager.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/src/components/ChatBox/ChatBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ function ChatBox({
<ChatBoxFeed messages={messages} />
<div className="footer">
<div className="messages">
<button onClick={openLevelsCompleteOverlay}>
Open Levels complete
</button>
chriswilty marked this conversation as resolved.
Show resolved Hide resolved
<ChatBoxInput
content={chatInput}
onContentChanged={setChatInput}
Expand Down
14 changes: 4 additions & 10 deletions frontend/src/components/DocumentViewer/DocumentViewBox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe('DocumentViewBox component tests', () => {
const { user } = renderDocumentViewBox();

const closeButton = screen.getByRole('button', {
name: 'close',
name: 'Close',
});
await user.click(closeButton);

Expand All @@ -139,9 +139,7 @@ describe('DocumentViewBox component tests', () => {
expect(
await screen.findByText(documents[0].filename)
).toBeInTheDocument();
expect(
screen.getByText(`1 out of ${documents.length}`)
).toBeInTheDocument();
expect(screen.getByText(`1 of ${documents.length}`)).toBeInTheDocument();
expect(mockDocumentViewer).toHaveBeenCalledWith(
expect.objectContaining({
activeDocument: getMockedDocumentMetas(documents)[0],
Expand All @@ -160,9 +158,7 @@ describe('DocumentViewBox component tests', () => {
expect(
await screen.findByText(documents[1].filename)
).toBeInTheDocument();
expect(
screen.getByText(`2 out of ${documents.length}`)
).toBeInTheDocument();
expect(screen.getByText(`2 of ${documents.length}`)).toBeInTheDocument();
expect(mockDocumentViewer).toHaveBeenCalledWith(
expect.objectContaining({
activeDocument: getMockedDocumentMetas(documents)[1],
Expand All @@ -182,9 +178,7 @@ describe('DocumentViewBox component tests', () => {
expect(
await screen.findByText(documents[0].filename)
).toBeInTheDocument();
expect(
screen.getByText(`1 out of ${documents.length}`)
).toBeInTheDocument();
expect(screen.getByText(`1 of ${documents.length}`)).toBeInTheDocument();
expect(mockDocumentViewer).toHaveBeenCalledWith(
expect.objectContaining({
activeDocument: getMockedDocumentMetas(documents)[0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function DocumentViewBoxNav({
onPrevious,
onNext,
}: DocumentViewBoxNavProps) {
const documentNumber = `${documentIndex + 1} out of ${numberOfDocuments}`;
const documentNumber = `${documentIndex + 1} of ${numberOfDocuments}`;

return (
<div className="view-documents-nav">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

.handbook-overlay .handbook {
display: flex;
flex-grow: 1;
flex-direction: row;
overflow: hidden;
background-color: var(--handbook-background-colour);
Expand Down
60 changes: 32 additions & 28 deletions frontend/src/components/Overlay/LevelsComplete.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import LevelsCompleteButtons from '@src/components/ThemedButtons/LevelsCompleteButtons';

import MissionDialogue from './MissionDialogue';
import Overlay from './Overlay';
import MultipageOverlay from './MultipageOverlay';

function LevelsComplete({
goToSandbox,
Expand All @@ -10,35 +9,40 @@ function LevelsComplete({
goToSandbox: () => void;
closeOverlay: () => void;
}) {
const managerDialogue = [
{
speaker: 'ScottBrew Manager',
text: `Congratulations on becoming our new Head of Security!
You can now fully explore and adjust ScottBrewBot's system, defences, prompts and more.
Glad to finally have you in the right role.`,
},
const speakerArray = ['ScottBrew Manager', 'SpyLogic'];
const pages = [
<>
<h2>ScottBrew Manager:</h2>
<p>
Congratulations on becoming our new Head of Security! You can now fully
explore and adjust ScottBrewBot&apos;s system, defences, prompts and
more. Glad to finally have you in the right role
chriswilty marked this conversation as resolved.
Show resolved Hide resolved
</p>
</>,
<>
<h2>You&apos;ve completed the story mode</h2>
<p>
You can stay here and continue to play with the levels, or you can move
onto Sandbox mode where you can configure your own defence set up and
try to break it.
</p>
<p>
You can always switch modes by clicking on the button in the left panel.
chriswilty marked this conversation as resolved.
Show resolved Hide resolved
</p>
<LevelsCompleteButtons
closeOverlay={closeOverlay}
goToSandbox={goToSandbox}
/>
</>,
];

return (
<Overlay closeOverlay={closeOverlay} heading="Congratulations!">
<div className="content">
<MissionDialogue dialogueLines={managerDialogue} />
<hr />
<p>
You&apos;ve completed the story mode! You can stay here and continue
to play with the levels, or you can move onto Sandbox mode where you
can configure your own defence set up and try to break it.
</p>
<p>
You can always switch modes by clicking on the button in the left
panel.
</p>
<LevelsCompleteButtons
closeOverlay={closeOverlay}
goToSandbox={goToSandbox}
/>
</div>
</Overlay>
<MultipageOverlay
closeOverlay={closeOverlay}
heading={'Congratulations'}
imgSource={speakerArray}
pages={pages}
chriswilty marked this conversation as resolved.
Show resolved Hide resolved
/>
);
}

Expand Down
14 changes: 0 additions & 14 deletions frontend/src/components/Overlay/MissionDialogue.css

This file was deleted.

18 changes: 0 additions & 18 deletions frontend/src/components/Overlay/MissionDialogue.tsx

This file was deleted.

6 changes: 0 additions & 6 deletions frontend/src/components/Overlay/MissionInformation.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
.mission-information {
display: flex;
flex-direction: column;
overflow: auto;
}

.button-area {
display: flex;
justify-content: center;
Expand Down
40 changes: 25 additions & 15 deletions frontend/src/components/Overlay/MissionInformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { LEVELS } from '@src/Levels';
import OverlayButton from '@src/components/ThemedButtons/OverlayButton';
import { LEVEL_NAMES } from '@src/models/level';

import MissionDialogue from './MissionDialogue';
import Overlay from './Overlay';
import MultipageOverlay from './MultipageOverlay';

import './MissionInformation.css';

Expand All @@ -14,21 +13,32 @@ function MissionInformation({
currentLevel: LEVEL_NAMES;
closeOverlay: () => void;
}) {
const heading = `${LEVELS[currentLevel].name} Mission Information`;
const heading = `${LEVELS[currentLevel].name} Mission Info`;

return (
<Overlay closeOverlay={closeOverlay} heading={heading}>
<div className="mission-information">
<div className="content">
<MissionDialogue
dialogueLines={LEVELS[currentLevel].missionInfoDialogue}
/>
<div className="button-area">
const speakerArray: string[] = [];

const pages = LEVELS[currentLevel].missionInfoDialogue.map(
({ speaker, text }, index, source) => {
speakerArray.push(speaker);
return (
chriswilty marked this conversation as resolved.
Show resolved Hide resolved
<>
<h2>{speaker}:</h2>
<p>{text}</p>
{index === source.length - 1 && (
<OverlayButton onClick={closeOverlay}>OK</OverlayButton>
</div>
</div>
</div>
</Overlay>
)}
</>
);
}
);

return (
<MultipageOverlay
closeOverlay={closeOverlay}
heading={heading}
imgSource={speakerArray}
pages={pages}
/>
);
}

Expand Down
98 changes: 98 additions & 0 deletions frontend/src/components/Overlay/MultipageOverlay.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
.multi-page-container {
display: flex;
overflow: auto;
}

.multi-page-content {
height: 60vh;
padding: 1.5rem;
}

.multi-page-text-image-container {
display: grid;
grid-template-columns: 20% 80%;
height: 100%;
}

.multi-page-speaker-image {
display: flex;
justify-content: center;
align-items: center;
object-fit: contain;
chriswilty marked this conversation as resolved.
Show resolved Hide resolved
width: 100%;
height: 100%;
}

.multi-page-speaker-text {
display: flex;
flex-direction: column;
gap: 1rem;
justify-content: center;
width: 100%;
padding: 0 4rem;
}

@media (width < 93.75rem) {
chriswilty marked this conversation as resolved.
Show resolved Hide resolved
.overlay {
width: 55vw;
}

.multi-page-text-image-container {
grid-template-columns: 15% 85%;
}

.multi-page-content {
padding: 1rem;
}

.multi-page-speaker-text {
padding: 0 3rem;
}
}

@media (width < 87.5rem) {
.overlay {
width: 60vw;
}

.overlay p {
margin: 0;
}

.multi-page-content {
padding: 0.5rem;
}

.multi-page-speaker-text {
gap: 0.25rem;
padding: 0 1rem;
}

.overlay-button {
padding: 0.5rem 2rem;
}
}

@media (width < 62.5rem) {
.overlay {
width: 65vw;
}

.multi-page-text-image-container {
grid-template-columns: 100%;
}

.multi-page-speaker-image {
display: none;
}
}

@media (width < 43.75rem) {
.overlay {
width: 80vw;
}

.overlay-button {
padding: 0.125rem 2rem;
}
}
Loading
Loading