diff --git a/react-typescript/src/components/App.tsx b/react-typescript/src/components/App.tsx
index 74f8e47a..a1fe4162 100644
--- a/react-typescript/src/components/App.tsx
+++ b/react-typescript/src/components/App.tsx
@@ -9,7 +9,7 @@ function App(): JSX.Element {
padding: 0;
}
html, body {
- background-color: RGB(132, 151, 149);
+ background-color: RGB(255, 255, 253);
color: RGB(227, 226, 215);
width: 100%;
height: 100%;
diff --git a/react-typescript/src/components/ItemsSection.tsx b/react-typescript/src/components/ItemsSection.tsx
index 5f4c2c25..1dfbb2fd 100644
--- a/react-typescript/src/components/ItemsSection.tsx
+++ b/react-typescript/src/components/ItemsSection.tsx
@@ -1,66 +1,23 @@
-import { useMemo } from "react";
import styled from "styled-components";
-import useAllItems from "../hooks/useAllItems";
import ItemsTable from './ItemsTable';
import Button from './Button';
+import useTableController from "../hooks/useTableController";
function ItemsSection(): JSX.Element {
const ItemsSection = styled.section`
- height: 85vh;
- ul {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- width: 100%;
- height: 100%;
- color: white;
- justify-content: center;
- align-items: center;
- }
- li {
- list-style: none;
- display: inline-block;
- height: 10%;
- width: 40%;
- border: 1px solid white;
- margin: 3% 3%;
- }
+ height: 100vh;
+ display: flex;
+ flex-flow: column wrap;
+ justify-content: center;
+ margin: 0 5%;
+ role: 'region';
`;
-const { items } = useAllItems();
-const data = useMemo(() => items, [items]);
-const columns = useMemo(() => [
- {
- Header: "Details",
- columns: [
- {
- Header: 'Name',
- accessor: 'name',
- },
- {
- Header: 'Conjured',
- accessor: 'isConjured'
- }
- ],
- },
- {
- Header: "Item Info",
- columns: [
- {
- Header: 'Quality',
- accessor: 'quality'
- },
- {
- Header: 'Days Left',
- accessor: 'sellIn'
- }
- ],
- }
-], []);
+const { columns, data } = useTableController();
return (
-
+
);
diff --git a/react-typescript/src/components/ItemsTable.tsx b/react-typescript/src/components/ItemsTable.tsx
index 1590144b..a2afc81b 100644
--- a/react-typescript/src/components/ItemsTable.tsx
+++ b/react-typescript/src/components/ItemsTable.tsx
@@ -3,25 +3,37 @@ import styled from "styled-components";
import { TTable } from "../types";
function ItemTable({ columns, data }: TTable): JSX.Element {
- const ItemsSection = styled.section`
- height: 85vh;
- ul {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- width: 100%;
- height: 100%;
- color: white;
- justify-content: center;
- align-items: center;
+ const ItemsTable = styled.table`
+ @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;500&family=Ubuntu:wght@300;400;500&display=swap');
+ height: 60%;
+ border: 1px solid RGB(12, 16, 36);
+ border-radius: 10px;
+ min-height: 30%;
+ color: RGB(12, 16, 36);
+th, td, tr {
+ font-family: 'Roboto', sans-serif;
+ outline: none;
+ border: none;
+ border-collapse: collapse;
+ text-align: center;
+ font-size: 1.2rem;
}
- li {
- list-style: none;
- display: inline-block;
- height: 10%;
- width: 40%;
- border: 1px solid white;
- margin: 3% 3%;
+
+
+ th {
+ font-weight: 300;
+ }
+
+ tr {
+ font-weight: 100;
+ }
+
+ tr:nth-child(n):hover {
+ background-color: #f2f2f2;
+ }
+
+ tr:nth-child(2n + 1) {
+ background-color: RGB(245, 245, 243);
}
`;
const {
@@ -36,10 +48,9 @@ function ItemTable({ columns, data }: TTable): JSX.Element {
});
return (
-
-
+
-
+
{headerGroups.map(headerGroup => (
@@ -47,27 +58,9 @@ function ItemTable({ columns, data }: TTable): JSX.Element {
{headerGroup.headers.map(column => (
- |
-
+ |
{column.render('Header')}
-
- |
+
))}
@@ -94,16 +87,7 @@ function ItemTable({ columns, data }: TTable): JSX.Element {
@@ -123,8 +107,7 @@ function ItemTable({ columns, data }: TTable): JSX.Element {
- |
-
+
)
}
diff --git a/react-typescript/src/hooks/useTableController.ts b/react-typescript/src/hooks/useTableController.ts
new file mode 100644
index 00000000..50e8185c
--- /dev/null
+++ b/react-typescript/src/hooks/useTableController.ts
@@ -0,0 +1,41 @@
+import { useMemo } from "react";
+import { useStore } from "../model";
+import { TTable } from "../types";
+
+function useTableController(): TTable {
+ const { state } = useStore();
+ const { items } = state;
+
+ const data = useMemo(() => items, [items]);
+ const columns = useMemo(() => [
+ {
+ Header: "Items",
+ columns: [
+ {
+ Header: 'Name',
+ accessor: 'name',
+ },
+ {
+ Header: 'Conjured',
+ accessor: 'isConjured',
+ Cell: ({ cell: { value } }: any) => { return value ? 'Yes' : 'No' },
+ },
+ {
+ Header: 'Quality',
+ accessor: 'quality'
+ },
+ {
+ Header: 'Days Left',
+ accessor: 'sellIn'
+ }
+ ],
+ },
+ ], []);
+
+ return {
+ columns,
+ data
+ }
+}
+
+export default useTableController;
\ No newline at end of file