Skip to content

Commit

Permalink
Move App and index to tsx (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanatteveldt committed Feb 8, 2022
1 parent 07d6c52 commit b7ed1f7
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 27 deletions.
19 changes: 19 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"@babel/cli": "^7.16.7",
"@babel/core": "^7.16.7",
"@babel/preset-env": "^7.16.7",
"@types/react-dom": "^17.0.11",
"react-styleguidist": "^11.2.0",
"ts-loader": "^9.2.6",
"typescript": "^4.5.5"
Expand Down
20 changes: 14 additions & 6 deletions src/App.js → src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import { useEffect, useState } from "react";
import { Grid, Menu, Segment } from "semantic-ui-react";

// Left column
Expand All @@ -10,6 +10,8 @@ import Query from "./lib/Query/Query";
import Upload from "./lib/Upload/Upload";
import Articles from "./lib/Articles/Articles";
import AggregatePane from "./lib/Aggregate/AggregatePane";
import Amcat from "./lib/apis/Amcat";
import { AmcatQuery } from "./lib/interfaces";

const menuItems = ["Upload", "Articles", "Aggregate"];

Expand All @@ -22,12 +24,12 @@ const testQuery = {

export default function App() {
const [selected, setSelected] = useState(menuItems[2]);
const [amcat, setAmcat] = useState(null);
const [index, setIndex] = useState(null);
const [query, setQuery] = useState();
const [amcat, setAmcat] = useState<Amcat>(null);
const [index, setIndex] = useState<string>(null);
const [query, setQuery] = useState<AmcatQuery>();

useEffect(() => {
setQuery();
setQuery(undefined);
}, [amcat, index]);

const render = () => {
Expand Down Expand Up @@ -69,7 +71,13 @@ export default function App() {
);
}

function ComponentMenu({ index, selected, setSelected }) {
interface ComponentMenuProps {
index: string,
selected: string,
setSelected: (value: string)=> void
}

function ComponentMenu({ index, selected, setSelected }: ComponentMenuProps) {
return (
<Menu attached="top" tabular>
{menuItems.map((name) => {
Expand Down
12 changes: 0 additions & 12 deletions src/index.js

This file was deleted.

8 changes: 8 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import "semantic-ui-css/semantic.min.css";
import * as ReactDOM from 'react-dom';
import App from "./App";

ReactDOM.render(
<App />,
document.getElementById('root') as HTMLElement
);
8 changes: 0 additions & 8 deletions src/lib/index.js

This file was deleted.

9 changes: 9 additions & 0 deletions src/lib/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// here import and export all components for the npm module
import AggregateResult from "./Aggregate/AggregateResult";
import AggregateOptionsChooser from "./Aggregate/AggregateOptionsChooser";
import Articles from "./Articles/Articles";
import Login from "./Login/Login";
import Query from "./Query/Query";
import Upload from "./Upload/Upload";

export { AggregateOptionsChooser, AggregateResult, Articles, Login, Query, Upload };
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"allowJs": true,
"moduleResolution": "node",
"lib": [
"ES2021.String"
"ES2021.String",
"DOM"
]
}
}

0 comments on commit b7ed1f7

Please sign in to comment.