Skip to content

Commit f07898e

Browse files
committed
SALG-1278: Initial styling of category selection and route browsing
1 parent 6187021 commit f07898e

File tree

14 files changed

+83
-45
lines changed

14 files changed

+83
-45
lines changed

src/App.jsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect, useState, useMemo, useRef, useContext } from "react";
2-
import { Routes, Navigate, Route, useNavigate } from "react-router-dom";
2+
import { Routes, Navigate, Route } from "react-router-dom";
33
import TagPage from "./components/tags/TagPage";
44
import LatLongContext from "./context/latitude-longitude-context";
55
import AudioContext from "./context/audio-context";
@@ -21,7 +21,6 @@ function App() {
2121
const [source, setSource] = useState(null);
2222
const [cache, setCache] = useState({});
2323
const audioRef = useRef();
24-
const navigate = useNavigate();
2524

2625
const cacheContext = useMemo(
2726
() => ({
@@ -119,12 +118,7 @@ function App() {
119118
const { fileUrl } = useContext(ApiEndpointContext);
120119

121120
return (
122-
<div className="App">
123-
<div>
124-
<button type="button" onClick={() => navigate(-1)}>
125-
go back
126-
</button>
127-
</div>
121+
<div className="App h-full min-h-screen w-screen p-3 text-zinc-800 dark:text-white bg-zinc-100 dark:bg-zinc-800">
128122
<LatLongContext.Provider value={contextLatLong}>
129123
<CacheContext.Provider value={cacheContext}>
130124
<AudioContext.Provider value={audio}>

src/components/BackButton.jsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { React } from "react";
2+
import { useNavigate } from "react-router-dom";
3+
import { ReactComponent as AngleLeft } from "../icons/angle-left-solid.svg";
4+
import { ReactComponent as Xmark } from "../icons/xmark-solid.svg";
5+
6+
function BackButton({ children }) {
7+
const navigate = useNavigate();
8+
9+
return (
10+
<button
11+
className="relative flex place-content-center dark:bg-zinc-800 dark:text-white text-sm"
12+
type="button"
13+
onClick={() => navigate(-1)}
14+
>
15+
<span className="bg-zinc-300 dark:bg-zinc-700 flex place-content-center px-3 mr-2 rounded">
16+
{children === "Afslut" ? (
17+
<Xmark className="inline w-2" />
18+
) : (
19+
<AngleLeft className="inline w-2" />
20+
)}
21+
</span>
22+
{children}
23+
</button>
24+
);
25+
}
26+
27+
export default BackButton;

src/components/map/MapWrapper.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,14 @@ function MapWrapper({ mapData, goToView }) {
168168
}
169169
}, [mapData]);
170170

171+
// TODO: Remove zoom and info btn
172+
171173
return (
172-
<div className="map-container">
173-
<div ref={mapElement} className="map" id="map">
174+
<div className="map-container absolute left-0 top-0 h-screen px-3 pt-12 pb-3">
175+
<div ref={mapElement} className="map rounded-xl overflow-hidden" id="map">
174176
<div id="tooltip" className="tooltip" />
175177
</div>
178+
<div className="map-color-overlay absolute left-0 top-0 bottom-0 right-0 w-screen h-screen bg-zinc-400 dark:bg-zinc-800 opacity-70 dark:opacity-80" />
176179
</div>
177180
);
178181
}

src/components/map/map-wrapper.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
.map-container,
44
.map {
5-
height: 400px;
5+
height: 100%;
66
width: 100%;
77
display: block;
88
/* filter: brightness(55%); */
@@ -389,7 +389,7 @@
389389
padding: 0 15px;
390390
height: 40px;
391391
align-items: center;
392-
justify-content: center;
392+
justify-content: center;
393393
}
394394

395395
.tooltip:not(:empty) .tooltip-btn {

src/components/routes/Route.jsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ function Route({ id }) {
1616
if (route === null) return null;
1717

1818
return (
19-
<span>
20-
<Link className="" to={`/route/${id}`}>
21-
{route.name}
22-
</Link>
23-
<div>{route.description}</div>
24-
<Image src={route.image} />
25-
</span>
19+
<Link className="bg-zinc-100 dark:bg-zinc-700 flex" to={`/route/${id}`}>
20+
<Image className="flex-1 w-32" src={route.image} />
21+
<div className="flex-initial text-left leading-none p-3">
22+
<span className="block mb-1">{route.name}</span>
23+
<span className="text-xs ">{route.description}</span>
24+
</div>
25+
</Link>
2626
);
2727
}
2828

src/components/routes/RouteCarousel.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import "react-responsive-carousel/lib/styles/carousel.min.css"; // requires a lo
77
function RouteCarousel({ routes, onCarouselChange }) {
88
return (
99
<Carousel
10+
className="absolute left-0 bottom-0 right-0 m-5 rounded-lg overflow-hidden max-h-96 md:max-w-xs"
1011
showThumbs={false}
1112
showStatus={false}
1213
autoplay

src/components/routes/RoutePage.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useParams } from "react-router-dom";
33
import useFetch from "../../util/useFetch";
44
import PointOfInterest from "../points-of-interest/PointOfInterest";
55
import { getAngleFromLocationToDestination } from "../../util/helper";
6+
import BackButton from "../BackButton";
67

78
function RoutePage() {
89
const { id } = useParams();
@@ -91,7 +92,8 @@ function RoutePage() {
9192
if (selectedRoute === null) return null;
9293
return (
9394
<>
94-
<h1>{selectedRoute.name}</h1>
95+
<BackButton>Afslut</BackButton>
96+
<h1 className="text-xl font-bold my-3">{selectedRoute.name}</h1>
9597
{pointsOfInterest &&
9698
pointsOfInterest
9799
.toReversed()

src/components/routes/SelectedRoute.jsx

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { React, useEffect, useState } from "react";
22
import MapWrapper from "../map/MapWrapper";
33
import { getFeaturesForMap } from "../../util/helper";
4+
import BackButton from "../BackButton";
45

56
function SelectedRoute({ selectedRoute }) {
67
const [featuresForMap, setFeaturesForMap] = useState(null);
@@ -18,23 +19,30 @@ function SelectedRoute({ selectedRoute }) {
1819
return (
1920
<>
2021
<MapWrapper mapData={featuresForMap} goToView={featuresForMap[0]} />
21-
<h1>{selectedRoute.name}</h1>
22-
<div>
23-
<label htmlFor="distance">
24-
Distance
25-
<div id="distance">{selectedRoute.distance}</div>
26-
</label>
27-
<label htmlFor="poi">
28-
Dele
29-
<div id="poi">{selectedRoute.pointsOfInterest.length}</div>
30-
</label>
31-
{/* todo skeleton screen (I think I recall tailwind having these ootb) or some wait indication */}
32-
{/* todo how to sum up podcasts */}
33-
<label htmlFor="length">
34-
Afspilningstid
35-
{/* todo */}
36-
<div id="length" />
37-
</label>
22+
<BackButton>Kategorier</BackButton>
23+
<div className="relative ml-2">
24+
<h1 className="text-4xl font-bold mt-10 mb-5">{selectedRoute.name}</h1>
25+
<div className="info-box bg-zinc-100 dark:bg-zinc-700 rounded p-3 w-32">
26+
<label htmlFor="distance" className="mb-5">
27+
<span className="text-xs">Distance</span>
28+
<div id="distance" className="text-lg">
29+
{selectedRoute.distance}
30+
</div>
31+
</label>
32+
<label htmlFor="poi" className="mb-5">
33+
<span className="text-xs">Dele</span>
34+
<div id="poi" className="text-lg">
35+
{selectedRoute.pointsOfInterest.length}
36+
</div>
37+
</label>
38+
{/* todo skeleton screen (I think I recall tailwind having these ootb) or some wait indication */}
39+
{/* todo how to sum up podcasts */}
40+
<label htmlFor="length">
41+
<span className="text-xs">Afspilningstid</span>
42+
{/* todo */}
43+
<div id="length" className="text-lg" />
44+
</label>
45+
</div>
3846
</div>
3947
</>
4048
);

src/components/tags/Tag.jsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import { Link } from "react-router-dom";
44
function Tag({ name, numberOfRoutes, id }) {
55
if (numberOfRoutes === 0) return null;
66
return (
7-
<div>
8-
<Link className="" to={`/tag/${id}`}>
9-
{name}
10-
</Link>
11-
</div>
7+
<Link
8+
className="block bg-emerald-500 mb-3 rounded-md p-3"
9+
to={`/tag/${id}`}
10+
>
11+
<span className="block text-lg font-bold">{name}</span>
12+
<span className="text-s text-zinc-600">{numberOfRoutes} historier</span>
13+
</Link>
1214
);
1315
}
1416

src/components/tags/TagsList.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function TagsList() {
1616

1717
return (
1818
<div>
19-
<h1>Kategorier</h1>
19+
<h1 className="mb-3">Kategorier</h1>
2020
{tags.map(({ name, routes, id }) => (
2121
<Tag key={name} numberOfRoutes={routes.length} name={name} id={id} />
2222
))}

0 commit comments

Comments
 (0)