From c4cc6a397a29fc6beaafbbdba853eb974b9cb443 Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Fri, 14 Apr 2023 12:38:40 +0200 Subject: [PATCH] Rework Table Header --- front/src/components/table/ColumnHead.tsx | 34 ++++++++++++++++++++ front/src/components/table/Table.tsx | 10 ++++-- front/src/components/table/TableHeader.tsx | 37 ++++++++++++++++++++-- front/src/pages/people/People.tsx | 24 +++++++------- 4 files changed, 87 insertions(+), 18 deletions(-) create mode 100644 front/src/components/table/ColumnHead.tsx diff --git a/front/src/components/table/ColumnHead.tsx b/front/src/components/table/ColumnHead.tsx new file mode 100644 index 0000000000..37d4c82288 --- /dev/null +++ b/front/src/components/table/ColumnHead.tsx @@ -0,0 +1,34 @@ +import styled from '@emotion/styled'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { IconProp } from '@fortawesome/fontawesome-svg-core'; + +type OwnProps = { + viewName: string; + viewIcon?: IconProp; +}; + +const StyledTitle = styled.div` + display: flex; + flex-direction: row; + align-items: center; + height: 40px; + color: ${(props) => props.theme.text60}; + font-weight: 500; + padding-left: ${(props) => props.theme.spacing(2)}; +`; + +const StyledIcon = styled.div` + display: flex; + margin-right: ${(props) => props.theme.spacing(1)}; +`; + +function TableHeader({ viewName, viewIcon }: OwnProps) { + return ( + + {viewIcon && } + {viewName} + + ); +} + +export default TableHeader; diff --git a/front/src/components/table/Table.tsx b/front/src/components/table/Table.tsx index 2aae3307ab..844e21ad8d 100644 --- a/front/src/components/table/Table.tsx +++ b/front/src/components/table/Table.tsx @@ -32,6 +32,12 @@ const StyledTable = styled.table` } `; +const StyledTableWithHeader = styled.div` + display: flex; + flex-direction: column; + flex: 1; +`; + function Table({ data, columns, viewName, viewIcon }: OwnProps) { const table = useReactTable({ data, @@ -40,7 +46,7 @@ function Table({ data, columns, viewName, viewIcon }: OwnProps) { }); return ( -
+ @@ -92,7 +98,7 @@ function Table({ data, columns, viewName, viewIcon }: OwnProps) { )} -
+ ); } diff --git a/front/src/components/table/TableHeader.tsx b/front/src/components/table/TableHeader.tsx index 553c421ba5..7d26e62964 100644 --- a/front/src/components/table/TableHeader.tsx +++ b/front/src/components/table/TableHeader.tsx @@ -11,16 +11,47 @@ const StyledTitle = styled.div` display: flex; flex-direction: row; align-items: center; - gap: 5px; + justify-content: space-between; + height: 40px; color: ${(props) => props.theme.text60}; font-weight: 500; + padding-left: ${(props) => props.theme.spacing(2)}; +`; + +const StyledIcon = styled.div` + display: flex; + margin-right: ${(props) => props.theme.spacing(2)}; +`; + +const StyledViewSection = styled.div` + display: flex; +`; + +const StyledFilters = styled.div` + display: flex; + font-weight: 400; + margin-right: ${(props) => props.theme.spacing(1)}; +`; + +const StyledFilterButton = styled.div` + display: flex; + margin-left: ${(props) => props.theme.spacing(4)}; `; function TableHeader({ viewName, viewIcon }: OwnProps) { return ( - {viewIcon && } - {viewName} + + + {viewIcon && } + + {viewName} + + + Filter + Sort + Settings + ); } diff --git a/front/src/pages/people/People.tsx b/front/src/pages/people/People.tsx index ff18ce5857..64f3f893de 100644 --- a/front/src/pages/people/People.tsx +++ b/front/src/pages/people/People.tsx @@ -13,7 +13,7 @@ import { Pipe } from '../../interfaces/pipe.interface'; import { createColumnHelper } from '@tanstack/react-table'; import styled from '@emotion/styled'; import CellLink from '../../components/table/CellLink'; -import TableHeader from '../../components/table/TableHeader'; +import ColumnHead from '../../components/table/ColumnHead'; import personPlaceholder from './placeholder.png'; import { parsePhoneNumber, CountryCode } from 'libphonenumber-js'; @@ -30,13 +30,11 @@ type Person = { }; const StyledPeopleContainer = styled.div` - padding: 8px; + display: flex; + padding-left: ${(props) => props.theme.spacing(2)}; + padding-right: ${(props) => props.theme.spacing(2)}; width: 100%; - table { - margin-top: 8px; - } - a { color: inherit; text-decoration: none; @@ -105,7 +103,7 @@ const columnHelper = createColumnHelper(); const columns = [ columnHelper.accessor('fullName', { - header: () => , + header: () => , cell: (props) => ( , + header: () => , cell: (props) => ( {props.row.original.email} @@ -123,7 +121,7 @@ const columns = [ ), }), columnHelper.accessor('company', { - header: () => , + header: () => , cell: (props) => ( , + header: () => , cell: (props) => ( , + header: () => , cell: (props) => new Intl.DateTimeFormat(undefined, { month: 'short', @@ -158,7 +156,7 @@ const columns = [ }).format(props.row.original.creationDate), }), columnHelper.accessor('pipe', { - header: () => , + header: () => , cell: (props) => ( , + header: () => , }), ];