Skip to content

Commit 4a8a3bc

Browse files
authored
Improvement/Tooltips on question type
1 parent 4daa923 commit 4a8a3bc

5 files changed

Lines changed: 107 additions & 9 deletions

File tree

locales/en/common.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,12 @@
3030
"title": "Display options",
3131
"OneQuestionPerStep": "One question per step",
3232
"DisplayTitle": "Display title"
33+
},
34+
"questionType": {
35+
"question": "Question",
36+
"emoji": "Emoji",
37+
"input": "Input",
38+
"choice": "Choice",
39+
"rate": "Rate"
3340
}
3441
}

package-lock.json

Lines changed: 67 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"react-beautiful-dnd": "^13.1.1",
4040
"react-dom": "^18.2.0",
4141
"react-hot-toast": "^2.2.0",
42+
"react-tooltip": "^5.25.1",
4243
"recharts": "^2.4.3",
4344
"sass": "^1.52.1",
4445
"typescript": "^5.0.2",

src/features/surveys/features/SurveyCreator/components/QuestionBlocks/QuestionBlockWrapper/QuestionBlockWrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export default function QuestionBlockWrapper({
7777
</button>
7878

7979
<div className="hidden sm:block">
80-
<QuestionTypeIcons type={questionData.type} />
80+
<QuestionTypeIcons type={questionData.type} index={index} />
8181
</div>
8282

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

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

103103
{(isDraggingPossible || isRemovingPossible) && (

src/shared/components/QuestionTypeIcons/QuestionTypeIcons.tsx

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,41 @@ import ChoiceIcon from 'shared/components/QuestionTypeIcons/ChoiceIcon';
44
import EmojiIcon from 'shared/components/QuestionTypeIcons/EmojiIcon';
55
import InputIcon from 'shared/components/QuestionTypeIcons/InputIcon';
66
import RateIcon from 'shared/components/QuestionTypeIcons/RateIcon';
7+
import { Tooltip } from 'react-tooltip';
8+
import useTranslation from 'next-translate/useTranslation';
79

810
interface QuestionTypeIconsProps {
11+
index: number;
912
type: QuestionType;
1013
}
1114

12-
export default function QuestionTypeIcons({ type }: QuestionTypeIconsProps) {
15+
export default function QuestionTypeIcons({
16+
type,
17+
index,
18+
}: QuestionTypeIconsProps) {
19+
const { t } = useTranslation('common');
20+
1321
return (
14-
<div className="mx-1 flex h-[42px] w-[26px] items-center justify-center px-[1px] text-gray-400">
15-
{type === QuestionType.EMOJI && <EmojiIcon />}
16-
{type === QuestionType.INPUT && <InputIcon />}
17-
{type === QuestionType.CHOICE && <ChoiceIcon />}
18-
{type === QuestionType.RATE && <RateIcon />}
19-
</div>
22+
<>
23+
<Tooltip
24+
className="z-10"
25+
id={`my-tooltip-${index}`}
26+
place="bottom"
27+
positionStrategy="fixed"
28+
>
29+
{`${t(`questionType.${type.toLowerCase()}`)} ${t(
30+
'questionType.question'
31+
)}`}
32+
</Tooltip>
33+
<div
34+
className="mx-1 flex h-[42px] w-[26px] items-center justify-center px-[1px] text-gray-400"
35+
data-tooltip-id={`my-tooltip-${index}`}
36+
>
37+
{type === QuestionType.EMOJI && <EmojiIcon />}
38+
{type === QuestionType.INPUT && <InputIcon />}
39+
{type === QuestionType.CHOICE && <ChoiceIcon />}
40+
{type === QuestionType.RATE && <RateIcon />}
41+
</div>
42+
</>
2043
);
2144
}

0 commit comments

Comments
 (0)