diff --git a/apps/quartz-app/src/components/InfoTooltip.tsx b/apps/quartz-app/src/components/InfoTooltip.tsx new file mode 100644 index 00000000..a8dfab70 --- /dev/null +++ b/apps/quartz-app/src/components/InfoTooltip.tsx @@ -0,0 +1,59 @@ +type TooltipProps = { + children: React.ReactNode; + tip: string | React.ReactNode; + position?: "left" | "right" | "middle" | "top"; + className?: string; + fullWidth?: boolean; +}; + +const Tooltip: React.FC = ({ + children, + tip, + position, + className, + fullWidth = false, +}) => { + let containerPositionClass = ""; + let tipPositionClass = ""; + switch (position) { + case "left": + containerPositionClass = "right-1"; + tipPositionClass = "-right-1 top-2"; + break; + case "right": + containerPositionClass = "left-1"; + tipPositionClass = "-left-1 top-2"; + break; + // case "middle": + // containerPositionClass = "right-5"; + // // containerPositionClass = "left-1/2 transform -translate-x-1/2"; + // tipPositionClass = "-right-1 top-0"; + // break; + // case "top": + // containerPositionClass = "bottom-5 right-2"; + // tipPositionClass = "-right-2 bottom-0"; + } + return ( +
+ {position !== "top" && children} + + {position === "top" && children} +
+ ); +}; + +export default Tooltip; diff --git a/apps/quartz-app/src/components/charts/Charts.tsx b/apps/quartz-app/src/components/charts/Charts.tsx index dcfd81ea..e185d115 100644 --- a/apps/quartz-app/src/components/charts/Charts.tsx +++ b/apps/quartz-app/src/components/charts/Charts.tsx @@ -19,7 +19,6 @@ import { SOLAR_COLOR, WIND_COLOR, } from "@/src/constants"; -import { LegendContainer } from "@/src/components/charts/legend/LegendContainer"; import { formatEpochToHumanDayName, formatEpochToPrettyTime, @@ -32,8 +31,7 @@ import { useChartData } from "@/src/hooks/useChartData"; import { CustomLabel } from "@/src/components/charts/labels/CustomLabel"; import { useGlobalState } from "../helpers/globalState"; import { DateTime } from "luxon"; -import { components } from "@/src/types/schema"; -import Spinner, { SpinnerTextInline } from "@/src/components/icons/icons"; +import { Spinner, SpinnerTextInline } from "@/src/components/icons/icons"; import HorizonSelect from "@/src/components/charts/HorizonSelect"; type ChartsProps = { diff --git a/apps/quartz-app/src/components/charts/HorizonSelect.tsx b/apps/quartz-app/src/components/charts/HorizonSelect.tsx index d377926d..e3b828bd 100644 --- a/apps/quartz-app/src/components/charts/HorizonSelect.tsx +++ b/apps/quartz-app/src/components/charts/HorizonSelect.tsx @@ -1,6 +1,44 @@ import { ChangeEvent, FC } from "react"; import { components } from "@/src/types/schema"; import useGlobalState from "../helpers/globalState"; +import { InfoIcon } from "../icons/icons"; +import InfoTooltip from "../InfoTooltip"; + +const HorizonInfo: FC = () => { + return ( + +
+ Latest +

The most up-to-date forecast data available

+
+
+ Horizon 1.5h/3h +

The forecast made N hours before the target time.

+

+ E.g. The 3 hour horizon forecast for 11am, was created at 8am the + same day. +

+
+
+ Day Ahead +

Forecast at 9.00 IST the day before.

+

+ E.g. The forecast for 11am, or any time in a day, was created at + 9am the day before. +

+
+ + } + position="left" + className={""} + fullWidth + > + +
+ ); +}; const HorizonSelect: FC = () => { const [forecastHorizon, setForecastHorizon] = @@ -37,11 +75,11 @@ const HorizonSelect: FC = () => { } }; return ( - <> +
- +
+ +
+
); }; diff --git a/apps/quartz-app/src/components/icons/icons.tsx b/apps/quartz-app/src/components/icons/icons.tsx index 1239f3b3..6afca396 100644 --- a/apps/quartz-app/src/components/icons/icons.tsx +++ b/apps/quartz-app/src/components/icons/icons.tsx @@ -205,7 +205,7 @@ type SpinnerProps = { children?: React.ReactNode; }; -const Spinner: React.FC = ({ className = "" }) => { +export const Spinner: React.FC = ({ className = "" }) => { return ( = ({ className = "" }) => { ); }; -export default Spinner; - export const SpinnerSmall = (props: React.SVGProps) => (