Okay, let's create a modern 90s aesthetic personal portfolio front-end using React, Styled Components, and Redux. This will involve:
- Project Setup: Creating a basic React application with Styled Components and Redux.
- Component Structure: Defining the main components (Header, Hero, About, Projects, Contact).
- Styling: Applying 90s-inspired styles using Styled Components (bright colors, pixelated fonts, bold patterns, glitch effects).
- State Management: Using Redux for managing application state (e.g., project data, theme).
- Functionality: Implementing basic navigation, form handling (for the contact form), and potentially some data fetching (e.g., project data from a mock API).
- Responsiveness: Making the design responsive for different screen sizes.
1. Project Setup (Create React App)
npx create-react-app my-portfolio
cd my-portfolio
npm install styled-components redux react-redux @reduxjs/toolkit
2. Directory Structure
my-portfolio/
├── src/
│ ├── components/
│ │ ├── Header.js
│ │ ├── Hero.js
│ │ ├── About.js
│ │ ├── ProjectCard.js // For individual projects
│ │ ├── Projects.js
│ │ ├── Contact.js
│ ├── redux/
│ │ ├── store.js
│ │ ├── projectSlice.js // Example Redux slice for projects
│ │ ├── themeSlice.js // Example Redux slice for theme
│ ├── App.js
│ ├── App.css // General app styles (basic reset, fonts, etc.)
│ ├── index.js
│ └── assets/ // Store images, fonts, etc.
│ ├── images/
│ ├── fonts/
├── package.json
└── ...
3. Redux Setup (store.js, projectSlice.js, themeSlice.js)
import { configureStore } from '@reduxjs/toolkit';
import projectReducer from './projectSlice';
import themeReducer from './themeSlice';
const store = configureStore({
reducer: {
projects: projectReducer,
theme: themeReducer,
},
});
export default store;
src/redux/projectSlice.js
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
// Mock API call (replace with real API)
export const fetchProjects = createAsyncThunk(
'projects/fetchProjects',
async () => {
// Simulate an API call with a delay
await new Promise(resolve => setTimeout(resolve, 500));
const response = {
data: [
{ id: 1, name: 'Project 1', description: 'Cool project', imageUrl: '/assets/images/project1.png' },
{ id: 2, name: 'Project 2', description: 'Another project', imageUrl: '/assets/images/project2.png' },
// Add more mock projects
],
};
return response.data;
}
);
const projectSlice = createSlice({
name: 'projects',
initialState: {
projects: [],
loading: false,
error: null,
},
reducers: {}, // No synchronous reducers needed for this example
extraReducers: (builder) => {
builder
.addCase(fetchProjects.pending, (state) => {
state.loading = true;
state.error = null;
})
.addCase(fetchProjects.fulfilled, (state, action) => {
state.loading = false;
state.projects = action.payload;
})
.addCase(fetchProjects.rejected, (state, action) => {
state.loading = false;
state.error = action.error.message;
});
},
});
export default projectSlice.reducer;
import { createSlice } from '@reduxjs/toolkit';
const themeSlice = createSlice({
name: 'theme',
initialState: {
isDark: false,
},
reducers: {
toggleTheme: (state) => {
state.isDark = !state.isDark;
},
},
});
export const { toggleTheme } = themeSlice.actions;
export default themeSlice.reducer;
4. Components (Example: Header.js, Hero.js)
import React from 'react';
import styled from 'styled-components';
import { useDispatch, useSelector } from 'react-redux';
import { toggleTheme } from '../redux/themeSlice';
const HeaderContainer = styled.header`
background-color: ${props => props.theme.headerBg};
color: ${props => props.theme.text};
padding: 1rem 2rem;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 2px dashed ${props => props.theme.accent};
`;
const Logo = styled.h1`
font-family: 'Press Start 2P', cursive; // Pixelated font
font-size: 1.5rem;
text-shadow: 2px 2px 0 ${props => props.theme.accent};
`;
const Nav = styled.nav`
ul {
list-style: none;
display: flex;
gap: 2rem;
}
a {
text-decoration: none;
color: ${props => props.theme.text};
font-weight: bold;
&:hover {
color: ${props => props.theme.accent};
}
}
`;
const ThemeButton = styled.button`
background-color: ${props => props.theme.buttonBg};
color: ${props => props.theme.buttonText};
border: none;
padding: 0.5rem 1rem;
border-radius: 5px;
cursor: pointer;
font-weight: bold;
&:hover {
opacity: 0.8;
}
`;
const Header = () => {
const dispatch = useDispatch();
const theme = useSelector((state) => state.theme.isDark);
return (
<HeaderContainer>
<Logo>My Portfolio</Logo>
<Nav>
<ul>
<li><a href="#about">About</a></li>
<li><a href="#projects">Projects</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</Nav>
<ThemeButton onClick={() => dispatch(toggleTheme())}>
{theme ? 'Light Mode' : 'Dark Mode'}
</ThemeButton>
</HeaderContainer>
);
};
export default Header;
import React from 'react';
import styled, { keyframes } from 'styled-components';
const HeroContainer = styled.section`
background-color: ${props => props.theme.heroBg};
color: ${props => props.theme.heroText};
padding: 4rem 2rem;
text-align: center;
`;
const Title = styled.h2`
font-size: 3rem;
font-family: 'Press Start 2P', cursive;
margin-bottom: 1rem;
text-shadow: 3px 3px 0 ${props => props.theme.accent};
`;
const Subtitle = styled.p`
font-size: 1.2rem;
margin-bottom: 2rem;
`;
const neonGlow = keyframes`
0% {
text-shadow: 0 0 5px ${props => props.theme.accent}, 0 0 10px ${props => props.theme.accent};
}
50% {
text-shadow: 0 0 20px ${props => props.theme.accent}, 0 0 30px ${props => props.theme.accent};
}
100% {
text-shadow: 0 0 5px ${props => props.theme.accent}, 0 0 10px ${props => props.theme.accent};
}
`;
const Button = styled.a`
background-color: ${props => props.theme.buttonBg};
color: ${props => props.theme.buttonText};
padding: 1rem 2rem;
text-decoration: none;
border-radius: 5px;
font-weight: bold;
display: inline-block;
margin-top: 1rem;
animation: ${neonGlow} 2s linear infinite; // Add a bit of glow
border: 2px solid ${props => props.theme.accent};
&:hover {
opacity: 0.9;
}
`;
const Hero = () => {
return (
<HeroContainer>
<Title>Welcome!</Title>
<Subtitle>Building cool things and embracing the 90s.</Subtitle>
<Button href="#projects">View My Work</Button>
</HeroContainer>
);
};
export default Hero;
import React from 'react';
import styled from 'styled-components';
const AboutContainer = styled.section`
background-color: ${props => props.theme.aboutBg};
color: ${props => props.theme.text};
padding: 3rem 2rem;
text-align: center;
border-bottom: 2px dashed ${props => props.theme.accent};
`;
const Title = styled.h2`
font-size: 2.5rem;
font-family: 'Press Start 2P', cursive;
margin-bottom: 1rem;
text-shadow: 2px 2px 0 ${props => props.theme.accent};
`;
const Description = styled.p`
font-size: 1.1rem;
line-height: 1.6;
margin-bottom: 1.5rem;
`;
const SkillsList = styled.ul`
list-style: none;
padding: 0;
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 1rem;
`;
const SkillItem = styled.li`
background-color: ${props => props.theme.skillBg};
color: ${props => props.theme.skillText};
padding: 0.5rem 1rem;
border-radius: 5px;
font-weight: bold;
border: 1px solid ${props => props.theme.accent};
text-shadow: 1px 1px 0 ${props => props.theme.accent};
`;
const About = () => {
return (
<AboutContainer id="about">
<Title>About Me</Title>
<Description>
Hi, I'm a developer with a passion for creating engaging and user-friendly web applications. I love blending modern technologies with a touch of nostalgia, drawing inspiration from the vibrant design aesthetics of the 90s.
</Description>
<Description>
I'm proficient in React, JavaScript, HTML, CSS, and more. I'm always eager to learn new skills and explore innovative solutions.
</Description>
<h3>Skills</h3>
<SkillsList>
<SkillItem>React</SkillItem>
<SkillItem>JavaScript</SkillItem>
<SkillItem>HTML</SkillItem>
<SkillItem>CSS</SkillItem>
<SkillItem>Styled Components</SkillItem>
<SkillItem>Redux</SkillItem>
<SkillItem>Node.js</SkillItem>
<SkillItem>Git</SkillItem>
</SkillsList>
</AboutContainer>
);
};
export default About;
src/components/ProjectCard.js
import React from 'react';
import styled from 'styled-components';
const CardContainer = styled.div`
background-color: ${props => props.theme.projectCardBg};
color: ${props => props.theme.text};
border: 2px dashed ${props => props.theme.accent};
border-radius: 10px;
padding: 1.5rem;
text-align: center;
box-shadow: 5px 5px 0 ${props => props.theme.accent};
transition: transform 0.3s ease-in-out;
&:hover {
transform: translateY(-5px);
}
`;
const Image = styled.img`
width: 100%;
max-height: 150px;
object-fit: cover;
border-radius: 5px;
margin-bottom: 1rem;
border: 1px solid ${props => props.theme.accent};
`;
const Title = styled.h3`
font-size: 1.3rem;
margin-bottom: 0.5rem;
font-family: 'Press Start 2P', cursive;
`;
const Description = styled.p`
font-size: 1rem;
line-height: 1.4;
`;
const ProjectCard = ({ project }) => {
return (
<CardContainer>
<Image src={project.imageUrl} alt={project.name} />
<Title>{project.name}</Title>
<Description>{project.description}</Description>
</CardContainer>
);
};
export default ProjectCard;
src/components/Projects.js
import React, { useEffect } from 'react';
import styled from 'styled-components';
import { useDispatch, useSelector } from 'react-redux';
import { fetchProjects } from '../redux/projectSlice';
import ProjectCard from './ProjectCard';
const ProjectsContainer = styled.section`
background-color: ${props => props.theme.projectsBg};
color: ${props => props.theme.text};
padding: 3rem 2rem;
text-align: center;
border-bottom: 2px dashed ${props => props.theme.accent};
`;
const Title = styled.h2`
font-size: 2.5rem;
font-family: 'Press Start 2P', cursive;
margin-bottom: 2rem;
text-shadow: 2px 2px 0 ${props => props.theme.accent};
`;
const ProjectsGrid = styled.div`
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 2rem;
`;
const LoadingMessage = styled.p`
font-size: 1.2rem;
font-style: italic;
`;
const ErrorMessage = styled.p`
color: red;
font-weight: bold;
`;
const Projects = () => {
const dispatch = useDispatch();
const { projects, loading, error } = useSelector((state) => state.projects);
useEffect(() => {
dispatch(fetchProjects());
}, [dispatch]);
return (
<ProjectsContainer id="projects">
<Title>My Projects</Title>
{loading && <LoadingMessage>Loading projects...</LoadingMessage>}
{error && <ErrorMessage>Error: {error}</ErrorMessage>}
<ProjectsGrid>
{projects.map((project) => (
<ProjectCard key={project.id} project={project} />
))}
</ProjectsGrid>
</ProjectsContainer>
);
};
export default Projects;
src/components/Contact.js
import React from 'react';
import styled from 'styled-components';
const ContactContainer = styled.section`
background-color: ${props => props.theme.contactBg};
color: ${props => props.theme.text};
padding: 3rem 2rem;
text-align: center;
`;
const Title = styled.h2`
font-size: 2.5rem;
font-family: 'Press Start 2P', cursive;
margin-bottom: 2rem;
text-shadow: 2px 2px 0 ${props => props.theme.accent};
`;
const ContactForm = styled.form`
display: flex;
flex-direction: column;
max-width: 500px;
margin: 0 auto;
`;
const InputField = styled.input`
padding: 0.8rem;
margin-bottom: 1.5rem;
border: 2px solid ${props => props.theme.accent};
border-radius: 5px;
background-color: ${props => props.theme.inputBg};
color: ${props => props.theme.text};
font-size: 1rem;
&:focus {
outline: none;
border-color: ${props => props.theme.accentHighlight};
box-shadow: 0 0 5px ${props => props.theme.accentHighlight};
}
`;
const TextAreaField = styled.textarea`
padding: 0.8rem;
margin-bottom: 1.5rem;
border: 2px solid ${props => props.theme.accent};
border-radius: 5px;
background-color: ${props => props.theme.inputBg};
color: ${props => props.theme.text};
font-size: 1rem;
height: 150px;
resize: vertical;
&:focus {
outline: none;
border-color: ${props => props.theme.accentHighlight};
box-shadow: 0 0 5px ${props => props.theme.accentHighlight};
}
`;
const SubmitButton = styled.button`
background-color: ${props => props.theme.buttonBg};
color: ${props => props.theme.buttonText};
padding: 1rem 2rem;
border: none;
border-radius: 5px;
font-weight: bold;
cursor: pointer;
font-size: 1.1rem;
&:hover {
opacity: 0.9;
}
`;
const Contact = () => {
return (
<ContactContainer id="contact">
<Title>Contact Me</Title>
<ContactForm>
<InputField type="text" placeholder="Your Name" />
<InputField type="email" placeholder="Your Email" />
<TextAreaField placeholder="Your Message" />
<SubmitButton type="submit">Send Message</SubmitButton>
</ContactForm>
</ContactContainer>
);
};
export default Contact;
5. App.js
import React from 'react';
import styled, { ThemeProvider } from 'styled-components';
import { useSelector } from 'react-redux';
import Header from './components/Header';
import Hero from './components/Hero';
import About from './components/About';
import Projects from './components/Projects';
import Contact from './components/Contact';
import GlobalStyle from './styles/GlobalStyle'; // Add this line
import { lightTheme, darkTheme } from './styles/theme';
const AppContainer = styled.div`
font-family: sans-serif;
`;
function App() {
const isDarkTheme = useSelector((state) => state.theme.isDark);
const theme = isDarkTheme ? darkTheme : lightTheme;
return (
<ThemeProvider theme={theme}>
<GlobalStyle/>
<AppContainer>
<Header />
<Hero />
<About />
<Projects />
<Contact />
</AppContainer>
</ThemeProvider>
);
}
export default App;
6. index.js
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import { Provider } from 'react-redux';
import store from './redux/store';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<Provider store={store}>
<App />
</Provider>
</React.StrictMode>
);
7. Styles (GlobalStyle.js, theme.js)
src/styles/GlobalStyle.js
import { createGlobalStyle } from 'styled-components';
const GlobalStyle = createGlobalStyle`
/* Basic Reset */
*, *::before, *::after {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
font-family: sans-serif;
transition: background-color 0.3s ease, color 0.3s ease; // Smooth theme transition
}
a {
text-decoration: none;
color: inherit;
}
`;
export default GlobalStyle;
export const lightTheme = {
body: '#fff',
text: '#333',
headerBg: '#f0f0f0',
heroBg: '#e0e0e0',
heroText: '#333',
buttonBg: '#4CAF50',
buttonText: '#fff',
accent: '#FF4081', // Example accent color (pinkish)
accentHighlight: '#ff80ab',
aboutBg: '#f5f5f5',
skillBg: '#fff',
skillText: '#333',
projectsBg: '#fff',
projectCardBg: '#f0f0f0',
contactBg: '#e0e0e0',
inputBg: '#fff',
};
export const darkTheme = {
body: '#121212',
text: '#eee',
headerBg: '#222',
heroBg: '#333',
heroText: '#eee',
buttonBg: '#007bff',
buttonText: '#fff',
accent: '#00bcd4', // Example accent color (tealish)
accentHighlight: '#4dd0e1',
aboutBg: '#282828',
skillBg: '#444',
skillText: '#eee',
projectsBg: '#333',
projectCardBg: '#444',
contactBg: '#282828',
inputBg: '#555',
};
8. 90s Aesthetics (in Styled Components)
-
Pixelated Fonts: Use fonts like "Press Start 2P" from Google Fonts for headers and titles. Import in index.html or GlobalStyle.js:
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
-
Bright Colors: Incorporate bold colors like teal, magenta, neon green, and electric blue. Use theme variables for easy customization.
-
Dashed Borders: Use border: 2px dashed {accent color}; for sections, cards, and elements.
-
Shadows: Add a lot of shadows.
-
Gradients: Subtle gradients in backgrounds can enhance the 90s feel. Consider using CSS gradients.
-
Glitch Effects: Implement a subtle glitch effect using CSS animations and text-shadow or filter: drop-shadow. See Hero Button in Hero.js.
-
Neon Glow: Implement neon glow effect using keyframes and text-shadows.
9. Responsiveness
Use media queries within your Styled Components to adjust layout and font sizes for different screen sizes. Consider a mobile-first approach.
const Button = styled.a`
/* ... your existing styles ... */
@media (max-width: 768px) {
padding: 0.8rem 1.5rem;
font-size: 1rem;
}
`;
Key Improvements and Considerations:
- Theme Switching: The Redux
themeSlice and ThemeProvider enable switching between light and dark themes.
- Project Data: The
projectSlice and fetchProjects shows an example of fetching data (though it is mocked here) and storing it using Redux. This allows you to manage a list of projects more effectively.
- Code Reusability: The
ProjectCard component promotes reusability.
- Scalability: Styled Components and Redux make the application more scalable as it grows.
- Error Handling: The
projectSlice includes error handling for API calls.
- Accessibility: Remember to consider accessibility (ARIA attributes, semantic HTML, keyboard navigation, contrast ratios) as you develop. Styled Components can accommodate ARIA attributes.
- Animations: Add more subtle animations (e.g., fade-in, slide-in) to enhance the user experience.
- Form Validation: Implement form validation in the
Contact component.
- Deployment: Create a production build (
npm run build) and deploy the application to a hosting platform like Netlify, Vercel, or GitHub Pages.
- Testing: Write unit and integration tests for your components and Redux logic.
- Assets: Add images and fonts to
src/assets/images and src/assets/fonts folder for the example to work.
This is a comprehensive starting point. You can customize the styles, components, and Redux state to match your specific requirements and vision for your 90s-inspired portfolio. Remember to prioritize user experience and accessibility. Good luck!