From bb7f9fa348d6acf9b9e2ae927fa15d19e6be282f Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Wed, 13 Apr 2022 21:50:01 +0100 Subject: [PATCH] Clean up code --- components/poll/poll.tsx | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/components/poll/poll.tsx b/components/poll/poll.tsx index 8c48fcc2e..1b62073d9 100644 --- a/components/poll/poll.tsx +++ b/components/poll/poll.tsx @@ -71,14 +71,9 @@ export const ControlledScrollDiv: React.VoidFunctionComponent<{ ); }; -const Poll: React.VoidFunctionComponent< - PollProps & { - width?: number; - sidebarWidth?: number; - columnWidth?: number; - actionColumnWidth?: number; - } -> = ({ +const minSidebarWidth = 200; + +const Poll: React.VoidFunctionComponent = ({ pollId, role, timeZone, @@ -87,27 +82,21 @@ const Poll: React.VoidFunctionComponent< highScore, targetTimeZone, onChangeTargetTimeZone, - actionColumnWidth = 160, - sidebarWidth: minSidebarWidth = 200, - columnWidth: defaultColumnWidth, - width: defaultWidth, }) => { const { t } = useTranslation("app"); - const [ref, { width: measuredWidth }] = useMeasure(); + const [ref, { width }] = useMeasure(); const [editingParticipantId, setEditingParticipantId] = React.useState(null); - const width = defaultWidth ?? measuredWidth; - const columnWidth = - defaultColumnWidth ?? - Math.min( - 100, - Math.max( - 95, - (width - minSidebarWidth - actionColumnWidth) / options.length, - ), - ); + const actionColumnWidth = 160; + const columnWidth = Math.min( + 100, + Math.max( + 95, + (width - minSidebarWidth - actionColumnWidth) / options.length, + ), + ); const numberOfVisibleColumns = Math.min( options.length,