Skip to content

Commit

Permalink
improve card layout
Browse files Browse the repository at this point in the history
  • Loading branch information
firsttris committed Dec 28, 2023
1 parent fd98591 commit 2346e81
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 169 deletions.
4 changes: 2 additions & 2 deletions src/app/BlindsControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export const BlindsControl = ({ channel }: ControlProps) => {
title={
<Box sx={{ display: 'flex', alignItems: 'center' }}>
{blindValue === 0 ? (
<BlindsClosedIcon sx={{ fontSize: '40px' }} />
<BlindsClosedIcon sx={{ fontSize: '30px' }} />
) : (
<BlindsOutlinedIcon sx={{ fontSize: '40px' }} />
<BlindsOutlinedIcon sx={{ fontSize: '30px' }} />
)}
<TypographyWithEllipsis>{name}</TypographyWithEllipsis>
</Box>
Expand Down
3 changes: 2 additions & 1 deletion src/app/FloorControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const FloorControl = (props: FloorControlProps) => {
<Icon
icon="mdi:radiator-coil"
color={getColor(value)}
fontSize={'40px'}
fontSize={'30px'}
/>
<Typography>{props.channel.name}</Typography>
</Box>
Expand All @@ -48,6 +48,7 @@ export const FloorControl = (props: FloorControlProps) => {

<CardContent sx={{ pt: '0px'}}>
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
<Icon icon="mdi:pipe-valve" fontSize="30px" style={{ marginRight: '5px'}} />
<Box sx={{ width: '100%', mr: 1 }}>
<LinearProgress variant="determinate" value={value} />
</Box>
Expand Down
6 changes: 3 additions & 3 deletions src/app/Room.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { useParams } from 'react-router-dom';
import { Channel, ChannelType, useGetChannelsForRoom } from '../hooks/useApi';
import { BlindsControl } from './BlindsControl';
import { LightControl } from './LightControl';
import { SwitchControl } from './SwitchControl';
import { ThermostatControl } from './ThermostatControl';
import { FloorControl } from './FloorControl';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
Expand Down Expand Up @@ -101,7 +101,7 @@ export const Room = () => {
case ChannelType.CLIMATECONTROL_FLOOR_TRANSCEIVER:
return <FloorControl channel={channel} />;
case ChannelType.SWITCH_VIRTUAL_RECEIVER:
return <LightControl refetch={refetch} channel={channel} />;
return <SwitchControl refetch={refetch} channel={channel} />;
case ChannelType.HEATING_CLIMATECONTROL_TRANSCEIVER:
return <ThermostatControl channel={channel} />;
case ChannelType.BLIND_VIRTUAL_RECEIVER:
Expand All @@ -126,7 +126,7 @@ export const Room = () => {
return channels.length ? (
<Box key={index}>
<ListItem disablePadding={true}>
<ListItemButton
<ListItemButton sx={{ '&:hover': { backgroundColor: 'transparent' } }}
onClick={() => handleExpandClick(channelType)}
disableRipple={true}
>
Expand Down
28 changes: 11 additions & 17 deletions src/app/LightControl.tsx → src/app/SwitchControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,15 @@ import {
SwitchVirtualReceiverChannel,
useSetValueMutation,
} from '../hooks/useApi';
import LightbulbOutlinedIconBase from '@mui/icons-material/LightbulbOutlined';
import LightbulbIconBase from '@mui/icons-material/Lightbulb';
import { IconButtonWithHover } from './components/IconButtonWithHover';
import { TypographyWithEllipsis } from './components/TypographyWithEllipsis';
import { Icon } from '@iconify/react';

interface ControlProps {
channel: SwitchVirtualReceiverChannel;
refetch: () => void;
}

const LightbulbIcon = styled(LightbulbIconBase)({
cursor: 'pointer',
color: 'orange',
fontSize: '40px',
});

const LightbulbOutlinedIcon = styled(LightbulbOutlinedIconBase)({
cursor: 'pointer',
fontSize: '40px',
});

const StyledBox = styled(Box)({
display: 'flex',
flexDirection: 'column',
Expand All @@ -35,9 +23,7 @@ const TitleBox = styled(Box)({
alignItems: 'center',
});



export const LightControl = ({ channel, refetch }: ControlProps) => {
export const SwitchControl = ({ channel, refetch }: ControlProps) => {
const setValueMutation = useSetValueMutation();
const { datapoints, name, address, interfaceName } = channel;
const checked = datapoints.STATE === 'true';
Expand All @@ -60,7 +46,15 @@ export const LightControl = ({ channel, refetch }: ControlProps) => {
title={
<TitleBox>
<IconButtonWithHover onClick={onHandleChange}>
{checked ? <LightbulbIcon /> : <LightbulbOutlinedIcon />}
{checked ? (
<Icon
icon="mdi:light-switch"
fontSize="40px"
color="orange"
/>
) : (
<Icon icon="mdi:light-switch-off" fontSize="40px" />
)}
</IconButtonWithHover>
<TypographyWithEllipsis>{name}</TypographyWithEllipsis>
</TitleBox>
Expand Down
Loading

0 comments on commit 2346e81

Please sign in to comment.