From e26c01432ab9dd5a9ec2df5584dd3a4f5592e03a Mon Sep 17 00:00:00 2001 From: Cheelax Date: Fri, 22 Sep 2023 09:46:50 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20Add=20credits=20button=20an?= =?UTF-8?q?d=20modal=20functionality=20in=20App.tsx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added `CreditsButton` component in `client/src/ui/CreditsButton.tsx`. - Imported `CreditsButton` component in `client/src/App.tsx`. - Updated JSX in `App` component to include the `CreditsButton` component. - Created a `modal-medium` CSS class in `client/src/index.css` for the styling of the modal. - Added `Modal` component from 'react-modal' library in `App` component to show a modal when the credits button is clicked. - Added a close button in the modal header to close the modal. Co-authored-by: [Your Name] <[Your Email]> --- client/src/App.tsx | 25 ++++--------------------- client/src/index.css | 32 +++++++++++++++++++++++++++++--- client/src/ui/CreditsButton.tsx | 6 +----- client/src/ui/NewGame.tsx | 15 ++++++++++++++- client/src/ui/NewGameButton.tsx | 3 +-- 5 files changed, 49 insertions(+), 32 deletions(-) diff --git a/client/src/App.tsx b/client/src/App.tsx index 0be5fae..3596990 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -22,6 +22,7 @@ function App() { Modal.setAppElement('#root'); const [isModalOpen, setModalOpen] = useState(false); const [isRuleModalOpen, setRuleModalOpen] = useState(false); + const [isLeaderBoardModalOpen, setLeaderBoardModalOpen] = useState(false); const [isMusicPlaying, setMusicPlaying] = useState(false); @@ -53,23 +54,6 @@ function App() { setRuleModalOpen(!isRuleModalOpen); }; - const modalStyle = { - content: { - top: '50%', - left: '50%', - width: '80%', - height: '57%', - right: 'auto', - bottom: 'auto', - marginRight: '-50%', - transform: 'translate(-50%, -50%)', - fontSize: '16px', - border: '4px solid #000', - boxShadow: '5px 5px #000', - textColor: 'red', - }, - }; - const credits = async () => { toggleModal(); }; @@ -101,7 +85,6 @@ function App() { > Rules - ); diff --git a/client/src/ui/NewGame.tsx b/client/src/ui/NewGame.tsx index 8af06fb..343ef29 100644 --- a/client/src/ui/NewGame.tsx +++ b/client/src/ui/NewGame.tsx @@ -1,7 +1,8 @@ import React, { useState } from 'react'; import NewGameButton from './NewGameButton'; import Modal from 'react-modal'; -import RulesModal from './RulesModal'; +import Credits from './Credits'; +import CreditsButton from './CreditsButton'; interface NewGameProps { onClick: () => void; @@ -40,6 +41,18 @@ const NewGame: React.FC = ({ onClick, onPseudoChange }) => { maxLength={18} // Limit the input to 30 characters /> + + +
+ + +
+
); }; diff --git a/client/src/ui/NewGameButton.tsx b/client/src/ui/NewGameButton.tsx index e0472ea..3906bee 100644 --- a/client/src/ui/NewGameButton.tsx +++ b/client/src/ui/NewGameButton.tsx @@ -10,8 +10,7 @@ const NewGameButton: React.FC = ({ onClick, disabled }) => {