Skip to content

Commit

Permalink
moment UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Asmeeeee committed Dec 3, 2024
1 parent 1b9fad0 commit cdb9a1e
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 53 deletions.
9 changes: 6 additions & 3 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useState, useEffect } from 'react';
import './App.css';
import DaySelector from './DaySelector';
import Header from './Header';
import WeatherCard from './WeatherCard';
import TimeSelector from './TimeSelector';

function App() {
const [data, setData] = useState({});
Expand All @@ -25,7 +25,7 @@ function App() {
.then(data => {
setData(data.docs[0]);
});
}, [selectedCity, selectedDate]);
}, [selectedCity, selectedDate, selectedMoment]);

useEffect(() => {
fetch('http://localhost:5984/ecometeo/_design/testCity/_view/city?reduce=true&group=true')
Expand All @@ -43,6 +43,9 @@ function App() {
const handleDate = (date) => {
setSelectedDate(date);
};
const handleMoment = (moment) => {
setSelectedMoment(moment);
}

return (
<div className="app-container">
Expand All @@ -52,9 +55,9 @@ function App() {
cityChange={handleCity}
selectedDate={selectedDate}
/>
<TimeSelector date={selectedDate} dateChange={handleDate} momentChange={handleMoment}/>
<main className="main-content">
<WeatherCard data={data} date={selectedDate} />
<DaySelector date={selectedDate} dateChange={handleDate} />
</main>
</div>
);
Expand Down
13 changes: 0 additions & 13 deletions frontend/src/DaySelector.jsx

This file was deleted.

37 changes: 0 additions & 37 deletions frontend/src/TabMeteo.jsx

This file was deleted.

26 changes: 26 additions & 0 deletions frontend/src/TimeSelector.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
button {
margin: 0.5rem;
padding: 0.8rem 1.5rem;
font-weight: bold;
font-size: 1rem;
cursor: pointer;
border-radius: 8px;
}

button:hover {
background-color: #0077cc;
color: white;
}

button:focus {
outline: none;
background-color: #005fa3;
color: white;
}

nav {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
gap: 1rem;
}

64 changes: 64 additions & 0 deletions frontend/src/TimeSelector.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import 'dayjs/locale/fr';
import './TimeSelector.css'

function TimeSelector({ date, dateChange, momentChange }) {
return (
<div className="container">
<nav className='grid'>
<button
className="button"
value={"2024-10-08"}
onClick={() => dateChange("2024-10-08")}
>
8 octobre
</button>
<button
className="button"
value={"2024-10-09"}
onClick={() => dateChange("2024-10-09")}
>
9 octobre
</button>
<button
className="button"
value={"2024-10-10"}
onClick={() => dateChange("2024-10-10")}
>
10 octobre
</button>
</nav>
<nav className='grid'>
<button
className="button"
value={"Matin"}
onClick={() => momentChange("matin")}
>
Matin
</button>
<button
className="button"
value={"Après-midi"}
onClick={() => momentChange("après-midi")}
>
Après-midi
</button>
<button
className="button"
value={"Soir"}
onClick={() => momentChange("soirée")}
>
Soir
</button>
<button
className="button"
value={"Nuit"}
onClick={() => momentChange("nuit")}
>
Nuit
</button>
</nav>
</div>
);
}

export default TimeSelector;

0 comments on commit cdb9a1e

Please sign in to comment.