From 742a530babe97f507582f31b84bcbf6eb78591e8 Mon Sep 17 00:00:00 2001
From: Jin Lee <86632227+jinlee93@users.noreply.github.com>
Date: Fri, 14 Jul 2023 09:58:10 -0700
Subject: [PATCH] feat(table)!: remove top-level sub-components (#1685)
* feat(table)!: remove top-level sub-components
* refactor(table): rename props type decl
---
.../Guildelines/CodeGuidelines.stories.mdx | 2 +-
.../CoursePlannerEdit/CoursePlannerEdit.tsx | 33 +-
.storybook/recipes/TabularInputs.stories.tsx | 39 +--
src/components/Table/Table.module.css | 58 ++++
src/components/Table/Table.stories.tsx | 19 +-
src/components/Table/Table.tsx | 286 +++++++++++++++++-
src/components/TableBody/TableBody.tsx | 22 --
src/components/TableBody/index.ts | 1 -
src/components/TableCaption/TableCaption.tsx | 18 --
src/components/TableCaption/index.ts | 1 -
src/components/TableCell/TableCell.module.css | 15 -
src/components/TableCell/TableCell.tsx | 50 ---
src/components/TableCell/index.ts | 1 -
src/components/TableFooter/TableFooter.tsx | 26 --
src/components/TableFooter/index.ts | 1 -
src/components/TableHeader/TableHeader.tsx | 26 --
src/components/TableHeader/index.ts | 1 -
.../TableHeaderCell.module.css | 35 ---
.../TableHeaderCell/TableHeaderCell.tsx | 118 --------
src/components/TableHeaderCell/index.ts | 2 -
src/components/TableRow/TableRow.module.css | 21 --
src/components/TableRow/TableRow.tsx | 38 ---
src/components/TableRow/index.ts | 1 -
src/index.ts | 7 -
24 files changed, 373 insertions(+), 448 deletions(-)
delete mode 100644 src/components/TableBody/TableBody.tsx
delete mode 100644 src/components/TableBody/index.ts
delete mode 100644 src/components/TableCaption/TableCaption.tsx
delete mode 100644 src/components/TableCaption/index.ts
delete mode 100644 src/components/TableCell/TableCell.module.css
delete mode 100644 src/components/TableCell/TableCell.tsx
delete mode 100644 src/components/TableCell/index.ts
delete mode 100644 src/components/TableFooter/TableFooter.tsx
delete mode 100644 src/components/TableFooter/index.ts
delete mode 100644 src/components/TableHeader/TableHeader.tsx
delete mode 100644 src/components/TableHeader/index.ts
delete mode 100644 src/components/TableHeaderCell/TableHeaderCell.module.css
delete mode 100644 src/components/TableHeaderCell/TableHeaderCell.tsx
delete mode 100644 src/components/TableHeaderCell/index.ts
delete mode 100644 src/components/TableRow/TableRow.module.css
delete mode 100644 src/components/TableRow/TableRow.tsx
delete mode 100644 src/components/TableRow/index.ts
diff --git a/.storybook/components/Docs/Guildelines/CodeGuidelines.stories.mdx b/.storybook/components/Docs/Guildelines/CodeGuidelines.stories.mdx
index 10c9c8273..2f001c3ef 100644
--- a/.storybook/components/Docs/Guildelines/CodeGuidelines.stories.mdx
+++ b/.storybook/components/Docs/Guildelines/CodeGuidelines.stories.mdx
@@ -299,7 +299,7 @@ You can continue to use the `Icon` components' `color` prop with JavaScript vari
## Tailwind utility classes
-EDS uses [tailwind utility classes](https://tailwindcss.com/docs/padding) (e.g. `mb-0` and `p-0`) inline in `*.stories.tsx` files to quickly add small styling tweaks, like spacing (e.g. ``). This reduces the need for CSS module files made specifically for stories. Use the `!` modifier to override default component styles (e.g. ``).
+EDS uses [tailwind utility classes](https://tailwindcss.com/docs/padding) (e.g. `mb-0` and `p-0`) inline in `*.stories.tsx` files to quickly add small styling tweaks, like spacing (e.g. ``). This reduces the need for CSS module files made specifically for stories. Use the `!` modifier to override default component styles (e.g. ``).
Consider installing the VSCode extension [Tailwind CSS IntelliSense](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss) for autocomplete, linting, and hover previews.
diff --git a/.storybook/pages/CoursePlannerEdit/CoursePlannerEdit.tsx b/.storybook/pages/CoursePlannerEdit/CoursePlannerEdit.tsx
index 784bfd81b..f6f1f3270 100644
--- a/.storybook/pages/CoursePlannerEdit/CoursePlannerEdit.tsx
+++ b/.storybook/pages/CoursePlannerEdit/CoursePlannerEdit.tsx
@@ -26,11 +26,6 @@ import {
PageHeader,
Panel,
Table,
- TableBody,
- TableCell,
- TableHeader,
- TableHeaderCell,
- TableRow,
Text,
} from '../../../src';
@@ -325,28 +320,28 @@ export const TableCard = ({
{title}
-
-
+
+
{tableColumns.map((item, index) => {
return (
-
{item.title}
-
+
);
})}
-
-
-
+
+
+
{tableRows.map((item) => {
return (
-
-
+
+
{item.value1}
-
-
+
+
{item.projects.map((item, index) => {
return (
@@ -361,11 +356,11 @@ export const TableCard = ({
);
})}
-
-
+
+
);
})}
-
+
diff --git a/.storybook/recipes/TabularInputs.stories.tsx b/.storybook/recipes/TabularInputs.stories.tsx
index f7942d787..e3d9e81e6 100644
--- a/.storybook/recipes/TabularInputs.stories.tsx
+++ b/.storybook/recipes/TabularInputs.stories.tsx
@@ -1,15 +1,6 @@
import type { StoryObj, Meta } from '@storybook/react';
import React from 'react';
-import {
- Table,
- TableBody,
- TableCell,
- TableRow,
- TableHeader,
- TableHeaderCell,
- InputField,
- Label,
-} from '../../src/';
+import { Table, InputField, Label } from '../../src/';
export default {
title: 'Recipes/TabularInput',
@@ -22,32 +13,32 @@ type Args = React.ComponentProps;
export const Default: StoryObj = {
render: (args) => (
-
-
- Label
- Field
-
-
-
-
-
+
+
+ Label
+ Field
+
+
+
+
+
-
-
+
+
-
-
-
+
+
+
),
};
diff --git a/src/components/Table/Table.module.css b/src/components/Table/Table.module.css
index 1f41f8984..70ab09333 100755
--- a/src/components/Table/Table.module.css
+++ b/src/components/Table/Table.module.css
@@ -9,3 +9,61 @@
border-collapse: collapse;
width: 100%;
}
+
+/**
+ * Table Cell
+ * The `:where` pseudo class function allows easy overriding via className.
+ */
+:where(.table-cell) {
+ font: var(--eds-theme-typography-body-sm);
+
+ padding: var(--eds-size-2) var(--eds-size-1);
+}
+
+/**
+ * Table header cell
+ * The `:where` pseudo class function allows easy overriding via className.
+ */
+:where(.table-header-cell) {
+ font: var(--eds-theme-typography-label-sm);
+ padding: var(--eds-size-1) var(--eds-size-1);
+ text-align: left;
+}
+
+/**
+ * Table header cell within table body
+ *
+ * Adjusts the padding to match the table__cell padding for alignment.
+ */
+.table-header-cell--body {
+ padding: var(--eds-size-2) var(--eds-size-1);
+}
+
+/**
+ * Table header cell button
+ *
+ * On table header cells that are sortable, the content is wrapped by a