Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: advanced grouping examples #293

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading