Skip to content

Commit f15c542

Browse files
Add navbar, button grid
1 parent 1ddc61c commit f15c542

File tree

12 files changed

+89
-43
lines changed

12 files changed

+89
-43
lines changed
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
# multi stage 🚀
2-
3-
FROM node:16.10-alpine3.11 AS build
1+
FROM node:lts-alpine AS build
42
WORKDIR /app
53
COPY ./ /app/
4+
ENV NODE_ENV production
65
RUN yarn install
76
RUN yarn build
87

98
FROM nginx:stable-alpine AS production
10-
LABEL org.opencontainers.image.source https://github.com/amberstarlight/zigbee-webui
11-
ENV NODE_ENV production
9+
LABEL org.opencontainers.image.source="https://github.com/amberstarlight/starlight"
1210
COPY --from=build /app/build /usr/share/nginx/html
1311
COPY .nginx.conf /etc/nginx/conf.d/default.conf
1412
EXPOSE 80
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,19 @@ services:
2020
network_mode: host
2121
privileged: true
2222
environment:
23-
- TZ=Europe/London
24-
env_file:
25-
- .env
23+
TZ: "Europe/London"
24+
ZIGBEE2MQTT_CONFIG_SERIAL_PORT: "/dev/ttyUSB0"
25+
ZIGBEE2MQTT_CONFIG_ADVANCED_RTSCTS: "false"
26+
ZIGBEE2MQTT_CONFIG_PERMIT_JOIN: "false"
2627

27-
webserver:
28-
container_name: zigbee_webui
29-
image: ghcr.io/amberstarlight/zigbee-webui:latest
28+
api:
29+
container_name: starlight_api
30+
image: ghcr.io/amberstarlight/starlight/ui:latest
31+
ports:
32+
- "80:80"
33+
34+
ui:
35+
container_name: starlight_ui
36+
image: gchr.io/amberstarlight/starlight/api:latest
3037
ports:
3138
- "80:80"

packages/ui/.env.production

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# .env.production
2+
VITE_API_URL=http://io.local

packages/ui/src/App.tsx

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ import styled, { ThemeProvider } from "styled-components";
88
import { GlobalStyles } from "./components/GlobalStyles/globalStyles";
99
import { useDarkMode } from "./components/UseDarkMode/useDarkMode";
1010
import { StyledText, themeColours, darkThemeColours } from "./utils/theme";
11+
import "./font.css";
1112

1213
import Devices from "./pages/Devices/Devices";
1314
import Settings from "./pages/Settings/Settings";
1415
import Groups from "./pages/Groups/Groups";
1516

17+
import NavBar from "./components/NavBar/NavBar";
1618
import Button from "./components/Button/Button";
1719
import DeviceSettings from "./components/DeviceSettings/DeviceSettings";
1820
import { type Device, type Group } from "starlight/types";
@@ -22,13 +24,6 @@ const Wrapper = styled.div`
2224
padding: 2em;
2325
`;
2426

25-
const NavBar = styled.div`
26-
display: flex;
27-
align-items: center;
28-
justify-content: center;
29-
margin-bottom: 1em;
30-
`;
31-
3227
const backend = import.meta.env.VITE_API_URL ?? "";
3328

3429
function App() {
@@ -52,17 +47,21 @@ function App() {
5247
<ThemeProvider theme={themeMode}>
5348
<GlobalStyles />
5449
<Wrapper>
55-
<NavBar>
56-
<Link href={"/devices"}>
57-
<Button text={"Devices"} />
58-
</Link>
59-
<Link href={"/groups"}>
60-
<Button text={"Groups"} />
61-
</Link>
62-
<Link href={"/settings"}>
63-
<Button text={"Settings"} />
64-
</Link>
65-
</NavBar>
50+
<NavBar
51+
items={
52+
<>
53+
<Link href={"/devices"}>
54+
<Button text={"Devices"} />
55+
</Link>
56+
<Link href={"/groups"}>
57+
<Button text={"Groups"} />
58+
</Link>
59+
<Link href={"/settings"}>
60+
<Button text={"Settings"} />
61+
</Link>
62+
</>
63+
}
64+
></NavBar>
6665

6766
{/* routes */}
6867
<Route path={"/devices"}>

packages/ui/src/components/Button/Button.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ const StyledButton = styled.button`
77
font-family: "Lilex Medium", monospace;
88
border: none;
99
padding: 0.75em 2em;
10+
margin-right: 0.5em;
1011
background: none;
1112
1213
display: inline-block;
13-
margin: 0.5rem;
1414
color: ${({ theme }) => theme.accent};
15-
border-radius: 0.25rem;
1615
border: 1px solid ${(props) => props.theme.accent};
1716
background: transparent;
1817
text-align: center;
@@ -23,12 +22,15 @@ const StyledButton = styled.button`
2322
background-color: ${({ theme }) => theme.accent};
2423
color: ${(props) => props.theme.background};
2524
}
25+
26+
&:is(:last-child):not(:first-child) {
27+
margin-right: 0;
28+
}
2629
`;
2730

2831
function Button(props) {
2932
return (
3033
<StyledButton
31-
className={props.className}
3234
type={props.type || "button"}
3335
disabled={props.disabled || false}
3436
onClick={props.onClick}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// SPDX-FileCopyrightText: © 2024 Amber Cronin <software@amber.vision>
2+
// SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+
import { ReactElement } from "react";
5+
import styled from "styled-components";
6+
7+
const StyledButtonGrid = styled.div`
8+
display: grid;
9+
grid-template-columns: repeat(auto-fit, minmax(9%, 1fr));
10+
`;
11+
12+
interface buttons {
13+
buttons: ReactElement[];
14+
}
15+
16+
function ButtonGrid(props: buttons) {
17+
return <StyledButtonGrid>{props.buttons}</StyledButtonGrid>;
18+
}
19+
20+
export default ButtonGrid;

packages/ui/src/components/ColorPicker/ColorPicker.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ function ColorPicker(props) {
66
<>
77
<label>
88
{props.label}
9-
<input type="color" value={props.value} onChange={props.onChange} />
9+
<input
10+
type="color"
11+
value={props.value}
12+
onChange={props.onChange}
13+
/>
1014
</label>
1115
<p>{props.value}</p>
1216
</>

packages/ui/src/components/DeviceCard/DeviceCard.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ const Card = styled.div`
2626
&:hover {
2727
background-color: ${({ theme }) => theme.hover};
2828
}
29-
30-
> *:visited {
31-
border: none;
32-
}
3329
`;
3430

3531
function DeviceCard(props: {

packages/ui/src/components/DeviceSettings/DeviceSettings.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ function DeviceSettings(props) {
7171
onChange={(event) => {
7272
const newFriendlyName = event.target.value;
7373
setDeviceFriendlyNameState(newFriendlyName);
74-
setDeviceFriendlyNameState(
75-
props.device.friendly_name,
76-
deviceFriendlyNameState,
77-
);
7874
}}
7975
/>
8076
<h3>{deviceDescription(deviceDefinition)}</h3>

packages/ui/src/components/EditableText/EditableText.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ function EditableText(props: EditableTextProps) {
6161

6262
const handleBlur = (event) => {
6363
setEditable(false);
64-
console.log(event.target.defaultValue);
6564
};
6665

6766
const handleFocus = () => {

0 commit comments

Comments
 (0)