function Hero()
) instead of class components.export function Hero()
).useState
, useEffect
).export * from './Button'
)
├── sections/ # Larger page sections
│ ├── Hero/
│ │ ├── index.js # Exports the section
│ │ ├── Hero.js # Section logic and layout
│ │ ├── styling.js # Styled-components for the section
│ │ ├── logic.js # Hooks and business logic
│ │ └── tests.js # Unit tests
│ ├── index.js # Re-exports all sections
├── pages/ # Full page layouts
│ ├── Home.jsx # Home page importing sections
│ ├── About.js # About page importing sections
│ └── index.js # Re-exports all pages
├── styles/ # Global styles and utilities
│ ├── GlobalStyles.js # Global CSS resets and styles
│ ├── keyframes.js # Reusable animation keyframes
│ └── index.js # Exports all styles
└── router.js # Routing configurationsrc/components/Button/
).styling.js
file with styled-components (e.g., export const StyledButton = styled.button
).logic.js
file for hooks and logic if complex (optional for simple components).logic.js
file.tests.js
file with unit tests (e.g., using Jest or React Testing Library).src/sections/Hero/
).src/components/
.styling.js
file for section-specific styles.logic.js
file for hooks and section-specific logic.logic.js
file.tests.js
file for unit tests..js
file in src/pages/
(e.g., Home.js
).src/router.js
file to define routes using react-router-dom
(e.g., BrowserRouter
, Route
).src/styles/GlobalStyles.js
:import { createGlobalStyle } from 'styled-components';
export const GlobalStyles = createGlobalStyle`
body {
margin: 0;
font-family: 'Poppins', sans-serif;
background: linear-gradient(135deg, #1e1e2f, #2a2a4a);
color: #ffffff;
}
`;
src/styles/animations.js
:import { keyframes } from 'styled-components';
export const fadeIn = keyframes`
from { opacity: 0; }
to { opacity: 1; }
`;
export const slideUp = keyframes`
from { transform: translateY(20px); opacity: 0; }
to { transform: translateY(0); opacity: 1; }
`;
import styled from 'styled-components';
import { fadeIn } from '../styles/keyframes';
export const StyledHero = styled.section`
animation: ${fadeIn} 1s ease-in-out;
padding: 4rem;
background: url('hero-bg.jpg') no-repeat center/cover;
`;
import { Button } from '~Components';
import { Hero } from '~Sections';
export * from './Button';
export * from './Text';
export function Text({ value }) {
return (
<Text>{value}</Text>
);
}
import React from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';
createRoot(document.getElementById('root')).render(<App />);