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

[mantine.dev] add example code of Nested Collapse Demo #7083

Closed
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,47 @@ function Demo() {
);
}

const code = `
export function CollapsedDemo({
children,
buttonProps,
...others
}: Partial<CollapseProps> & { buttonProps?: any }) {
const [opened, setOpened] = useState(false);

return (
<Box maw={400} mx="auto" mt="md">
<Button onClick={() => setOpened((o) => !o)} mb={5} {...buttonProps} />
<Collapse in={opened} {...others}>
{children}
</Collapse>
</Box>
);
}

const lorem =
'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ea atque in est quaerat dolore odio! Quibusdam, a nihil modi, maiores consequuntur ex quod suscipit illum ducimus doloribus odit commodi tenetur.';

function Demo() {
return (
<CollapsedDemo buttonProps={{ children: 'Root collapse' }}>
<Text mt="md" size="lg" fw={700}>
This collapse contains another collapse
</Text>
<Text mt="xs">{lorem}</Text>
<CollapsedDemo buttonProps={{ variant: 'outline', children: 'Inner collapse' }}>
<Text mt="md" size="lg" fw={700}>
This collapse is inside another collapse
</Text>
<Text mt="xs">{lorem}</Text>
</CollapsedDemo>
</CollapsedDemo>
);
}
`;

export const nested: MantineDemo = {
type: 'code',
code,
component: Demo,
};
Loading