Skip to content

Commit

Permalink
feat: advanced grouping examples (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrojcm authored Mar 18, 2024
1 parent 0d92431 commit 2ab7649
Show file tree
Hide file tree
Showing 18 changed files with 4,433 additions and 0 deletions.
52 changes: 52 additions & 0 deletions apps/mantine-react-table-docs/example-groups/ExpandingExamples.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { useState } from 'react';
import { useRouter } from 'next/router';
import { Box, Tabs } from '@mantine/core';
import ExampleGrouping from '../examples/enable-column-grouping';
import MinimalExample from '../examples/minimal';
import AdvancedExample from '../examples/advanced';
import AggregationAndGroupingExample from '../examples/aggregation-and-grouping';
import CustomHeadlessExample from '../examples/custom-headless';

const ExpandingExamples = ({ isPage = false }) => {
const { pathname, push } = useRouter();
const [activeTab, setActiveTab] = useState('column-grouping');

return (
<Box w={'100%'} mt={1}>
<Tabs
value={isPage ? pathname.split('/').pop() : activeTab}
onChange={(newPath) =>
isPage && newPath !== 'more'
? push(newPath as string)
: setActiveTab(newPath as string)
}
keepMounted={false}
>
<Tabs.List grow={!isPage}>
<Tabs.Tab value="column-grouping">Column Grouping</Tabs.Tab>
<Tabs.Tab value="customized-grouping">Customized Grouping</Tabs.Tab>
<Tabs.Tab value="aggregation-and-grouping">Aggregation</Tabs.Tab>
<Tabs.Tab value="detail-panel">Detail Panel</Tabs.Tab>
<Tabs.Tab value="chart-detail-panel">Chart Detail Panel</Tabs.Tab>
</Tabs.List>
<Tabs.Panel value="column-grouping">
<ExampleGrouping showTopRow={isPage} />
</Tabs.Panel>
<Tabs.Panel value="customized-grouping">
<MinimalExample showTopRow={isPage} />
</Tabs.Panel>
<Tabs.Panel value="detail-panel">
<AdvancedExample showTopRow={isPage} />
</Tabs.Panel>
<Tabs.Panel value="detail-panel">
<AggregationAndGroupingExample showTopRow={isPage} />
</Tabs.Panel>
<Tabs.Panel value="chart-detail-panel">
<CustomHeadlessExample showTopRow={isPage} />
</Tabs.Panel>
</Tabs>
</Box>
);
};

export default ExpandingExamples;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { SourceCodeSnippet } from '../../components/mdx/SourceCodeSnippet';
import ExampleGrouping from './sandbox/src/TS';
const TS = require('!!raw-loader!./sandbox/src/TS.tsx').default;

const ExampleTable = ({ showTopRow = true }) => {
return (
<SourceCodeSnippet
Component={ExampleGrouping}
typeScriptCode={TS}
tableId="enable-column-grouping"
showTopRow={showTopRow}
/>
);
};

export default ExampleTable;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.DS_Store
dist
dist-ssr
*.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Example

To run this example:

- `npm install` or `yarn`
- `npm run start` or `yarn start`
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Mantine React Table Example</title>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading

0 comments on commit 2ab7649

Please sign in to comment.