-
Notifications
You must be signed in to change notification settings - Fork 0
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
Evol/drawer #4
base: evol/lists-and-filters
Are you sure you want to change the base?
Evol/drawer #4
Changes from all commits
e33d2c5
09aad91
e8b489c
9e81c71
41e7fcb
573d116
9e8603b
814657f
3217a2a
e06ad10
3b9a62f
3c210d4
9104597
a464d77
25ee52d
143bbe0
7528548
f133c5f
bc4adc8
2589eb9
2d6b1c1
9721d99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
@use "variables" as *; | ||
@use "mixins" as *; | ||
|
||
.app { | ||
.app, .MuiModal-root { | ||
|
||
/* BUTTONS */ | ||
.MuiButton-root { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
@use 'assets/scss/variables' as *; | ||
|
||
.drawer { | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
|
||
&--20 { | ||
.MuiDrawer-paper { | ||
width: 20%; | ||
} | ||
} | ||
|
||
&--40 { | ||
.MuiDrawer-paper { | ||
width: 40%; | ||
} | ||
} | ||
|
||
&--50 { | ||
.MuiDrawer-paper { | ||
width: 50%; | ||
} | ||
} | ||
|
||
&--60 { | ||
.MuiDrawer-paper { | ||
width: 60%; | ||
} | ||
} | ||
|
||
&--80 { | ||
.MuiDrawer-paper { | ||
width: 80%; | ||
} | ||
} | ||
|
||
&--80, &--full { | ||
.MuiDrawer-paper { | ||
width: 100%; | ||
} | ||
} | ||
} | ||
|
||
.drawer-header { | ||
height: 6%; | ||
display: flex; | ||
padding: $spacer-6 + $spacer-2; | ||
position: relative; | ||
justify-content: center; | ||
background: rgba($secondary-color, 10%); | ||
|
||
button { | ||
position: absolute; | ||
top: 50%; | ||
left: $spacer-5; | ||
transform: translateY(-50%); | ||
|
||
span { | ||
margin-right: $spacer-3; | ||
} | ||
} | ||
|
||
.drawer-title-container { | ||
position: absolute; | ||
height: 100%; | ||
top: 50%; | ||
left: 40%; | ||
display: flex; | ||
align-items: center; | ||
transform: translateY(-50%); | ||
|
||
h1 { | ||
color: $secondary-color; | ||
font-size: $font-size-large; | ||
text-align: center; | ||
} | ||
} | ||
} | ||
|
||
.drawer-content { | ||
height: 100%; | ||
overflow: auto; | ||
padding: $spacer-6 $spacer-8; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
@forward 'sort-menu'; | ||
@forward 'filter-menu'; | ||
@forward 'search-bar'; | ||
@forward 'drawers'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
@forward 'layout'; | ||
@forward 'navigation'; | ||
@forward 'columns'; | ||
@forward 'lists'; | ||
@forward 'lists'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@use "../variables" as *; | ||
|
||
:export{ | ||
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. Je ne comprends pas bien à quoi sert ce fichier |
||
widthSmallScreen: $width-small-screen-px; | ||
widthMediumScreen: $width-medium-screen-px; | ||
|
||
primaryColor: $primary-color; | ||
secondaryColor: $secondary-color; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Drawer as MaterialDrawer, Icon } from '@mui/material'; | ||
import React from 'react'; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
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. Pourquoi ts ignore ? Normalement c'est interdit d'utiliser ça d'ailleurs |
||
import cssVariables from '../../../../assets/scss/modules/_variables.module.scss'; | ||
import useMessages from '../../../i18n/hooks/messagesHook'; | ||
import ActionStyle from '../../../lib/plume-admin-theme/action/ActionStyle'; | ||
import { | ||
DrawerTypeProps, | ||
} from '../../../lib/plume-admin-theme/drawer/DrawerProps'; | ||
import { ActionButton } from '../action/Actions'; | ||
|
||
export default function Drawer( | ||
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. Antoine LL Tu penses qu'on peut reprendre des choses du slider de la VEL ? |
||
{ | ||
title, children, open, close, size, fullScreen, sizedByWidth, className, | ||
}: DrawerTypeProps) { | ||
const { messages } = useMessages(); | ||
const { widthSmallScreen, widthMediumScreen } = cssVariables; | ||
|
||
// Returns width percentage of drawer | ||
const drawerSize = () => { | ||
const defaultSize: number = 40; | ||
const largeSize: number = 60; | ||
if (sizedByWidth) { | ||
const width: number = window.innerWidth; | ||
if (width < widthSmallScreen) { | ||
return 'full'; | ||
} | ||
|
||
return width < widthMediumScreen ? largeSize : defaultSize; | ||
} | ||
|
||
return size || defaultSize; | ||
}; | ||
|
||
return ( | ||
<MaterialDrawer | ||
anchor="right" | ||
open={open} | ||
onClose={close} | ||
className={`drawer${className || ''} ${fullScreen ? ' drawer--full-screen' : ''} drawer--${drawerSize()}`} | ||
> | ||
<div className={`drawer ${fullScreen ? 'drawer--full' : ''}`}> | ||
<div className="drawer-header"> | ||
<div className="drawer-button-container"> | ||
<ActionButton | ||
onClick={close} | ||
style={ActionStyle.SECONDARY} | ||
cssClasses={ActionStyle.SECONDARY} | ||
> | ||
<Icon>chevron_left</Icon> | ||
{messages.action.close} | ||
</ActionButton> | ||
</div> | ||
<div className="drawer-title-container"> | ||
<h1>{title || ''}</h1> | ||
</div> | ||
<div /> | ||
</div> | ||
<div className="drawer-content">{children}</div> | ||
</div> | ||
</MaterialDrawer> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { getGlobalInstance } from 'plume-ts-di'; | ||
import React, { useEffect } from 'react'; | ||
import { | ||
UncontrolledDrawerTypeProps, | ||
} from '../../../lib/plume-admin-theme/drawer/DrawerProps'; | ||
import PlumeAdminTheme from '../../../lib/plume-admin-theme/PlumeAdminTheme'; | ||
import useToggle from '../../../lib/react-hook-toggle/ReactHookToggle'; | ||
|
||
/** | ||
* When a drawer is a all page, there is no state to control its opening / closing | ||
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. is a whole page* ? 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. y a pas de state dans le parent pour controler l'ouverture / la fermeture. Donc c'est lui même qui gère son état d'ouverture / fermeture et le parent ne se charge de rien 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. Dans ce cas, le composant est mal nommé, c'est plutôt |
||
*/ | ||
function UncontrolledDrawer( | ||
{ | ||
title, | ||
onClose, | ||
children, | ||
size, | ||
sizedByWidth, | ||
fullScreen, | ||
className, | ||
}: UncontrolledDrawerTypeProps, | ||
) { | ||
const theme: PlumeAdminTheme = getGlobalInstance(PlumeAdminTheme); | ||
const [isDrawerOpened, toggleDrawer] = useToggle(false); | ||
|
||
useEffect(() => { | ||
if (!isDrawerOpened) { | ||
setTimeout(toggleDrawer, 0); | ||
} | ||
}, [children]); | ||
|
||
const uncontrolledClose = () => { | ||
toggleDrawer(); | ||
setTimeout(onClose, 300); | ||
}; | ||
|
||
return ( | ||
<theme.drawer | ||
title={title} | ||
open={isDrawerOpened} | ||
close={uncontrolledClose} | ||
size={size} | ||
sizedByWidth={sizedByWidth} | ||
fullScreen={fullScreen} | ||
className={className} | ||
> | ||
{children} | ||
</theme.drawer> | ||
); | ||
} | ||
|
||
export default (UncontrolledDrawer); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { MenuItem, TextField } from '@mui/material'; | ||
import React from 'react'; | ||
import { SelectElement } from 'react-hook-form-mui'; | ||
import { useController } from 'react-hook-form'; | ||
import { | ||
InputSelectProps, | ||
SelectOptionProps, | ||
} from '../../../../lib/plume-admin-theme/form/FormInputProps'; | ||
|
||
export default function InputSelect( | ||
|
@@ -20,24 +22,50 @@ export default function InputSelect( | |
}: InputSelectProps) { | ||
const fieldId: string = useNameAsId ? (name ?? 'undefined_input_name') : (id ?? 'undefined_input_id'); | ||
|
||
const { field } = useController({ | ||
name: fieldId, | ||
control, | ||
rules: { required: required ?? false }, | ||
defaultValue: defaultValue || '', | ||
}); | ||
|
||
const onBlurCombined = (value: React.FocusEvent<HTMLTextAreaElement | HTMLInputElement>) => { | ||
field.onBlur(); | ||
if (onBlur) { | ||
onBlur(value); | ||
} | ||
}; | ||
|
||
const onChangeField = (event: React.ChangeEvent<HTMLTextAreaElement>) => { | ||
field.onChange(event); | ||
if (onChange) { | ||
onChange(event.target.value); | ||
} | ||
}; | ||
|
||
return ( | ||
<SelectElement | ||
<TextField | ||
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. Pourquoi TextField et pas Select ? |
||
className={required ? 'field-required' : ''} | ||
control={control} | ||
select | ||
label={label} | ||
name={fieldId} | ||
name={name} | ||
variant="filled" | ||
id={fieldId} | ||
options={options} | ||
valueKey="value" | ||
labelKey="label" | ||
defaultValue={defaultValue} | ||
required={required} | ||
id={useNameAsId ? name : id} | ||
disabled={disabled ?? false} | ||
onBlur={onBlur} | ||
onChange={onChange} | ||
// disable FormHelper | ||
parseError={() => ''} | ||
/> | ||
value={field.value} | ||
inputRef={field.ref} | ||
onBlur={onBlurCombined} | ||
onChange={onChangeField} | ||
> | ||
{ | ||
React.Children.toArray( | ||
options?.map((option: SelectOptionProps) => ( | ||
<MenuItem key={`${option.label}-${option.value}`} value={option.value}> | ||
{option.label} | ||
</MenuItem> | ||
)), | ||
) | ||
} | ||
</TextField> | ||
); | ||
} |
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.
Pourquoi ça ?