Created header component and navigation indicator · ifmcode/podcaster@2ec47cb · GitHub
Skip to content

Commit 2ec47cb

Browse files
committed
Created header component and navigation indicator
1 parent b0f8ce1 commit 2ec47cb

8 files changed

Lines changed: 111 additions & 15 deletions

File tree

‎src/App.js‎

Lines changed: 14 additions & 9 deletions

‎src/components/Header/Header.css‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.header-wrapper {
2+
position: relative;
3+
width: 100%;
4+
height: 50px;
5+
border-bottom: 1px solid lightgray;
6+
display: flex;
7+
flex-direction: row;
8+
justify-content: space-between;
9+
align-items: center;
10+
padding: 10px;
11+
box-sizing: border-box;
12+
}
13+
14+
.header-logo {
15+
position: relative;
16+
align-self: flex-start;
17+
text-decoration: none;
18+
color: rgb(91, 91, 247);
19+
font-weight: bold;
20+
font-size: 22px;
21+
}
22+
23+
.header-indicator {
24+
position: relative;
25+
display: none;
26+
align-self: flex-end;
27+
width: 30px;
28+
height: 30px;
29+
background-color: rgb(91, 91, 247);
30+
border-radius: 30px;
31+
animation: throb 1s infinite;
32+
}
33+
34+
.header-indicator.visible {
35+
display: block;
36+
}
37+
38+
@keyframes throb {
39+
0% {
40+
opacity: 1;
41+
}
42+
50% {
43+
opacity: 0.3;
44+
}
45+
100% {
46+
opacity: 1;
47+
}
48+
}

‎src/components/Header/Header.js‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { useEffect, useRef } from 'react';
2+
import { Link, useNavigation } from 'react-router-dom';
3+
import "./Header.css"
4+
5+
const Header = () => {
6+
const navigationIndicatorRef = useRef(null),
7+
navigation = useNavigation(),
8+
IDLE_STATUS = "idle";
9+
10+
useEffect(() => {
11+
console.log(navigation.state);
12+
navigationIndicatorRef.current.className = (navigation.state !== IDLE_STATUS)
13+
? "header-indicator visible"
14+
: "header-indicator";
15+
}, [navigation.state]);
16+
17+
return (
18+
<header className="header-wrapper">
19+
<Link to="/" className="header-logo">Podcaster</Link>
20+
<div className="header-indicator" ref={navigationIndicatorRef}></div>
21+
</header>
22+
);
23+
}
24+
25+
export default Header;

‎src/redux/podcasterSlice.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,10 @@ export const podcasterSlice = createSlice({
2525
},
2626
});
2727

28-
export const { updatePodcaster } = podcasterSlice.actions;
28+
const { updatePodcaster } = podcasterSlice.actions;
29+
30+
export {
31+
updatePodcaster,
32+
status,
33+
}
2934
export default podcasterSlice.reducer;

‎src/screens/Episode/Episode.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import "./Episode.css"
2-
import React from 'react';
32
import {useParams} from 'react-router-dom';
43

54
const Episode = () => {

‎src/screens/Home/Home.js‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import "./Home.css"
2-
import React, {useEffect} from 'react';
2+
import {useEffect} from 'react';
33
import {useSelector, useDispatch} from 'react-redux';
44
import moment from "moment/moment";
55
import { requestPodcastList } from "../../services/data";
6-
import {updatePodcaster} from "../../redux/podcasterSlice";
6+
import {updatePodcaster, status} from "../../redux/podcasterSlice";
7+
import { Link } from "react-router-dom";
78

89
const Home = () => {
910
const dispatch = useDispatch(),
@@ -18,7 +19,7 @@ const Home = () => {
1819
}));
1920
}
2021

21-
if (podcaster.status === "ZERO") {
22+
if (podcaster.status === status.ZERO || podcaster.status === status.OUTDATED) {
2223
fetchData();
2324
}
2425
}, [podcaster.status]);
@@ -28,6 +29,7 @@ const Home = () => {
2829
<p className="home-title">Home:</p>
2930
<p>Estado de la store: {podcaster.status}</p>
3031
<p>Numero de podcasts: {podcaster.podcastList.length}</p>
32+
<Link to="/podcast/2">Pulsa aqui para ir al podcast</Link>
3133
</>);
3234
}
3335

‎src/screens/Podcast/Podcast.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import "./Podcast.css"
2-
import React from 'react';
32
import {useParams} from 'react-router-dom';
43

54
const Podcast = () => {

‎src/screens/Root/Root.js‎

Lines changed: 13 additions & 0 deletions

0 commit comments

Comments
 (0)