|
| 1 | +import ComponentPanelItem from '../right/ComponentPanelItem'; |
| 2 | +import Grid from '@mui/material/Grid'; |
1 | 3 | import React from 'react'; |
| 4 | +import { RootState } from '../../redux/store'; |
| 5 | +import makeStyles from '@mui/styles/makeStyles'; |
| 6 | +import { useSelector } from 'react-redux'; |
2 | 7 |
|
3 | 8 | const ComponentsContainer = () => { |
4 | | - return <div>ComponentsContainer</div>; |
| 9 | + const classes = useStyles(); |
| 10 | + const state = useSelector((store: RootState) => store.appState); |
| 11 | + const isDarkMode = useSelector( |
| 12 | + (store: RootState) => store.darkMode.isDarkMode |
| 13 | + ); |
| 14 | + const isFocus = (targetId: Number) => { |
| 15 | + return state.canvasFocus.componentId === targetId ? true : false; |
| 16 | + }; |
| 17 | + return ( |
| 18 | + <div> |
| 19 | + <div className={classes.panelWrapper}> |
| 20 | + <div className={classes.panelWrapperList}> |
| 21 | + <h4 |
| 22 | + className={ |
| 23 | + !isDarkMode |
| 24 | + ? classes.lightThemeFontColor |
| 25 | + : classes.darkThemeFontColor |
| 26 | + } |
| 27 | + > |
| 28 | + Reusable Components |
| 29 | + </h4> |
| 30 | + <Grid |
| 31 | + container |
| 32 | + direction="row" |
| 33 | + justifyContent="center" |
| 34 | + alignItems="center" |
| 35 | + > |
| 36 | + {state.components |
| 37 | + .filter((comp) => !state.rootComponents.includes(comp.id)) |
| 38 | + .map((comp) => { |
| 39 | + return ( |
| 40 | + <ComponentPanelItem |
| 41 | + isFocus={isFocus(comp.id)} |
| 42 | + key={`comp-${comp.id}`} |
| 43 | + name={comp.name} |
| 44 | + id={comp.id} |
| 45 | + root={false} |
| 46 | + /> |
| 47 | + ); |
| 48 | + })} |
| 49 | + </Grid> |
| 50 | + </div> |
| 51 | + </div> |
| 52 | + </div> |
| 53 | + ); |
5 | 54 | }; |
6 | 55 |
|
| 56 | +const useStyles = makeStyles({ |
| 57 | + panelWrapper: { |
| 58 | + display: 'flex', |
| 59 | + flexDirection: 'column', |
| 60 | + alignItems: 'center', |
| 61 | + flexGrow: 1, |
| 62 | + overflow: 'auto' |
| 63 | + }, |
| 64 | + panelWrapperList: { |
| 65 | + minHeight: '120px', |
| 66 | + marginLeft: '-15px', |
| 67 | + marginRight: '-15px', |
| 68 | + width: '100%', |
| 69 | + display: 'flex', |
| 70 | + flexDirection: 'column', |
| 71 | + alignItems: 'center', |
| 72 | + wordWrap: 'break-word' |
| 73 | + }, |
| 74 | + lightThemeFontColor: { |
| 75 | + color: '#fff' |
| 76 | + }, |
| 77 | + darkThemeFontColor: { |
| 78 | + color: '#fff' |
| 79 | + } |
| 80 | +}); |
| 81 | + |
7 | 82 | export default ComponentsContainer; |
0 commit comments