Skip to content

Commit 2e0ac4f

Browse files
committed
Refactor code for consistency and readability
- Updated import statements across multiple files to use double quotes for consistency. - Simplified object property definitions in the translation data for improved readability. - Enhanced the redirect logic in public/redirect.js to utilize template literals. - Cleaned up the layout and Navbar components by organizing imports and ensuring consistent formatting. - Refactored the Subscribe component to improve state management and error handling. - Streamlined the App component by consolidating imports and ensuring a cleaner structure.
1 parent fd0fa40 commit 2e0ac4f

File tree

14 files changed

+748
-670
lines changed

14 files changed

+748
-670
lines changed

jsconfig.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
{
22
"compilerOptions": {
33
"paths": {
4-
"@/*": [
5-
"./src/*"
6-
],
7-
"@/node_modules/*": [
8-
"./node_modules/*"
9-
]
4+
"@/*": ["./src/*"],
5+
"@/node_modules/*": ["./node_modules/*"]
106
}
117
}
128
}

public/redirect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
var lastSlash = path.lastIndexOf("/");
55
var base = lastSlash <= 0 ? "/" : path.slice(0, lastSlash);
66
var route = lastSlash <= 0 ? path : path.slice(lastSlash);
7-
window.location.replace(base + "#" + route);
7+
window.location.replace(`${base}#${route}`);
88
})();

src/App.jsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import { useContext, useEffect, useState } from "react";
22
import { Route, Routes } from "react-router-dom";
3+
import LanguageContext from "@/LanguageContext";
4+
import Layout from "@/layout";
5+
import data from "@/translation";
36
import { usePageTracking } from "./hooks/usePageTracking";
47
import Home from "./pages/Home";
58
import Sponsors from "./pages/Sponsors";
69
import Team from "./pages/Team";
710

8-
import Layout from '@/layout';
9-
import LanguageContext from '@/LanguageContext';
10-
11-
import data from '@/translation';
12-
13-
import './App.scss';
11+
import "./App.scss";
1412
import LandingPage from "@/pages/LandingPage";
1513

1614
function App() {

src/LanguageContext.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { PropTypes } from 'prop-types';
2-
import { createContext, useState, useEffect } from 'react';
1+
import { PropTypes } from "prop-types";
2+
import { createContext, useEffect, useState } from "react";
33

44
const LanguageContext = createContext();
55

66
export const LanguageProvider = ({ children }) => {
7-
const storedLang = localStorage.getItem('language') || 'en';
7+
const storedLang = localStorage.getItem("language") || "en";
88
const [language, setLanguage] = useState(storedLang);
99

1010
useEffect(() => {
11-
localStorage.setItem('language', language);
11+
localStorage.setItem("language", language);
1212
}, [language]);
1313

1414
return (
@@ -19,7 +19,7 @@ export const LanguageProvider = ({ children }) => {
1919
};
2020

2121
LanguageProvider.propTypes = {
22-
children: PropTypes.node.isRequired
22+
children: PropTypes.node.isRequired,
2323
};
2424

2525
export default LanguageContext;

src/components/Footer.jsx

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
1-
import PropTypes from 'prop-types';
2-
import { Container, Row, Col } from 'react-bootstrap';
3-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
41
import {
52
faGithubAlt,
63
faInstagram,
74
faXTwitter,
8-
faYoutube
9-
} from '@fortawesome/free-brands-svg-icons';
10-
import { NavLink } from 'react-router-dom';
5+
faYoutube,
6+
} from "@fortawesome/free-brands-svg-icons";
7+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
8+
import PropTypes from "prop-types";
9+
import { Col, Container, Row } from "react-bootstrap";
10+
import { NavLink } from "react-router-dom";
1111

1212
const Footer = ({ dataTranslate }) => {
1313
const f = dataTranslate?.footer ?? {};
1414

1515
const socialLinks = [
16-
{ icon: faGithubAlt, href: 'https://github.com/PyConColombia', label: 'GitHub' },
16+
{
17+
icon: faGithubAlt,
18+
href: "https://github.com/PyConColombia",
19+
label: "GitHub",
20+
},
1721
{
1822
icon: faInstagram,
19-
href: 'https://www.instagram.com/pyconcolombia/',
20-
label: 'Instagram'
23+
href: "https://www.instagram.com/pyconcolombia/",
24+
label: "Instagram",
25+
},
26+
{ icon: faXTwitter, href: "https://twitter.com/pyconcolombia", label: "X" },
27+
{
28+
icon: faYoutube,
29+
href: "https://www.youtube.com/@PyConColombia",
30+
label: "YouTube",
2131
},
22-
{ icon: faXTwitter, href: 'https://twitter.com/pyconcolombia', label: 'X' },
23-
{ icon: faYoutube, href: 'https://www.youtube.com/@PyConColombia', label: 'YouTube' }
2432
];
2533

2634
const legalLinks = [
27-
{ to: '/code-of-conduct', label: f.codeOfConduct },
28-
{ to: '/coc-enforcement', label: f.codeOfConductEnforcementProcedure },
29-
{ to: '/health-safety', label: f.HealthSafetyPolicy }
35+
{ to: "/code-of-conduct", label: f.codeOfConduct },
36+
{ to: "/coc-enforcement", label: f.codeOfConductEnforcementProcedure },
37+
{ to: "/health-safety", label: f.HealthSafetyPolicy },
3038
];
3139

3240
return (
@@ -92,7 +100,7 @@ const Footer = ({ dataTranslate }) => {
92100
};
93101

94102
Footer.propTypes = {
95-
dataTranslate: PropTypes.object
103+
dataTranslate: PropTypes.object,
96104
};
97105

98106
export default Footer;

src/components/NavbarCustom.jsx

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import PropTypes from 'prop-types';
2-
import { NavLink } from 'react-router-dom';
3-
import Container from 'react-bootstrap/Container';
4-
import Nav from 'react-bootstrap/Nav';
5-
import Navbar from 'react-bootstrap/Navbar';
6-
import NavDropdown from 'react-bootstrap/NavDropdown';
1+
import PropTypes from "prop-types";
2+
import Container from "react-bootstrap/Container";
3+
import Nav from "react-bootstrap/Nav";
4+
import Navbar from "react-bootstrap/Navbar";
5+
import NavDropdown from "react-bootstrap/NavDropdown";
6+
import { NavLink } from "react-router-dom";
77

88
const ArrowUpRightIcon = () => (
99
<svg
@@ -12,7 +12,8 @@ const ArrowUpRightIcon = () => (
1212
viewBox="0 0 24 24"
1313
fill="none"
1414
xmlns="http://www.w3.org/2000/svg"
15-
aria-hidden={true}>
15+
aria-hidden={true}
16+
>
1617
<path
1718
d="M7 17 17 7M17 7H7M17 7v10"
1819
stroke="currentColor"
@@ -31,7 +32,8 @@ const ChevronDownIcon = () => (
3132
viewBox="0 0 24 24"
3233
fill="none"
3334
xmlns="http://www.w3.org/2000/svg"
34-
aria-hidden={true}>
35+
aria-hidden={true}
36+
>
3537
<path
3638
d="m6 9 6 6 6-6"
3739
stroke="currentColor"
@@ -44,10 +46,20 @@ const ChevronDownIcon = () => (
4446

4547
const NavbarCustom = ({ dataTranslate }) => {
4648
const t = dataTranslate?.navbar ?? {};
47-
const years = ['2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023', '2024'];
49+
const years = [
50+
"2016",
51+
"2017",
52+
"2018",
53+
"2019",
54+
"2020",
55+
"2021",
56+
"2022",
57+
"2023",
58+
"2024",
59+
];
4860

4961
const linkClass = ({ isActive }) =>
50-
`navbar-custom__link${isActive ? ' navbar-custom__link--active' : ''}`;
62+
`navbar-custom__link${isActive ? " navbar-custom__link--active" : ""}`;
5163

5264
return (
5365
<Navbar expand="lg" fixed="top" variant="light" className="navbar-custom">
@@ -56,44 +68,52 @@ const NavbarCustom = ({ dataTranslate }) => {
5668
PYCON COLOMBIA 2026
5769
</Navbar.Brand>
5870

59-
<Navbar.Toggle aria-controls="navbar-custom-collapse" className="ms-auto" />
71+
<Navbar.Toggle
72+
aria-controls="navbar-custom-collapse"
73+
className="ms-auto"
74+
/>
6075

61-
<Navbar.Collapse id="navbar-custom-collapse" className="navbar-custom__collapse">
76+
<Navbar.Collapse
77+
id="navbar-custom-collapse"
78+
className="navbar-custom__collapse"
79+
>
6280
<div className="navbar-custom__collapse-inner">
6381
<div className="navbar-custom__pill-outer">
6482
<div className="navbar-custom__pill-inner">
6583
<Nav as="div" className="navbar-custom__nav-links">
6684
<NavLink to="/" end className={linkClass}>
67-
{t.home ?? 'Home'}
85+
{t.home ?? "Home"}
6886
</NavLink>
6987
<NavLink to="/sponsors" className={linkClass}>
70-
{t.sponsors ?? 'Sponsors'}
88+
{t.sponsors ?? "Sponsors"}
7189
</NavLink>
7290
<NavLink to="/keynotes" className={linkClass}>
73-
{t.keynotes ?? 'Keynotes'}
91+
{t.keynotes ?? "Keynotes"}
7492
</NavLink>
7593
<NavLink to="/speakers" className={linkClass}>
76-
{t.speakers ?? 'Speakers'}
94+
{t.speakers ?? "Speakers"}
7795
</NavLink>
7896
<NavLink to="/team" className={linkClass}>
79-
{t.team ?? 'Team'}
97+
{t.team ?? "Team"}
8098
</NavLink>
8199
<NavDropdown
82100
className="navbar-custom__dropdown"
83101
title={
84102
<span className="d-inline-flex align-items-center gap-2">
85-
{t.schedule ?? 'Schedule'}
103+
{t.schedule ?? "Schedule"}
86104
<ChevronDownIcon />
87105
</span>
88106
}
89107
id="navbar-schedule-dropdown"
90-
align="end">
108+
align="end"
109+
>
91110
{years.map((year) => (
92111
<NavDropdown.Item
93112
key={year}
94113
href={`https://${year}.pycon.co`}
95114
rel="noopener noreferrer"
96-
target="_blank">
115+
target="_blank"
116+
>
97117
PyCon Colombia {year}
98118
</NavDropdown.Item>
99119
))}
@@ -104,10 +124,11 @@ const NavbarCustom = ({ dataTranslate }) => {
104124

105125
<a
106126
className="navbar-custom__cta"
107-
href={t.ticketsUrl ?? '#'}
127+
href={t.ticketsUrl ?? "#"}
108128
rel="noopener noreferrer"
109-
target="_blank">
110-
{t.getTickets ?? 'GET YOUR TICKETS'}
129+
target="_blank"
130+
>
131+
{t.getTickets ?? "GET YOUR TICKETS"}
111132
<ArrowUpRightIcon />
112133
</a>
113134
</div>
@@ -118,7 +139,7 @@ const NavbarCustom = ({ dataTranslate }) => {
118139
};
119140

120141
NavbarCustom.propTypes = {
121-
dataTranslate: PropTypes.object
142+
dataTranslate: PropTypes.object,
122143
};
123144

124145
export default NavbarCustom;

0 commit comments

Comments
 (0)