My Blog

My WordPress Blog

My Blog

My WordPress Blog

Social Media Dashboard

Basic Structure

  1. HTML: Create the structure of the dashboard.
  2. CSS: Style the dashboard to make it visually appealing.
  3. JavaScript: Add interactivity and dynamic data (simulated in this case).

Step 1: HTML

Create an index.html file:

<!DOCTYPE html>
<html lang="en">
<head>
&lt;meta charset="UTF-8">
&lt;meta name="viewport" content="width=device-width, initial-scale=1.0">
&lt;title>Social Media Dashboard&lt;/title>
&lt;link rel="stylesheet" href="styles.css">
</head> <body>
&lt;div class="container">
    &lt;header>
        &lt;h1>Social Media Dashboard&lt;/h1>
    &lt;/header>
    &lt;div class="stats">
        &lt;div class="stat-card">
            &lt;h2>Followers&lt;/h2>
            &lt;p id="followersCount">0&lt;/p>
        &lt;/div>
        &lt;div class="stat-card">
            &lt;h2>Likes&lt;/h2>
            &lt;p id="likesCount">0&lt;/p>
        &lt;/div>
        &lt;div class="stat-card">
            &lt;h2>Posts&lt;/h2>
            &lt;p id="postsCount">0&lt;/p>
        &lt;/div>
    &lt;/div>
    &lt;button id="updateButton">Update Stats&lt;/button>
&lt;/div>
&lt;script src="script.js">&lt;/script>
</body> </html>

Step 2: CSS

Create a styles.css file:

body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 20px;
} .container {
max-width: 600px;
margin: auto;
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
} header {
text-align: center;
margin-bottom: 20px;
} .stats {
display: flex;
justify-content: space-between;
} .stat-card {
background: #e7e7e7;
padding: 20px;
border-radius: 8px;
text-align: center;
flex: 1;
margin: 0 10px;
} button {
display: block;
width: 100%;
padding: 10px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
margin-top: 20px;
} button:hover {
background-color: #0056b3;
}

Step 3: JavaScript

Create a script.js file:

document.getElementById('updateButton').addEventListener('click', updateStats);

function updateStats() {
const followersCount = Math.floor(Math.random() * 1000);
const likesCount = Math.floor(Math.random() * 5000);
const postsCount = Math.floor(Math.random() * 100);
document.getElementById('followersCount').textContent = followersCount;
document.getElementById('likesCount').textContent = likesCount;
document.getElementById('postsCount').textContent = postsCount;
}

Running the Dashboard

  1. Save the files in the same directory.
  2. Open index.html in a web browser.
  3. Click the “Update Stats” button to see random statistics.

Extending the Dashboard

You can expand this basic dashboard by:

  • Integrating real APIs (like the Twitter API, Instagram Graph API, etc.) to fetch live data.
  • Adding charts using libraries like Chart.js for better visualization.
  • Implementing user authentication to personalize the dashboard for different users.
Social Media Dashboard

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top