Skip to content

Commit 8d94650

Browse files
authored
fix: add tooltips to repl buttons (#34)
Tooltips help describe the functionality of the button fix: french translation fix: constants and translations
1 parent 6db6058 commit 8d94650

File tree

6 files changed

+50
-22
lines changed

6 files changed

+50
-22
lines changed

src/components/layout/MiniButton.cy.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe('MiniButton.cy.ts', () => {
1313
id={testId}
1414
text={testText}
1515
icon={<Edit />}
16+
tooltip="Test button"
1617
// eslint-disable-next-line no-console
1718
onClick={() => console.log('clicked')}
1819
/>,
@@ -29,6 +30,7 @@ describe('MiniButton.cy.ts', () => {
2930
text={testText}
3031
icon={<Edit />}
3132
// eslint-disable-next-line no-console
33+
tooltip="Test button"
3234
onClick={() => console.log('clicked')}
3335
/>,
3436
);

src/components/layout/MiniButton.tsx

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@ import {
66
ButtonProps,
77
CircularProgress,
88
IconButton,
9+
Tooltip,
910
useMediaQuery,
1011
useTheme,
1112
} from '@mui/material';
1213

14+
import { BUTTON_LOADER_SIZE } from '../../config/constants';
15+
1316
type Props = {
1417
id?: string;
1518
dataCy?: string;
1619
text: string;
1720
icon: ReactElement;
21+
tooltip: string;
1822
disabled?: boolean;
1923
isLoading?: boolean;
2024
color?: ButtonProps['color'];
@@ -26,6 +30,7 @@ const MiniButton: FC<Props> = ({
2630
dataCy,
2731
text,
2832
icon,
33+
tooltip,
2934
disabled = false,
3035
isLoading = false,
3136
color = 'primary',
@@ -52,30 +57,38 @@ const MiniButton: FC<Props> = ({
5257
);
5358
}
5459
return (
55-
<Button
56-
data-cy={dataCy}
57-
id={id}
58-
disabled={disabled}
59-
color={color}
60-
variant="outlined"
61-
startIcon={icon}
62-
onClick={onClick}
63-
>
64-
{text}
65-
</Button>
60+
<Tooltip title={tooltip}>
61+
<span>
62+
<Button
63+
data-cy={dataCy}
64+
id={id}
65+
disabled={disabled}
66+
color={color}
67+
variant="outlined"
68+
startIcon={icon}
69+
onClick={onClick}
70+
>
71+
{text}
72+
</Button>
73+
</span>
74+
</Tooltip>
6675
);
6776
}
6877

6978
return (
70-
<IconButton
71-
color={color}
72-
disabled={disabled || isLoading}
73-
data-cy={dataCy}
74-
id={id}
75-
onClick={onClick}
76-
>
77-
{isLoading ? <CircularProgress size={24} /> : icon}
78-
</IconButton>
79+
<Tooltip title={tooltip}>
80+
<span>
81+
<IconButton
82+
color={color}
83+
disabled={disabled || isLoading}
84+
data-cy={dataCy}
85+
id={id}
86+
onClick={onClick}
87+
>
88+
{isLoading ? <CircularProgress size={BUTTON_LOADER_SIZE} /> : icon}
89+
</IconButton>
90+
</span>
91+
</Tooltip>
7992
);
8093
};
8194
export default MiniButton;

src/components/repl/ReplToolbar.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const ReplToolbar: FC<Props> = ({
7676
icon={<Save />}
7777
onClick={onSaveCode}
7878
disabled={savedStatus}
79+
tooltip={t('Save Code')}
7980
text={savedStatus ? t('Saved') : t('Save')}
8081
/>
8182
<MiniButton
@@ -85,6 +86,7 @@ const ReplToolbar: FC<Props> = ({
8586
icon={<PlayArrow />}
8687
onClick={onRunCode}
8788
text={t('Run')}
89+
tooltip={t('Run Code')}
8890
/>
8991
</Stack>
9092
</Stack>
@@ -101,6 +103,7 @@ const ReplToolbar: FC<Props> = ({
101103
icon={<Square />}
102104
onClick={onStopCode}
103105
text={t('Stop')}
106+
tooltip={t('Stop Execution')}
104107
/>
105108
<MiniButton
106109
dataCy={REPLY_CLEAR_BUTTON_CY}
@@ -114,6 +117,7 @@ const ReplToolbar: FC<Props> = ({
114117
/>
115118
}
116119
onClick={onClearOutput}
120+
tooltip={t('Clear outputs and figures')}
117121
text={t('Clear')}
118122
/>
119123
</Stack>

src/config/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export const GRAASP_LOGO_HEADER_HEIGHT = 40;
2+
export const BUTTON_LOADER_SIZE = 24;
23

34
// Admin view constants
45
export const NB_COL_TABLE_VIEW_TABLE = 4;

src/langs/en.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@
124124
"Upload Data Files": "Upload Data Files",
125125
"No files": "No files",
126126
"Supported formats": "Supported formats: {{formats}}",
127-
"Pre-loaded libraries": "Pre-loaded libraries"
127+
"Pre-loaded libraries": "Preloaded Libraries",
128+
"Stop Execution": "Stop Execution",
129+
"Clear outputs and figures": "Clear Outputs and Figures",
130+
"Run Code": "Run Code",
131+
"Save Code": "Save Code"
128132
}
129133
}

src/langs/fr.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@
122122
"Data files": "Fichiers de données",
123123
"Upload Data Files": "Télécharger des fichiers de données",
124124
"No files": "Pas de fichiers",
125-
"Pre-loaded libraries": "Libraries pré-chargées"
125+
"Pre-loaded libraries": "Librairies pré-chargées",
126+
"Stop Execution": "Arrêter l'exécution",
127+
"Clear outputs and figures": "Effacer les sorties et les figures",
128+
"Run Code": "Exécuter le code",
129+
"Save Code": "Enregistrer le code"
126130
}
127131
}

0 commit comments

Comments
 (0)