Skip to content

lab solved #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
63 changes: 62 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"react-router-dom": "^6.28.0"
},
"devDependencies": {
"@types/react": "^18.0.37",
Expand Down
86 changes: 86 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,89 @@
.read-the-docs {
color: #888;
}

nav {
background-color: aqua;
text-align: start;
padding: 1em;
margin: 0;
border: 0;
color: white;
font-weight: bold;
}

.company-profile {
display: flex;
justify-content: center;
align-items: center;
flex-direction: row;
}

.company-profile > div:first-child {
display: flex;
justify-content: space around;
align-items: center;
flex-direction: column;
margin: 2em;
padding: 1em;
gap: 1em;
border: 1px solid #ccc;
border-radius: 1em;
}
.company-profile img {
height: 200px;
width: auto;
padding: 3em;
}

.company-profile-techstack {
display: flex;
justify-content: center;
align-items: center;
flex-direction: row;
flex-wrap: wrap;
gap: 1em;
margin-top: 1em;

}
.company-profile-techstack :link {
border: 1px solid #ccc;
border-radius: 1em;
padding: 1em;
color: black;
}

.company-profile-techstack img {
height: 50px;
min-width: 120px;
max-width: 150px;
object-fit: contain;
}

.company-list {
display: flex;
justify-content: space-between;
align-items: center;
flex-direction: row;
flex-wrap: wrap;
}

.company-card {
display: flex;
justify-content: center;
align-items: center;
flex-direction: row;
gap: 1em;
padding: 1em;
border: 1px solid #ccc;
border-radius: 1em;
margin: 1em;
}

.company-card img {
height: 100px;
min-width: 120px;
max-width: 150px;
object-fit: contain;
}

35 changes: 33 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,42 @@
import { Route, Routes } from "react-router-dom";
import "./App.css";
import companiesData from "./companies.json";
import Navbar from "./components/Navbar";
import technologiesData from "./technologies.json";
import { useState } from "react";
import CompanyPage from "./pages/CompanyPage";
import HomePage from "./pages/HomePage";
import TechnologyPage from "./pages/TechnologyPage";

function App() {
const [companies, setCompanies] = useState(companiesData);
const [technologies, setTechnologies] = useState(technologiesData);

return (
<div className="App">
<h1>LAB | React Stack Tracker</h1>
<Navbar />
<div>
<Routes>
<Route
path="/"
element={
<HomePage companies={companies} technologies={technologies} />
}
/>
<Route
path="/tech/:slug"
element={<TechnologyPage technologies={technologies} />}
/>
<Route
path="/company/:companySlug"
element={
<CompanyPage companies={companies} technologies={technologies} />
}
/>
</Routes>
</div>
</div>
);
}

export default App;
export default App;
2 changes: 1 addition & 1 deletion src/components/Navbar.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function Navbar() {
return <nav>Navbar</nav>;
return <nav>StackTracker</nav>;
}

export default Navbar;
10 changes: 7 additions & 3 deletions src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'

import { BrowserRouter as Router } from "react-router-dom";

ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
<Router>
<App />
</Router>
</React.StrictMode>
);
56 changes: 52 additions & 4 deletions src/pages/CompanyPage.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,56 @@
function CompanyPage() {
import { useParams, Link } from "react-router-dom";

function CompanyPage({ companies, technologies }) {
const { companySlug } = useParams();
console.log(`Company Slug: ${companySlug}`);

const company = companies.find((company) => company.slug === companySlug);
console.log("Company:", company);

if (!company) {
return <div>Error: Company not found</div>;
}

// Ensure techStack is an array of slugs
const techStackSlugs = company.techStack.map((tech) => tech.slug || tech);
const companyTechnologies = technologies.filter((technology) =>
techStackSlugs.includes(technology.slug)
);
console.log("Company Technologies:", companyTechnologies);

return (
<div>
<h1>CompanyPage</h1>
</div>
<>
<div key={company.id} className="company-profile">
<div>
{company.logo ? (
<img
src={company.logo}
alt={company.name}
onError={(e) => {
e.target.onerror = null;
e.target.src = "https://via.placeholder.com/150";
}}
/>
) : (
<p>No logo available</p>
)}
</div>
<div>
<h1>{company.name}</h1>
<h3>About:</h3>
<p>{company.description}</p>
</div>
</div>

<div className="company-profile-techstack">
{companyTechnologies.map((technology) => (
<Link to={`/tech/${technology.slug}`} key={technology.slug}>
<img src={technology.image} alt={technology.name} />
<p>{technology.name}</p>
</Link>
))}
</div>
</>
);
}

Expand Down
30 changes: 25 additions & 5 deletions src/pages/HomePage.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
function HomePage() {
import React from 'react';
import { Link } from 'react-router-dom';

const HomePage = ({ companies, technologies }) => {
if (!Array.isArray(companies)) {
return <div>Error: companies is not an array</div>;
}

return (
<div>
<h1>HomePage</h1>
</div>
<>
<h3>StackTracker: Discover Tech Stacks Used by Top Companies</h3>
<div>
<article className='company-list'>
{companies.map((company) => (
<Link className='company-card' to={`/company/${company.slug}`} key={company.id} style={{ textDecoration: 'none', color: 'inherit' }}>
<div>
<h2>{company.name}</h2>
<img src={company.logo} alt={company.name} />
</div>
</Link>
))}
</article>
</div>
</>
);
}
};

export default HomePage;

Loading