-
-
Notifications
You must be signed in to change notification settings - Fork 39
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: improve Nutri-Score game #93
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a85abdf
improve nutriscore game
alexfauquette c817749
run prettier
alexfauquette f910bd1
Merge remote-tracking branch 'origin/master' into nutriscore-game
alexfauquette af7a5c9
Apply suggestions from code review
alexfauquette bac9bb7
Merge remote-tracking branch 'origin/master' into nutriscore-game
alexfauquette 1a696db
Merge remote-tracking branch 'origin/master' into nutriscore-game
alexfauquette 9fb98e3
last modifications
alexfauquette File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,11 +12,16 @@ import Card from "@mui/material/Card"; | |
import CardActionArea from "@mui/material/CardActionArea"; | ||
import CardMedia from "@mui/material/CardMedia"; | ||
import Checkbox from "@mui/material/Checkbox"; | ||
import Paper from "@mui/material/Paper"; | ||
import Slider from "@mui/material/Slider"; | ||
import Typography from "@mui/material/Typography"; | ||
|
||
const BUFFER_THRESHOLD = 30; | ||
const PAGE_SIZE = 50; | ||
|
||
export default function NutriscoreValidator() { | ||
const [imageSize, setImageSize] = React.useState(300); | ||
|
||
const [nutriscoreGrade, setNutriscoreGrade] = React.useState("a"); | ||
const [filterState, setFilterState] = React.useState({ | ||
insightType: "label", | ||
|
@@ -56,27 +61,52 @@ export default function NutriscoreValidator() { | |
|
||
return ( | ||
<Box> | ||
<Box sx={{ padding: 5, textAlign: "center" }}> | ||
<Stack | ||
direction="row" | ||
justifyContent="center" | ||
alignItems="center" | ||
sx={{ padding: 5, textAlign: "center" }} | ||
> | ||
<TextField value={nutriscoreGrade} onChange={updateSearchedGrad} select> | ||
<MenuItem value="a">Nutriscore A</MenuItem> | ||
<MenuItem value="b">Nutriscore B</MenuItem> | ||
<MenuItem value="c">Nutriscore C</MenuItem> | ||
<MenuItem value="d">Nutriscore D</MenuItem> | ||
<MenuItem value="e">Nutriscore E</MenuItem> | ||
</TextField> | ||
</Box> | ||
<Box sx={{ mx: 2, width: 500, maxWidth: 500, textAlign: "left" }}> | ||
<Typography gutterBottom>Image sizes</Typography> | ||
<Slider | ||
aria-label="Temperature" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :v
alexfauquette marked this conversation as resolved.
Show resolved
Hide resolved
|
||
defaultValue={imageSize} | ||
onChangeCommitted={(event, newValue) => setImageSize(newValue)} | ||
valueLabelDisplay="auto" | ||
step={50} | ||
marks | ||
min={50} | ||
max={500} | ||
sx={{ maxWidth: 500 }} | ||
/> | ||
</Box> | ||
</Stack> | ||
|
||
<Divider sx={{ mb: 4 }} /> | ||
<div | ||
style={{ | ||
display: "grid", | ||
gridTemplateColumns: "repeat(auto-fill, minmax(410px, 1fr))", | ||
gridTemplateColumns: `repeat(auto-fill, minmax(${ | ||
imageSize + 10 | ||
}px, 1fr))`, | ||
gridGap: 10, | ||
}} | ||
> | ||
{buffer.map((question) => ( | ||
<Card sx={{ width: 400, height: 400 }} key={question.insight_id}> | ||
<Card | ||
sx={{ width: imageSize, height: imageSize }} | ||
key={question.insight_id} | ||
> | ||
<CardActionArea | ||
sx={{ width: 400, height: 400, position: "relative" }} | ||
sx={{ width: imageSize, height: imageSize, position: "relative" }} | ||
onClick={toggleSelection(question.insight_id)} | ||
tabIndex={-1} | ||
> | ||
|
@@ -103,41 +133,47 @@ export default function NutriscoreValidator() { | |
))} | ||
</div> | ||
|
||
<Stack | ||
direction="row" | ||
justifyContent="end" | ||
sx={{ paddingX: 5, paddingY: 10 }} | ||
<Paper | ||
sx={{ | ||
paddingX: 2, | ||
paddingY: 1, | ||
position: "sticky", | ||
bottom: 0, | ||
marginTop: 2, | ||
}} | ||
> | ||
<Button | ||
size="large" | ||
variant="contained" | ||
color="error" | ||
onClick={() => { | ||
selectedIds.forEach((insight_id) => | ||
answerQuestion({ value: 0, insightId: insight_id }) | ||
); | ||
setSelectedIds([]); | ||
}} | ||
fullWidth | ||
> | ||
Wrong | ||
</Button> | ||
<Button | ||
sx={{ ml: 3 }} | ||
size="large" | ||
variant="contained" | ||
color="success" | ||
onClick={() => { | ||
selectedIds.forEach((insight_id) => | ||
answerQuestion({ value: 1, insightId: insight_id }) | ||
); | ||
setSelectedIds([]); | ||
}} | ||
fullWidth | ||
> | ||
Correct (Nutriscore {nutriscoreGrade.toUpperCase()}) | ||
</Button> | ||
</Stack> | ||
<Stack direction="row" justifyContent="end"> | ||
<Button | ||
size="large" | ||
variant="contained" | ||
color="error" | ||
onClick={() => { | ||
selectedIds.forEach((insight_id) => | ||
answerQuestion({ value: 0, insightId: insight_id }) | ||
); | ||
setSelectedIds([]); | ||
}} | ||
fullWidth | ||
> | ||
Wrong | ||
</Button> | ||
<Button | ||
sx={{ ml: 3 }} | ||
size="large" | ||
variant="contained" | ||
color="success" | ||
onClick={() => { | ||
selectedIds.forEach((insight_id) => | ||
answerQuestion({ value: 1, insightId: insight_id }) | ||
); | ||
setSelectedIds([]); | ||
}} | ||
fullWidth | ||
> | ||
Correct (Nutriscore {nutriscoreGrade.toUpperCase()}) | ||
</Button> | ||
</Stack> | ||
</Paper> | ||
</Box> | ||
); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha made me think we could rename devMode