Skip to content
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

refactor: react-table --> tanstack #72

Merged
merged 39 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f18d4c2
wip: to tanstack
eldu Feb 15, 2024
39e1b7a
wip: to tanstack
eldu Feb 15, 2024
84cf201
refactor: js --> tsx
eldu Feb 16, 2024
b3004d9
refactor: Use some basic React Bootstrap components
eldu Feb 27, 2024
b2c54a7
Merge branch 'build-update' into refactor-tanstack
eldu Feb 27, 2024
ae57867
fix: some dependencies that were trouble
eldu Feb 27, 2024
b36e2f0
style: Table Controls
eldu Feb 27, 2024
ed1186b
fix: missing package lock
eldu Feb 27, 2024
df9a796
refactor: remove _table.scss
eldu Feb 29, 2024
2ab4f6f
style: fix theme colors
eldu Feb 29, 2024
f9e2b30
style: closer to original table
eldu Feb 29, 2024
9474cbd
refactor: font awesome icon
eldu Feb 29, 2024
8af8f41
refactor: tanstack columns
eldu Feb 29, 2024
ac59cf5
refactor: sorting icon
eldu Feb 29, 2024
2ad9a31
style: refactor out _addPub.scss
eldu Feb 29, 2024
0934920
build: remove reactstrap
eldu Feb 29, 2024
fb02993
style: clean up some more style
eldu Feb 29, 2024
024da4a
style: clean up some more style
eldu Feb 29, 2024
d486873
style: fix table controls
eldu Feb 29, 2024
8515c6a
style: refactor to same same
eldu Feb 29, 2024
dc7cc26
style: fix div
eldu Feb 29, 2024
00816cf
wip: why is this table resizing so hard
eldu Mar 1, 2024
bac55c1
fix: most of my table resizing sadness
eldu Mar 1, 2024
3c8b9e7
fix: pagination
eldu Mar 1, 2024
8bf6240
refactor: move out components
eldu Mar 1, 2024
c19aa86
refactor: more clean up
eldu Mar 1, 2024
c1c147f
refactor: more clean up
eldu Mar 1, 2024
9c6229a
refactor: more clean up
eldu Mar 1, 2024
8e10aec
refactor: remove unneeded flex
eldu Mar 1, 2024
11cd4e7
Merge branch 'build-update' into refactor-tanstack
eldu Mar 1, 2024
5af92a5
fix: package-lock.json
eldu Mar 1, 2024
8dff126
refactor: clean up
eldu Mar 1, 2024
53fdaae
refactor: sorting icons
eldu Mar 1, 2024
f696930
fix: clicking header
eldu Mar 1, 2024
0cedba2
fix: quick fix for footer. trying to not touch the rest ! :scream:
eldu Mar 1, 2024
d16c5e1
refactor: pagination clean up
eldu Mar 1, 2024
00f03be
refactor: some more style clean up
eldu Mar 4, 2024
bfea3cb
refactor: some more style clean up
eldu Mar 4, 2024
2b9d6d3
docs: add issue number for word cloud
eldu Mar 4, 2024
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
31,968 changes: 2,629 additions & 29,339 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"@reduxjs/toolkit": "^2.0.1",
"@tanstack/match-sorter-utils": "^8.11.8",
"@tanstack/react-table": "^8.12.0",
"bootstrap": "^5.3.2",
"firebase": "^10.7.2",
"formik": "^2.4.5",
Expand All @@ -29,27 +31,21 @@
"react-router-dom": "^6.21.2",
"react-scripts": "^5.0.1",
"react-spinners": "^0.13.8",
"react-table": "^6.10.0",
"react-vega": "^7.6.0",
"redux": "^5.0.1",
"sass": "^1.69.7",
"seamless-immutable": "^7.1.4",
"table": "^5.4.1",
"vega": "^5.27.0",
"vega-lite": "^5.16.3",
"yup": "^1.3.3"
},
"devDependencies": {
"@brown-ccv/eslint-config": "^0.3.0",
"@brown-ccv/prettier-config": "^0.3.0",
"chromedriver": "^83.0.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"firebase-admin": "^12.0.0",
"firebase-tools": "^13.0.3",
"husky": "^8.0.3",
"lint-staged": "^15.2.0",
"nightwatch": "^1.3.6",
"prettier": "^3.2.4"
},
"eslintConfig": {
Expand Down
18 changes: 8 additions & 10 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ export function App() {
return (
<div aria-live="polite">
<Navbar />
<div className="App">
<BrowserRouter>
<main>
<Routes>
<Route exact path="/" element={<ContentPage />} />
</Routes>
</main>
</BrowserRouter>
<Footer />
</div>
<BrowserRouter>
<main className="main">
<Routes>
<Route exact path="/" element={<ContentPage />} />
</Routes>
</main>
</BrowserRouter>
<Footer />
</div>
);
}
6 changes: 3 additions & 3 deletions src/components/AddPublicationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function AddPublicationModal() {

return (
<>
<Button variant="contained" color="primary" onClick={handleShow}>
<Button variant="primary" onClick={handleShow}>
Add Publication
</Button>

Expand Down Expand Up @@ -149,7 +149,7 @@ const SearchDoiForm = ({
>
Enter Manually
</Button>
<LoadingButton loading={loading} type="submit" variant="contained" form={searchFormId}>
<LoadingButton loading={loading} type="submit" variant="primary" form={searchFormId}>
Search
</LoadingButton>
</Modal.Footer>
Expand Down Expand Up @@ -324,7 +324,7 @@ const ManualForm = ({
>
Back
</Button>
<LoadingButton loading={loading} type="submit" variant="contained" form={manualFormId}>
<LoadingButton loading={loading} type="submit" variant="primary" form={manualFormId}>
Submit
</LoadingButton>
</Modal.Footer>
Expand Down
53 changes: 53 additions & 0 deletions src/components/ColumnFilter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';
import { DebouncedInput } from './DebouncedInput.tsx';

export function ColumnFilter({ column, table }) {
const firstValue = table.getPreFilteredRowModel().flatRows[0]?.getValue(column.id);

const columnFilterValue = column.getFilterValue();

const sortedUniqueValues = React.useMemo(
() =>
typeof firstValue === 'number'
? []
: Array.from(column.getFacetedUniqueValues().keys()).sort(),
// eslint-disable-next-line react-hooks/exhaustive-deps
[column.getFacetedUniqueValues()]
);

return typeof firstValue === 'number' ? (
<div className="d-flex">
<DebouncedInput
type="number"
min={Number(column.getFacetedMinMaxValues()?.[0] ?? '')}
max={Number(column.getFacetedMinMaxValues()?.[1] ?? '')}
value={(columnFilterValue as [number, number])?.[0] ?? ''}
onChange={(value) => column.setFilterValue((old: [number, number]) => [value, old?.[1]])}
placeholder="min"
/>
<DebouncedInput
type="number"
min={Number(column.getFacetedMinMaxValues()?.[0] ?? '')}
max={Number(column.getFacetedMinMaxValues()?.[1] ?? '')}
value={(columnFilterValue as [number, number])?.[1] ?? ''}
onChange={(value) => column.setFilterValue((old: [number, number]) => [old?.[0], value])}
placeholder="max"
/>
</div>
) : (
<>
<datalist id={column.id + 'list'}>
{sortedUniqueValues.slice(0, 5000).map((value) => (
<option value={value} key={value} />
))}
</datalist>
<DebouncedInput
type="text"
value={(columnFilterValue ?? '') as string}
onChange={(value) => column.setFilterValue(value)}
list={column.id + 'list'}
/>
<div className="h-1" />
</>
);
}
29 changes: 14 additions & 15 deletions src/components/ContentPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faBook } from '@fortawesome/free-solid-svg-icons';
import { useSelector } from 'react-redux';
import { selectPublications, selectUser } from '../store/slice/appState';
import { PubsTable } from './PubsTable';
import { PublicationsTable } from './PublicationsTable.tsx';
import Spinner from './Spinner';
import { AddPublicationModal } from './AddPublicationModal.tsx';
import { YearChart } from './YearChart.tsx';
Expand All @@ -13,34 +13,33 @@ export function ContentPage() {
const user = useSelector(selectUser);

return (
<div className="ContentPage main-content">
<div className="main-content d-flex flex-column align-items-center">
{user ? (
<div align="right">
<div className="align-self-end">
<AddPublicationModal />
</div>
) : null}
<div className="d-flex flex-row justify-content-center align-items-center">
<div className="pub-title bg-dark rounded-circle p-2 mx-2">
<FontAwesomeIcon icon={faBook} color="white" />
</div>
<h1 className="pl-2">Publications</h1>

<div className="d-flex flex-row align-items-center justify-content-center">
<FontAwesomeIcon icon={faBook} color="dark" size="2xl" />
<h1 className="mx-2">Publications</h1>
</div>

<Spinner loading={publications.length === 0} className="spinner" size={100} />

{publications.length !== 0 && (
<div id="main-content">
<div className="PubsTable-CP">
<PubsTable />
</div>
<>
<PublicationsTable />

{/* TODO: Word Cloud */}
<h3 className="word-cloud-title pt-4 mt-4">What are these publications all about? </h3>
{/* TODO: Word Cloud #58 */}
<h2 className="title pt-4 m-4 is-2 text-center">
What are these publications all about?
</h2>
{/*<div className="viz d-flex justify-content-center pt-5">*/}
{/* <WordCloud />*/}
<YearChart />
{/*</div>*/}
</div>
</>
)}
</div>
);
Expand Down
34 changes: 34 additions & 0 deletions src/components/DebouncedInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// A debounced input react component
import React from 'react';
import Form from 'react-bootstrap/Form';

export function DebouncedInput({
value: initialValue,
onChange,
debounce = 500,
...props
}: {
value: string | number;
onChange: (value: string | number) => void;
debounce?: number;
} & Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange'>) {
const [value, setValue] = React.useState(initialValue);

React.useEffect(() => {
setValue(initialValue);
}, [initialValue]);

React.useEffect(
() => {
const timeout = setTimeout(() => {
onChange(value);
}, debounce);

return () => clearTimeout(timeout);
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[value]
);

return <Form.Control {...props} value={value} onChange={(e) => setValue(e.target.value)} />;
}
Loading
Loading