Skip to content

Commit

Permalink
adapted version
Browse files Browse the repository at this point in the history
  • Loading branch information
Me1rlan committed Apr 5, 2024
1 parent e2c7e44 commit cd4a63a
Show file tree
Hide file tree
Showing 18 changed files with 185 additions and 89 deletions.
2 changes: 0 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import Header from "./components/header/Header";
import HomePage from "./pages/home/HomePage";
import useLocalStorage from "use-local-storage";
import Footer from "./components/footer/Footer";


function App() {
Expand All @@ -11,7 +10,6 @@ function App() {
<div className={'wrapper'} data-theme={isDark ? 'dark' : 'light'}>
<Header isDark={isDark} setIsDark={setIsDark}/>
<HomePage/>
<Footer/>
</div>
);
}
Expand Down
42 changes: 12 additions & 30 deletions src/components/HourlyForecast/HourlyForecast.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,23 @@
h2{
text-align: center;
}
@media (max-width: 529px) {
padding: 20px 10px;
}
}
.items{
margin-top: 1.4em;
display: flex;
justify-content: space-between;
}
.item{
text-align: center;
padding: 20px 15px;
border-radius: 2em;
box-shadow: 8px 9px 11px 0 rgba(0, 0, 0, 0.50);
width: 15%;
.icon{
position: relative;
width: 100%;
height: 140px;
img{
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
-webkit-filter: drop-shadow(3px 5px 5px #363535);
filter: drop-shadow(3px 5px 5px #363535);
}
}
.time{
font-size: 1.33em;
font-weight: 700;
@media (max-width: 1024px) {
flex-wrap: wrap;
justify-content: start;
column-gap: 1em;
row-gap: 1em;
}
p{
font-weight: 700;
font-size: 1.1em;
& + p{
margin-top: 5px;
}
@media (max-width: 529px) {
column-gap: 0;
justify-content: space-between;
}

}
19 changes: 5 additions & 14 deletions src/components/HourlyForecast/HourlyForecast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import React, {useEffect} from 'react';
import s from './HourlyForecast.module.scss'
import {useAppDispatch, useAppSelector} from "../../hooks/hooks";
import {hourlyForecastThunk} from "../../store/thunks/hourlyForecast.thunk";
import Icon from "../imageIcon/Icon";
import {toast} from "react-toastify";
import HourlyForecastItem from "../hourlyForecastItem/HourlyForecastItem";

const HourlyForecast = React.memo(() => {
const HourlyForecast = () => {
const name = useAppSelector(state => state.currentWeather.name)
const error = useAppSelector(state => state.hourlyWeather.error)
const {list} = useAppSelector(state => state.hourlyWeather)
const list = useAppSelector(state => state.hourlyWeather.list)
const dispatch = useAppDispatch()
useEffect(() => {
name && dispatch(hourlyForecastThunk(name))
Expand All @@ -18,19 +18,10 @@ const HourlyForecast = React.memo(() => {
<div className={s.body}>
<h2 className="title">Hourly Forecast:</h2>
<div className={s.items}>
{list.map((item, index) => {
return <div key={index} className={s.item}>
<div className={s.time}>{item.dt_txt && item.dt_txt.slice(10,16)}</div>
<div className={s.icon}>
<Icon icon={item.weather[0].icon} />
</div>
<p className={s.temp}>{item.main.temp && Math.round(item.main.temp - 273.15)}°C</p>
<p className={s.speed}>{item.wind.speed && Math.round(item.wind.speed)}km/h</p>
</div>
})}
{list.map((item, index) => <HourlyForecastItem item={item} key={index}/>)}
</div>
</div>
);
});
};

export default HourlyForecast;
21 changes: 20 additions & 1 deletion src/components/currentWeather/CurrentWeather.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@
justify-content: space-between;
align-items: center;
color: var(--primary-color);
@media (max-width: 1024px) {
justify-content: start;
column-gap: 4em;
flex-wrap: wrap;
}
@media (max-width: 768px) {
justify-content: center;
column-gap: 1em;
row-gap: 1em;
width: 100%;
}
@media (max-width: 529px) {
padding: 20px 10px;
row-gap: 0;
}
.degree, .feelsLike{
background: linear-gradient(80deg, var(--primary-color) -2.93%, var(--primary-color) 212.44%);
background-clip: text;
Expand All @@ -22,7 +37,7 @@
color: var(--primary-color);
}
.feelsLike{
margin-top: -11px;
margin-top: -7px;
padding-left: .5em;
font-size: 1.1em;
font-weight: 600;
Expand All @@ -36,5 +51,9 @@
margin-left: -2em;
-webkit-filter: drop-shadow(3px 3px 3px #000);
filter: drop-shadow(3px 3px 3px #000);
@media (max-width: 1300px){
width: 9em;
margin-left: 0;
}
}
}
7 changes: 3 additions & 4 deletions src/components/currentWeather/CurrentWeather.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import Icon from '../imageIcon/Icon';
import CurrentWeatherInfo from "../currentWeatherInfo/CurrentWeatherInfo";
import {currentWeatherThunk} from "../../store/thunks/currentWeather.thunk";

const CurrentWeather = React.memo(() => {
console.log('CurrentWeather')
const CurrentWeather = () => {
const dispatch = useAppDispatch()
const temp = useAppSelector(state => state.currentWeather.temp)
const weather = useAppSelector(state => state.currentWeather.weather)
const feels_like = useAppSelector(state => state.currentWeather.feels_like)

useEffect(() => {
dispatch(currentWeatherThunk('astana'))
dispatch(currentWeatherThunk(JSON.parse(String(localStorage.getItem("city"))) || 'astana'))
}, [dispatch]);

return (
Expand All @@ -26,6 +25,6 @@ const CurrentWeather = React.memo(() => {
<CurrentWeatherInfo />
</div>
);
});
};

export default CurrentWeather;
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,26 @@
display: flex;
flex-direction: column;
justify-content: center;
@media (max-width: 768px) {
padding: 30px;
width: 100%;
}
@media (max-width: 529px) {
padding: 30px 10px;
}
}
.city{
text-align: center;
font-size: 3em;
font-weight: 700;
@media (max-width: 1024px) {
font-size: 2.4em;
}
@media (max-width: 529px) {
font-size: 2.1em;
}
& p{
margin-top: .4em;
font-size: .6em;
font-size: .55em;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.content{
width: 36%;
@media (max-width: 1024px) {
width: 100%;
}
h3{
font-size: 1em;
margin: 0;
Expand All @@ -10,6 +13,12 @@
justify-content: space-between;
flex-wrap: wrap;
row-gap: 1.2em;
@media (max-width: 1024px) {
flex-wrap: nowrap;
}
@media (max-width: 529px) {
flex-wrap: wrap;
}
}
.description{
text-transform: uppercase;
Expand Down
7 changes: 2 additions & 5 deletions src/components/currentWeatherInfo/CurrentWeatherInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ const CurrentWeatherInfo = () => {
return (
<div className={s.content}>
<div className={s.body}>
{/*<p className={s.maxTemp}>Temp max <span>{state.temp_max && Math.round(state.temp_max)}°C</span></p>*/}
{/*<p className={s.minTemp}>Temp min <span>{state.temp_min && Math.round(state.temp_min)}°C</span></p>*/}
<div className={s.item}>
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 322.881 322.881"><g>
<path d="M161.288,106.839c-3.304,2.498-3.957,7.201-1.459,10.506c18.253,24.142,48.873,70.369,48.873,108.734
Expand Down Expand Up @@ -55,8 +53,7 @@ const CurrentWeatherInfo = () => {
</div>
<div className={s.item}>
<svg fill="#000000" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 188.377 188.377" >
<g>
viewBox="0 0 188.377 188.377" ><g>
<g>
<g>
<path d="M158.717,24.669c-5.23-12.101-17.528-20.058-31.432-20.058c-17.526,0-32,12.741-33.825,29.07
Expand All @@ -77,7 +74,7 @@ const CurrentWeatherInfo = () => {
</g>
</g>
</g>
</svg>
</svg>
<p className={s.cloudy}><span>{state.pressure && state.pressure}hPa</span> <br/>Pressure</p>
</div>
</div>
Expand Down
12 changes: 0 additions & 12 deletions src/components/footer/Footer.module.scss

This file was deleted.

14 changes: 0 additions & 14 deletions src/components/footer/Footer.tsx

This file was deleted.

7 changes: 6 additions & 1 deletion src/components/header/Header.module.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
.header{
position: relative;
z-index: 10;
padding: 1.2em 0;
padding: .9em 0;
color: var(--primary-color);
}
.items{
display: flex;
justify-content: space-between;
align-items: center;
column-gap: 10px;
@media (max-width: 529px) {
flex-wrap: wrap;
row-gap: .6em;
}
}
42 changes: 42 additions & 0 deletions src/components/hourlyForecastItem/HourlyForecastItem.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.item{
text-align: center;
padding: 15px;
border-radius: 2em;
box-shadow: 8px 9px 11px 0 rgba(0, 0, 0, 0.50);
width: 15%;
@media (max-width: 1024px) {
width: 23%;
}
@media (max-width: 728px) {
width: 31%;
}
@media (max-width: 529px) {
width: 48%;
}
.icon{
position: relative;
width: 100%;
img{
@media (max-width: 1300px) {
width: 6.4em;
height: 6.4em;
}
margin: 0 auto;
width: 7em;
height: 7em;
-webkit-filter: drop-shadow(3px 5px 5px #363535);
filter: drop-shadow(3px 5px 5px #363535);
}
}
.time{
font-size: 1.33em;
font-weight: 700;
}
p{
font-weight: 700;
font-size: 1.1em;
& + p{
margin-top: 5px;
}
}
}
23 changes: 23 additions & 0 deletions src/components/hourlyForecastItem/HourlyForecastItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import s from './HourlyForecastItem.module.scss'
import Icon from "../imageIcon/Icon";
import {HourlyForecastInfo} from "../../models/hourlyForecast.models";

interface IHourlyForecastItem{
item: HourlyForecastInfo
}

const HourlyForecastItem: React.FC<IHourlyForecastItem> = ({item}) => {
return (
<div className={s.item}>
<div className={s.time}>{item.dt_txt && item.dt_txt.slice(10,16)}</div>
<div className={s.icon}>
<Icon icon={item.weather[0].icon} />
</div>
<p className={s.temp}>{item.main.temp && Math.round(item.main.temp - 273.15)}°C</p>
<p className={s.speed}>{item.wind.speed && Math.round(item.wind.speed)}km/h</p>
</div>
);
};

export default HourlyForecastItem;
Loading

0 comments on commit cd4a63a

Please sign in to comment.