Skip to content

Commit

Permalink
Improvement/Tooltips on question type
Browse files Browse the repository at this point in the history
  • Loading branch information
monu-simon authored Jan 20, 2024
1 parent 4daa923 commit 4a8a3bc
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 9 deletions.
7 changes: 7 additions & 0 deletions locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,12 @@
"title": "Display options",
"OneQuestionPerStep": "One question per step",
"DisplayTitle": "Display title"
},
"questionType": {
"question": "Question",
"emoji": "Emoji",
"input": "Input",
"choice": "Choice",
"rate": "Rate"
}
}
67 changes: 67 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"react-beautiful-dnd": "^13.1.1",
"react-dom": "^18.2.0",
"react-hot-toast": "^2.2.0",
"react-tooltip": "^5.25.1",
"recharts": "^2.4.3",
"sass": "^1.52.1",
"typescript": "^5.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function QuestionBlockWrapper({
</button>

<div className="hidden sm:block">
<QuestionTypeIcons type={questionData.type} />
<QuestionTypeIcons type={questionData.type} index={index} />
</div>

<div className="w-full grow">
Expand All @@ -97,7 +97,7 @@ export default function QuestionBlockWrapper({

<div className="mb-2 flex w-full items-center justify-end gap-2 sm:mb-0 sm:w-auto">
<div className="mr-1 sm:hidden">
<QuestionTypeIcons type={questionData.type} />
<QuestionTypeIcons type={questionData.type} index={index} />
</div>

{(isDraggingPossible || isRemovingPossible) && (
Expand Down
37 changes: 30 additions & 7 deletions src/shared/components/QuestionTypeIcons/QuestionTypeIcons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,41 @@ import ChoiceIcon from 'shared/components/QuestionTypeIcons/ChoiceIcon';
import EmojiIcon from 'shared/components/QuestionTypeIcons/EmojiIcon';
import InputIcon from 'shared/components/QuestionTypeIcons/InputIcon';
import RateIcon from 'shared/components/QuestionTypeIcons/RateIcon';
import { Tooltip } from 'react-tooltip';
import useTranslation from 'next-translate/useTranslation';

interface QuestionTypeIconsProps {
index: number;
type: QuestionType;
}

export default function QuestionTypeIcons({ type }: QuestionTypeIconsProps) {
export default function QuestionTypeIcons({
type,
index,
}: QuestionTypeIconsProps) {
const { t } = useTranslation('common');

return (
<div className="mx-1 flex h-[42px] w-[26px] items-center justify-center px-[1px] text-gray-400">
{type === QuestionType.EMOJI && <EmojiIcon />}
{type === QuestionType.INPUT && <InputIcon />}
{type === QuestionType.CHOICE && <ChoiceIcon />}
{type === QuestionType.RATE && <RateIcon />}
</div>
<>
<Tooltip
className="z-10"
id={`my-tooltip-${index}`}
place="bottom"
positionStrategy="fixed"
>
{`${t(`questionType.${type.toLowerCase()}`)} ${t(
'questionType.question'
)}`}
</Tooltip>
<div
className="mx-1 flex h-[42px] w-[26px] items-center justify-center px-[1px] text-gray-400"
data-tooltip-id={`my-tooltip-${index}`}
>
{type === QuestionType.EMOJI && <EmojiIcon />}
{type === QuestionType.INPUT && <InputIcon />}
{type === QuestionType.CHOICE && <ChoiceIcon />}
{type === QuestionType.RATE && <RateIcon />}
</div>
</>
);
}

1 comment on commit 4a8a3bc

@vercel
Copy link

@vercel vercel bot commented on 4a8a3bc Jan 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

formslab – ./

formslab-ryczko.vercel.app
formslab-git-main-ryczko.vercel.app
formslab.vercel.app

Please sign in to comment.