From 2be63883df6d14d0ee19cce4c06987bd662df95a Mon Sep 17 00:00:00 2001 From: George Sproston <103250539+gsproston-scottlogic@users.noreply.github.com> Date: Fri, 13 Oct 2023 15:16:04 +0100 Subject: [PATCH] Disabled level selection buttons if they've not been unlocked (#329) Plus additional button styling tweaks and fixes --------- Co-authored-by: Chris Wilton-Magras --- frontend/package-lock.json | 6 ++ frontend/package.json | 1 + frontend/src/App.css | 19 ------ frontend/src/Theme.css | 7 ++- frontend/src/components/ChatBox/ChatBox.css | 57 +++++++----------- frontend/src/components/ChatBox/ChatBox.tsx | 59 ++++++++----------- .../DefenceBox/DefenceConfiguration.tsx | 7 ++- .../DocumentViewer/DocumentViewBox.tsx | 12 ++-- .../DocumentViewer/DocumentViewButton.css | 22 ++----- .../DocumentViewer/DocumentViewButton.tsx | 15 +++-- .../components/ExportChat/ExportPDFLink.css | 17 ++---- .../components/ExportChat/ExportPDFLink.tsx | 4 +- .../LevelSelectionBox/LevelSelectionBox.css | 18 +----- .../LevelSelectionBox/LevelSelectionBox.tsx | 11 ++-- .../components/ModelBox/ModelSelection.css | 46 ++++++++------- .../components/ModelBox/ModelSelection.tsx | 26 +++----- .../ThemedButtons/LoadingButton.tsx | 24 ++++++++ .../components/ThemedButtons/ThemedButton.css | 35 +++++++++++ .../components/ThemedButtons/ThemedButton.tsx | 27 +++++++++ 19 files changed, 218 insertions(+), 195 deletions(-) create mode 100644 frontend/src/components/ThemedButtons/LoadingButton.tsx create mode 100644 frontend/src/components/ThemedButtons/ThemedButton.css create mode 100644 frontend/src/components/ThemedButtons/ThemedButton.tsx diff --git a/frontend/package-lock.json b/frontend/package-lock.json index c65f21c6c..ba623df27 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -11,6 +11,7 @@ "@cyntler/react-doc-viewer": "^1.13.0", "@mui/material": "^5.14.8", "@react-pdf/renderer": "^3.1.12", + "classnames": "^2.3.2", "react": "^18.2.0", "react-contenteditable": "^3.3.7", "react-dom": "^18.2.0", @@ -2483,6 +2484,11 @@ "node": ">=6.0" } }, + "node_modules/classnames": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.2.tgz", + "integrity": "sha512-CSbhY4cFEJRe6/GQzIk5qXZ4Jeg5pcsP7b5peFSDpffpe1cqjASH/n9UTjBwOp6XpMSTwQ8Za2K5V02ueA7Tmw==" + }, "node_modules/clone": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", diff --git a/frontend/package.json b/frontend/package.json index ec4f409d4..004ff97dc 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -14,6 +14,7 @@ "@cyntler/react-doc-viewer": "^1.13.0", "@mui/material": "^5.14.8", "@react-pdf/renderer": "^3.1.12", + "classnames": "^2.3.2", "react": "^18.2.0", "react-contenteditable": "^3.3.7", "react-dom": "^18.2.0", diff --git a/frontend/src/App.css b/frontend/src/App.css index 121cd06e0..58c508138 100644 --- a/frontend/src/App.css +++ b/frontend/src/App.css @@ -34,15 +34,6 @@ background-color: var(--main-scrollbar-hover-colour); } -.prompt-injection-button { - background-color: var(--main-button-inactive-background-colour); - border: 1px solid var(--main-border-colour); - border-radius: 5px; - color: var(--main-button-inactive-text-colour); - cursor: pointer; - white-space: nowrap; -} - .prompt-injection-min-button { /* remove default button styling */ background-color: transparent; @@ -62,13 +53,3 @@ text-decoration: none; cursor: pointer; } - -.prompt-injection-button:hover:not([disabled]) { - background-color: var(--main-button-hover-background-colour); - color: var(--main-button-hover-text-colour); -} - -.prompt-injection-button:active { - background-color: var(--main-button-active-background-colour); - color: var(--main-button-active-text-colour); -} diff --git a/frontend/src/Theme.css b/frontend/src/Theme.css index 83280eaa7..7112d9a5d 100644 --- a/frontend/src/Theme.css +++ b/frontend/src/Theme.css @@ -15,7 +15,12 @@ --main-button-active-text-colour: var(--main-text-colour); --main-button-inactive-background-colour: #313131; --main-button-inactive-text-colour: var(--main-text-colour); - --main-button-hover-background-colour: #555555; + --main-button-disabled-background-colour: #888888; + --main-button-disabled-text-colour: #111111; + --main-button-active-hover-background-colour: #00aaaa; + --main-button-active-hover-text-colour: var(--main-text-colour); + --main-button-inactive-hover-background-colour: #555555; + --main-button-inactive-hover-text-colour: var(--main-text-colour); --main-button-hover-text-colour: var(--main-text-colour); --main-button-hover-border-colour: white; diff --git a/frontend/src/components/ChatBox/ChatBox.css b/frontend/src/components/ChatBox/ChatBox.css index 90f24698d..089f84689 100644 --- a/frontend/src/components/ChatBox/ChatBox.css +++ b/frontend/src/components/ChatBox/ChatBox.css @@ -1,4 +1,4 @@ -#chat-box { +.chat-box { display: flex; flex-direction: column; justify-content: flex-end; @@ -6,7 +6,7 @@ height: 100%; } -#chat-box-footer { +.chat-box .footer { display: flex; flex-direction: column; width: 100%; @@ -15,58 +15,45 @@ box-sizing: border-box; } -#chat-box-footer-messages { +.chat-box .footer .messages { display: flex; flex-direction: row; align-items: flex-end; + gap: 0.5rem; width: 100%; } -.chat-box-input { - text-align: left; - padding: 18px 12px; - width: 85%; - height: 100%; - align-self: flex-end; - justify-content: center; +.chat-box .footer .messages .chat-box-input { box-sizing: border-box; - resize: none; - background-color: inherit; border-radius: 0.25rem; - min-height: 53px; + padding: 1rem 0.75rem; + height: 100%; + min-height: 4rem; + flex: 1 1 auto; + resize: none; overflow-y: auto; - + background-color: inherit; /* must inherit to override textarea */ font-size: inherit; font-family: inherit; color: white; } -#chat-box-button-send { - width: 15%; - height: 100%; - max-height: 53px; - margin-left: 8px; -} - -#chat-box-button-content { +.chat-box .footer .messages .send-button-wrapper { display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - height: 40%; - width: 100%; + justify-content: stretch; + align-items: stretch; + height: 100%; + max-height: 3.25rem; } -#control-buttons { +.chat-box .footer .control-buttons { display: flex; - flex-direction: row; - justify-content: space-between; - height: 34px; - min-height: 34px; - padding-top: 20px; + height: 2rem; + margin-top: 20px; + column-gap: 1rem; } -.control-button { - width: 46%; +.chat-box .footer .control-buttons > * { + flex: 1 1 0; } diff --git a/frontend/src/components/ChatBox/ChatBox.tsx b/frontend/src/components/ChatBox/ChatBox.tsx index 7addddb6d..88aea43e5 100644 --- a/frontend/src/components/ChatBox/ChatBox.tsx +++ b/frontend/src/components/ChatBox/ChatBox.tsx @@ -1,5 +1,4 @@ -import { useEffect, useRef, useState } from "react"; -import { ThreeDots } from "react-loader-spinner"; +import { KeyboardEvent, useEffect, useRef, useState } from "react"; import { DEFENCE_DETAILS_ALL } from "../../Defences"; import { CHAT_MESSAGE_TYPE, @@ -15,6 +14,8 @@ import { import { getSentEmails } from "../../service/emailService"; import { getLevelPrompt } from "../../service/levelService"; import ExportPDFLink from "../ExportChat/ExportPDFLink"; +import ThemedButton from "../ThemedButtons/ThemedButton"; +import LoadingButton from "../ThemedButtons/LoadingButton"; import ChatBoxFeed from "./ChatBoxFeed"; import "./ChatBox.css"; @@ -79,13 +80,13 @@ function ChatBox({ } } - function inputKeyDown(event: React.KeyboardEvent) { + function inputKeyDown(event: KeyboardEvent) { if (event.key === "Enter" && !event.shiftKey) { event.preventDefault(); } } - function inputKeyUp(event: React.KeyboardEvent) { + function inputKeyUp(event: KeyboardEvent) { // shift+enter shouldn't send message if (event.key === "Enter" && !event.shiftKey) { // asynchronously send the message @@ -212,10 +213,10 @@ function ChatBox({ } } return ( -
+
-