From 35ce124213da205567ab24de9f8c86c64d671b78 Mon Sep 17 00:00:00 2001
From: Matt Gallo <mdgallo@us.ibm.com>
Date: Fri, 15 Nov 2024 12:09:10 -0500
Subject: [PATCH] feat: add example dir to global filter

---
 react/filterPanel/tsconfig.app.json           |  2 +-
 react/globalFilter/src/Example/Example.tsx    | 11 +++++++
 .../src/{ => Example}/GlobalFilter.tsx        | 23 +-------------
 .../src/{ => Example}/customTypings.d.ts      |  0
 .../src/{App.scss => Example/example.scss}    | 17 +++++++++++
 react/globalFilter/src/Example/index.ts       |  1 +
 .../src/{ => Example}/makeData.ts             |  0
 react/globalFilter/src/ExampleLink.tsx        |  9 ------
 react/globalFilter/src/index.scss             | 30 -------------------
 react/globalFilter/src/index.ts               |  3 --
 react/globalFilter/src/main.tsx               | 11 ++-----
 react/globalFilter/tsconfig.app.json          |  2 +-
 12 files changed, 34 insertions(+), 75 deletions(-)
 create mode 100644 react/globalFilter/src/Example/Example.tsx
 rename react/globalFilter/src/{ => Example}/GlobalFilter.tsx (88%)
 rename react/globalFilter/src/{ => Example}/customTypings.d.ts (100%)
 rename react/globalFilter/src/{App.scss => Example/example.scss} (63%)
 create mode 100644 react/globalFilter/src/Example/index.ts
 rename react/globalFilter/src/{ => Example}/makeData.ts (100%)
 delete mode 100644 react/globalFilter/src/ExampleLink.tsx
 delete mode 100644 react/globalFilter/src/index.ts

diff --git a/react/filterPanel/tsconfig.app.json b/react/filterPanel/tsconfig.app.json
index a68cf5e..a6e3949 100644
--- a/react/filterPanel/tsconfig.app.json
+++ b/react/filterPanel/tsconfig.app.json
@@ -21,7 +21,7 @@
     "noUnusedParameters": true,
     "noFallthroughCasesInSwitch": true,
 
-    "types": [ "./src/customTypings.d.ts" ],
+    "types": ["./src/Example/customTypings.d.ts"],
     "resolveJsonModule": true
   },
   "include": ["./src"]
diff --git a/react/globalFilter/src/Example/Example.tsx b/react/globalFilter/src/Example/Example.tsx
new file mode 100644
index 0000000..c0ad655
--- /dev/null
+++ b/react/globalFilter/src/Example/Example.tsx
@@ -0,0 +1,11 @@
+import { Grid, Column } from '@carbon/react';
+import { GlobalFilter } from './GlobalFilter';
+import './example.scss';
+
+export const Example = () => (
+  <Grid className="page-grid">
+    <Column sm={4} md={8} lg={16}>
+      <GlobalFilter />
+    </Column>
+  </Grid>
+);
diff --git a/react/globalFilter/src/GlobalFilter.tsx b/react/globalFilter/src/Example/GlobalFilter.tsx
similarity index 88%
rename from react/globalFilter/src/GlobalFilter.tsx
rename to react/globalFilter/src/Example/GlobalFilter.tsx
index 47d90ec..38d0f31 100644
--- a/react/globalFilter/src/GlobalFilter.tsx
+++ b/react/globalFilter/src/Example/GlobalFilter.tsx
@@ -27,9 +27,8 @@ import {
 
 // A TanStack fork of Kent C. Dodds' match-sorter library that provides ranking information
 import { rankItem } from '@tanstack/match-sorter-utils';
-import { ExampleLink } from './ExampleLink';
 import { Launch } from '@carbon/react/icons';
-import * as packageJson from '../package.json';
+import * as packageJson from '../../package.json';
 
 import { makeData, Resource } from './makeData';
 
@@ -112,26 +111,6 @@ export const GlobalFilter = () => {
       <TableContainer
         title="Global filter"
         className="basic-table"
-        description={
-          <span className="flex">
-            <ExampleLink
-              url={`${import.meta.env.VITE_CODE_SANDBOX_URL_ROOT}/${
-                packageJson.name
-              }`}
-              icon={Launch}
-              label="Code sandbox"
-            />
-            <ExampleLink
-              url={`${import.meta.env.VITE_STACK_BLITZ_URL_ROOT}/${
-                packageJson.name
-              }`}
-              icon={Launch}
-              label="StackBlitz"
-            />
-            excludes <CodeSnippet type="inline">Example</CodeSnippet> column
-            from global filtering
-          </span>
-        }
         style={{
           width: table.getCenterTotalSize(),
         }}>
diff --git a/react/globalFilter/src/customTypings.d.ts b/react/globalFilter/src/Example/customTypings.d.ts
similarity index 100%
rename from react/globalFilter/src/customTypings.d.ts
rename to react/globalFilter/src/Example/customTypings.d.ts
diff --git a/react/globalFilter/src/App.scss b/react/globalFilter/src/Example/example.scss
similarity index 63%
rename from react/globalFilter/src/App.scss
rename to react/globalFilter/src/Example/example.scss
index 8b9e65e..e21ac10 100644
--- a/react/globalFilter/src/App.scss
+++ b/react/globalFilter/src/Example/example.scss
@@ -56,3 +56,20 @@
 .tanstack-example {
   padding-bottom: 2rem;
 }
+
+.cds--data-table.empty-table-wrapper td,
+.cds--data-table.empty-table-wrapper tbody th,
+.cds--data-table.empty-table-wrapper tbody tr:hover td {
+  border-block-end: 0;
+}
+
+.cds--data-table tbody.empty-table-body,
+.cds--data-table tbody.empty-table-body tr:not([data-child-row]):hover,
+.cds--data-table tbody.empty-table-body tr[data-child-row]:hover > td {
+  background-color: transparent;
+}
+
+.cds--data-table td .empty-table {
+  position: absolute;
+  max-width: 265px;
+}
diff --git a/react/globalFilter/src/Example/index.ts b/react/globalFilter/src/Example/index.ts
new file mode 100644
index 0000000..8765fbd
--- /dev/null
+++ b/react/globalFilter/src/Example/index.ts
@@ -0,0 +1 @@
+export { Example } from './Example';
diff --git a/react/globalFilter/src/makeData.ts b/react/globalFilter/src/Example/makeData.ts
similarity index 100%
rename from react/globalFilter/src/makeData.ts
rename to react/globalFilter/src/Example/makeData.ts
diff --git a/react/globalFilter/src/ExampleLink.tsx b/react/globalFilter/src/ExampleLink.tsx
deleted file mode 100644
index 7a03b61..0000000
--- a/react/globalFilter/src/ExampleLink.tsx
+++ /dev/null
@@ -1,9 +0,0 @@
-export const ExampleLink = ({ icon, label, url }) => {
-  const Icon = icon;
-  return (
-    <a className="example--link" href={url} target="_blank">
-      {icon && <Icon className="example--link__icon" />}
-      {label}
-    </a>
-  );
-};
diff --git a/react/globalFilter/src/index.scss b/react/globalFilter/src/index.scss
index db79429..e3f9104 100644
--- a/react/globalFilter/src/index.scss
+++ b/react/globalFilter/src/index.scss
@@ -3,38 +3,8 @@
 );
 @use '@carbon/styles/scss/type';
 @use '@carbon/ibm-products/css/index';
-@use './App';
 
 body {
   margin: 0;
   padding: 0;
 }
-
-.example--link {
-  @include type.type-style('label-01');
-
-  display: flex;
-  align-items: center;
-  margin-right: 0.5rem;
-}
-
-.example--link__icon {
-  margin-right: 0.25rem;
-}
-
-.cds--data-table.empty-table-wrapper td,
-.cds--data-table.empty-table-wrapper tbody th,
-.cds--data-table.empty-table-wrapper tbody tr:hover td {
-  border-block-end: 0;
-}
-
-.cds--data-table tbody.empty-table-body,
-.cds--data-table tbody.empty-table-body tr:not([data-child-row]):hover,
-.cds--data-table tbody.empty-table-body tr[data-child-row]:hover > td {
-  background-color: transparent;
-}
-
-.cds--data-table td .empty-table {
-  position: absolute;
-  max-width: 265px;
-}
diff --git a/react/globalFilter/src/index.ts b/react/globalFilter/src/index.ts
deleted file mode 100644
index 49f4700..0000000
--- a/react/globalFilter/src/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { GlobalFilter } from './GlobalFilter';
-
-export { GlobalFilter };
diff --git a/react/globalFilter/src/main.tsx b/react/globalFilter/src/main.tsx
index be19653..4337d51 100644
--- a/react/globalFilter/src/main.tsx
+++ b/react/globalFilter/src/main.tsx
@@ -2,14 +2,11 @@ import { StrictMode } from 'react';
 import { createRoot } from 'react-dom/client';
 import {
   CodeSnippet,
-  Column,
-  Grid,
   Header,
   HeaderContainer,
   HeaderName,
 } from '@carbon/react';
-
-import { GlobalFilter } from './GlobalFilter';
+import { Example } from './Example';
 
 import './index.scss';
 
@@ -32,10 +29,6 @@ const renderUIShellHeader = () => (
 createRoot(document.getElementById('root')!).render(
   <StrictMode>
     {renderUIShellHeader()}
-    <Grid className="page-grid">
-      <Column sm={4} md={8} lg={16}>
-        <GlobalFilter />
-      </Column>
-    </Grid>
+    <Example />
   </StrictMode>
 );
diff --git a/react/globalFilter/tsconfig.app.json b/react/globalFilter/tsconfig.app.json
index a68cf5e..a6e3949 100644
--- a/react/globalFilter/tsconfig.app.json
+++ b/react/globalFilter/tsconfig.app.json
@@ -21,7 +21,7 @@
     "noUnusedParameters": true,
     "noFallthroughCasesInSwitch": true,
 
-    "types": [ "./src/customTypings.d.ts" ],
+    "types": ["./src/Example/customTypings.d.ts"],
     "resolveJsonModule": true
   },
   "include": ["./src"]