From 2e90c813d0cf924bb9e8b383c1202aae15b14684 Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com> Date: Mon, 3 Mar 2025 22:54:36 +0100 Subject: Add theme provider and errorBoundary --- src/ErrorBoundary.tsx | 34 ++++++++++++++++++++++++++++++++++ src/Layout.css | 2 +- src/Layout.tsx | 6 ++---- src/ThemeContext.tsx | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/main.tsx | 8 +++++++- 5 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 src/ErrorBoundary.tsx create mode 100644 src/ThemeContext.tsx diff --git a/src/ErrorBoundary.tsx b/src/ErrorBoundary.tsx new file mode 100644 index 0000000..d3f5a60 --- /dev/null +++ b/src/ErrorBoundary.tsx @@ -0,0 +1,34 @@ +import React, { Component, ReactNode } from 'react'; + +interface ErrorBoundaryProps { + children: ReactNode; +} + +interface ErrorBoundaryState { + hasError: boolean; +} + +class ErrorBoundary extends Component { + constructor(props: ErrorBoundaryProps) { + super(props); + this.state = { hasError: false }; + } + + static getDerivedStateFromError(_: Error): ErrorBoundaryState { + return { hasError: true }; + } + + componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { + console.error("Uncaught error:", error, errorInfo); + } + + render() { + if (this.state.hasError) { + return

Something went wrong.

; + } + + return this.props.children; + } +} + +export default ErrorBoundary; \ No newline at end of file diff --git a/src/Layout.css b/src/Layout.css index 7af97b8..0148da4 100644 --- a/src/Layout.css +++ b/src/Layout.css @@ -37,7 +37,7 @@ color: #616161; text-decoration: none; width: 33.3%; - font-size: 12px; + font-size: 14px; } .nav-item.active { diff --git a/src/Layout.tsx b/src/Layout.tsx index 34f5dbf..30db47b 100644 --- a/src/Layout.tsx +++ b/src/Layout.tsx @@ -1,6 +1,7 @@ import { ReactNode } from 'react'; import { Link, useLocation } from 'react-router'; import { MapPin, Map, Info } from 'lucide-react'; +import { useTheme } from './ThemeContext'; import './Layout.css'; interface LayoutProps { @@ -30,17 +31,14 @@ export function Layout({ children }: LayoutProps) { return (
- {/* Main content area */}
{children}
- - {/* Android style bottom navigation bar */}