-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bca5cb5
commit 2803d99
Showing
9 changed files
with
123 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-FileCopyrightText: © 2024 Amber Cronin <software@amber.vision> | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
import styled from "styled-components"; | ||
import { StyledText, StyledHeader } from "../../utils/theme"; | ||
|
||
import { type Group } from "../../../../types/zigbee_types"; | ||
|
||
const Card = styled.div` | ||
margin: 2em 0em; | ||
padding: 1em; | ||
cursor: pointer; | ||
border-radius: 2rem; | ||
&:hover { | ||
background-color: ${({ theme }) => theme.hover}; | ||
} | ||
`; | ||
|
||
function GroupCard(props: { group: Group; onClick: Function }) { | ||
return ( | ||
<Card onClick={props.onClick}> | ||
<StyledHeader>{props.group.friendly_name}</StyledHeader> | ||
<StyledText>{`${props.group.members.length} devices`}</StyledText> | ||
</Card> | ||
); | ||
} | ||
|
||
export default GroupCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-FileCopyrightText: © 2024 Amber Cronin <software@amber.vision> | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
import { Link } from "wouter"; | ||
import GroupCard from "../GroupCard/GroupCard"; | ||
import { type Group } from "../../../../types/zigbee_types"; | ||
|
||
function GroupList(props: { groups: Group[]; onClick?: Function }) { | ||
return ( | ||
<div> | ||
{props.groups.map((group: Group) => ( | ||
<Link href={`/groups/${group.id}`} key={group.id}> | ||
<GroupCard group={group} onClick={() => props.onClick} /> | ||
</Link> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
export default GroupList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-FileCopyrightText: © 2024 Amber Cronin <software@amber.vision> | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
import LoadingSpinner from "../../components/LoadingSpinner/LoadingSpinner"; | ||
import GroupList from "../../components/GroupList/GroupList"; | ||
|
||
function Groups(props) { | ||
const selectedGroup = props.selectedGroup; | ||
|
||
let groupContent = undefined; | ||
|
||
if (!props.groups || !selectedGroup) groupContent = <LoadingSpinner />; | ||
|
||
if (selectedGroup) groupContent = <GroupSettings group={selectedGroup} />; | ||
|
||
if (props.groups && !selectedGroup) { | ||
groupContent = <GroupList groups={props.groups} />; | ||
} | ||
|
||
return <>{groupContent !== undefined ? groupContent : ""}</>; | ||
} | ||
|
||
export default Groups; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters