Repository navigation
feat: Let users dock the action menu to any edge #1092
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
Open
ivnnv
wants to merge
8
commits into
pascalorg:main
Choose a base branch
from
ivnnv:action-menu-dock-picker
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6278f4c
Let users dock the action menu to any edge from the menu itself
ivnnv 4dc30d6
Name the dock picker button for screen readers
ivnnv ed0e7cc
Merge remote-tracking branch 'upstream/main' into action-menu-dock-pi…
ivnnv 334d54d
Document the left and right placements and the user's dock picker
ivnnv 192c8a2
Move the level selector clear of a left-docked menu
ivnnv 0020290
Only step the level selector and inspector aside while the menu shows
ivnnv 61066ae
Keep the side rails on the right edge and clear of the corner chrome
ivnnv b78a726
Keep the user's dock with the editor's other preferences
ivnnv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
78 changes: 78 additions & 0 deletions
78
packages/editor/src/components/ui/action-menu/placement-control.tsx
This file contains hidden or 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,78 @@ | ||
| 'use client' | ||
|
|
||
| import { PanelBottom, PanelLeft, PanelRight, PanelTop } from 'lucide-react' | ||
| import { useState } from 'react' | ||
| import { cn } from '../../../lib/utils' | ||
| import useEditor from '../../../store/use-editor' | ||
| import { Popover, PopoverContent, PopoverTrigger } from '../primitives/popover' | ||
| import { ActionButton } from './action-button' | ||
| import { type ActionMenuPlacement, useActionMenuPlacement, useActionMenuPopupSide } from './placement' | ||
|
|
||
| const PLACEMENT_OPTIONS: { value: ActionMenuPlacement; label: string; icon: typeof PanelBottom }[] = | ||
| [ | ||
| { value: 'bottom', label: 'Bottom', icon: PanelBottom }, | ||
| { value: 'top', label: 'Top', icon: PanelTop }, | ||
| { value: 'left', label: 'Left', icon: PanelLeft }, | ||
| { value: 'right', label: 'Right', icon: PanelRight }, | ||
| ] | ||
|
|
||
| /** Lets the user dock the action menu to another edge of the viewer. */ | ||
| export function PlacementControl() { | ||
| const placement = useActionMenuPlacement() | ||
| const popupSide = useActionMenuPopupSide() | ||
| const setPlacement = useEditor((state) => state.setActionMenuPlacement) | ||
| const [isOpen, setIsOpen] = useState(false) | ||
| const CurrentIcon = | ||
| PLACEMENT_OPTIONS.find((option) => option.value === placement)?.icon ?? PanelBottom | ||
|
|
||
| return ( | ||
| <Popover onOpenChange={setIsOpen} open={isOpen}> | ||
| <PopoverTrigger asChild> | ||
| <ActionButton | ||
| aria-label="Menu position" | ||
| className="group text-muted-foreground hover:bg-white/5" | ||
| isActive={isOpen} | ||
| label="Menu position" | ||
| size="icon" | ||
| variant="ghost" | ||
| > | ||
| <CurrentIcon aria-hidden="true" className="h-5 w-5" /> | ||
| </ActionButton> | ||
| </PopoverTrigger> | ||
| <PopoverContent | ||
| align="center" | ||
| className="w-max min-w-36 rounded-lg border-border/45 bg-background/96 p-2 shadow-elevation-3 backdrop-blur-xl" | ||
| side={popupSide} | ||
| sideOffset={14} | ||
| > | ||
| <div aria-label="Menu position" className="space-y-1" role="menu"> | ||
| {PLACEMENT_OPTIONS.map((option) => { | ||
| const OptionIcon = option.icon | ||
| const isSelected = option.value === placement | ||
| return ( | ||
| <button | ||
| aria-checked={isSelected} | ||
| className={cn( | ||
| 'flex h-9 w-full items-center gap-2 rounded-md px-2.5 text-left text-sm transition-colors', | ||
| isSelected | ||
| ? 'bg-white/10 text-foreground' | ||
| : 'text-muted-foreground hover:bg-white/8 hover:text-foreground', | ||
| )} | ||
| key={option.value} | ||
| onClick={() => { | ||
| setPlacement(option.value) | ||
| setIsOpen(false) | ||
| }} | ||
| role="menuitemradio" | ||
| type="button" | ||
| > | ||
| <OptionIcon aria-hidden="true" className="h-4 w-4" /> | ||
| <span>{option.label}</span> | ||
| </button> | ||
| ) | ||
| })} | ||
| </div> | ||
| </PopoverContent> | ||
| </Popover> | ||
| ) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.