Skip to content

Commit c19a642

Browse files
committed
navbar elements are now responsive to screen changes
1 parent 58c0642 commit c19a642

File tree

10 files changed

+137
-47
lines changed

10 files changed

+137
-47
lines changed

docs/README.es.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ Esto levantará el servidor y pondrá en funcionamiento el API REST para que pue
129129
- Asegúrate de tener correctamente instalados todos los programas necesarios antes de proceder con la ejecución del proyecto.
130130

131131
- En el archivo db.json se posee tres cuentas y 14 posts. Estas son las credenciales de cada cuenta para por iniciar sesión en el proyecto y editar los posts ya creados:
132-
- pablsch.it@gmail.com / pwd: 123456
133-
- Pedro.it@gmail.com / pwd: 123456
134-
- jose.JJ@gmail.com / pwd: 123456
132+
- [pablsch.it@gmail.com](mailto:pablsch.it@gmail.com) / pwd: 123456
133+
- [Pedro.it@gmail.com](mailto:Pedro.it@gmail.com) / pwd: 123456
134+
- [jose.JJ@gmail.com](mailto:jose.JJ@gmail.com) / pwd: 123456
135135

136136
## Sin Contribuciones ni Licencias
137137

etc/TODO List.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
1. Improve the CSS
1+
# TODO List
2+
3+
1. Improve the CSS.
24
2. Load the image to the input of this one when you edit a post because currently this one doesn't receive anything, so you don't have to load the same original image again from the client.
35
3. In the search panel, keep the search parameters when you search by word or tag.
46
4. Improve the notifications in terms of appearance on the screen and its aesthetics.

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<link rel="stylesheet" href="src/styles/components/loader.css">
2020
<link rel="stylesheet" href="src/styles/components/loader-container.css">
2121

22-
<link rel="stylesheet" href="src/styles/components/posts-display.css">
22+
<link rel="stylesheet" href="src/styles/components/post-card-container.css">
2323
<link rel="stylesheet" href="src/styles/components/post.css">
2424
</head>
2525

@@ -38,7 +38,7 @@ <h1>Posts</h1>
3838

3939
<div class="notifications"></div>
4040

41-
<div class="showPosts-container"></div>
41+
<div class="post-card-container"></div>
4242

4343
<div class="pages" id="pages"></div>
4444
</main>

src/js/components/navbar/navbarController.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,35 @@ export function navbarController(container) {
1313
function handleVisibility() {
1414
const path = window.location.pathname;
1515

16-
const searchBtn = document.querySelector('.nav-center');
16+
const searchContainer = document.querySelector('.nav-center');
1717
const logoutBtn = document.getElementById('logout-btn');
1818
const loginBtn = document.getElementById('login-btn');
1919
const signupBtn = document.getElementById('signup-btn');
2020
const createPostBtn = document.getElementById('create-post-btn');
2121

2222
// Button visibility logic based on path
23-
if (searchBtn) searchBtn.style.display = 'none';
23+
if (searchContainer) searchContainer.style.display = 'none';
2424

2525
if (path.endsWith('index.html')) {
26-
if (searchBtn) searchBtn.style.display = 'block'; // Make sure it's visible
26+
if (searchContainer) searchContainer.style.display = 'flex'; // Make sure it's visible
2727
}
2828

2929
// Button visibility logic based on authentication state
3030
if (isAuthenticated()) {
3131

3232
// Show "Logout" and "Create Post", hide "Login" and "Sign Up"
33-
if (logoutBtn) logoutBtn.style.display = 'block'; // Make sure it's visible
33+
if (logoutBtn) logoutBtn.style.display = 'flex'; // Make sure it's visible
3434
if (loginBtn) loginBtn.style.display = 'none'; // Hide if there's a token
3535
if (signupBtn) signupBtn.style.display = 'none'; // Hide if there's a token
36-
if (createPostBtn) createPostBtn.style.display = 'block'; // Make sure it's visible
36+
if (createPostBtn) createPostBtn.style.display = 'flex'; // Make sure it's visible
3737

3838
} else {
3939

4040
// Show "Login" and "Sign Up", hide "Logout" and "Create Post"
4141
if (logoutBtn) logoutBtn.style.display = 'none'; // Hide if there's no token
4242
if (createPostBtn) createPostBtn.style.display = 'none'; // Hide if there's no token
43-
if (loginBtn) loginBtn.style.display = 'block'; // Make sure it's visible
44-
if (signupBtn) signupBtn.style.display = 'block'; // Make sure it's visible
43+
if (loginBtn) loginBtn.style.display = 'flex'; // Make sure it's visible
44+
if (signupBtn) signupBtn.style.display = 'flex'; // Make sure it's visible
4545
}
4646

4747
}

src/js/components/navbar/navbarView.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,31 @@ export function navbarView() {
1010
`;
1111

1212
return `
13-
<a id="index-btn" class="nav-left">Home</a>
14-
15-
<div class="nav-center">
16-
<form id="search-form">
13+
<div class='navbar-container'>
14+
<div class="nav-left">
15+
<a id="index-btn">Home</a>
16+
</div>
17+
18+
<div class="nav-center">
19+
<form id="search-form">
1720
18-
<input id="search" name="search" type="text" placeholder="Search" />
21+
<input id="search" name="search" type="text" placeholder="Search" />
1922
20-
<select id="post-tag" name="tag">
21-
${tagSelector}
22-
</select>
23+
<select id="post-tag" name="tag">
24+
${tagSelector}
25+
</select>
2326
24-
<button type="submit">Search</button>
27+
<button type="submit">Search</button>
2528
26-
</form>
27-
</div>
29+
</form>
30+
</div>
2831
29-
<div class="nav-right">
30-
<a id="create-post-btn">Create Post</a>
31-
<a id="login-btn">Login</a>
32-
<a id="signup-btn">Sign Up</a>
33-
<a id="logout-btn">Log Out</a>
32+
<div class="nav-right">
33+
<a id="create-post-btn">Create Post</a>
34+
<a id="login-btn">Login</a>
35+
<a id="signup-btn">Sign Up</a>
36+
<a id="logout-btn">Log Out</a>
37+
</div>
3438
</div>
3539
`;
3640
}

src/js/modules/show-posts/showPosts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { loginController } from "../../modules/login/loginController.js";
99
export function initShowPosts() {
1010

1111
// Here I go to the DOM and select the nodes I need to manage in my code and I manage them in my controllers.
12-
const container = document.querySelector(".showPosts-container")
12+
const container = document.querySelector(".post-card-container")
1313
const loader = document.querySelector(".loader")
1414
const notifications = document.querySelector(".notifications")
1515
const session = document.querySelector(".session")

src/styles/common.css

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,17 @@ body {
1818
}
1919

2020
main {
21+
max-width: 1440px;
22+
2123
margin: clamp(5px, 2vw, 1rem) clamp(10px, 5vw, 2rem);
24+
margin-top: 0;
25+
margin-bottom: 0;
26+
27+
padding: 1rem;
28+
2229
background-color: var(--bg-color-4);
30+
margin-left: auto;
31+
margin-right: auto;
2332
}
2433

2534
video,
@@ -48,7 +57,7 @@ h3,
4857
h4,
4958
p {
5059
margin: 0;
51-
text-align: justify;
60+
text-align: left;
5261
}
5362

5463
input,

src/styles/components/posts-display.css renamed to src/styles/components/post-card-container.css

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
.showPosts-container {
1+
.post-card-container {
22
display: grid;
33
gap: 1rem;
44
grid-template-columns: repeat(2, 1fr);
5-
padding: 1rem;
65

76
a {
87
color: inherit;
@@ -14,7 +13,7 @@
1413
}
1514

1615
@media (min-width: 768px) {
17-
.showPosts-container {
16+
.post-card-container {
1817
grid-template-columns: repeat(4, 1fr);
1918
}
2019
}

src/styles/components/post.css

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ a {
1111

1212
height: 100%;
1313

14-
padding: 1rem;
14+
padding: 5px;
1515

1616
border-radius: 8px;
1717
transition: transform 0.2s ease;
1818
background-color: var(--bg-post);
1919
}
2020

21+
.post .post-image{
22+
justify-content: center;
23+
}
24+
2125
.post .title {
2226
font-weight: bold;
2327
}
@@ -59,21 +63,21 @@ a {
5963

6064
.post-image {
6165
/* DO NOT TOUCH THE CODE! */
62-
display: block;
63-
6466
width: 100%;
67+
max-width: 300px;
6568
/* IMPORTANT TO BE WITH: 100% and HEIGHT: AUTO! */
6669
height: auto;
6770

68-
max-height: 200px;
69-
71+
/* max-height: 200px; */
7072
object-fit: cover;
7173
margin: 0.5rem 0;
7274

7375
border: 1px solid #ddd;
7476
}
7577

7678
.sale-label {
79+
font-size: small;
80+
7781
position: absolute;
7882
top: 10px;
7983
right: 10px;
@@ -93,7 +97,11 @@ a {
9397
}
9498

9599
@media (min-width: 460px) {
96-
.post p {
97-
padding: 5px;
100+
.sale-label {
101+
font-size: 1rem;
102+
}
103+
104+
.post {
105+
padding: 1rem;
98106
}
99107
}

src/styles/navbar.css

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
.navbar {
2-
display: flex;
2+
background-color: var(--bg-color);
3+
}
4+
5+
.navbar-container {
6+
display: grid;
7+
grid-template-columns: repeat(6, 1fr);
8+
grid-template-rows: repeat(2, 1fr);
9+
10+
grid-column-gap: 1rem;
11+
grid-row-gap: 1rem;
12+
13+
margin-left: auto;
14+
margin-right: auto;
315

4-
font-weight: bold;
5-
justify-content: space-between;
6-
align-items: center;
716
padding: clamp(1px, 5vw, 16px);
817

9-
background-color: var(--bg-color);
18+
max-width: 1440px;
19+
20+
font-weight: bold;
1021
}
1122

1223
.navbar a {
@@ -16,7 +27,64 @@
1627
background-color: var(--bg-color-4);
1728
}
1829

30+
.nav-right a {
31+
display: flex;
32+
33+
width: 100%;
34+
justify-content: center;
35+
align-items: center;
36+
}
37+
38+
.nav-left {
39+
grid-area: 1 / 1 / 2 / 4;
40+
}
41+
42+
.nav-left a {
43+
display: flex;
44+
45+
width: 100%;
46+
justify-content: center;
47+
align-items: center;
48+
}
49+
50+
.nav-center {
51+
grid-area: 2 / 1 / 3 / 7;
52+
}
53+
54+
#search-form {
55+
display: flex;
56+
width: 100%;
57+
justify-content: space-evenly;
58+
gap: 1rem;
59+
}
60+
61+
#search-form input,
62+
#search-form select,
63+
#search-form button {
64+
65+
width: 100%;
66+
}
67+
1968
.nav-right {
2069
display: flex;
21-
gap: clamp(1px, 5vw, 16px);
70+
justify-content: flex-end;
71+
gap: 1rem;
72+
grid-area: 1 / 4 / 2 / 7;
73+
}
74+
75+
@media (min-width: 768px) {
76+
.nav-left {
77+
grid-area: 1 / 1 / 3 / 2;
78+
}
79+
.nav-center {
80+
grid-area: 1 / 2 / 3 / 5;
81+
}
82+
83+
#search-form {
84+
gap: 0.5rem;
85+
}
86+
.nav-right {
87+
grid-area: 1 / 5 / 3 / 7;
88+
gap: 0.5rem;
89+
}
2290
}

0 commit comments

Comments
 (0)