From cb834c156b8bfdae8b19a4fb6e0f60a7251a23c4 Mon Sep 17 00:00:00 2001 From: e26chiu Date: Sun, 11 Dec 2022 20:46:11 -0500 Subject: [PATCH] Fix responsive problem with quotationCarousels --- components/QuotationCarousel.tsx | 8 +++++--- pages/intimacy-and-drugs.tsx | 18 +++++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/components/QuotationCarousel.tsx b/components/QuotationCarousel.tsx index fed81a7..e1adce1 100644 --- a/components/QuotationCarousel.tsx +++ b/components/QuotationCarousel.tsx @@ -6,12 +6,14 @@ import styles from "./QuotationCarousel.module.css"; interface QuotationCarouselProps { data: string[]; /** Width of the entire carousel including the buttons, in px. */ - width?: number; + width: number; /** Minimum height of the carousel, in px. */ height?: number; /** Diameter of the background circles, in px. Set to 0 for no circles. */ circleDiameter?: number; className?: string; + /** Minimum width of the graph. */ + minWidth?: number; } interface CarouselButtonProps { @@ -22,12 +24,12 @@ interface CarouselButtonProps { export function QuotationCarousel(props: QuotationCarouselProps) { const { data, - width = 600, height = 100, circleDiameter = 120, + minWidth = 600, className, } = props; - + const width = props.width < minWidth ? minWidth : props.width; const [activeIdx, setActiveIdx] = useState(0); function showNextCard() { diff --git a/pages/intimacy-and-drugs.tsx b/pages/intimacy-and-drugs.tsx index 0934e6c..d924cc1 100644 --- a/pages/intimacy-and-drugs.tsx +++ b/pages/intimacy-and-drugs.tsx @@ -91,7 +91,11 @@ export default function Demographics() { heading="How many committed relationships have you been in during university?" bodyText="Our respondents most commonly have been in either 0 or 1 committed relationship during their undergrad. On the other end, 5 is the most number of committed relationships indicated." > - + - + @@ -170,7 +178,7 @@ export default function Demographics() { data={I9} circleDiameter={0} width={barGraphWidth(isMobile, pageWidth)} - height={400} + height={isMobile ? 600 : 500} /> @@ -184,7 +192,7 @@ export default function Demographics() { data={I10} circleDiameter={0} width={barGraphWidth(isMobile, pageWidth)} - height={400} + height={600} />