Skip to content

Commit

Permalink
Updated menu example
Browse files Browse the repository at this point in the history
  • Loading branch information
fgatti675 committed Dec 17, 2024
1 parent 7409991 commit f8ba393
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
14 changes: 7 additions & 7 deletions website/docs/components/menu.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ import MenuBasicSource from '!!raw-loader!../../samples/components/menu/menu_bas

<CodeBlock language="tsx">{MenuBasicSource}</CodeBlock>

## Menu with Custom Trigger
## Controlled Menu

Demonstrating how to use a custom element as the trigger for opening the menu.
You can control the visibility of the `Menu` component by passing the `open` and `onOpenChange` props.

import MenuCustomTriggerDemo from '../../samples/components/menu/menu_custom_trigger';
import MenuCustomTriggerSource from '!!raw-loader!../../samples/components/menu/menu_custom_trigger';
import MenuControlledDemo from '../../samples/components/menu/menu_controlled';
import MenuControlledSource from '!!raw-loader!../../samples/components/menu/menu_controlled';

<CodeSample>
<MenuCustomTriggerDemo/>
<MenuControlledDemo/>
</CodeSample>

<CodeBlock language="tsx">{MenuCustomTriggerSource}</CodeBlock>
<CodeBlock language="tsx">{MenuControlledSource}</CodeBlock>

## Dense Menu Items

Expand All @@ -50,4 +50,4 @@ import MenuDenseItemsSource from '!!raw-loader!../../samples/components/menu/men
<MenuDenseItemsDemo/>
</CodeSample>

<CodeBlock language="tsx">{MenuDenseItemsSource}</CodeBlock>
<CodeBlock language="tsx">{MenuDenseItemsSource}</CodeBlock>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { CircularProgress } from "@firecms/ui";
export default function CircularProgressSizesDemo() {
return (
<div>
<div>
<p>Smallest</p>
<CircularProgress size="smallest" />
</div>
<div>
<p>Small</p>
<CircularProgress size="small" />
Expand All @@ -18,4 +22,4 @@ export default function CircularProgressSizesDemo() {
</div>
</div>
);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import React from "react";
import { Menu, MenuItem } from "@firecms/ui";
import { Button, Menu, MenuItem } from "@firecms/ui";

export default function MenuCustomTriggerDemo() {

const [open, setOpen] = React.useState(false);

return (
<Menu trigger={<div style={{ cursor: 'pointer', padding: '10px', background: 'grey', color: 'white' }}>Click me</div>}>
<Menu
onOpenChange={setOpen}
open={open}
trigger={
<Button onClick={() => setOpen(true)}>Click me</Button>
}>
<MenuItem onClick={() => alert("Action 1")}>Action 1</MenuItem>
<MenuItem onClick={() => alert("Action 2")}>Action 2</MenuItem>
<MenuItem onClick={() => alert("Action 3")}>Action 3</MenuItem>
</Menu>
);
}
}
1 change: 1 addition & 0 deletions website/src/partials/ui/ClientUIComponentsShowcase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ export default function ClientUIComponentsShowcase({
<CircularProgress size="large"/>
<CircularProgress/>
<CircularProgress size="small"/>
<CircularProgress size="smallest"/>
</div>
</Card>

Expand Down

0 comments on commit f8ba393

Please sign in to comment.