From 58cb92d4322b1f67e2a750b266d446c2e46641ec Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Sun, 6 Sep 2020 15:18:05 +1000 Subject: [PATCH] Added full screen button --- src/components/map/MapControls.js | 23 +++++ src/components/party/DiceTrayButton.js | 5 +- src/components/party/Party.js | 126 ++++++++++++++----------- src/components/token/Tokens.js | 3 + src/icons/FullScreenExitIcon.js | 18 ++++ src/icons/FullScreenIcon.js | 18 ++++ src/settings.js | 1 + 7 files changed, 138 insertions(+), 56 deletions(-) create mode 100644 src/icons/FullScreenExitIcon.js create mode 100644 src/icons/FullScreenIcon.js diff --git a/src/components/map/MapControls.js b/src/components/map/MapControls.js index ca46ae1..94b36a4 100644 --- a/src/components/map/MapControls.js +++ b/src/components/map/MapControls.js @@ -16,6 +16,10 @@ import BrushToolIcon from "../../icons/BrushToolIcon"; import MeasureToolIcon from "../../icons/MeasureToolIcon"; import ExpandMoreIcon from "../../icons/ExpandMoreIcon"; import PointerToolIcon from "../../icons/PointerToolIcon"; +import FullScreenIcon from "../../icons/FullScreenIcon"; +import FullScreenExitIcon from "../../icons/FullScreenExitIcon"; + +import useSetting from "../../helpers/useSetting"; function MapContols({ onMapChange, @@ -31,6 +35,7 @@ function MapContols({ disabledSettings, }) { const [isExpanded, setIsExpanded] = useState(true); + const [fullScreen, setFullScreen] = useSetting("map.fullScreen"); const toolsById = { pan: { @@ -190,6 +195,24 @@ function MapContols({ {controls} {getToolSettings()} + + setFullScreen(!fullScreen)} + aria-label={fullScreen ? "Exit Full Screen" : "Enter Full Screen"} + title={fullScreen ? "Exit Full Screen" : "Enter Full Screen"} + > + {fullScreen ? : } + + ); } diff --git a/src/components/party/DiceTrayButton.js b/src/components/party/DiceTrayButton.js index 475324a..96679db 100644 --- a/src/components/party/DiceTrayButton.js +++ b/src/components/party/DiceTrayButton.js @@ -6,6 +6,8 @@ import DiceTrayOverlay from "../dice/DiceTrayOverlay"; import { DiceLoadingProvider } from "../../contexts/DiceLoadingContext"; +import useSetting from "../../helpers/useSetting"; + function DiceTrayButton({ shareDice, onShareDiceChage, @@ -13,13 +15,14 @@ function DiceTrayButton({ onDiceRollsChange, }) { const [isExpanded, setIsExpanded] = useState(false); + const [fullScreen] = useSetting("map.fullScreen"); return ( - - Party - - - - - {Object.entries(partyNicknames).map(([id, partyNickname]) => ( + + + Party + + + - ))} - {timer && } - {Object.entries(partyTimers).map(([id, partyTimer], index) => ( - ( + + ))} + {timer && } + {Object.entries(partyTimers).map(([id, partyTimer], index) => ( + + ))} + + + - ))} - - - - - - - - + + + + + + - + ); } diff --git a/src/components/token/Tokens.js b/src/components/token/Tokens.js index bd40ae4..ae9b8b6 100644 --- a/src/components/token/Tokens.js +++ b/src/components/token/Tokens.js @@ -9,6 +9,7 @@ import ProxyToken from "./ProxyToken"; import SelectTokensButton from "./SelectTokensButton"; import { fromEntries } from "../../helpers/shared"; +import useSetting from "../../helpers/useSetting"; import AuthContext from "../../contexts/AuthContext"; import TokenDataContext from "../../contexts/TokenDataContext"; @@ -18,6 +19,7 @@ const listTokenClassName = "list-token"; function Tokens({ onMapTokenStateCreate }) { const { userId } = useContext(AuthContext); const { ownedTokens, tokens } = useContext(TokenDataContext); + const [fullScreen] = useSetting("map.fullScreen"); function handleProxyDragEnd(isOnMap, token) { if (isOnMap && onMapTokenStateCreate) { @@ -48,6 +50,7 @@ function Tokens({ onMapTokenStateCreate }) { width: "80px", minWidth: "80px", overflow: "hidden", + display: fullScreen ? "none" : "block", }} > diff --git a/src/icons/FullScreenExitIcon.js b/src/icons/FullScreenExitIcon.js new file mode 100644 index 0000000..7e23c78 --- /dev/null +++ b/src/icons/FullScreenExitIcon.js @@ -0,0 +1,18 @@ +import React from "react"; + +function FullScreenIcon() { + return ( + + + + + ); +} + +export default FullScreenIcon; diff --git a/src/icons/FullScreenIcon.js b/src/icons/FullScreenIcon.js new file mode 100644 index 0000000..0abc848 --- /dev/null +++ b/src/icons/FullScreenIcon.js @@ -0,0 +1,18 @@ +import React from "react"; + +function FullScreenIcon() { + return ( + + + + + ); +} + +export default FullScreenIcon; diff --git a/src/settings.js b/src/settings.js index 214a00a..e526c36 100644 --- a/src/settings.js +++ b/src/settings.js @@ -27,6 +27,7 @@ function loadVersions(settings) { style: "galaxy", }, })); + settings.version(2, (prev) => ({ ...prev, map: { fullScreen: false } })); } export function getSettings() {