Skip to content

Commit c748c57

Browse files
committed
lang selector
1 parent e0eeffb commit c748c57

8 files changed

Lines changed: 117 additions & 49 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ This is a website that i designed and created for:
88
- link social media where you can find me;
99

1010
# Run the project
11-
`npx run dev`
11+
`npm run dev`
1212

1313
# Packages to install
14+
- `npm install`
1415
- `npm install sass`
1516
- `npm install negotiator @formatjs/intl-localematcher`
1617

components/LangSwitcher.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { useState, useEffect, useRef } from "react";
55
import styles from "../styles/LangSwitcher.module.scss";
66

77
const LANGS = [
8-
{ code: "it", label: "Italiano", flag: "🇮🇹" },
9-
{ code: "en", label: "English", flag: "🇬🇧" },
8+
{ code: "it", label: "Italiano", flag: "/images//flags/ita.png" },
9+
{ code: "en", label: "English", flag: "/images//flags/eng.png" },
1010
];
1111

1212
export default function LangSwitcher() {
@@ -28,7 +28,8 @@ export default function LangSwitcher() {
2828
return () => document.removeEventListener("mousedown", handleClickOutside);
2929
}, []);
3030

31-
const currentLang = LANGS.find((l) => pathname.startsWith(`/${l.code}`)) || LANGS[0];
31+
const currentLang =
32+
LANGS.find((l) => pathname.startsWith(`/${l.code}`)) || LANGS[0];
3233

3334
function changeLanguage(lang: string) {
3435
document.cookie = `NEXT_LOCALE=${lang}; path=/; max-age=31536000`;
@@ -45,27 +46,35 @@ export default function LangSwitcher() {
4546
aria-haspopup="listbox"
4647
aria-expanded={open}
4748
>
48-
<span>{currentLang.flag}</span> {currentLang.label}
49+
<img
50+
src={currentLang.flag}
51+
alt={currentLang.label}
52+
className={styles.flag}
53+
/>
4954
</button>
5055

5156
{open && (
52-
<ul role="listbox" tabIndex={-1} className={styles.dropdown}>
57+
<ul role="listbox" className={styles.dropdown}>
5358
{LANGS.filter((l) => l.code !== currentLang.code).map((lang) => (
5459
<li
5560
key={lang.code}
5661
role="option"
5762
onClick={() => changeLanguage(lang.code)}
5863
className={styles.option}
64+
tabIndex={0}
5965
onKeyDown={(e) => {
6066
if (e.key === "Enter" || e.key === " ") changeLanguage(lang.code);
6167
}}
62-
tabIndex={0}
6368
>
64-
{lang.flag} {lang.label}
69+
<img
70+
src={lang.flag}
71+
alt={lang.label}
72+
className={styles.flag}
73+
/>
6574
</li>
6675
))}
6776
</ul>
6877
)}
6978
</div>
7079
);
71-
}
80+
}

public/images/flags/eng.png

26.4 KB
Loading

public/images/flags/ita.png

23.3 KB
Loading

styles/HeroPortfolio.module.scss

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@
44
display: flex;
55
justify-content: center;
66
align-items: center;
7-
height: 100vh;
7+
min-height: 100vh;
88
background-color: var(--background);
9-
padding: 20px; // Aggiunto padding per evitare che il contenuto tocchi i bordi
9+
padding: 20px;
10+
11+
@media (max-width: 768px) {
12+
padding-top: 80px; // spazio sufficiente sotto la navbar
13+
padding-bottom: 40px; // spazio sufficiente sotto i pulsanti
14+
flex-direction: column;
15+
justify-content: flex-start;
16+
}
1017
}
1118

1219
.container {
@@ -114,17 +121,17 @@
114121
}
115122
}
116123

117-
/* Miglioramenti pulsanti */
118124
.buttonGroup {
119125
margin-top: 20px;
120126
display: flex;
121127
gap: 15px;
122128
flex-wrap: wrap;
123-
justify-content: center; // Centra i pulsanti
129+
justify-content: center;
124130

125131
@media (max-width: 600px) {
126-
flex-direction: column; // Disposizione verticale per evitare sovrapposizioni
132+
flex-direction: column;
127133
align-items: center;
134+
margin-bottom: 40px; // spazio extra sotto i pulsanti
128135
}
129136
}
130137

@@ -152,3 +159,15 @@
152159
border-top: 2px solid var(--accent);
153160
text-align: center;
154161
}
162+
163+
164+
@media (max-width: 768px) {
165+
.heroSection {
166+
padding-top: 120px; // abbassa immagine sotto la navbar
167+
padding-bottom: 80px; // evita che i bottoni tocchino il footer
168+
}
169+
170+
.buttonGroup {
171+
margin-bottom: 40px; // spazio aggiuntivo sotto i bottoni
172+
}
173+
}

styles/LangSwitcher.module.scss

Lines changed: 52 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,73 @@
1-
.container {
2-
position: relative;
3-
display: inline-block;
4-
right: 5px;
5-
}
6-
71
.button {
8-
cursor: pointer;
9-
font-size: 1rem;
10-
padding: 0.5rem 1rem;
11-
background: white;
2+
width: 40px;
3+
height: 40px;
4+
border-radius: 50%;
125
border: 1px solid #ccc;
13-
border-radius: 4px;
14-
user-select: none;
6+
background: white;
157
display: flex;
168
align-items: center;
17-
gap: 0.5rem;
18-
min-width: 100px; /* larghezza minima per il bottone */
9+
justify-content: center;
10+
padding: 0;
11+
}
12+
13+
.flag {
14+
object-fit: cover;
15+
width: 100%;
1916
}
2017

2118
.dropdown {
2219
position: absolute;
23-
top: 100%;
20+
top: 100%; /* subito sotto il bottone */
2421
left: 0;
25-
background: white;
26-
border: 1px solid #ccc;
27-
border-radius: 4px;
28-
margin-top: 4px;
29-
list-style: none;
30-
padding: 0;
22+
transform: none;
23+
display: flex;
24+
flex-direction: column;
25+
background: transparent; /* puoi cambiare se vuoi */
26+
padding: 8px 0; /* piccolo padding verticale */
3127
z-index: 9999;
32-
min-width: 130px;
33-
max-width: 180px; /* massimo */
34-
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
28+
}
29+
30+
.container {
31+
position: relative;
32+
display: inline-block;
3533
}
3634

3735
.option {
38-
padding: 0.4rem 0.8rem;
39-
cursor: pointer;
40-
user-select: none;
36+
width: 40px;
37+
height: 40px;
38+
border-radius: 50%;
4139
display: flex;
4240
align-items: center;
43-
gap: 0.5rem;
44-
font-size: 16px !important;
41+
justify-content: center;
42+
background: white;
43+
border: 1px solid #ccc;
44+
cursor: pointer;
45+
transition: transform 0.2s;
4546

4647
&:hover,
4748
&:focus {
48-
background-color: #f0f0f0;
49+
transform: scale(1.2);
4950
outline: none;
5051
}
5152
}
53+
54+
55+
@media (max-width: 600px) {
56+
.button {
57+
width: 40px; /* mantieni la dimensione circolare */
58+
height: 40px;
59+
padding: 0;
60+
}
61+
62+
.dropdown {
63+
top: 100%; /* dropdown sotto il bottone anche su mobile */
64+
left: 50%;
65+
transform: translateX(-50%);
66+
}
67+
68+
.option {
69+
width: 40px; /* mantiene la forma circolare */
70+
height: 40px;
71+
padding: 0; /* nessun padding extra */
72+
}
73+
}

styles/Navbar.module.scss

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,10 @@
1212
list-style-type: none;
1313
margin: 0;
1414
padding: 0;
15-
filter: blur(0.5px);
16-
-webkit-filter: blur(0.5px); /* Safari */
1715
position: relative;
1816

1917
&:hover {
2018
opacity: 1;
21-
filter: blur(0);
22-
-webkit-filter: blur(0); /* Safari */
2319
}
2420

2521
@media (max-width: $media-mobile) {
@@ -79,3 +75,25 @@
7975
display: flex;
8076
align-items: center;
8177
}
78+
79+
80+
@media (max-width: 600px) {
81+
.navList {
82+
flex-wrap: wrap;
83+
justify-content: center;
84+
}
85+
86+
.navList li {
87+
margin-right: 0.5rem;
88+
}
89+
90+
.right {
91+
margin-left: 0;
92+
flex-wrap: wrap;
93+
gap: 0.5rem;
94+
}
95+
96+
.right > * {
97+
flex: 1 1 auto;
98+
}
99+
}

styles/StudyPlan.module.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
justify-content: center;
1414
align-items: center;
1515
gap: 8px;
16-
1716
}
1817

1918
.diploma a{

0 commit comments

Comments
 (0)