Social-Media-Mockup is a beginner-friendly social media demo application that illustrates the fundamentals of making API requests and managing client-side data persistence. This project demonstrates GET, POST, and DELETE operations with the JSONPlaceholder API while implementing local data persistence using browser localStorage.
- π Fetch and display posts from a remote API
- βοΈ Create new posts and persist them locally
- ποΈ Delete posts with visual feedback
- πΎ Local storage integration for data persistence
- π¨ Modern glassmorphism UI design
- π± Fully responsive layout
- π Display server responses for educational purposes
You can view a live demo of the application at: https://social-media-mockup-ivin.vercel.app/
- HTML5
- CSS3 (with modern features like backdrop-filter)
- Vanilla JavaScript (ES6+)
- localStorage for client-side data persistence
- Fetch API for AJAX requests
- JSONPlaceholder for simulated backend API
This project uses JSONPlaceholder - a free fake API for testing and prototyping. Since JSONPlaceholder doesn't actually save data on their server, we've implemented client-side persistence using localStorage.
Important Note: JSONPlaceholder simulates successful API responses but doesn't actually store your data. This is explained in the status messages displayed within the application.
-
Asynchronous Functions (async/await)
async function getPosts() { const response = await fetch("https://jsonplaceholder.typicode.com/posts"); const data = await response.json(); // Process data }
-
HTTP Methods with Fetch API
// GET request fetch("https://jsonplaceholder.typicode.com/posts") // POST request fetch("https://jsonplaceholder.typicode.com/posts", { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title, body, userId: 1 }) }) // DELETE request fetch(`https://jsonplaceholder.typicode.com/posts/${postId}`, { method: "DELETE" })
-
Local Storage Operations
// Save data localStorage.setItem('socialGlassPosts', JSON.stringify(posts)); // Retrieve data const posts = JSON.parse(localStorage.getItem('socialGlassPosts'));
-
DOM Manipulation
// Create element const postElement = document.createElement("div"); postElement.className = "post glass"; // Add content postElement.innerHTML = `<h3>${post.title}</h3>...`; // Append to parent postDiv.appendChild(postElement);
-
Event Handling
form.addEventListener("submit", createPost); deleteBtn.addEventListener('click', () => deletePost(post.id));
-
Initial Load:
- Check localStorage for existing posts
- If empty, fetch initial posts from JSONPlaceholder API
- Display posts in UI
-
Creating Posts:
- Collect user input from form
- Send POST request to JSONPlaceholder API
- Display API response as a status message
- Create post object with unique ID and timestamp
- Save to localStorage
- Update UI
-
Deleting Posts:
- Send DELETE request to JSONPlaceholder API
- Display server response status above the post
- Update localStorage after a brief delay
- Remove post from UI with animation
The project includes modern CSS techniques:
- Glassmorphism Effect: Creates frosted glass appearance with backdrop-filter
- CSS Variables: For consistent theming and easier modifications
- Flexbox Layout: For responsive design
- CSS Animations: For smooth transitions and loading indicators
- CSS Gradients: For attractive visual elements
Social-Media-Mockup/
βββ files/
| βββ script.js # Javascript code : Logic behind page working
| βββ style.css # CSS code : Page Styles
βββ index.html # HTML file : Page Structure
βββ README.md # Project documentation
βββ LICENSE # MIT License
- Modern web browser (Chrome, Firefox, Safari, Edge)
- Basic knowledge of HTML, CSS, and JavaScript
-
Clone the repository:
git clone https://github.com/ivin-titus/Social-Media-Mockup
-
Open
index.htmlin your browser.
That's it! No server setup, dependencies, or build process required.
Loads posts either from localStorage or from the API if localStorage is empty.
Handles new post creation, sends data to API, and updates local storage.
Processes post deletion and displays server response.
Displays temporary status messages to the user.
Handle interaction with localStorage.
- User authentication system
- Comment functionality
- Post categories or tags
- Rich text editor for post content
- Image uploads
- Search functionality
This project can be easily deployed on:
-
GitHub Pages:
- Push to a GitHub repository
- Enable GitHub Pages in repository settings
-
Netlify:
- Connect your GitHub repository
- Set build command to:
N/A(No build needed) - Set publish directory to:
.(Root directory)
-
Vercel:
- Import your GitHub repository
- No configuration required
This project is licensed under the MIT License - see the LICENSE file for details.
- JSONPlaceholder for providing a free testing API
- Inspired by modern web design trends and glassmorphism UI
Created by Ivin Titus | Β© 2025
