-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
display modal on mobile and modal hidden in desktop view
- Loading branch information
1 parent
24b07ac
commit 1b04977
Showing
6 changed files
with
228 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
|
||
import Checkbox from '@mui/material/Checkbox'; | ||
|
||
import PelicoNeutre from 'src/svg/pelico/pelico_neutre.svg'; | ||
|
||
const CheckboxAdmin = () => { | ||
const label = { inputProps: { 'aria-label': 'Pelico' } }; | ||
|
||
return ( | ||
<div style={{ display: 'flex', width: '80px' }}> | ||
<Checkbox {...label} /> | ||
<PelicoNeutre style={{ margin: 'auto', height: '16px', width: 'auto', cursor: 'pointer' }} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CheckboxAdmin; |
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import React from 'react'; | ||
|
||
import FormControl from '@mui/material/FormControl'; | ||
import MenuItem from '@mui/material/MenuItem'; | ||
import OutlinedInput from '@mui/material/OutlinedInput'; | ||
import type { SelectChangeEvent } from '@mui/material/Select'; | ||
import Select from '@mui/material/Select'; | ||
import { useTheme } from '@mui/material/styles'; | ||
import type { Theme } from '@mui/material/styles'; | ||
|
||
const ITEM_HEIGHT = 48; | ||
const ITEM_PADDING_TOP = 8; | ||
const MenuProps = { | ||
PaperProps: { | ||
style: { | ||
maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP, | ||
width: 250, | ||
}, | ||
}, | ||
}; | ||
|
||
function getStyles(label: string, labelName: readonly string[], theme: Theme) { | ||
return { | ||
fontWeight: labelName.indexOf(label) === -1 ? theme.typography.fontWeightRegular : theme.typography.fontWeightMedium, | ||
}; | ||
} | ||
|
||
type FilterProps = { | ||
labels: string[]; | ||
placeholder: string; | ||
}; | ||
|
||
const FilterMultipleChoice = ({ labels, placeholder }: FilterProps) => { | ||
const theme = useTheme(); | ||
const [labelName, setLabelName] = React.useState<string[]>([]); | ||
|
||
const handleChange = (event: SelectChangeEvent<typeof labelName>) => { | ||
const { | ||
target: { value }, | ||
} = event; | ||
setLabelName( | ||
// On autofill we get a stringified value. | ||
typeof value === 'string' ? value.split(',') : value, | ||
); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<FormControl sx={{ m: 1, width: 140 }} size="small"> | ||
<Select | ||
multiple | ||
displayEmpty | ||
value={labelName} | ||
onChange={handleChange} | ||
input={<OutlinedInput />} | ||
renderValue={(selected) => { | ||
if (selected.length === 0) { | ||
return <em>{placeholder}</em>; | ||
} | ||
|
||
return selected.join(', '); | ||
}} | ||
MenuProps={MenuProps} | ||
inputProps={{ 'aria-label': 'Without label' }} | ||
> | ||
<MenuItem disabled value=""> | ||
<em>Placeholder</em> | ||
</MenuItem> | ||
{labels.map((label: string, index: number) => ( | ||
<MenuItem key={index} value={label} style={getStyles(label, labelName, theme)}> | ||
{label} | ||
</MenuItem> | ||
))} | ||
</Select> | ||
</FormControl> | ||
</div> | ||
); | ||
}; | ||
|
||
export default FilterMultipleChoice; |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react'; | ||
|
||
import RefreshIcon from '@mui/icons-material/Refresh'; | ||
import Box from '@mui/material/Box'; | ||
import Button from '@mui/material/Button'; | ||
import IconButton from '@mui/material/IconButton'; | ||
import Modal from '@mui/material/Modal'; | ||
|
||
import CheckboxAdmin from 'src/components/admin/mediatheque/CheckboxAdmin'; | ||
import FilterMultipleChoice from 'src/components/admin/mediatheque/Filter'; | ||
import { activitiesLabel } from 'src/config/mediatheque/dataFilters'; | ||
|
||
const styleModal = { | ||
position: 'absolute' as const, | ||
top: '50%', | ||
left: '50%', | ||
transform: 'translate(-50%, -50%)', | ||
width: 250, | ||
bgcolor: 'background.paper', | ||
border: '2px solid #000', | ||
borderRadius: '10px', | ||
boxShadow: 24, | ||
p: 4, | ||
}; | ||
|
||
const ModalFilter = () => { | ||
const [open, setOpen] = React.useState(false); | ||
const handleOpen = () => setOpen(true); | ||
const handleClose = () => setOpen(false); | ||
|
||
return ( | ||
<div style={{ display: 'flex', justifyContent: 'center' }}> | ||
<Button onClick={handleOpen}>Filtres</Button> | ||
<Modal open={open} onClose={handleClose} aria-labelledby="modal-modal-title" aria-describedby="modal-modal-description"> | ||
<Box sx={styleModal}> | ||
<FilterMultipleChoice labels={activitiesLabel} placeholder="Activités" /> | ||
<FilterMultipleChoice labels={activitiesLabel} placeholder="Thèmes" /> | ||
<FilterMultipleChoice labels={activitiesLabel} placeholder="VM" /> | ||
<FilterMultipleChoice labels={activitiesLabel} placeholder="Pays" /> | ||
<FilterMultipleChoice labels={activitiesLabel} placeholder="Classes" /> | ||
<div style={{ display: 'flex', justifyContent: 'center' }}> | ||
<CheckboxAdmin /> | ||
<IconButton aria-label="delete" color="primary"> | ||
<RefreshIcon /> | ||
</IconButton> | ||
</div> | ||
</Box> | ||
</Modal> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ModalFilter; |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export const activitiesLabel = [ | ||
'Présentation', | ||
'Enigme', | ||
'Défi', | ||
'Question', | ||
'Jeux', | ||
'Contenu libre', | ||
'Indice', | ||
'Symbole', | ||
'Mascotte', | ||
'Reportage', | ||
'Reaction', | ||
'Hymne', | ||
'Couplet ?', | ||
'Histoire', | ||
'Réinventer une histoire', | ||
]; |
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