Skip to content

Commit 231115d

Browse files
committed
Better responsive
1 parent 3354a4b commit 231115d

File tree

2 files changed

+15
-31
lines changed

2 files changed

+15
-31
lines changed

src/components/Topbar.tsx

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,15 @@ export default function TopBar({ octoprintState }: TopBarProps) {
4444
useEffect(() => {
4545
let color = "bg-green-500";
4646
let message = "";
47-
if (
48-
!backendStatus.connected &&
49-
octoprintState.connectionInfos.connected === false
50-
) {
47+
if (!backendStatus.connected && octoprintState.connectionInfos.connected === false) {
5148
color = "bg-red-600";
5249
message = "Backend is not connected and printer is disconnected.";
5350
setGlobalStatus({
5451
color,
5552
message,
5653
});
5754
return;
58-
} else if (
59-
!backendStatus.connected ||
60-
octoprintState.connectionInfos.connected === false
61-
) {
55+
} else if (!backendStatus.connected || octoprintState.connectionInfos.connected === false) {
6256
color = "bg-orange-400";
6357
}
6458
if (!backendStatus.connected) {
@@ -74,7 +68,7 @@ export default function TopBar({ octoprintState }: TopBarProps) {
7468
});
7569
}, [backendStatus, octoprintState.connectionInfos]);
7670
return (
77-
<div className="relative flex items-center justify-between bg-slate-800 sm:h-10 md:h-20">
71+
<div className="relative flex items-center justify-between bg-slate-800 sm:h-10 md:h-15 lg:h-20">
7872
<div className="flex flex-row items-center">
7973
{octoprintState.toolTemp.current !== 0 && (
8074
<>
@@ -83,9 +77,7 @@ export default function TopBar({ octoprintState }: TopBarProps) {
8377
</div>
8478
<p className="text-lg">
8579
{String(Math.round(octoprintState.toolTemp.current)) +
86-
(octoprintState.toolTemp.target !== 0
87-
? `/${octoprintState.toolTemp.target}`
88-
: "")}
80+
(octoprintState.toolTemp.target !== 0 ? `/${octoprintState.toolTemp.target}` : "")}
8981
</p>
9082
</>
9183
)}
@@ -96,9 +88,7 @@ export default function TopBar({ octoprintState }: TopBarProps) {
9688
</div>
9789
<p className="text-lg">
9890
{String(Math.round(octoprintState.bedTemp.current)) +
99-
(octoprintState.bedTemp.target !== 0
100-
? `/${octoprintState.bedTemp.target}`
101-
: "")}
91+
(octoprintState.bedTemp.target !== 0 ? `/${octoprintState.bedTemp.target}` : "")}
10292
</p>
10393
</>
10494
)}
@@ -112,7 +102,7 @@ export default function TopBar({ octoprintState }: TopBarProps) {
112102
<div
113103
className={cn(
114104
"flex items-center justify-center rounded-lg bg-slate-700 hover:cursor-pointer md:h-8 md:w-8 md:rounded-md lg:h-12 lg:w-12",
115-
loading && "!cursor-not-allowed",
105+
loading && "!cursor-not-allowed"
116106
)}
117107
onClick={async () => {
118108
if (loading) return;
@@ -122,8 +112,7 @@ export default function TopBar({ octoprintState }: TopBarProps) {
122112
message: "Refreshing status and trying to connect to printer...",
123113
});
124114
try {
125-
const response =
126-
await octoprintState.node.local.getBackendStatus();
115+
const response = await octoprintState.node.local.getBackendStatus();
127116
await octoprintState.node.printer.connectPrinter();
128117
setBackendStatus(response);
129118
} catch (error) {
@@ -135,12 +124,7 @@ export default function TopBar({ octoprintState }: TopBarProps) {
135124
}
136125
}}
137126
>
138-
<RefreshCw
139-
className={cn(
140-
"md:h-6 md:w-6 lg:h-8 lg:w-8",
141-
loading && "animate-spin",
142-
)}
143-
/>
127+
<RefreshCw className={cn("md:h-6 md:w-6 lg:h-8 lg:w-8", loading && "animate-spin")} />
144128
</div>
145129
</div>
146130
</div>

src/routes/app/Control.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,23 +111,23 @@ function GeneralControlPanel() {
111111
printer && (
112112
<div className="flex w-[50vw] flex-row items-center justify-center gap-6">
113113
<div>
114-
<div className="relative flex h-60 w-60 rounded-2xl border-2 border-transparent bg-gradient-to-br from-slate-800 to-slate-900 p-3 shadow-lg">
114+
<div className="relative flex rounded-2xl border-2 border-transparent bg-gradient-to-br from-slate-800 to-slate-900 p-3 shadow-lg md:h-30 md:w-60 lg:h-60 lg:w-60">
115115
<div
116-
className="absolute top-4 left-1/2 flex -translate-x-1/2 flex-col items-center justify-center"
116+
className="absolute flex flex-col items-center justify-center md:top-1/2 md:left-2 md:-translate-y-1/2 lg:top-4 lg:left-1/2 lg:-translate-x-1/2"
117117
onClick={() => printer.tool.extrude(-Number(step))}
118118
>
119119
<p className="text-base font-bold text-blue-400">Intrude</p>
120-
<ChevronUp size={50} />
120+
<ChevronUp size={50} className="md:-rotate-90 lg:rotate-0" />
121121
</div>
122122
<Nozzle
123123
className="absolute top-1/2 left-1/2 h-14 w-14 -translate-x-1/2 -translate-y-1/2"
124124
stroke="var(--color-blue-400)"
125125
/>
126126
<div
127-
className="absolute bottom-4 left-1/2 flex -translate-x-1/2 flex-col items-center justify-center"
127+
className="absolute flex items-center justify-center md:top-1/2 md:right-2 md:-translate-y-1/2 md:flex-col-reverse lg:bottom-4 lg:left-1/2 lg:flex-col"
128128
onClick={() => printer.tool.extrude(Number(step))}
129129
>
130-
<ChevronDown size={50} />
130+
<ChevronDown size={50} className="md:-rotate-90 lg:rotate-0" />
131131
<p className="text-base font-bold text-blue-400">Extrude</p>
132132
</div>
133133
</div>
@@ -157,13 +157,13 @@ function GeneralControlPanel() {
157157
</div>
158158
<div className="flex-col items-center justify-center">
159159
<TempViewer
160-
className={"mb-6 w-60"}
160+
className={"mb-6 md:w-30 xl:w-60"}
161161
inputClassName={"!w-25 !text-2xl"}
162162
octoprintState={OctoprintState}
163163
target="tool"
164164
/>
165165
<TempViewer
166-
className={"w-60"}
166+
className={"md:w-30 xl:w-60"}
167167
inputClassName={"!w-25 !text-2xl"}
168168
octoprintState={OctoprintState}
169169
target="bed"

0 commit comments

Comments
 (0)