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

feat(ui): file upload button has a tooltip showing csv style formatting. #190

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 3 deletions src/components/Admin/AdminSettings/BuzzerSoundSettings.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import InfoTooltip from "@/components/ui/tooltip";
import ToolTipIcon from "@/components/ui/tooltip";
import { useTranslation } from "react-i18next";

function BuzzerSoundSettings({ game, setGame, send }) {
Expand All @@ -9,7 +9,7 @@ function BuzzerSoundSettings({ game, setGame, send }) {
<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")} />
<ToolTipIcon 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
Expand All @@ -31,7 +31,7 @@ function BuzzerSoundSettings({ game, setGame, send }) {
<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")} />
<ToolTipIcon 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
Expand Down
8 changes: 7 additions & 1 deletion src/components/Admin/GameLoader.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ToolTipIcon from "@/components/ui/tooltip";
import { ERROR_CODES } from "@/i18n/errorCodes";
import { handleCsvFile, handleJsonFile, isValidFileType } from "@/lib/utils";
import { FileUp } from "lucide-react";
Expand Down Expand Up @@ -90,7 +91,12 @@ const GameLoader = ({ gameSelector, send, setError, setCsvFileUpload, setCsvFile
<div id="gamePickerFileUploadButton">
<label htmlFor="gamePickerFileUpload">
<div className="flow-row flex items-center space-x-2">
<FileUp className="cursor-pointer text-secondary-900 hover:text-secondary-500" size={38} />
<ToolTipIcon
Icon={FileUp}
size={32}
cursor="pointer"
message={`CSV ${t("Expected format")}: ${t("Question")}, ${t("Answer")}, ${t("Points")}, ${t("Answer")}, ${t("Points")} ...`}
/>
<div>
<p className="text-s text-secondary-900">{t("upload game")}</p>
<p className="text-xs text-secondary-900">.json, .csv</p>
Expand Down
9 changes: 5 additions & 4 deletions src/components/ui/tooltip.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Info } from "lucide-react";
import { useState } from "react";

const InfoTooltip = ({ message }) => {
const ToolTipIcon = ({ message, Icon = Info, size = 20, cursor = "default" }) => {
const [isVisible, setIsVisible] = useState(false);

return (
<div className="relative inline-block">
<Info
className="size-5 text-secondary-900 transition-colors hover:text-secondary-700"
<Icon
className={`cursor-${cursor} text-secondary-900 transition-colors hover:text-secondary-700`}
size={size}
onMouseEnter={() => setIsVisible(true)}
onMouseLeave={() => setIsVisible(false)}
/>
Expand All @@ -24,4 +25,4 @@ const InfoTooltip = ({ message }) => {
);
};

export default InfoTooltip;
export default ToolTipIcon;