From c12f213cd099c7c1eaab72181f80d55ec2de8b2e Mon Sep 17 00:00:00 2001 From: sirlolcat Date: Tue, 7 Jun 2022 00:40:42 +0430 Subject: [PATCH] feat: add table styling and components --- react-typescript/src/components/App.tsx | 2 +- .../src/components/ItemsSection.tsx | 61 ++----------- .../src/components/ItemsTable.tsx | 89 ++++++++----------- .../src/hooks/useTableController.ts | 41 +++++++++ 4 files changed, 87 insertions(+), 106 deletions(-) create mode 100644 react-typescript/src/hooks/useTableController.ts 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 ( - +