Skip to content

Commit

Permalink
Merge pull request #5 from oslabs-beta/feature/CustomPanelButtons
Browse files Browse the repository at this point in the history
Feature/custom panel buttons
  • Loading branch information
JesseWowczuk authored Apr 23, 2024
2 parents bc63540 + d5f634e commit 10573b4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/src/components/main/DeleteButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ function DeleteButton({ id, name, onClickHandler }: DeleteButtons) {
id={'btn' + id}
onClick={(event) => {
event.stopPropagation();
onClickHandler(event);
if (typeof onClickHandler === 'function') {
onClickHandler(event);
}
deleteHTMLtype(id);
}}
>
Expand Down
42 changes: 39 additions & 3 deletions app/src/containers/CustomizationPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
const [flexDir, setFlexDir] = useState('');
const [flexJustify, setFlexJustify] = useState('');
const [flexAlign, setFlexAlign] = useState('');
const [flexOptionsVisible, setFlexOptionsVisible] = useState(false);
const [BGColor, setBGColor] = useState('');
const [compText, setCompText] = useState('');
const [compLink, setCompLink] = useState('');
Expand All @@ -69,7 +70,9 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
const [useContextObj, setUseContextObj] = useState({});
const [stateUsedObj, setStateUsedObj] = useState({});
const [eventAll, setEventAll] = useState(['', '']);
const [eventOptionsVisible, setEventOptionsVisible] = useState(false);
const [eventRow, setEventRow] = useState([]);
const [eventRowsVisible, setEventRowsVisible] = useState(false);

const currFocus = getFocus().child;

Expand All @@ -86,6 +89,35 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
}
}, [state]);

useEffect(() => {
if (displayMode === 'flex') {
return setFlexOptionsVisible(true);
}
return setFlexOptionsVisible(false);
}, [displayMode]);

useEffect(() => {
if (eventAll[0] !== '') {
return setEventOptionsVisible(true);
}
return setEventOptionsVisible(false);
}, [eventAll]);

useEffect(() => {
if (eventRow.length) {
return setEventRowsVisible(true);
}
return setEventRowsVisible(false);
}, [eventRow]);

const marginTopAmount = () => {
let totalMargin = 0;
if (eventOptionsVisible) totalMargin += 90;
if (flexOptionsVisible) totalMargin = Math.max(totalMargin, 210);
if (eventRowsVisible) totalMargin = Math.max(totalMargin, 335);
return `${totalMargin}px`;
};

//this function allows properties to persist and appear in nested divs
function deepIterate(arr) {
const output = [];
Expand Down Expand Up @@ -128,7 +160,7 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
resetFields();
}, [state.canvasFocus.componentId, state.canvasFocus.childId]);
// handles all input field changes, with specific updates called based on input's name
const handleChange = (e: React.ChangeEvent<{ value: any }>) => {
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const inputVal = e.target.value;
switch (e.target.name) {
case 'display':
Expand Down Expand Up @@ -862,7 +894,10 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
)}
</div>
</section>
<div className={classes.buttonRow}>
<div
className={classes.buttonRow}
style={{ marginTop: marginTopAmount() }}
>
<div>
<Button
variant="contained"
Expand Down Expand Up @@ -957,7 +992,7 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
</Button>
</div>
)}
<div style={{marginLeft: '17px'}}>
<div style={{ marginLeft: '17px' }}>
<Button
variant="contained"
color="primary"
Expand Down Expand Up @@ -1039,6 +1074,7 @@ const useStyles = makeStyles({
justifyContent: 'center',
alignItems: 'center',
textAlign: 'center',
marginLeft: '15px',
'& > .MuiButton-textSecondary': {
color: isThemeLight ? '#808080' : '#ECECEA', // color for delete page
border: isThemeLight ? '1px solid #808080' : '1px solid #ECECEA'
Expand Down

0 comments on commit 10573b4

Please sign in to comment.