Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Commit

Permalink
Implement Typescript in project
Browse files Browse the repository at this point in the history
Fixes #7
  • Loading branch information
sebastienHUGDELARAUZE-Dedalus committed Feb 23, 2021
1 parent 74ab6d4 commit f5af33e
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 20 deletions.
63 changes: 60 additions & 3 deletions package-lock.json

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

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.5",
"@testing-library/user-event": "^12.7.2",
"@types/jest": "^26.0.20",
"@types/node": "^14.14.31",
"@types/react": "^17.0.2",
"@types/react-dom": "^17.0.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-feather": "^2.0.9",
"react-scripts": "4.0.2",
"typescript": "^4.1.5",
"web-vitals": "^1.1.0"
},
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/App.js → src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Trash,
} from "react-feather";
import ResultExplorerTable from "./components/ResultExplorerTable";

import ResultListTest from "./assets/resultList.json";

function App() {
Expand Down Expand Up @@ -92,7 +93,7 @@ function App() {
<div className="mb-3 pb-1 font-semibold text-2xl border-b-2 dark:text-white">
Job Browser
</div>
<ResultExplorerTable resultList={ResultListTest} />
<ResultExplorerTable results={ResultListTest} />
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
import { PlusCircle, XCircle } from "react-feather";
import ResultExplorerTag from "./ResultExplorerTag";

function ResultExplorerLine(props) {
type LineProps = {
result: Result;
};

export type Result = {
id: string;
name: string;
tags: string[];
submitted_at: string;
};

function ResultExplorerLine(props: LineProps) {
return (
<tr>
<td className="border py-2 text-center">
<input type="checkbox" className="h-4 w-4" />
</td>
<td className="border px-4 text-left truncate">{ props.result.name }</td>
<td className="border px-4 text-left truncate">{props.result.name}</td>
<td className="border px-4">
<div className="flex flex-row justify-start space-x-2 overflow-x-auto scrollbar-thin scrollbar-thumb-ovh_blue scrollbar-track-gray-200">
{ props.result.tags.map((tag, index) => (
<ResultExplorerTag key={index+'_'+tag} text={ tag } />
)) }
{props.result.tags.map((tag, index) => (
<ResultExplorerTag key={index + "_" + tag} text={tag} />
))}
</div>
</td>
<td className="border px-4 text-xs">{ props.result.submitted_at }</td>
<td className="border px-4 text-xs">{props.result.submitted_at}</td>
<td className="border px-4">
<div className="flex flex-row justify-evenly">
<button className="text-red-500">
<XCircle/>
<XCircle />
</button>
<button className="text-blue-500">
<PlusCircle/>
<PlusCircle />
</button>
</div>
</td>
</tr>
);
}

export default ResultExplorerLine;
export default ResultExplorerLine;
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import ResultExplorerLine from "./ResultExplorerLine";
import { Result } from "./ResultExplorerLine";

function ResultExplorerTable(props) {
type TableProps = {
results: Result[];
};

function ResultExplorerTable(props: TableProps) {
return (
<table className="shadow-md bg-white table-fixed w-full">
<tr className="bg-ovh_blue text-white text-left border">
Expand All @@ -13,10 +18,9 @@ function ResultExplorerTable(props) {
<th className="py-4 w-32 text-center">Actions</th>
</tr>

{ props.resultList.map((result) => (
<ResultExplorerLine key={ result.id } result={result} />
)) }

{props.results.map((result) => (
<ResultExplorerLine key={result.id} result={result} />
))}
</table>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { Tag } from "react-feather";

function ResultExplorerTag(props) {
type TagProps = {
key: string;
text: string;
};

function ResultExplorerTag(props: TagProps) {
return (
<div className="flex flex-row flex-none bg-gray-300 rounded-full px-2 my-1 items-center">
<Tag className="w-4 pr-1" />
<div className="font-bold text-black text-xs">{ props.text }</div>
<div className="font-bold text-black text-xs">{props.text}</div>
</div>
);
}
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
26 changes: 26 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
}

0 comments on commit f5af33e

Please sign in to comment.