diff --git a/global.d.ts b/global.d.ts index 584cfa9..946171c 100644 --- a/global.d.ts +++ b/global.d.ts @@ -1,2 +1,4 @@ // without this TypeScript complains when importing CSS files -declare module '*.css'; \ No newline at end of file +declare module '*.css'; +declare module '*.png'; +declare module '*.ttf'; \ No newline at end of file diff --git a/src/Plant/DigitalWatch/DigitalWatch.tsx b/src/Plant/DigitalWatch/DigitalWatch.tsx new file mode 100644 index 0000000..e1d24a3 --- /dev/null +++ b/src/Plant/DigitalWatch/DigitalWatch.tsx @@ -0,0 +1,68 @@ +import { useRef } from "react"; + +import imgNote from "./noteSmall.png"; +import imgWatch from "./watch.png"; +import imgWatchLight from "./watch-light.png"; +import digitalFont from "./digital-font.ttf"; + +type DigitalWatchProps = { + light: boolean; + h: number; + m: number; + s: number; + alarm: boolean; + callbacks: { + onTopLeftPressed: () => void; + onTopRightPressed: () => void; + onBottomRightPressed: () => void; + onBottomLeftPressed: () => void; + onTopLeftReleased: () => void; + onTopRightReleased: () => void; + onBottomRightReleased: () => void; + onBottomLeftReleased: () => void; + }, +} + +export function DigitalWatch({light, h, m, s, alarm, callbacks}: DigitalWatchProps) { + const refText = useRef(null); + const twoDigits = (n: number) => ("0"+n.toString()).slice(-2); + const hhmmss = `${twoDigits(h)}:${twoDigits(m)}:${twoDigits(s)}`; + + return <> + + + {light ? + + : + } + + {hhmmss} + + callbacks.onTopLeftPressed()} + onMouseUp={() => callbacks.onTopLeftReleased()} + /> + callbacks.onTopRightPressed()} + onMouseUp={() => callbacks.onTopRightReleased()} + /> + callbacks.onBottomLeftPressed()} + onMouseUp={() => callbacks.onBottomLeftReleased()} + /> + callbacks.onBottomRightPressed()} + onMouseUp={() => callbacks.onBottomRightReleased()} + /> + + {alarm && + + } + + ; +} diff --git a/src/Plant/DigitalWatch/digital-font.ttf b/src/Plant/DigitalWatch/digital-font.ttf new file mode 100644 index 0000000..a481b97 Binary files /dev/null and b/src/Plant/DigitalWatch/digital-font.ttf differ diff --git a/src/Plant/DigitalWatch/noteSmall.png b/src/Plant/DigitalWatch/noteSmall.png new file mode 100644 index 0000000..c64fb6f Binary files /dev/null and b/src/Plant/DigitalWatch/noteSmall.png differ diff --git a/src/Plant/DigitalWatch/watch-light.png b/src/Plant/DigitalWatch/watch-light.png new file mode 100644 index 0000000..a510178 Binary files /dev/null and b/src/Plant/DigitalWatch/watch-light.png differ diff --git a/src/Plant/DigitalWatch/watch.png b/src/Plant/DigitalWatch/watch.png new file mode 100644 index 0000000..d76c31e Binary files /dev/null and b/src/Plant/DigitalWatch/watch.png differ