A small React + Vite practice project that demonstrates:
- theme switching with
useReducer - cross-component state sharing with
useContext - fetching latest repository activity from the GitHub API
- responsive side-by-side layout for Theme and Repo panels
- Toggle between
LightandDarkthemes using a reducer action. - Share the active theme via
ThemeContext. - Display the latest public event from:
rbalogic/toggle-theme-reducer
- Render two panels side by side on desktop and stack on smaller screens.
- React
- Vite
- JavaScript (JSX)
- CSS variables for theming
src/
App.jsx # Reducer state + context provider
Theme.jsx # Theme UI and toggle button
Repos.jsx # Fetches and renders latest GitHub repo activity
ThemeContext.js # Shared React context
index.css # Theme variables and responsive layout
App.jsxmanages theme state withuseReducer.- The active theme (
LightorDark) is provided throughThemeContext.Provider. Theme.jsxconsumes context, applies theme classes, and dispatches toggle action.Repos.jsxconsumes context and fetches latest repo event from GitHub on mount.index.cssapplies theme colors and desktop/mobile layout behavior.
npm installnpm run devThen open the local URL shown in the terminal (usually http://localhost:5173).
npm run dev- Run development servernpm run build- Create production buildnpm run preview- Preview production build locallynpm run lint- Run ESLint (if configured)
- GitHub API requests in
Repos.jsxuse public endpoints and can be rate-limited. - Theme values are title-cased (
Light/Dark) and converted to lowercase for CSS class names.