From 10c79d3308fe13f6c31629d501f8e8cc95f19d6a Mon Sep 17 00:00:00 2001 From: Piotr Rogowski Date: Sun, 17 Jul 2022 22:09:06 +0200 Subject: [PATCH] Improve Hub mobile view --- src/pages/Hub.tsx | 83 +++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 50 deletions(-) diff --git a/src/pages/Hub.tsx b/src/pages/Hub.tsx index 1e9d8ef..31e7153 100644 --- a/src/pages/Hub.tsx +++ b/src/pages/Hub.tsx @@ -1,22 +1,19 @@ import { - Badge, Button, - Card, - Col, - Grid, Input, - Row, Space, Table, Tooltip, Typography, } from 'antd'; +import { ColumnsType } from 'antd/lib/table'; import { CopyOutlined, StarOutlined, ArrowRightOutlined, } from '@ant-design/icons'; import { + Fragment, useCallback, useEffect, useState, @@ -27,31 +24,14 @@ import { } from 'react-router'; import debounce from 'lodash.debounce'; import useDb from '../hooks/useDb'; -import { TuneDbDocument } from '../types/dbData'; import { Routes } from '../routes'; import { buildFullUrl } from '../utils/url'; import { aspirationMapper } from '../utils/tune/mappers'; - -const { useBreakpoint } = Grid; - -const loadingCards = ( - <> - - - - - - - - - - -); +import { TuneDbDocument } from '../types/dbData'; const tunePath = (tuneId: string) => generatePath(Routes.TUNE_TUNE, { tuneId }); const Hub = () => { - const { md } = useBreakpoint(); const { searchTunes } = useDb(); const navigate = useNavigate(); const [dataSource, setDataSource] = useState([]); @@ -91,56 +71,79 @@ const Hub = () => { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); // TODO: fix this - const columns = [ + const columns: ColumnsType = [ + { + title: 'Tune', + render: (tune: TuneDbDocument) => ( + <> + {tune.vehicleName} ({tune.signature}) +
+ {tune.engineMake}, {tune.engineCode}, {tune.displacement}, {tune.cylindersCount} cylinders, {tune.aspiration} +
+ author: ? 0 + + ), + responsive: ['xs', 'sm', 'md'], + }, { title: 'Vehicle name', dataIndex: 'vehicleName', key: 'vehicleName', + responsive: ['lg'], }, { title: 'Engine make', dataIndex: 'engineMake', key: 'engineMake', + responsive: ['lg'], }, { title: 'Engine code', dataIndex: 'engineCode', key: 'engineCode', + responsive: ['lg'], }, { title: 'Displacement', dataIndex: 'displacement', key: 'displacement', + responsive: ['lg'], }, { title: 'Cylinders', dataIndex: 'cylindersCount', key: 'cylindersCount', + responsive: ['lg'], }, { title: 'Aspiration', dataIndex: 'aspiration', key: 'aspiration', + responsive: ['lg'], }, { title: 'Author', dataIndex: 'author', key: 'author', + responsive: ['lg'], }, { title: 'Signature', dataIndex: 'signature', key: 'author', + responsive: ['lg'], }, { title: 'Published', dataIndex: 'updatedAt', key: 'updatedAt', + responsive: ['lg'], }, { title: , dataIndex: 'stars', key: 'stars', + responsive: ['lg'], }, { dataIndex: 'tuneId', @@ -165,32 +168,12 @@ const Hub = () => { placeholder="Search..." onChange={({ target }) => debounceLoadData(target.value)} /> - {md ? - - : - - {isLoading ? loadingCards : ( - dataSource.map((tune: TuneDbDocument) => ( - - - - , - - copyToClipboard(buildFullUrl([tunePath(tune.id!)]))} /> - , - navigate(tunePath(tune.id!))} />, - ]} - > - - {tune.engineMake} {tune.engineCode} {tune.year} - - - - )))} - } +
); };