feat: initialize frontend with Next.js, Tailwind CSS, and internationalization support
- Added package.json for project dependencies and scripts - Configured PostCSS with Tailwind CSS - Created global styles and theme context for dark mode support - Implemented layout and routing for internationalization using next-intl - Developed main components: Header, Footer, Hero, About, Skills, Projects, Contact - Added language switcher and contact form with validation - Created project card component to display project details - Set up localization files for English and Portuguese - Configured Tailwind CSS for styling and responsive design - Added favicon and logo assets
This commit is contained in:
43
frontend/src/configuration/ThemeContext.tsx
Normal file
43
frontend/src/configuration/ThemeContext.tsx
Normal file
@@ -0,0 +1,43 @@
|
||||
'use client';
|
||||
import React, { createContext, useState, useEffect, useContext, ReactNode } from 'react';
|
||||
|
||||
interface ThemeContextType {
|
||||
theme: string;
|
||||
toggleTheme: () => void;
|
||||
}
|
||||
|
||||
const ThemeContext = createContext<ThemeContextType | undefined>(undefined);
|
||||
|
||||
export const ThemeProvider = ({ children }: { children: ReactNode }) => {
|
||||
const [theme, setTheme] = useState<string>('dark'); // Default to dark mode
|
||||
|
||||
useEffect(() => {
|
||||
const storedTheme = localStorage.getItem('theme');
|
||||
if (storedTheme) {
|
||||
setTheme(storedTheme);
|
||||
}
|
||||
// Apply theme to HTML element for Tailwind's 'class' strategy
|
||||
document.documentElement.classList.toggle('dark', theme === 'dark');
|
||||
}, [theme]);
|
||||
|
||||
const toggleTheme = () => {
|
||||
const newTheme = theme === 'light'? 'dark' : 'light';
|
||||
setTheme(newTheme);
|
||||
localStorage.setItem('theme', newTheme);
|
||||
document.documentElement.classList.toggle('dark', newTheme === 'dark');
|
||||
};
|
||||
|
||||
return (
|
||||
<ThemeContext.Provider value={{ theme, toggleTheme }}>
|
||||
{children}
|
||||
</ThemeContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useTheme = () => {
|
||||
const context = useContext(ThemeContext);
|
||||
if (context === undefined) {
|
||||
throw new Error('useTheme must be used within a ThemeProvider');
|
||||
}
|
||||
return context;
|
||||
};
|
||||
Reference in New Issue
Block a user