From 12bfcb45753d04f3917dea2e886d9576974fafbc Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Fri, 8 Jul 2022 21:49:17 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Form=20elements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Form/Card.tsx | 28 +++++++++++++++++----------- src/components/Form/Heading.tsx | 13 +++++++------ src/components/Form/Input.tsx | 4 +++- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/components/Form/Card.tsx b/src/components/Form/Card.tsx index c750e7f..60a0cdd 100644 --- a/src/components/Form/Card.tsx +++ b/src/components/Form/Card.tsx @@ -1,26 +1,32 @@ import styled from 'styled-components'; +// import Heading from 'components/Form/Heading'; import colors from 'styles/colors'; -export const StyledCard = styled.section` +export const Card = styled.section` background: ${colors.backgroundLighter}; box-shadow: 4px 4px 0px ${colors.bgShadowColor}; border-radius: 8px; padding: 1rem; margin: 1rem; - max-width: 24rem; `; -interface CardProps { - children: React.ReactNode; -}; +// interface CardProps { +// children: React.ReactNode; +// heading?: string, +// }; -const Card = (props: CardProps): JSX.Element => { - const { children } = props; - return ( - {children} - ); -} +// const Card = (props: CardProps): JSX.Element => { +// const { children, heading } = props; +// return ( +// +// { heading && +// {heading} +// } +// {children} +// +// ); +// } export default Card; diff --git a/src/components/Form/Heading.tsx b/src/components/Form/Heading.tsx index ffe8f8e..b5d713c 100644 --- a/src/components/Form/Heading.tsx +++ b/src/components/Form/Heading.tsx @@ -1,23 +1,25 @@ import styled from 'styled-components'; import colors from 'styles/colors'; +import { TextSizes } from 'styles/typography'; interface HeadingProps { as?: 'h1' | 'h2' | 'h3' | 'h4' | 'p'; align?: 'left' | 'center' | 'right'; color?: string; - size?: 'small' | 'medium' | 'large'; + size?: 'xSmall' | 'small' | 'medium' | 'large'; inline?: boolean; children: React.ReactNode; }; const StyledHeading = styled.h1` - margin: 0.5rem; + margin: 0.5rem 0; text-shadow: 2px 2px 0px ${colors.bgShadowColor}; ${props => { switch (props.size) { - case 'small': return 'font-size: 1rem;'; - case 'medium': return 'font-size: 2rem;'; - case 'large': return 'font-size: 3rem;'; + case 'xSmall': return `font-size: ${TextSizes.small};`; + case 'small': return `font-size: ${TextSizes.medium};`; + case 'medium': return `font-size: ${TextSizes.large};`; + case 'large': return `font-size: ${TextSizes.xLarge};`; } }}; ${props => { @@ -31,7 +33,6 @@ const StyledHeading = styled.h1` ${props => props.inline ? 'display: inline;' : '' } `; - const Heading = (props: HeadingProps): JSX.Element => { const { children, as, size, align, color, inline } = props; return ( diff --git a/src/components/Form/Input.tsx b/src/components/Form/Input.tsx index c47174f..11158ea 100644 --- a/src/components/Form/Input.tsx +++ b/src/components/Form/Input.tsx @@ -10,6 +10,7 @@ interface Props { value: string, label?: string, placeholder?: string, + disabled?: boolean, size?: InputSize, orientation?: Orientation; handleChange: (nweVal: React.ChangeEvent) => void, @@ -47,7 +48,7 @@ const StyledLabel = styled.label` const Input = (inputProps: Props): JSX.Element => { - const { id, value, label, placeholder, size, orientation, handleChange } = inputProps; + const { id, value, label, placeholder, disabled, size, orientation, handleChange } = inputProps; return ( @@ -56,6 +57,7 @@ const Input = (inputProps: Props): JSX.Element => { id={id} value={value} placeholder={placeholder} + disabled={disabled} onChange={handleChange} inputSize={size} />