Skip to content

Commit

Permalink
[1155] Use different colors for the left and right bars's backgrounds
Browse files Browse the repository at this point in the history
Bug: #1155
Signed-off-by: Pierre-Charles David <[email protected]>
  • Loading branch information
pcdavid committed Apr 14, 2022
1 parent ba9fc5e commit 0154373
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions frontend/src/workbench/Site.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ import Typography from '@material-ui/core/Typography';
import React, { useState } from 'react';
import { SiteProps } from './Site.types';

declare module '@material-ui/core/styles' {
interface Theme {
navigation: {
leftBackground: React.CSSProperties['color'];
rightBackground: React.CSSProperties['color'];
};
}
}

const useSiteStyles = makeStyles((theme) => ({
leftSite: {
display: 'grid',
Expand All @@ -31,10 +40,21 @@ const useSiteStyles = makeStyles((theme) => ({
justifyItems: 'stretch',
alignItems: 'stretch',
},
viewSelector: {
viewSelectorLeft: {
display: 'flex',
flexDirection: 'column',
background: 'var(--blue-lagoon-lighten-60)',
background: theme.navigation.leftBackground,
},
viewSelectorRight: {
display: 'flex',
flexDirection: 'column',
background: theme.navigation.rightBackground,
},
viewSelectorIcon: {
color: theme.palette.common.white,
},
viewSelectorIconSelected: {
color: theme.palette.secondary.main,
},
viewIcon: {
padding: theme.spacing(1),
Expand All @@ -55,22 +75,25 @@ const useSiteStyles = makeStyles((theme) => ({
borderBottomWidth: '1px',
borderBottomStyle: 'solid',
},
viewContent: {},
}));

export const Site = ({ editingContextId, selection, setSelection, readOnly, side, contributions }: SiteProps) => {
const classes = useSiteStyles();
const [selectedViewIndex, setSelectedViewIndex] = useState<number | null>(0);

const viewSelector = (
<div className={classes.viewSelector}>
<div className={side === 'left' ? classes.viewSelectorLeft : classes.viewSelectorRight}>
{contributions.map((contribution, index) => {
const title = contribution.props.title;
const icon = contribution.props.icon;
let iconClassName = classes.viewSelectorIcon;
if (index === selectedViewIndex) {
iconClassName = classes.viewSelectorIconSelected;
}
return (
<Tooltip enterDelay={250} title={title} key={index} className={classes.viewIcon}>
<IconButton
color={index === selectedViewIndex ? 'primary' : 'secondary'}
className={iconClassName}
aria-label={title}
data-testid={`viewselector-${title}`}
onClick={() => setSelectedViewIndex(index)}
Expand All @@ -92,7 +115,7 @@ export const Site = ({ editingContextId, selection, setSelection, readOnly, side
{icon}
<Typography>{title}</Typography>
</div>
<div className={classes.viewContent} data-testid={`view-${title}`}>
<div data-testid={`view-${title}`}>
<Component
editingContextId={editingContextId}
selection={selection}
Expand Down

0 comments on commit 0154373

Please sign in to comment.