Skip to content

Commit 46e6cdd

Browse files
author
Thiago Jorge Almeida dos Santos
committed
2nd class updates
1 parent 7c2804a commit 46e6cdd

File tree

18 files changed

+255
-80
lines changed

18 files changed

+255
-80
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This project is an adaptation and evolution of the **[AluraTube](https://github.
1919

2020
<br />
2121
<p align="center">
22-
<img alt="Preview" src="./screenshots/preview.png" width="800" />
22+
<img alt="Preview" src="./screenshots/preview light.png" width="800" />
2323
</p>
2424
<br />
2525

@@ -74,7 +74,7 @@ git push origin my-new-feature
7474
- After your pull request is merged, you can safely delete your branch.
7575

7676
## Todo List
77-
77+
7878
- [ ] Obtain a list of videos dinamically from [Google API](https://www.npmjs.com/package/googleapis);
7979
- [ ] Add fade efect in horizontal scrolls extremities;
8080
- [ ] Create, edit and remove playlists;

README_pt-br.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Este projeto é uma adaptação e evolução do projeto **[AluraTube](https://gi
1919

2020
<br />
2121
<p align="center">
22-
<img alt="Preview" src="./screenshots/preview.png" width="800" />
22+
<img alt="Preview" src="./screenshots/preview light.png" width="800" />
2323
</p>
2424
<br />
2525

config.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
"instagram": "thiago.tjas",
1111
"github": "tjas"
1212
},
13-
"banner": "https://images.unsplash.com/photo-1500534314209-a25ddb2bd429",
14-
"banner-ref": "https://unsplash.com/photos/HDd-NQ_AMNQ"
13+
"banner": {
14+
"image": "https://images.unsplash.com/photo-1500534314209-a25ddb2bd429",
15+
"reference": "https://unsplash.com/photos/HDd-NQ_AMNQ"
16+
}
1517
},
1618
"playlists": {
1719
"jogos": [
@@ -258,6 +260,6 @@
258260
}
259261
},
260262
"environment": "development",
261-
"version": "0.1.0",
262-
"build": "20221109"
263+
"version": "0.2.0",
264+
"build": "20221113"
263265
}

package-lock.json

+17-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"react": "18.2.0",
1111
"react-dom": "18.2.0",
1212
"react-icons": "4.6.0",
13-
"styled-components": "5.3.6"
13+
"styled-components": "5.3.6",
14+
"use-local-storage": "2.3.6"
1415
}
1516
}

pages/index.js

+32-14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from "react";
12
import config from "../config.json";
23
import styled from "styled-components";
34

@@ -11,32 +12,49 @@ import { Favorites } from "../src/components/Favorites";
1112
import { Footer } from "../src/components/Footer";
1213

1314
function HomePage() {
15+
16+
const defaultDark = false;
17+
const [theme, setTheme] = React.useState(defaultDark ? 'dark' : 'light');
18+
const [valorDoFiltro, setValorDoFiltro] = React.useState("");
19+
20+
// References to use LocalStorage to keep variables between refreshes (i.e., the theme selected),
21+
// and to verify if any local variable exists or has previous value:
22+
// https://www.freecodecamp.org/news/how-to-use-localstorage-with-react-hooks-to-set-and-get-items/
23+
// https://www.freecodecamp.org/news/how-to-use-localstorage-with-react-hooks-to-set-and-get-items/
24+
25+
const switchTheme = () => {
26+
const newTheme = theme === 'light' ? 'dark' : 'light';
27+
//console.log("Switched theme to: " + newTheme);
28+
setTheme(newTheme);
29+
}
30+
1431
return (
15-
<>
32+
<div data-theme={theme}>
1633
<CSSReset />
1734
<div style={{
18-
display: "flex",
19-
flexDirection: "column",
20-
flex: 1,
35+
"display": "flex",
36+
"flexDirection": "column",
37+
"flex": 1,
38+
"background-color": "var(--backgroundBase)",
39+
"color": "var(--textColorBase)"
2140
}}>
22-
41+
{/* Prop Drilling */}
2342
<StyledHeader>
24-
<Menu />
25-
<Banner user={config.user} />
26-
<Header user={config.user} />
43+
<Menu valorDoFiltro={valorDoFiltro} setValorDoFiltro={setValorDoFiltro} theme={theme} switchTheme={switchTheme} />
44+
<Banner banner={config.user.banner} theme={theme} />
45+
{/* <div align="right" style={{"text-transform": "capitalize", "color": "white", "font-size": "22px", "translate": "0px -35px", "padding-right": "48px" }}>{theme} Theme</div> */}
46+
<Header user={config.user} theme={theme} />
2747
</StyledHeader>
28-
2948
<StyledContent>
30-
<Timeline playlists={config.playlists} />
31-
<Favorites favorites={config.favorites} />
49+
<Timeline searchValue={valorDoFiltro} playlists={config.playlists} theme={theme} />
50+
<Favorites favorites={config.favorites} theme={theme} />
3251
</StyledContent>
33-
3452
<StyledFooter>
35-
<Footer />
53+
<Footer theme={theme} />
3654
</StyledFooter>
3755

3856
</div>
39-
</>
57+
</div>
4058
);
4159
}
4260

screenshots/preview dark.png

527 KB
Loading

screenshots/preview light.png

526 KB
Loading

screenshots/preview.png

-523 KB
Binary file not shown.

src/components/Banner.js src/components/Banner/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ const StyledBanner = styled.header`
1818

1919
export function Banner(properties) {
2020
return (
21-
<StyledBanner>
21+
<StyledBanner data-theme={properties.theme}>
2222
<div className="crop">
23-
<img src={`${properties.user.banner}`} />
23+
<img src={`${properties.banner.image}`} />
2424
</div>
2525
</StyledBanner>
2626
);

src/components/CSSReset.js

+50-19
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,40 @@
11
import { createGlobalStyle } from "styled-components";
22

3+
// Reference to themes:
4+
// https://css-tricks.com/easy-dark-mode-and-multiple-color-themes-in-react/
5+
36
export const CSSReset = createGlobalStyle`
47
58
/* CSS Variables */
69
:root {
7-
/* Light Mode */
8-
--light-backgroundBase: #F9F9F9;
9-
--light-backgroundLevel1: #FFFFFF;
10-
--light-backgroundLevel2: #F0F0F0;
11-
--light-borderBase: #E5E5E5;
12-
--light-textColorBase: #222222;
13-
14-
/* Dark Mode */
15-
--dark-backgroundBase: #181818;
16-
--dark-backgroundLevel1: #202020;
17-
--dark-backgroundLevel2: #313131;
18-
--dark-borderBase: #383838;
19-
--dark-textColorBase: #FFFFFF;
10+
/* Default Theme */
11+
--backgroundBase: #F9F9F9;
12+
--backgroundLevel1: #FFFFFF;
13+
--backgroundLevel2: #F0F0F0;
14+
--borderBase: #E5E5E5;
15+
--textColorBase: #222222;
16+
--textColorLevel1: #555555;
17+
--textColorLevel2: #888888;
18+
}
19+
[data-theme='light'] {
20+
/* Light Theme */
21+
--backgroundBase: #F9F9F9;
22+
--backgroundLevel1: #FFFFFF;
23+
--backgroundLevel2: #F0F0F0;
24+
--borderBase: #E5E5E5;
25+
--textColorBase: #222222;
26+
--textColorLevel1: #555555;
27+
--textColorLevel2: #888888;
28+
}
29+
[data-theme='dark'] {
30+
/* Dark Theme */
31+
--backgroundBase: #181818;
32+
--backgroundLevel1: #202020;
33+
--backgroundLevel2: #313131;
34+
--borderBase: #383838;
35+
--textColorBase: #FFFFFF;
36+
--textColorLevel1: #CCCCCC;
37+
--textColorLevel2: #999999;
2038
}
2139
2240
/* Reset */
@@ -34,7 +52,7 @@ export const CSSReset = createGlobalStyle`
3452
justify-content: center;
3553
text-transform: capitalize;
3654
margin: 16px 16px;
37-
border-bottom: 1px solid #eeeeee;
55+
border-bottom: 1px solid var(--borderBase);
3856
svg {
3957
font-size: 80%;
4058
}
@@ -65,15 +83,28 @@ export const CSSReset = createGlobalStyle`
6583
}
6684
}
6785
86+
/* Scrollbars */
6887
body ::-webkit-scrollbar {
69-
width: 8px; /* width of the entire scrollbar */
70-
height: 8px; /* height of the entire scrollbar */
88+
width: 8px; /* width of the entire scrollbar */
89+
height: 8px; /* height of the entire scrollbar */
7190
}
7291
body ::-webkit-scrollbar-track {
73-
background: #ffffff; /* color of the tracking area */
92+
background: var(--backgroundBase); /* color of the tracking area */
7493
}
7594
body ::-webkit-scrollbar-thumb {
76-
background-color: #dddddd; /* color of the scroll thumb */
77-
border-radius: 8px; /* roundness of the scroll thumb */
95+
background-color: var(--backgroundLevel2); /* color of the scroll thumb */
96+
border-radius: 8px; /* roundness of the scroll thumb */
97+
}
98+
99+
/* Placeholders */
100+
::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
101+
color: var(--textColorLevel2);
102+
opacity: 1; /* Firefox */
103+
}
104+
:-ms-input-placeholder { /* Internet Explorer 10-11 */
105+
color: var(--textColorLevel2);
106+
}
107+
::-ms-input-placeholder { /* Microsoft Edge */
108+
color: var(--textColorLevel2);
78109
}
79110
`;

src/components/Favorites.js src/components/Favorites/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const StyledFavorites = styled.section`
1515
width: 80px;
1616
height: 80px;
1717
border-radius: 50%;
18-
border: 1px solid #eeeeee;
18+
border: 1px solid var(--borderBase);
1919
}
2020
section {
2121
width: calc(100vw - 16px * 4);
@@ -37,7 +37,7 @@ const StyledFavorites = styled.section`
3737
padding-top: 8px;
3838
display: flex;
3939
text-align: center;
40-
color: ${({ theme }) => theme.textColorBase || "#222222"};
40+
color: var(--textColorBase);
4141
}
4242
}
4343
}
@@ -52,13 +52,13 @@ export function Favorites(properties) {
5252
// Statement
5353
// Retorno por expressão
5454
return (
55-
<StyledFavorites>
55+
<StyledFavorites data-theme={properties.theme}>
5656
<h1><BsStar /> Favorites</h1>
5757
<section>
5858
{favorites.map((index) => {
5959
const favorite = properties.favorites[index];
6060
return (
61-
<div nameclass="favorite">
61+
<div key={index} nameclass="favorite">
6262
<a href={favorite.url} target="_blank">
6363
<img src={favorite.thumb} />
6464
<span>{favorite.name}</span>

src/components/Footer.js src/components/Footer/index.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const StyledFooter = styled.section`
99
justify-content: space-between;
1010
gap: 16px;
1111
margin-top: 16px;
12-
border-top: 1px solid #eeeeee;
12+
border-top: 1px solid var(--borderBase);
1313
padding: 28px 32px;
1414
div {
1515
display: flex;
@@ -21,30 +21,30 @@ const StyledFooter = styled.section`
2121
display: flex;
2222
align-items: center;
2323
font-size: 13px;
24-
color: #777777;
24+
color: var(--textColorLevel2);
2525
a {
2626
color: inherit;
2727
cursor: pointer;
2828
}
2929
}
3030
}
3131
.localization {
32-
border: 1px solid #eeeeee;
32+
border: 1px solid var(--borderBase);
3333
padding: 6px;
3434
gap: 4px;
3535
}
3636
.icon {
37-
color: #888888;
37+
color: var(--textColorLevel2);
3838
font-size: 10px;
3939
}
4040
@media (max-width: 750px) {
4141
flex-direction: column;
4242
}
4343
`;
4444

45-
export function Footer() {
45+
export function Footer(properties) {
4646
return (
47-
<StyledFooter>
47+
<StyledFooter data-theme={properties.theme}>
4848
<div>
4949
<div className="left">
5050
<a>About</a>
@@ -54,8 +54,7 @@ export function Footer() {
5454
<a>Service Terms</a>
5555
</div>
5656
<div className="right">
57-
<BsGlobe style={{color: "#888888"}} />
58-
{/* Language: */}
57+
<BsGlobe style={{"color": "var(--textColorLevel2)"}} />
5958
<a>
6059
<div className="localization">
6160
EN

0 commit comments

Comments
 (0)