From cbd26743f3ba8fc2a98b32033034540008b8acb3 Mon Sep 17 00:00:00 2001 From: jagerts <94642410+jagerts@users.noreply.github.com> Date: Mon, 23 May 2022 13:38:25 +0300 Subject: [PATCH] add types for styled components in styles (#1830) Signed-off-by: Evgeny Zhgulev --- src/styles/base.ts | 30 +++++++++++++++++++++++------- src/styles/media-breakpoints.ts | 12 ++++++------ 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/styles/base.ts b/src/styles/base.ts index d2e9817c0d..5bc9c6901d 100644 --- a/src/styles/base.ts +++ b/src/styles/base.ts @@ -21,6 +21,22 @@ import {css} from 'styled-components'; import {DIMENSIONS} from 'constants/default-settings'; +type InputProps = { + active: boolean; + disabled: boolean; + error: string; + size: string; + type: string; +}; + +type SecondaryInputProps = { + error: string; +}; + +type SwitchableProps = { + checked: boolean; +}; + export const transition = 'all .4s ease'; export const transitionFast = 'all .2s ease'; export const transitionSlow = 'all .8s ease'; @@ -443,7 +459,7 @@ export const breakPoints = { // it is used by styled-components to pass along to // all child components -const input = css` +const input = css` ::placeholder { color: ${props => props.theme.inputPlaceholderColor}; font-weight: ${props => props.theme.inputPlaceholderFontWeight}; @@ -552,7 +568,7 @@ const inputLT = css` } `; -const secondaryInput = css` +const secondaryInput = css` ${props => props.theme.input} color: ${props => props.theme.secondaryInputColor}; background-color: ${props => props.theme.secondaryInputBgd}; @@ -626,7 +642,7 @@ const inlineInput = css` } `; -const switchTrack = css` +const switchTrack = css` background: ${props => props.checked ? props.theme.switchTrackBgdActive : props.theme.switchTrackBgd}; position: absolute; @@ -639,7 +655,7 @@ const switchTrack = css` border-radius: ${props => props.theme.switchTrackBorderRadius}; `; -const switchButton = css` +const switchButton = css` transition: ${props => props.theme.transition}; position: absolute; top: ${props => (props.theme.switchHeight - props.theme.switchBtnHeight) / 2}px; @@ -682,7 +698,7 @@ const inputSwitch = css` `; // This is a light version checkbox -const checkboxBox = css` +const checkboxBox = css` display: block; position: absolute; top: 0; @@ -698,7 +714,7 @@ const checkboxBox = css` content: ''; `; -const checkboxCheck = css` +const checkboxCheck = css` width: 10px; height: 5px; border-bottom: 2px solid white; @@ -763,7 +779,7 @@ const inputRadio = css` } `; -const secondarySwitch = css` +const secondarySwitch = css` ${props => props.theme.inputSwitch} :before { diff --git a/src/styles/media-breakpoints.ts b/src/styles/media-breakpoints.ts index ab2c939e7e..876ebd61d0 100644 --- a/src/styles/media-breakpoints.ts +++ b/src/styles/media-breakpoints.ts @@ -36,21 +36,21 @@ const breakPoints = { */ export const media = { - palm: (...args): string => css` + palm: (first, ...args) => css` @media (max-width: ${props => (props.theme.breakPoints || breakPoints).palm}px) { - ${css(...args)}; + ${css(first, ...args)}; } `, - portable: (...args): string => css` + portable: (first, ...args) => css` @media (max-width: ${props => (props.theme.breakPoints || breakPoints).desk}px) { - ${css(...args)}; + ${css(first, ...args)}; } `, - desk: (...args): string => css` + desk: (first, ...args) => css` @media (min-width: ${props => (props.theme.breakPoints || breakPoints).desk + 1}px) { - ${css(...args)}; + ${css(first, ...args)}; } ` };