Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17,430 changes: 17,430 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"tailwindcss": "^3.4.1"
}
}
18 changes: 15 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import "./App.css";

import useFetch from "./Hooks/useFetch";
import UserCard from "./components/UserCard";
function App() {
return <div></div>;
const [dataInfo] = useFetch("https://jsonplaceholder.typicode.com/users");

return (
<div className="flex flex-wrap justify-center gap-10 items-center my-10">
{dataInfo === null ? (
<p>Loading</p>
) : (
dataInfo.map((user) => {
return <UserCard key={user.id} user={user} />;
})
)}
</div>
);
}

export default App;
22 changes: 22 additions & 0 deletions src/Hooks/useFetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useState, useEffect } from "react";

function useFetch(url) {
const [dataInfo, setDataInfo] = useState(null);

const fetchData = async () => {
try {
const response = await fetch(url);
const data = await response.json();
console.log(data);
setDataInfo(data);
} catch (error) {
console.log("Error fetching data:", error);
}
};

useEffect(() => {
fetchData();
}, []);
return [dataInfo];
}
export default useFetch;
14 changes: 14 additions & 0 deletions src/components/UserCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// a list item with their name, email, phone number & company.
function UserCard({ user }) {
return (
<div className="flex flex-col justify-center gap-25 items-center font-bold text-left bg-gray-300 p-6 rounded drop-shadow-2xl w-72">
<ul>
Name: {user.name}
<li className="font-thin"> Email: {user.email}</li>
<li className="font-thin"> Phone: {user.phone}</li>
<li className="font-thin"> Company{user.company.name}</li>
</ul>
</div>
);
}
export default UserCard;
9 changes: 6 additions & 3 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}
8 changes: 8 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./src/**/*.{html,js}"],
theme: {
extend: {},
},
plugins: [],
};
2,969 changes: 1,558 additions & 1,411 deletions yarn.lock

Large diffs are not rendered by default.