From 7ec29b85f573f9d33dd6185b71827e2f7bdbbb6f Mon Sep 17 00:00:00 2001 From: Tatiana Cherednichenko Date: Thu, 27 May 2021 13:51:19 +0300 Subject: [PATCH] feat: implement data-table --- src/ui/atoms/table/index.tsx | 10 +- src/ui/molecules/data-table/filter.tsx | 88 ++++++++++++++++ src/ui/molecules/data-table/index.tsx | 57 +++++++++++ src/ui/molecules/data-table/usage.mdx | 134 +++++++++++++++++++++++++ src/ui/molecules/index.ts | 3 +- 5 files changed, 289 insertions(+), 3 deletions(-) create mode 100644 src/ui/molecules/data-table/filter.tsx create mode 100644 src/ui/molecules/data-table/index.tsx create mode 100644 src/ui/molecules/data-table/usage.mdx diff --git a/src/ui/atoms/table/index.tsx b/src/ui/atoms/table/index.tsx index 5098b183..b3f0b373 100644 --- a/src/ui/atoms/table/index.tsx +++ b/src/ui/atoms/table/index.tsx @@ -1,4 +1,4 @@ -import styled from 'styled-components'; +import styled, { StyledComponent } from 'styled-components'; import { Variant } from 'lib/types'; const map = (properties: { columns: number } & Variant) => ({ @@ -17,7 +17,7 @@ export const Table = styled.table.attrs(map)` display: grid; grid-template-columns: repeat(var(--local-columns), auto); gap: var(--local-gap); -`; +` as StyledComponent<'table', Record, { columns: number } & Variant>; export const Thead = styled.thead` display: contents; @@ -28,11 +28,16 @@ export const Tbody = styled.tbody` `; export const Th = styled.th` + display: flex; + align-items: center; box-sizing: border-box; max-width: var(--local-cell-max-width); padding: var(--local-vertical) var(--local-horizontal); color: var(--woly-canvas-text-disabled); + font-weight: normal; + + line-height: var(--woly-line-height); background: var(--woly-shape-text-default); `; @@ -43,6 +48,7 @@ export const Td = styled.td` padding: var(--local-vertical) var(--local-horizontal); color: var(--woly-canvas-text-default); + line-height: var(--woly-line-height); background: var(--woly-shape-text-default); `; diff --git a/src/ui/molecules/data-table/filter.tsx b/src/ui/molecules/data-table/filter.tsx new file mode 100644 index 00000000..0c4b0037 --- /dev/null +++ b/src/ui/molecules/data-table/filter.tsx @@ -0,0 +1,88 @@ +import * as React from 'react'; +import styled from 'styled-components'; +import { Button, ListContainer, Surface } from 'ui/atoms'; +import { Popover } from 'ui/molecules'; +import { box } from 'ui/elements/box'; + +import { Checkbox } from '../checkbox'; +import { IconArrowDown } from '../../../static/icons'; + +interface FilterProps { + options: Array>; + title: string; +} + +export const Filter: React.FC = ({ options, title }) => { + const [isOpen, setOpen] = React.useReducer((is) => !is, false); + const [isChecked, setChecked] = React.useReducer((is) => !is, false); + if (options.length === 0) return null; + + return ( + + + + {options.map(({ name, value }) => ( + + ))} +