@@ -14,10 +14,12 @@ import TrashIcon from "components/img/Trash";
1414import TextIcon from "components/img/Text" ;
1515import MultiIcon from "components/img/Multi" ;
1616import HashIcon from "components/img/Hash" ;
17+ import AdjustmentsIcon from "components/img/AdjustmentsIcon" ;
1718import React , { useContext , useEffect , useState } from "react" ;
1819import { ActionType } from "react-table" ;
1920import { usePopper } from "react-popper" ;
2021import { HeaderContext } from "components/contexts/HeaderContext" ;
22+ import { FormControlLabel , FormGroup , Switch } from "@material-ui/core" ;
2123type HeaderMenuProps = {
2224 dispatch : ( action : ActionType ) => void ;
2325 setSortBy : any ;
@@ -31,6 +33,8 @@ type HeaderMenuProps = {
3133 labelState : string ;
3234 setLabelState : ( label : string ) => void ;
3335 initialState : TableDataType ;
36+ isInline : boolean ;
37+ setIsInline : ( isInline : boolean ) => void ;
3438} ;
3539const HeaderMenu = ( headerMenuProps : HeaderMenuProps ) => {
3640 const {
@@ -44,6 +48,8 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
4448 labelState,
4549 setLabelState,
4650 initialState,
51+ isInline,
52+ setIsInline,
4753 } = headerMenuProps ;
4854 /** state of width columns */
4955 const { columnWidthState, setColumnWidthState } = useContext ( HeaderContext ) ;
@@ -56,11 +62,17 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
5662 placement : "bottom" ,
5763 strategy : "absolute" ,
5864 } ) ;
65+ // Manage type of data
5966 const [ typeReferenceElement , setTypeReferenceElement ] = useState ( null ) ;
6067 const [ typePopperElement , setTypePopperElement ] = useState ( null ) ;
61-
6268 const [ showType , setShowType ] = useState ( false ) ;
6369
70+ // Manage settings
71+ const [ settingsReferenceElement , setSettingsReferenceElement ] =
72+ useState ( null ) ;
73+ const [ settingsPopperElement , setSettingsPopperElement ] = useState ( null ) ;
74+ const [ showSettings , setShowSettings ] = useState ( false ) ;
75+
6476 useEffect ( ( ) => {
6577 if ( created ) {
6678 setExpanded ( true ) ;
@@ -193,6 +205,15 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
193205 strategy : "fixed" ,
194206 } ) ;
195207
208+ const settingsPopper = usePopper (
209+ settingsReferenceElement ,
210+ settingsPopperElement ,
211+ {
212+ placement : "right" ,
213+ strategy : "fixed" ,
214+ }
215+ ) ;
216+
196217 function persistLabelChange ( ) {
197218 dispatch ( {
198219 type : ActionTypes . UPDATE_COLUMN_LABEL ,
@@ -240,6 +261,15 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
240261 return { name : columnName , position : columnNumber , label : columnLabel } ;
241262 }
242263
264+ function handleChangeToggleInlineFrontmatter ( e : any ) {
265+ setIsInline ( e . target . checked ) ;
266+ dispatch ( {
267+ type : ActionTypes . TOGGLE_INLINE_FRONTMATTER ,
268+ columnId : id ,
269+ isInline : e . target . checked ,
270+ } ) ;
271+ }
272+
243273 return (
244274 < div >
245275 { expanded && (
@@ -288,7 +318,7 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
288318 Property Type
289319 </ span >
290320 </ div >
291- { /** Edit header label section */ }
321+ { /** Type of column section */ }
292322 < div style = { { padding : "4px 0px" } } >
293323 < button
294324 className = "sort-button"
@@ -330,6 +360,7 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
330360 </ div >
331361 ) }
332362 </ div >
363+ { /** Action buttons section */ }
333364 < div
334365 style = { {
335366 borderTop : `2px solid ${ StyleVariables . BACKGROUND_DIVIDER } ` ,
@@ -350,6 +381,58 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
350381 </ button >
351382 ) ) }
352383 </ div >
384+ < div
385+ style = { {
386+ borderTop : `2px solid ${ StyleVariables . BACKGROUND_DIVIDER } ` ,
387+ padding : "4px 0px" ,
388+ } }
389+ >
390+ { /** Column settings section */ }
391+ < div style = { { padding : "4px 0px" } } >
392+ < button
393+ className = "sort-button"
394+ type = "button"
395+ onMouseEnter = { ( ) => setShowSettings ( true ) }
396+ onMouseLeave = { ( ) => setShowSettings ( false ) }
397+ ref = { setSettingsReferenceElement }
398+ >
399+ < span className = "svg-icon svg-text icon-margin" >
400+ < AdjustmentsIcon />
401+ </ span >
402+ < span > Settings</ span >
403+ </ button >
404+ { showSettings && (
405+ < div
406+ className = "shadow-5 border-radius-m"
407+ ref = { setSettingsPopperElement }
408+ onMouseEnter = { ( ) => setShowSettings ( true ) }
409+ onMouseLeave = { ( ) => setShowSettings ( false ) }
410+ { ...settingsPopper . attributes . popper }
411+ style = { {
412+ ...settingsPopper . styles . popper ,
413+ width : 200 ,
414+ backgroundColor : StyleVariables . BACKGROUND_SECONDARY ,
415+ zIndex : 4 ,
416+ padding : "4px 0px" ,
417+ } }
418+ >
419+ < FormGroup >
420+ < FormControlLabel
421+ control = {
422+ < Switch
423+ checked = { isInline }
424+ onChange = { ( event ) => {
425+ handleChangeToggleInlineFrontmatter ( event ) ;
426+ } }
427+ />
428+ }
429+ label = "Inline"
430+ />
431+ </ FormGroup >
432+ </ div >
433+ ) }
434+ </ div >
435+ </ div >
353436 </ div >
354437 </ div >
355438 ) }
0 commit comments