From 2dbf1ddf2594143f382c8efa17a5844e49e726d5 Mon Sep 17 00:00:00 2001 From: witt Date: Sat, 26 Jun 2021 19:50:19 +0800 Subject: [PATCH] refactor(table): redesign interfaces to improve the experience in TypeScript (#569) * refactor(table): redesign interfaces to improve the experience in TypeScript * docs: upgrade to new type exports * style: fix lint warnings --- components/rating/rating.tsx | 1 - .../__snapshots__/index.test.tsx.snap | 109 ++++++++++-- components/table/__tests__/index.test.tsx | 74 +++++---- components/table/index.ts | 30 ++-- components/table/table-body.tsx | 35 ++-- components/table/table-cell.tsx | 62 +++---- components/table/table-column.tsx | 54 +++--- components/table/table-context.ts | 22 +-- components/table/table-head.tsx | 25 +-- components/table/table-types.ts | 32 ++++ components/table/table.tsx | 121 +++++++------- lib/components/index.ts | 1 + pages/en-us/components/table.mdx | 156 +++++++++++++----- pages/en-us/components/use-media-query.mdx | 3 +- pages/zh-cn/components/table.mdx | 153 ++++++++++++----- pages/zh-cn/components/use-media-query.mdx | 3 +- 16 files changed, 577 insertions(+), 304 deletions(-) create mode 100644 components/table/table-types.ts diff --git a/components/rating/rating.tsx b/components/rating/rating.tsx index 91b510eab..f6b538126 100644 --- a/components/rating/rating.tsx +++ b/components/rating/rating.tsx @@ -47,7 +47,6 @@ const getColor = (type: RatingTypes, palette: GeistUIThemesPalette): string => { const RatingComponent: React.FC = ({ type, - children, className, icon, count, diff --git a/components/table/__tests__/__snapshots__/index.test.tsx.snap b/components/table/__tests__/__snapshots__/index.test.tsx.snap index e3ff705df..99b619abb 100644 --- a/components/table/__tests__/__snapshots__/index.test.tsx.snap +++ b/components/table/__tests__/__snapshots__/index.test.tsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Table should be no erros when width is too large 1`] = ` -"
property
description
default
type
Content type
-
Component
DOM element to use
-
bold
Bold style
true
type
Content type
-
Component
DOM element to use
-
bold
Bold style
true
type
Component
bold
type
Component
bold
type
Content type
-
Component
DOM element to use
-
bold
Bold style
true
type
Content type
-
Component
DOM element to use
-
bold
Bold style
true
type
Content type
-
Component
DOM element to use
-
bold
Bold style
true
type
Content type
-
Component
DOM element to use
-
bold
Bold style
true
" +`; + +exports[`Table should work correctly with multiple identical props 1`] = ` +"
property3
description2
type
Content type
Component
DOM element to use
bold
Bold style
type
Content type
-
Component
DOM element to use
-
bold
Bold style
true
bold
boolean
true
type
Content type
-
Component
DOM element to use
-
bold
Bold style
true
bold
boolean
true
type
Content type
-
Component
DOM element to use
-
bold
Bold style
true
type
Content type
-
Component
DOM element to use
-
bold
Bold style
true