-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ContextMenu): support switch and selection mode in context menu …
…section (#1051)
- Loading branch information
Showing
12 changed files
with
194 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export type ContextMenuSelectionMode = | ||
| "single" | ||
| "multiple" | ||
| "navigation" | ||
| "switch"; | ||
|
||
export const getAriaSelectionMode = ( | ||
selectionMode?: ContextMenuSelectionMode, | ||
) => { | ||
return selectionMode === "navigation" | ||
? "none" | ||
: selectionMode === "switch" | ||
? "multiple" | ||
: selectionMode; | ||
}; | ||
|
||
export const getMenuItemSelectionVariant = ( | ||
selectionMode?: ContextMenuSelectionMode, | ||
) => { | ||
return selectionMode === "single" || selectionMode === "multiple" | ||
? "control" | ||
: selectionMode; | ||
}; | ||
|
||
export const getCloseOverlayType = ( | ||
selectionMode?: ContextMenuSelectionMode, | ||
) => { | ||
return selectionMode === "single" || selectionMode === "navigation" | ||
? "ContextMenu" | ||
: undefined; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
packages/docs/src/content/03-components/actions/context-menu/examples/section.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import ContextMenu, { | ||
ContextMenuSection, | ||
ContextMenuTrigger, | ||
} from "@mittwald/flow-react-components/ContextMenu"; | ||
import Button from "@mittwald/flow-react-components/Button"; | ||
import MenuItem from "@mittwald/flow-react-components/MenuItem"; | ||
import Heading from "@mittwald/flow-react-components/Heading"; | ||
import Separator from "@mittwald/flow-react-components/Separator"; | ||
import Section from "@mittwald/flow-react-components/Section"; | ||
|
||
<ContextMenuTrigger> | ||
<Button>Trigger</Button> | ||
<ContextMenu> | ||
<Section> | ||
<ContextMenuSection> | ||
<Heading>Section 1</Heading> | ||
<MenuItem id="1">Item 1</MenuItem> | ||
<MenuItem id="2">Item 2</MenuItem> | ||
<MenuItem id="3">Item 3</MenuItem> | ||
</Section> | ||
</ContextMenuSection> | ||
<Separator /> | ||
<Section> | ||
<ContextMenuSection> | ||
<Heading>Section 2</Heading> | ||
<MenuItem id="4">Item 4</MenuItem> | ||
<MenuItem id="5">Item 5</MenuItem> | ||
</Section> | ||
</ContextMenuSection> | ||
</ContextMenu> | ||
</ContextMenuTrigger>; |
Oops, something went wrong.