From 599e968c22b2efdbf40eaabc4f6b332a0b588724 Mon Sep 17 00:00:00 2001 From: MauriceNino Date: Sat, 31 Dec 2022 16:51:59 +0100 Subject: [PATCH] fix(view): errors for transient props in styled-components --- apps/view/src/components/chart-container.tsx | 18 +++++------- apps/view/src/components/glass-pane.tsx | 19 +++++++----- .../components/hardware-info-container.tsx | 19 ++++++------ .../src/components/main-widget-container.tsx | 29 ++++++++++--------- apps/view/src/widgets/server.tsx | 8 ++--- libs/common/src/types.ts | 4 +++ 6 files changed, 52 insertions(+), 45 deletions(-) diff --git a/apps/view/src/components/chart-container.tsx b/apps/view/src/components/chart-container.tsx index 307c6772a..9e710a0e2 100644 --- a/apps/view/src/components/chart-container.tsx +++ b/apps/view/src/components/chart-container.tsx @@ -1,3 +1,4 @@ +import { Transient } from '@dash/common'; import { motion } from 'framer-motion'; import { forwardRef, ReactElement } from 'react'; import { SwapSpinner } from 'react-spinners-kit'; @@ -5,18 +6,17 @@ import ReactVirtualizedAutoSizer from 'react-virtualized-auto-sizer'; import styled, { useTheme } from 'styled-components'; import { useIsMobile } from '../services/mobile'; -type ContainerProps = { - mobile: boolean; +type ContainerProps = Transient<{ edges: [boolean, boolean, boolean, boolean]; loading: boolean; -}; +}>; const Container = styled.div` position: relative; display: flex; min-width: 0; background-color: ${({ theme }) => theme.colors.surface}; - border-radius: ${({ edges: [top, right, bottom, left] }) => + border-radius: ${({ $edges: [top, right, bottom, left] }) => `${top ? '25px' : '10px'} ${right ? '25px' : '10px'} ${ bottom ? '25px' : '10px' } ${left ? '25px' : '10px'}`}; @@ -28,8 +28,8 @@ const Container = styled.div` > div { overflow: hidden; - ${({ edges: [top, right, bottom, left], loading }) => - !loading && + ${({ $edges: [top, right, bottom, left], $loading }) => + !$loading && ` position: absolute; border-radius: ${`${top ? '25px' : '10px'} ${right ? '25px' : '10px'} ${ @@ -76,14 +76,12 @@ type ChartContainerProps = { export const ChartContainer = motion( forwardRef((props, ref) => { const theme = useTheme(); - const isMobile = useIsMobile(); return ( {props.contentLoaded ? ( <> diff --git a/apps/view/src/components/glass-pane.tsx b/apps/view/src/components/glass-pane.tsx index 1a12a4b91..6e623cdbb 100644 --- a/apps/view/src/components/glass-pane.tsx +++ b/apps/view/src/components/glass-pane.tsx @@ -1,17 +1,20 @@ +import { Transient } from '@dash/common'; import { motion } from 'framer-motion'; import { forwardRef } from 'react'; import styled from 'styled-components'; import { useIsMobile } from '../services/mobile'; -type SCProps = GlassPaneProps & { mobile: boolean }; +type SCProps = Transient< + Pick & { mobile: boolean } +>; const Container = styled.div` - min-width: ${({ minWidth, mobile }) => (mobile ? 0 : minWidth)}px; - width: ${({ mobile }) => (mobile ? '100%' : 'unset')}; + min-width: ${({ $minWidth, $mobile }) => ($mobile ? 0 : $minWidth)}px; + width: ${({ $mobile }) => ($mobile ? '100%' : 'unset')}; min-height: 360px; - max-height: ${({ mobile }) => (mobile ? 'unset' : '500px')}; + max-height: ${({ $mobile }) => ($mobile ? 'unset' : '500px')}; - flex-grow: ${props => props.grow ?? 1}; + flex-grow: ${({ $grow }) => $grow ?? 1}; transition: opacity 0.3 ease-in-out; display: flex; @@ -35,9 +38,9 @@ export const GlassPane = motion( return ( {props.children} diff --git a/apps/view/src/components/hardware-info-container.tsx b/apps/view/src/components/hardware-info-container.tsx index 2fe10fa87..757d076aa 100644 --- a/apps/view/src/components/hardware-info-container.tsx +++ b/apps/view/src/components/hardware-info-container.tsx @@ -1,3 +1,4 @@ +import { Transient } from '@dash/common'; import { IconProp } from '@fortawesome/fontawesome-svg-core'; import { faArrowLeft, faArrowRight } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; @@ -8,18 +9,18 @@ import { useIsMobile } from '../services/mobile'; import { InfoTable, InfoTableProps } from './info-table'; import { ThemedText } from './text'; -const Container = styled.div<{ mobile: boolean }>` +const Container = styled.div` position: relative; display: flex; flex-direction: column; width: 100%; `; -const ContentContainer = styled.div<{ mobile: boolean }>` +const ContentContainer = styled.div>` display: flex; - flex-direction: ${({ mobile }) => (mobile ? 'column-reverse' : 'row')}; + flex-direction: ${({ $mobile }) => ($mobile ? 'column-reverse' : 'row')}; flex: 1 1 auto; - ${({ mobile }) => mobile && 'padding: 20px 0'}; + ${({ $mobile }) => $mobile && 'padding: 20px 0'}; `; const InfoContainer = styled.div` @@ -31,7 +32,7 @@ const InfoContainer = styled.div` flex-grow: 0 !important; `; -const InfoIcon = styled.div` +const InfoIcon = styled.div>` display: flex; align-items: center; justify-content: center; @@ -43,7 +44,7 @@ const InfoIcon = styled.div` top: -10px; left: 20px; - background-color: ${props => props.color}; + background-color: ${props => props.$color}; border-radius: 10px; box-shadow: 13px 13px 35px 0px rgba(0, 0, 0, 0.15); @@ -99,12 +100,12 @@ export const HardwareInfoContainer: FC = props => { }; return ( - - + + - + {props.heading} diff --git a/apps/view/src/components/main-widget-container.tsx b/apps/view/src/components/main-widget-container.tsx index 5b5d051f0..e01ce1d97 100644 --- a/apps/view/src/components/main-widget-container.tsx +++ b/apps/view/src/components/main-widget-container.tsx @@ -1,3 +1,4 @@ +import { Transient } from '@dash/common'; import { motion, Variants } from 'framer-motion'; import { FC, useEffect } from 'react'; import { default as styled } from 'styled-components'; @@ -31,28 +32,28 @@ const itemVariants: Variants = { }, }; -const FlexContainer = styled(motion.div)<{ mobile: boolean }>` - width: ${({ mobile }) => (mobile ? 'calc(100vw - 50px)' : '92vw')}; - min-height: ${({ mobile }) => (mobile ? 'calc(100vh - 50px)' : '86vh')}; - margin: ${({ mobile }) => (mobile ? '50px' : '7vh')} auto - ${({ mobile }) => (mobile ? '50px' : '7vh')} auto; +const FlexContainer = styled(motion.div)>` + width: ${({ $mobile }) => ($mobile ? 'calc(100vw - 50px)' : '92vw')}; + min-height: ${({ $mobile }) => ($mobile ? 'calc(100vh - 50px)' : '86vh')}; + margin: ${({ $mobile }) => ($mobile ? '50px' : '7vh')} auto + ${({ $mobile }) => ($mobile ? '50px' : '7vh')} auto; display: flex; flex-flow: row wrap; column-gap: 40px; - row-gap: ${({ mobile }) => (mobile ? '40px' : '70px')}; + row-gap: ${({ $mobile }) => ($mobile ? '40px' : '70px')}; `; -const ErrorContainer = styled(motion.div)<{ mobile: boolean }>` - width: ${({ mobile }) => (mobile ? 'calc(100vw - 50px)' : '92vw')}; - min-height: ${({ mobile }) => (mobile ? 'calc(100vh - 50px)' : '86vh')}; - margin: ${({ mobile }) => (mobile ? '50px' : '7vh')} auto - ${({ mobile }) => (mobile ? '50px' : '7vh')} auto; +const ErrorContainer = styled(motion.div)>` + width: ${({ $mobile }) => ($mobile ? 'calc(100vw - 50px)' : '92vw')}; + min-height: ${({ $mobile }) => ($mobile ? 'calc(100vh - 50px)' : '86vh')}; + margin: ${({ $mobile }) => ($mobile ? '50px' : '7vh')} auto + ${({ $mobile }) => ($mobile ? '50px' : '7vh')} auto; display: flex; flex-flow: row wrap; column-gap: 40px; - row-gap: ${({ mobile }) => (mobile ? '40px' : '70px')}; + row-gap: ${({ $mobile }) => ($mobile ? '40px' : '70px')}; justify-content: center; align-items: center; @@ -93,7 +94,7 @@ export const MainWidgetContainer: FC = () => { initial='initial' animate='animate' exit='exit' - mobile={isMobile} + $mobile={isMobile} > @@ -150,7 +151,7 @@ export const MainWidgetContainer: FC = () => { return ( ` +const StyledInfoTable = styled(InfoTable)>` width: 100%; - padding: 15px 5px ${({ mobile }) => (mobile ? 15 : 5)}px 5px; + padding: 15px 5px ${({ $mobile }) => ($mobile ? 15 : 5)}px 5px; `; const SFontAwesomeIcon = styled(FontAwesomeIcon)` @@ -256,7 +256,7 @@ export const ServerWidget: FC = ({ data, config }) => { = { + [K in keyof T & string as `$${K}`]: T[K]; +};