Skip to content

Commit

Permalink
improve styling
Browse files Browse the repository at this point in the history
  • Loading branch information
firsttris committed Dec 29, 2023
1 parent 359c541 commit de96d26
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 14 deletions.
17 changes: 12 additions & 5 deletions src/app/ChannelsForType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@ const ExpandMore = styled(Icon)<ExpandMoreProps>(({ expanded }) => ({
}));

const StyledCard = styled(Card)(({ theme }) => ({
maxWidth: 288,
[theme.breakpoints.down('md')]: {
width: '100%',
width: 288
}));

const StyledBox = styled(Box)(({ theme }) => ({
display: 'flex',
flexWrap: 'wrap',
gap: '5px',
[theme.breakpoints.down('sm')]: {
justifyContent: 'center',
},
}));


const getControlComponent = (channel: Channel, refetch: () => void) => {
switch (channel.type) {
case ChannelType.CLIMATECONTROL_FLOOR_TRANSCEIVER:
Expand Down Expand Up @@ -117,15 +124,15 @@ export const ChannelsForType: React.FC<ChannelTypeProps> = ({
setHasTransitionExited(true)
}
>
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: '5px' }}>
<StyledBox>
{channels.map((channel, index) => {
return (
<StyledCard key={index}>
{getControlComponent(channel, refetch)}
</StyledCard>
);
})}
</Box>
</StyledBox>
<Divider sx={{ mt: '10px' }} />
</Collapse>
</Box>
Expand Down
1 change: 0 additions & 1 deletion src/app/Room.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const Room = () => {
return <LinearProgress />;
}

console.log('channelsPerType', channelsPerType)
return (
<StyledContainer maxWidth="xl">
<List disablePadding={true}>
Expand Down
34 changes: 27 additions & 7 deletions src/app/controls/DoorControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@ import { Box, CardHeader, Typography } from '@mui/material';
import { StyledIconButton } from '../components/StyledIcons';
import { KeymaticChannel } from './../../types/types';
import { useSetValueMutation } from './../../hooks/useApi';
import { styled } from '@mui/system';

const StyledOuterBox = styled(Box)({
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
});

const StyledInnerBox = styled(Box)({
display: 'flex',
gap: '10px',
alignItems: 'center',
});

interface StyledTypographyProps {
isUncertain: boolean;
}
const StyledTypography = styled(Typography)<StyledTypographyProps>(({ isUncertain }) => ({
display: isUncertain ? 'block' : 'none',
}));

interface DoorControlProps {
channel: KeymaticChannel;
Expand Down Expand Up @@ -53,8 +73,8 @@ export const DoorControl: React.FC<DoorControlProps> = ({ channel, refetch }) =>
return (
<CardHeader
title={
<Box>
<Box sx={{ display: 'flex', gap: '10px', alignItems: 'center' }}>
<StyledOuterBox>
<StyledInnerBox>
<StyledIconButton
icon="material-symbols:lock-outline"
active={(!isUnlocked).toString()}
Expand All @@ -69,14 +89,14 @@ export const DoorControl: React.FC<DoorControlProps> = ({ channel, refetch }) =>
icon="material-symbols:door-open-outline"
onClick={openDoor}
/>
</Box>
<Typography
sx={{ display: isUncertain ? 'block' : 'none' }}
</StyledInnerBox>
<StyledTypography
isUncertain={isUncertain}
variant="caption"
>
Door state is uncertain
</Typography>
</Box>
</StyledTypography>
</StyledOuterBox>
}
/>
);
Expand Down
5 changes: 4 additions & 1 deletion src/app/controls/RainDetectionControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { StyledHeaderIcon } from '../components/StyledIcons';

const StyledBox = styled(Box)({
display: 'flex',
flexDirection: 'column',
flexDirection: 'row',
justifyContent: 'center',
width: '100%',
gap: '20px'
});

const StyledIconBox = styled(Box)({
Expand Down

0 comments on commit de96d26

Please sign in to comment.