Update card styles and content

This commit is contained in:
Hazem Krimi
2021-01-21 19:54:17 +01:00
parent 40467e5709
commit 90b7bea1bd
+20 -12
View File
@@ -10,6 +10,7 @@ const Wrapper = styled.div`
justify-content: center; justify-content: center;
align-items: center; align-items: center;
text-align: center; text-align: center;
width: 100%;
padding: 1rem; padding: 1rem;
margin: 1rem 0rem; margin: 1rem 0rem;
@@ -18,34 +19,41 @@ const Wrapper = styled.div`
} }
.cold { .cold {
color: #429BB8; color: #429bb8;
} }
.hot { .hot {
color: #FF4500; color: #ff4500;
} }
`; `;
interface Props { interface Props {
date: Date, date: Date;
data: string, data: string;
icon: number, icon: number;
time: boolean, time: boolean;
temp?: 'hot' | 'cold' | null, temp?: 'hot' | 'cold' | null;
description?: string description?: string;
}; }
const Card: React.FC<Props> = ({ date, time, data, temp, icon, description }) => { const Card: React.FC<Props> = ({ date, time, data, temp, icon, description }) => {
const timeString: string = `${date.getHours() < 10 ? 0 : ''}${date.getHours()}:${date.getMinutes() < 10 ? 0 : ''}${date.getMinutes()}`; const timeString: string = `${date.getHours() < 10 ? 0 : ''}${date.getHours()}:${
date.getMinutes() < 10 ? 0 : ''
}${date.getMinutes()}`;
return ( return (
<Wrapper> <Wrapper>
<p>{time ? timeString : ''} {date.toDateString().split(' ')[0]} {date.getDate() + '/' + (date.getMonth() + 1)}</p> <p>
{date.toDateString().split(' ')[0]} {time ? timeString : ''}{' '}
{(date.getMonth() + 1 < 10 ? `0${date.getMonth() + 1}` : date.getMonth()) +
'/' +
date.getDate()}
</p>
<h3>{data}</h3> <h3>{data}</h3>
<i className={`wi wi-owm-${icon} ${temp && temp}`}></i> <i className={`wi wi-owm-${icon} ${temp && temp}`}></i>
<p>{description && description}</p> <p>{description && description}</p>
</Wrapper> </Wrapper>
); );
} };
export default Card; export default Card;