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
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@ For each technology, display its `name` and `image`, and wrap them in a React Ro

---

### Iteration 6 | Technology Details
### Bonus: Iteration 6 | Technology Details

In this iteration, you will work on the `TechologyPage` component to display the information of a specific technology.
In this iteration, you will work on the `TechologyPage` component to display information about a specific technology.

The component should take 1 prop:

Expand Down Expand Up @@ -485,16 +485,19 @@ To set up the React Router in your React application, follow these steps:
npm install react-router-dom
```

2. Import the `BrowserRouter` component in your app's entry point (usually `index.js`) and wrap your `<App />` component with it:
2. Import the `BrowserRouter` component in your app's entry point (usually `main.jsx`) and wrap your `<App />` component with it:

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

ReactDOM.render(
<Router>
<App />
</Router>,
document.getElementById("root")
const root = ReactDOM.createRoot(document.getElementById("root"));

root.render(
<React.StrictMode>
<Router>
<App />
</Router>
</React.StrictMode>
);
```

Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React</title>
<title>LAB Stack Tracker</title>
</head>
<body>
<div id="root"></div>
Expand Down
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.18.0"
},
"devDependencies": {
"@types/react": "^18.0.37",
Expand Down
14 changes: 14 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import { Routes, Route } from "react-router-dom";
import "./App.css";
import companiesJson from "./companies.json"
import technologiesJson from "./technologies.json"
import { useState } from "react";
import HomePage from "./pages/HomePage";
import CompanyPage from "./pages/CompanyPage";
import TechnologyPage from "./pages/TechnologyPage";

function App() {
const [technologies, setTechnologies] = useState(technologiesJson)
const [companies, setCompanies]= useState (companiesJson)
return (
<div className="App">
<h1>LAB | React Stack Tracker</h1>
<Routes>
<Route path="/" element={<HomePage companies={companies}/>} />
<Route path="/company/:companySlug" element={<CompanyPage companies={companies}/>}/>
<Route path="/tech/:slug" element={<TechnologyPage technologies={technologies}/>}/>
</Routes>
</div>
);
}
Expand Down
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;
21 changes: 13 additions & 8 deletions src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
// src/main.jsx
import ReactDOM from "react-dom/client";
import "./index.css";
import App from "./App";
import React from "react";

ReactDOM.createRoot(document.getElementById('root')).render(
import { BrowserRouter as Router } from "react-router-dom";

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

function CompanyPage(props) {
const { companySlug } = useParams();
const result = props.companies.find((company) => {
if (companySlug === company.slug) {
return true;
} else {
return false;
}
});
if (!result) return <div>Error</div>;
return (
<div>
<h1>CompanyPage</h1>
<h1>Company Profile</h1>
<h3>{result.name}</h3>
<div>{result.website}</div>
<div>{result.description}</div>
<img src={result.logo} />
{result.techStack.map((techStack) => (
<div key={techStack.slug}>
<Link to={`/tech/${techStack.slug}`}>
<img src={techStack.image} style={{ width: "50px" }} />
</Link>
</div>
))}
<p> {companySlug}</p>
</div>
);
}
Expand Down
18 changes: 16 additions & 2 deletions src/pages/HomePage.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
function HomePage() {
import { Link } from "react-router-dom";
import React from "react";

function HomePage(props) {
console.log(props.companies)
return (
<div>
<h1>HomePage</h1>
<h1>StackTracker: Discover Tech Stacks Used by Top Companies</h1>
<ul>
{props.companies.map(company=>(
<li key={company.slug}>
<Link to={`/company/${company.slug}`}>
<img src={company.logo} style={{width:"50px"}}/>
{company.name}
</Link>
</li>
))}
</ul>
</div>
);
}
Expand Down
20 changes: 18 additions & 2 deletions src/pages/TechnologyPage.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
function TechnologyPage() {
import { useParams } from "react-router-dom";

function TechnologyPage(props) {
const { slug } = useParams();
let result;
for (let i = 0; i < props.technologies.length; i++) {
if (props.technologies[i].slug === slug) {
result = props.technologies[i];
break;
}
}
if (!result) {
return <div>Error slug not found</div>;
}
return (
<div>
<h1>TechnologyPage</h1>
<h1>Technology Details</h1>
<div>{result.name}</div>
<img src={result.image}/>
<div>{result.description}</div>
</div>
);
}
Expand Down