Skip to content

Commit 3354a4b

Browse files
committed
Added attributes organizer + right side of control
1 parent e8494be commit 3354a4b

File tree

6 files changed

+215
-37
lines changed

6 files changed

+215
-37
lines changed

.prettierrc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22
"tabWidth": 2,
33
"useTabs": false,
44
"semi": true,
5-
"printWidth": 80,
5+
"printWidth": 120,
6+
"trailingComma": "es5",
7+
"bracketSpacing": true,
8+
"arrowParens": "always",
9+
"bracketSameLine": false,
10+
611
"plugins": [
712
"@ianvs/prettier-plugin-sort-imports",
13+
"prettier-plugin-organize-attributes",
814
"prettier-plugin-tailwindcss"
915
],
1016
"importOrder": [

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@radix-ui/react-progress": "^1.1.7",
2020
"@radix-ui/react-radio-group": "^1.3.7",
2121
"@radix-ui/react-select": "^2.2.5",
22+
"@radix-ui/react-slider": "^1.3.5",
2223
"@radix-ui/react-slot": "^1.2.3",
2324
"@radix-ui/react-switch": "^1.2.5",
2425
"@radix-ui/react-tabs": "^1.1.12",
@@ -65,6 +66,7 @@
6566
"eslint-plugin-react-refresh": "^0.4.19",
6667
"globals": "^16.0.0",
6768
"prettier": "^3.5.3",
69+
"prettier-plugin-organize-attributes": "^1.0.0",
6870
"prettier-plugin-tailwindcss": "^0.6.12",
6971
"tw-animate-css": "^1.3.0",
7072
"typescript": "~5.8.3",

pnpm-lock.yaml

Lines changed: 51 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/home/PrinterStatus.tsx

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ClassValue } from "clsx";
12
import { useEffect, useState } from "react";
23
import { useOutletContext } from "react-router-dom";
34
import { toast } from "sonner";
@@ -11,27 +12,29 @@ import ControlledInput from "../ControlledInput";
1112
import HeatedPlate from "../svg/HeatedPlate";
1213
import Nozzle from "../svg/Nozzle";
1314

14-
function TempViewer({
15+
export function TempViewer({
1516
octoprintState,
1617
target,
18+
className,
19+
inputClassName,
1720
}: {
1821
octoprintState: OctoprintState;
1922
target: PrinterTarget;
23+
className?: ClassValue;
24+
inputClassName?: ClassValue;
2025
}) {
2126
const [tempInput, setNumberInput] = useState("");
2227
const [temp, setTemp] = useState<Temp | undefined>(undefined);
2328

2429
useEffect(() => {
25-
setTemp(
26-
target === "tool" ? octoprintState.toolTemp : octoprintState.bedTemp,
27-
);
30+
setTemp(target === "tool" ? octoprintState.toolTemp : octoprintState.bedTemp);
2831
}, [octoprintState]);
2932

3033
return (
3134
<div
3235
className={cn(
33-
"sm:gap-3sm:p-2 relative flex flex-1 flex-col items-center justify-between gap-2 rounded-2xl border-2 border-transparent bg-gradient-to-br from-slate-800 to-slate-900 p-2 !px-0 shadow-lg transition hover:border-blue-500 active:scale-100 sm:p-2 md:p-5",
34-
"min-w-0",
36+
"sm:gap-3sm:p-2 relative flex min-w-0 flex-1 flex-col items-center justify-between gap-2 rounded-2xl border-2 border-transparent bg-gradient-to-br from-slate-800 to-slate-900 p-2 !px-0 shadow-lg transition hover:border-blue-500 active:scale-100 sm:p-2 md:p-5",
37+
className
3538
)}
3639
style={{
3740
minWidth: 0,
@@ -41,10 +44,7 @@ function TempViewer({
4144
{target === "tool" ? (
4245
<Nozzle stroke={"var(--nozzle-color)"} className="h-full w-full" />
4346
) : (
44-
<HeatedPlate
45-
stroke={"var(--heated-bed-color)"}
46-
className="h-full w-full"
47-
/>
47+
<HeatedPlate stroke={"var(--heated-bed-color)"} className="h-full w-full" />
4848
)}
4949
</div>
5050
{temp && (
@@ -62,30 +62,24 @@ function TempViewer({
6262
toast.success(`Set ${target}'s temp to ${Number(input)}°C`);
6363
})
6464
.catch((e) => {
65-
toast.error(
66-
`Failed to set ${target}'s temp to ${Number(input)}°C: ${e.message}`,
67-
);
65+
toast.error(`Failed to set ${target}'s temp to ${Number(input)}°C: ${e.message}`);
6866
});
6967
setNumberInput("");
7068
setIsKeyboardVisible(false);
7169
}}
7270
inputClassName={cn(
7371
"text-center w-20 sm:w-28 sm:text-4xl xl:w-50 2xl:w-80 lg:text-5xl",
74-
target === "tool"
75-
? "text-blue-200 font-bold"
76-
: "text-yellow-200 font-bold",
72+
target === "tool" ? "text-blue-200 font-bold" : "text-yellow-200 font-bold",
73+
inputClassName
7774
)}
7875
className="flex flex-col items-center justify-center gap-2 text-center"
7976
/>
8077
)}
81-
<p className="text-lg text-slate-500 sm:text-xl">
82-
{temp && (temp.target !== 0 ? `${temp.target}` : "")}
83-
</p>
84-
{/* Optional: bottom colored bar for accent */}
78+
<p className="text-lg text-slate-500 sm:text-xl">{temp && (temp.target !== 0 ? `${temp.target}` : "")}</p>
8579
<div
8680
className={cn(
8781
"absolute bottom-0 h-2 w-full rounded-b-2xl",
88-
target === "tool" ? "bg-blue-500" : "bg-yellow-500",
82+
target === "tool" ? "bg-blue-500" : "bg-yellow-500"
8983
)}
9084
/>
9185
</div>

src/components/ui/slider.tsx

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import * as React from "react"
2+
import * as SliderPrimitive from "@radix-ui/react-slider"
3+
4+
import { cn } from "@/lib/utils"
5+
6+
function Slider({
7+
className,
8+
defaultValue,
9+
value,
10+
min = 0,
11+
max = 100,
12+
...props
13+
}: React.ComponentProps<typeof SliderPrimitive.Root>) {
14+
const _values = React.useMemo(
15+
() =>
16+
Array.isArray(value)
17+
? value
18+
: Array.isArray(defaultValue)
19+
? defaultValue
20+
: [min, max],
21+
[value, defaultValue, min, max]
22+
)
23+
24+
return (
25+
<SliderPrimitive.Root
26+
data-slot="slider"
27+
defaultValue={defaultValue}
28+
value={value}
29+
min={min}
30+
max={max}
31+
className={cn(
32+
"relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
33+
className
34+
)}
35+
{...props}
36+
>
37+
<SliderPrimitive.Track
38+
data-slot="slider-track"
39+
className={cn(
40+
"bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
41+
)}
42+
>
43+
<SliderPrimitive.Range
44+
data-slot="slider-range"
45+
className={cn(
46+
"bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"
47+
)}
48+
/>
49+
</SliderPrimitive.Track>
50+
{Array.from({ length: _values.length }, (_, index) => (
51+
<SliderPrimitive.Thumb
52+
data-slot="slider-thumb"
53+
key={index}
54+
className="border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
55+
/>
56+
))}
57+
</SliderPrimitive.Root>
58+
)
59+
}
60+
61+
export { Slider }

0 commit comments

Comments
 (0)