1+ import type { ClassValue } from "clsx" ;
12import { useEffect , useState } from "react" ;
23import { useOutletContext } from "react-router-dom" ;
34import { toast } from "sonner" ;
@@ -11,27 +12,29 @@ import ControlledInput from "../ControlledInput";
1112import HeatedPlate from "../svg/HeatedPlate" ;
1213import 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 >
0 commit comments