Skip to content

Commit 943f7fb

Browse files
authored
Various small fixes (#16)
* hint loading * linkes order and formatting * zindex of header & footer * remove one comming soon item * progress bar fix * ZIndex refix * tooltips for grammar
1 parent 783fd09 commit 943f7fb

File tree

8 files changed

+67
-28
lines changed

8 files changed

+67
-28
lines changed

frontend/src/lib/components/createExercise.tsx

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
IconCheck,
2727
IconCirclePlus,
2828
IconCircleX,
29+
IconHelp,
2930
IconInfoCircle,
3031
IconPlus,
3132
IconX,
@@ -51,7 +52,9 @@ import { Identifier } from "./formula/formulaParts";
5152
const CreateExerciseForm = () => {
5253
const [opened, { open, close }] = useDisclosure(false);
5354

54-
const [[lhsFormulaStr, rhsFormulaStr], setFormulaStr] = useState<[string, string]>(["", ""]);
55+
const [[lhsFormulaStr, rhsFormulaStr], setFormulaStr] = useState<
56+
[string, string]
57+
>(["", ""]);
5558
const [debouncedLhsFormulaStr] = useDebouncedValue(lhsFormulaStr, 150);
5659
const [debouncedRhsFormulaStr] = useDebouncedValue(rhsFormulaStr, 150);
5760

@@ -146,12 +149,12 @@ const CreateExerciseForm = () => {
146149
useEffect(() => {
147150
if (!debouncedLhsFormulaStr) return;
148151
parseFormulaRequest(debouncedLhsFormulaStr, true);
149-
}, [debouncedLhsFormulaStr])
152+
}, [debouncedLhsFormulaStr]);
150153

151154
useEffect(() => {
152155
if (!debouncedRhsFormulaStr) return;
153156
parseFormulaRequest(debouncedRhsFormulaStr, false);
154-
}, [debouncedRhsFormulaStr])
157+
}, [debouncedRhsFormulaStr]);
155158

156159
const parseFormulaRequest = async (formula: string, lhs: boolean) => {
157160
if (lhs) {
@@ -231,7 +234,14 @@ const CreateExerciseForm = () => {
231234
</ListItem>
232235
</List>
233236
<Divider mt={"md"} />
234-
<Stack justify="center" align="stretch" gap={10}>
237+
<Stack justify="center" align="stretch" gap={0}>
238+
<Group>
239+
<Title order={4}>Statement</Title>
240+
<Tooltip label={<GrammarTooltip />}>
241+
<IconHelp />
242+
</Tooltip>
243+
</Group>
244+
235245
<Group justify="center">
236246
<Card withBorder miw={"50%"} mih={125} mt={"xl"}>
237247
<Card.Section h={"100%"}>
@@ -264,7 +274,6 @@ const CreateExerciseForm = () => {
264274
</Card.Section>
265275
</Card>
266276
</Group>
267-
268277
<Grid pt={"xl"} align="center" grow columns={26}>
269278
<Grid.Col span={12}>
270279
<Group justify="right" align="center">
@@ -280,7 +289,9 @@ const CreateExerciseForm = () => {
280289
))}
281290
<TextInput
282291
placeholder="Enter Formula"
283-
onChange={(e) => setFormulaStr(([_, rhs]) => [e?.currentTarget?.value, rhs])}
292+
onChange={(e) =>
293+
setFormulaStr(([_, rhs]) => [e?.currentTarget?.value, rhs])
294+
}
284295
rightSection={
285296
<ActionIcon
286297
variant="transparent"
@@ -310,7 +321,12 @@ const CreateExerciseForm = () => {
310321
) : (
311322
<TextInput
312323
placeholder="Enter Formula"
313-
onChange={(e) => setFormulaStr(([lhs, _]) => [lhs, e?.currentTarget?.value])}
324+
onChange={(e) =>
325+
setFormulaStr(([lhs, _]) => [
326+
lhs,
327+
e?.currentTarget?.value,
328+
])
329+
}
314330
rightSection={
315331
<ActionIcon
316332
variant="transparent"
@@ -329,6 +345,7 @@ const CreateExerciseForm = () => {
329345
</Grid.Col>
330346
</Grid>
331347
<Divider my={"md"} />
348+
<Title order={4}>Side Conditions</Title>
332349
<Stack align="center">
333350
{sideCon.map((sc, i) => (
334351
<Group key={i} gap={1}>
@@ -391,7 +408,8 @@ const CreateExerciseForm = () => {
391408
</Group>
392409
</Stack>
393410
<Divider my={"md"} />
394-
<Group justify="center">
411+
{/* <Title order={4}>Side Conditions</Title> */}
412+
<Group justify="center" pb={"md"}>
395413
{hasRhs ? (
396414
<Text>✅ Structure</Text>
397415
) : (

frontend/src/lib/components/exercise/hint.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,13 @@ type HintProps = {
7777
};
7878

7979
const Hint = ({ statement, opened, close }: HintProps) => {
80-
const [getHint] = useGetTippMutation();
80+
const [getHint, refetch] = useGetTippMutation();
8181
const [hints, hintsHandler] = useListState<Tipp>([]);
8282

8383
useEffect(() => {
84+
console.log("load hint");
8485
loadHint();
85-
}, []);
86-
useEffect(() => {
87-
loadHint();
88-
}, []);
86+
}, [opened]);
8987

9088
const loadHint = async () => {
9189
try {

frontend/src/lib/components/exercise/matcher.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
import { useListState } from "@mantine/hooks";
3232
import {
3333
IconCheck,
34+
IconHelp,
3435
IconInfoCircle,
3536
IconPlus,
3637
IconX,
@@ -344,7 +345,7 @@ const Matcher = () => {
344345
click={handleClick}
345346
/>
346347
</Center>
347-
<Group>
348+
<Group wrap="nowrap" gap={"xs"}>
348349
<TextInput
349350
value={customFormula}
350351
onChange={(event) => setCustomFormula(event.currentTarget.value)}
@@ -356,6 +357,9 @@ const Matcher = () => {
356357
</ActionIcon>
357358
}
358359
/>
360+
<Tooltip label={<GrammarTooltip />}>
361+
<IconHelp />
362+
</Tooltip>
359363
</Group>
360364
{parseError.length > 0 && (
361365
<Textarea disabled value={parseError} rows={6} bg={"#ff8787"} />

frontend/src/lib/components/exerciseListElement.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Grid,
77
Group,
88
Indicator,
9+
SimpleGrid,
910
Text,
1011
Tooltip,
1112
} from "@mantine/core";
@@ -45,14 +46,21 @@ const ExerciseListElment = ({ exercise }: exerciseListElementProps) => {
4546
<Card withBorder>
4647
<Grid grow align="center" pb={"md"}>
4748
<Grid.Col span={1}>
48-
<Group gap={3} p={0} m={0}>
49-
<Text pr={5}>{exercise.likes}</Text>
49+
<SimpleGrid cols={2} spacing={0} verticalSpacing={0}>
50+
{/* <SimpleGi gap={3} p={0} m={0} wrap="nowrap"> */}
51+
<Text pr={5} styles={{ root: { textAlign: "right" } }}>
52+
{exercise.likes}
53+
</Text>
5054
<IconThumbUp />
51-
</Group>
52-
<Group gap={3}>
53-
<Text pr={5}> {exercise.dislikes}</Text>
55+
{/* </Group> */}
56+
{/* <Group gap={3}> */}
57+
<Text pr={5} styles={{ root: { textAlign: "right" } }}>
58+
{" "}
59+
{exercise.dislikes}
60+
</Text>
5461
<IconThumbDown />
55-
</Group>
62+
</SimpleGrid>
63+
{/* </Group> */}
5664
</Grid.Col>
5765
<Grid.Col span={7}>
5866
<Difficulty
@@ -96,6 +104,7 @@ const ExerciseListElment = ({ exercise }: exerciseListElementProps) => {
96104
style={{ textDecoration: "none" }}
97105
>
98106
<Indicator
107+
styles={{ indicator: { zIndex: 1 } }}
99108
color="lightgray"
100109
label={<IconBulb size={20} color="black" />}
101110
size={"lg"}

frontend/src/lib/components/exerciseOverview.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ const ExerciseOverview = () => {
6060
const likeCompare = (a: Exercise, b: Exercise) => {
6161
if (a.likes == 0 && a.dislikes == 0) {
6262
return 1;
63-
} else if (b.likes == 0 && b.dislikes == 0) {
63+
} else if (a.likes > b.likes) {
64+
return -1;
65+
} else if (a.dislikes <= b.dislikes) {
6466
return -1;
6567
}
66-
return b.likes / (b.likes + b.dislikes) - a.likes / (a.likes + a.dislikes);
68+
return 1;
6769
};
6870

6971
return (

frontend/src/lib/components/info.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ const Info = () => {
2424
};
2525

2626
return (
27-
<Accordion value={value} onChange={changeCollapse} variant="filled">
27+
<Accordion
28+
value={value}
29+
onChange={changeCollapse}
30+
variant="filled"
31+
styles={{ control: { cursor: "default" } }}
32+
>
2833
<Accordion.Item value="info">
2934
<Accordion.Control>
3035
<Group mr={"md"} align="center">
@@ -113,9 +118,6 @@ const Info = () => {
113118
<List.Item>
114119
<Text>🤖 Automated exercise generation</Text>
115120
</List.Item>
116-
<List.Item>
117-
<Text>💡 Hints for which rule to apply</Text>
118-
</List.Item>
119121
</List>
120122

121123
<Title order={4}>⚠️ Disclaimer</Title>

frontend/src/lib/components/semesterProgress.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@ const SemsterProgress = () => {
1313
(dates[dates.length - 1][0] as Date).getTime() -
1414
(dates[0][0] as Date).getTime();
1515

16+
const now = new Date();
17+
const current_progress = Math.min(
18+
100,
19+
((now.getTime() - (dates[0][0] as Date).getTime()) / duration) * 100,
20+
);
21+
1622
return (
1723
<Slider
1824
ml={100}
1925
mr={"md"}
2026
style={{ flexGrow: "1", pointerEvents: "none" }}
21-
value={10}
27+
value={current_progress}
2228
marks={dates.map(([date, label]) => {
2329
return {
2430
value:

frontend/src/lib/utils/export.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function exportToTypst(root: NodeType, nodes: Array<NodeType>): string {
1313
return `$${element.value} "not occuring freely in" ${placeholder.value}$`;
1414
},
1515
);
16-
16+
1717
conditions.push(...footnotes.map(([id, note]) => `$"${id}:" ${note}$`));
1818

1919
let typstStr = `${imp}\n${page}\n${prooftree}`;

0 commit comments

Comments
 (0)