From eb7f0fdee70c6fc10bf931378f64fab76312198a Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 16 Oct 2024 14:03:36 -0700 Subject: [PATCH] fix: use widget controls layout --- .../src/layout/Controls/index.tsx | 2 +- .../widgets/SupernovaThreeVector/index.tsx | 141 ++++++++++-------- .../widgets/SupernovaThreeVector/styles.ts | 22 +-- 3 files changed, 81 insertions(+), 84 deletions(-) diff --git a/packages/epo-widget-lib/src/layout/Controls/index.tsx b/packages/epo-widget-lib/src/layout/Controls/index.tsx index 4204e5d4..4ebe340c 100644 --- a/packages/epo-widget-lib/src/layout/Controls/index.tsx +++ b/packages/epo-widget-lib/src/layout/Controls/index.tsx @@ -4,7 +4,7 @@ import * as Styled from "./styles"; interface WidgetControlsProps { widget: ReactNode; - controls: ReactNode; + controls?: ReactNode; ratio?: Ratios; controlsId?: string; actions?: ReactNode; diff --git a/packages/epo-widget-lib/src/widgets/SupernovaThreeVector/index.tsx b/packages/epo-widget-lib/src/widgets/SupernovaThreeVector/index.tsx index 6b2aebc2..ff5a20de 100644 --- a/packages/epo-widget-lib/src/widgets/SupernovaThreeVector/index.tsx +++ b/packages/epo-widget-lib/src/widgets/SupernovaThreeVector/index.tsx @@ -5,6 +5,8 @@ import HorizontalSlider from "@rubin-epo/epo-react-lib/HorizontalSlider"; import { ImageShape } from "@rubin-epo/epo-react-lib/Image"; import { ChartMargin, HistogramData } from "@/types/charts"; import { getLinearScale, between } from "@/lib/utils"; +import ResetButton from "@/atomic/Button/patterns/Reset"; +import Controls from "@/layout/Controls"; import { SkymapObject } from "./Skymap"; import LiveLabel from "./LiveLabel"; import * as Styled from "./styles"; @@ -82,74 +84,81 @@ const SupernovaThreeVector: FunctionComponent = ({ }, 0); return ( - - - - - {t("supernova_three_vector.histogram.title")} - - - - - - t("supernova_three_vector.slider.valueLabel", { value: valueNow }) - } - color="var(--turquoise85,#12726D)" - minLabel={`${xMin} Mlyr`} - maxLabel={`${xMax} Mlyr`} - onChangeCallback={(value) => - Array.isArray(value) && setActiveRange(value) - } - /> - - - - {t("supernova_three_vector.skymap.title")} - - + + + + {t("supernova_three_vector.histogram.title")} + + + + + + t("supernova_three_vector.slider.valueLabel", { + value: valueNow, + }) + } + color="var(--turquoise85,#12726D)" + minLabel={`${xMin} Mlyr`} + maxLabel={`${xMax} Mlyr`} + onChangeCallback={(value) => + Array.isArray(value) && setActiveRange(value) + } + /> + + + + {t("supernova_three_vector.skymap.title")} + + + + + - - setActiveRange([xMin, xMax])} - /> - - - + + } + actions={ + setActiveRange([xMin, xMax])} /> + } + > ); }; diff --git a/packages/epo-widget-lib/src/widgets/SupernovaThreeVector/styles.ts b/packages/epo-widget-lib/src/widgets/SupernovaThreeVector/styles.ts index 7c34dfd8..507af043 100644 --- a/packages/epo-widget-lib/src/widgets/SupernovaThreeVector/styles.ts +++ b/packages/epo-widget-lib/src/widgets/SupernovaThreeVector/styles.ts @@ -1,34 +1,26 @@ import styled from "styled-components"; import { token } from "@rubin-epo/epo-react-lib/styles"; -import AspectRatio from "@/layout/AspectRatio"; -import * as Button from "@/atomic/Button"; import DistanceHistogram from "./Histogram"; import BaseSkymap from "./Skymap"; -export const ThreeVectorContainer = styled(AspectRatio)` - container-type: inline-size; -`; - export const ThreeVectorLayout = styled.div` --three-vector-gap: calc(var(--PADDING_SMALL, 20px) / 2); display: grid; grid-template-columns: 1fr; - grid-template-rows: min-content 1fr min-content min-content; + grid-auto-rows: min-content; grid-template-areas: "skymap" "histogram" - "slider" - "reset"; + "slider"; gap: var(--three-vector-gap); - @container (min-width: ${token("BREAK_LARGE_TABLET")}) { + @media (orientation: landscape) { grid-template-columns: 1fr 1fr; - grid-template-rows: 1fr min-content min-content; + grid-template-rows: 1fr min-content; grid-template-areas: "histogram skymap" - "slider ." - "reset reset"; + "slider ."; } @container (min-width: ${token("BREAK_TABLET_MIN")}) { @@ -59,10 +51,6 @@ export const SliderContainer = styled.div` grid-area: slider; `; -export const ResetButton = styled(Button.Reset)` - grid-area: reset; -`; - export const SkymapContainer = styled.div` display: flex; flex-direction: column;