-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from theredwillow/issue-70-explode-files
Exploding files: Part 1 (AdminSettings, Players, utils/debounce)
- Loading branch information
Showing
14 changed files
with
255 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/components/Admin/AdminSettings/BuzzerSoundSettings.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import InfoTooltip from "@/components/ui/tooltip"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
function BuzzerSoundSettings({game, setGame, send}) { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<div className="flex flex-col space-y-4"> | ||
<div className="flex flex-col"> | ||
<div className="flex flex-row items-center space-x-5"> | ||
<div className="flex flex-row items-center space-x-2"> | ||
<InfoTooltip message={t("Allow players to hear sound on their devices when they press their buzzer")} /> | ||
<p className="text-xl normal-case text-foreground">{t("Player Buzzer Sounds")}</p> | ||
</div> | ||
<input | ||
className="size-4 rounded placeholder:text-secondary-900" | ||
checked={game.settings.player_buzzer_sound} | ||
onChange={(e) => { | ||
game.settings.player_buzzer_sound = e.target.checked; | ||
if (!e.target.checked) { | ||
game.settings.first_buzzer_sound_only = false; | ||
} | ||
setGame((prv) => ({ ...prv })); | ||
send({ action: "data", data: game }); | ||
}} | ||
type="checkbox" | ||
></input> | ||
</div> | ||
</div> | ||
|
||
<div className={`flex flex-col ${!game.settings.player_buzzer_sound ? "opacity-50" : ""}`}> | ||
<div className="flex flex-row items-center space-x-5"> | ||
<div className="flex flex-row items-center space-x-2"> | ||
<InfoTooltip message={t("Only play sound for the first player to buzz in")} /> | ||
<p className="text-xl normal-case text-foreground">{t("First Press Only")}</p> | ||
</div> | ||
<input | ||
className="size-4 rounded placeholder:text-secondary-900" | ||
checked={game.settings.first_buzzer_sound_only} | ||
disabled={!game.settings.player_buzzer_sound} | ||
onChange={(e) => { | ||
game.settings.first_buzzer_sound_only = e.target.checked; | ||
setGame((prv) => ({ ...prv })); | ||
send({ action: "data", data: game }); | ||
}} | ||
type="checkbox" | ||
></input> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default BuzzerSoundSettings; |
24 changes: 24 additions & 0 deletions
24
src/components/Admin/AdminSettings/FinalRoundTitleChanger.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { debounce } from "@/lib/utils"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
function FinalRoundTitleChanger({game, setGame, send}) { | ||
const { t } = useTranslation(); | ||
return ( | ||
<div className="flex flex-row items-center space-x-5"> | ||
<p className="text-xl text-foreground">{t("Final Round Title")}:</p> | ||
<input | ||
id="finalRoundTitleChangerInput" | ||
className="w-32 rounded border-4 bg-secondary-500 p-1 text-xl text-foreground placeholder:text-secondary-900" | ||
onChange={debounce((e) => { | ||
game.settings.final_round_title = e.target.value; | ||
setGame((prv) => ({ ...prv })); | ||
send({ action: "data", data: game }); | ||
})} | ||
defaultValue={game.settings.final_round_title} | ||
placeholder={t("fast money")} | ||
></input> | ||
</div> | ||
); | ||
} | ||
|
||
export default FinalRoundTitleChanger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useTranslation } from "react-i18next"; | ||
|
||
function HideGameQuestions({game, setGame, send}) { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<div className="flex flex-col"> | ||
<div className="flex flex-row items-center space-x-5"> | ||
<div> | ||
<p className="text-xl normal-case text-foreground">{t("Hide questions")}:</p> | ||
</div> | ||
<input | ||
id="hideQuestionsInput" | ||
className="size-4 rounded placeholder:text-secondary-900" | ||
checked={game.settings.hide_questions} | ||
onChange={(e) => { | ||
game.settings.hide_questions = e.target.checked; | ||
setGame((prv) => ({ ...prv })); | ||
send({ action: "data", data: game }); | ||
}} | ||
type="checkbox" | ||
></input> | ||
</div> | ||
<div> | ||
<p className="max-w-xs text-sm normal-case italic text-secondary-900"> | ||
{t("hide questions on the game window and player buzzer screens")} | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default HideGameQuestions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import "@/i18n/i18n"; | ||
import ThemeSwitcher from "@/components/Admin/ThemeSwitcher"; | ||
import HideGameQuestions from "./HideGameQuestions"; | ||
import FinalRoundTitleChanger from "./FinalRoundTitleChanger"; | ||
import BuzzerSoundSettings from "./BuzzerSoundSettings"; | ||
|
||
export default function AdminSettings({game, setGame, send}) { | ||
return ( | ||
<div className="flex flex-col items-center"> | ||
<div className="grid grid-cols-2 gap-x-48 gap-y-10"> | ||
<HideGameQuestions game={game} setGame={setGame} send={send} /> | ||
<ThemeSwitcher game={game} setGame={setGame} send={send} /> | ||
<FinalRoundTitleChanger game={game} setGame={setGame} send={send} /> | ||
<BuzzerSoundSettings game={game} setGame={setGame} send={send} /> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.