-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbusinesscard.html
More file actions
187 lines (158 loc) · 9.18 KB
/
Copy pathbusinesscard.html
File metadata and controls
187 lines (158 loc) · 9.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Digital Business Card</title>
<script src="https://cdn.tailwindcss.com"></script>
<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=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Inter', sans-serif;
}
</style>
</head>
<body class="bg-gray-100 dark:bg-gray-900 flex items-center justify-center min-h-screen p-4 transition-colors duration-500">
<!-- Business Card -->
<div class="w-full max-w-sm bg-white dark:bg-gray-800 rounded-2xl shadow-lg p-8 transform hover:scale-105 transition-transform duration-300">
<div class="flex flex-col items-center">
<!-- Profile Picture -->
<img class="w-28 h-28 rounded-full shadow-md border-4 border-white dark:border-gray-700" src="https://res.cloudinary.com/phikit/image/upload/w_400,h_400,c_fill,g_auto/v1759981346/xoyc7ufecjucngx9rwuo.jpg" alt="Profile Picture">
<!-- Name and Title -->
<div class="text-center mt-4">
<h1 id="name-container" class="text-2xl font-bold text-gray-800 dark:text-white"></h1>
<p id="title-container" class="text-md text-gray-500 dark:text-gray-400"></p>
</div>
<!-- Tagline -->
<p id="tagline-container" class="text-center text-gray-600 dark:text-gray-300 mt-4 text-sm"></p>
<!-- Contact Information -->
<div class="mt-6 w-full text-sm">
<div class="flex items-center text-gray-700 dark:text-gray-300 mb-3">
<svg class="w-5 h-5 mr-3 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"></path></svg>
<span id="email-container"></span>
</div>
<div class="flex items-center text-gray-700 dark:text-gray-300">
<svg class="w-5 h-5 mr-3 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"></path></svg>
<span id="phone-container"></span>
</div>
</div>
<!-- QR Code and Social Link -->
<div class="mt-6 flex w-full items-center justify-between">
<!-- QR Code -->
<div class="w-24 h-24 p-1 bg-white rounded-lg shadow-inner">
<img src="https://api.qrserver.com/v1/create-qr-code/?size=100x100&data=https://phi-kit.github.io/" alt="QR Code" class="rounded-md">
</div>
<!-- Social Link -->
<a href="https://github.com/phi-kit" class="group flex flex-col items-center text-gray-500 dark:text-gray-400 hover:text-indigo-500 dark:hover:text-indigo-400 transition-colors duration-300">
<svg class="w-10 h-10" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.49.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"/>
</svg>
<span class="mt-2 text-xs font-medium">GitHub</span>
</a>
</div>
</div>
</div>
<script>
// --- Main function to fetch and display data ---
async function loadContent() {
// Target containers
const nameContainer = document.getElementById('name-container');
const titleContainer = document.getElementById('title-container');
const taglineContainer = document.getElementById('tagline-container');
const emailContainer = document.getElementById('email-container');
const phoneContainer = document.getElementById('phone-container');
// Show loading indicators
showLoadingState(nameContainer, 1);
showLoadingState(titleContainer, 1);
showLoadingState(taglineContainer, 1);
showLoadingState(emailContainer, 1);
showLoadingState(phoneContainer, 1);
try {
// Use the Fetch API to get the JSON file
// It returns a "Promise" which is a placeholder for a future value
const response = await fetch('https://cdn.jsdelivr.net/gh/phi-kit/CDN@main/content/json/profile.json');
// Check if the request was successful
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
// Parse the JSON data from the response
const data = await response.json();
// Short delay to simulate network latency and see the loader
await new Promise(resolve => setTimeout(resolve, 500));
// Clear loading states
nameContainer.innerHTML = '';
// Populate the containers with the fetched data
populateName(data.name);
populateTitle(data.title);
populateTagline(data.tagline);
populateEmail(data.email);
populatePhone(data.phone);
} catch (error) {
// If something goes wrong, log it and show an error message
console.error("Could not fetch the data:", error);
nameContainer.innerHTML = `<p class="text-red-400 col-span-full">Failed to load data.</p>`;
}
}
function populateName(field) {
const container = document.getElementById('name-container');
if (!field) {
container.innerHTML = `<p>No name found in the data file.</p>`;
return;
}
container.innerHTML = `${field}`;
}
function populateTitle(field) {
const container = document.getElementById('title-container');
if (!field) {
container.innerHTML = `<p>No title found in the data file.</p>`;
return;
}
container.innerHTML = `${field}`;
}
function populateTagline(field) {
const container = document.getElementById('tagline-container');
if (!field) {
container.innerHTML = `<p>No tagline found in the data file.</p>`;
return;
}
container.innerHTML = `${field}`;
}
function populateEmail(field) {
const container = document.getElementById('email-container');
if (!field) {
container.innerHTML = `<p>No email found in the data file.</p>`;
return;
}
container.innerHTML = `${field}`;
}
function populatePhone(field) {
const container = document.getElementById('phone-container');
if (!field) {
container.innerHTML = `<p>No phone found in the data file.</p>`;
return;
}
container.innerHTML = `${field}`;
}
// --- Helper function to show a loading state ---
function showLoadingState(container, count) {
console.log(container);
container.innerHTML = ''; // Clear previous content
for (let i = 0; i < count; i++) {
const loaderCard = `
<div class="bg-gray-800 rounded-lg p-4 animate-pulse">
<div class="bg-gray-700 h-48 rounded-md mb-4"></div>
<div class="h-6 bg-gray-700 rounded w-3/4 mb-2"></div>
<div class="h-4 bg-gray-700 rounded w-1/2"></div>
</div>
`;
container.innerHTML += loaderCard;
}
}
// --- Event Listener ---
// Run the loadContent function once the webpage's DOM is fully loaded
document.addEventListener('DOMContentLoaded', loadContent);
</script>
</body>
</html>