Skip to content

Commit 6e3ad19

Browse files
authored
Merge pull request #675 from icflorescu/next
Docs website: add interactive empty state example
2 parents a31cccf + 35caa18 commit 6e3ad19

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

app/examples/empty-state/EmptyStateExamples.tsx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { Box, Image, Stack, Text } from '@mantine/core';
1+
'use client';
2+
3+
import { Box, Button, Image, Stack, Text } from '@mantine/core';
4+
import { notifications } from '@mantine/notifications';
25
import { IconMoodSad } from '@tabler/icons-react';
36
import { DataTable } from '__PACKAGE__';
47
import classes from './EmptyStateExamples.module.css';
@@ -87,3 +90,32 @@ export function EmptyStateExampleCustomContent() {
8790
);
8891
// example-end
8992
}
93+
94+
export function EmptyStateExampleCustomInteractiveContent() {
95+
// example-start custom-interactive-content
96+
return (
97+
<DataTable
98+
minHeight={280}
99+
records={[]}
100+
emptyState={
101+
<Stack align="center" gap="xs">
102+
<Text c="dimmed" size="sm">
103+
No data found...
104+
</Text>
105+
<Button
106+
style={{ pointerEvents: 'all' }} // 👈 enable button pointer events
107+
onClick={() => notifications.show({ message: 'Should add a new record' })}
108+
>
109+
Add a record
110+
</Button>
111+
</Stack>
112+
}
113+
// example-skip
114+
withTableBorder
115+
withColumnBorders
116+
columns={[{ accessor: 'name' }, { accessor: 'email' }]}
117+
// example-resume
118+
/>
119+
);
120+
// example-end
121+
}

app/examples/empty-state/page.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Code } from '@mantine/core';
22
import type { Route } from 'next';
33
import { CodeBlock } from '~/components/CodeBlock';
44
import { PageNavigation } from '~/components/PageNavigation';
5+
import { PageSubtitle } from '~/components/PageSubtitle';
56
import { PageTitle } from '~/components/PageTitle';
67
import { Txt } from '~/components/Txt';
78
import { readCodeFile } from '~/lib/code';
@@ -10,6 +11,7 @@ import {
1011
EmptyStateExample,
1112
EmptyStateExampleCustomContent,
1213
EmptyStateExampleCustomIconAndText,
14+
EmptyStateExampleCustomInteractiveContent,
1315
EmptyStateExampleCustomText,
1416
} from './EmptyStateExamples';
1517

@@ -19,9 +21,12 @@ export const metadata = getRouteMetadata(PATH);
1921

2022
export default async function EmptyStateExamplePage() {
2123
const rawCode = await allPromiseProps({
22-
tsx: readCodeFile<Record<'default' | 'custom-text' | 'custom-icon-and-text' | 'custom-content', string>>(
23-
`${PATH}/EmptyStateExamples.tsx`
24-
),
24+
tsx: readCodeFile<
25+
Record<
26+
'default' | 'custom-text' | 'custom-icon-and-text' | 'custom-content' | 'custom-interactive-content',
27+
string
28+
>
29+
>(`${PATH}/EmptyStateExamples.tsx`),
2530
css: readCodeFile<string>(`${PATH}/EmptyStateExamples.module.css`),
2631
});
2732

@@ -65,6 +70,15 @@ export default async function EmptyStateExamplePage() {
6570
</Txt>
6671
<EmptyStateExampleCustomContent />
6772
<CodeBlock code={code['custom-content']} />
73+
<PageSubtitle value="Interactive custom empty state content" />
74+
<Txt>
75+
The empty state component has the <Code>pointer-events</Code> CSS property set to <Code>none</Code>.
76+
<br />
77+
Which means that if you need to add interactive content to the custom empty state, you’ll have to enable pointer
78+
interactions using the <Code>pointer-events</Code> CSS prop:
79+
</Txt>
80+
<EmptyStateExampleCustomInteractiveContent />
81+
<CodeBlock code={code['custom-interactive-content']} />
6882
<Txt>Head over to the next example to discover more features.</Txt>
6983
<PageNavigation of={PATH} />
7084
</>

0 commit comments

Comments
 (0)