-
Notifications
You must be signed in to change notification settings - Fork 56
feat: new baseui popover + site controls #272
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
iamEvanYT
wants to merge
15
commits into
main
Choose a base branch
from
evan/sidebar-info-popover-2
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
15 commits
Select commit
Hold shift + click to select a range
d260676
feat: change icon
iamEvanYT 3a86a1d
chore: add @base-ui/react
iamEvanYT 4952f9c
feat: new BaseUI Popover Component
iamEvanYT 1c7516c
feat: portal baseui popover
iamEvanYT 5e2e96b
fix: arrow style
iamEvanYT 4df2f18
refactor: migrate bottom extras menu
iamEvanYT f7644b5
refactor: migrate navigation controls
iamEvanYT 1abf817
refactor: migrate extensions list
iamEvanYT e3dbee6
chore: remove unused popover component
iamEvanYT a5326d3
chore: rename baseui popover to just popover
iamEvanYT dc3cf48
fix: colors
iamEvanYT ba74bea
feat: site controls component instaed of browser actions (extensions)
iamEvanYT 4de07d0
improve
iamEvanYT bf19f47
chore: revert to old browser action list
iamEvanYT d401b91
chore: revert 2
iamEvanYT 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
99 changes: 59 additions & 40 deletions
99
...derer/src/components/browser-ui/browser-sidebar/_components/bottom/bottom-extras-menu.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 |
|---|---|---|
| @@ -1,57 +1,76 @@ | ||
| import { PortalPopover } from "@/components/portal/popover"; | ||
| import { BubbleEvent } from "@/components/logic/bubble-event"; | ||
| import { Popover, PopoverContent, PopoverTrigger } from "@/components/portal/popover"; | ||
| import { useSpaces } from "@/components/providers/spaces-provider"; | ||
| import { Button } from "@/components/ui/button"; | ||
| import { PopoverListboxItem, PopoverListboxList, usePopoverListbox } from "@/components/ui/popover-listbox"; | ||
| import { PopoverTrigger } from "@/components/ui/popover"; | ||
| import { Command, CommandItem, CommandList } from "@/components/ui/command"; | ||
| import { cn } from "@/lib/utils"; | ||
| import { ArchiveIcon, HistoryIcon, SettingsIcon } from "lucide-react"; | ||
| import { useCallback, useState } from "react"; | ||
| import { ArchiveIcon, HistoryIcon, LucideIcon, SettingsIcon } from "lucide-react"; | ||
| import { useCallback, useRef, useState } from "react"; | ||
|
|
||
| const EXTRA_ITEM_COUNT = 2; | ||
| function BottomExtrasMenuItem({ | ||
| id, | ||
| Icon, | ||
| label, | ||
| url, | ||
| onItemSelected | ||
| }: { | ||
| id: string; | ||
| Icon: LucideIcon; | ||
| label: string; | ||
| url: string; | ||
| onItemSelected: (url: string) => void; | ||
| }) { | ||
| return ( | ||
| <CommandItem value={id} onSelect={() => onItemSelected(url)} className="text-black dark:text-white"> | ||
| <Icon className="size-4 text-black dark:text-white" /> | ||
| {label} | ||
| </CommandItem> | ||
| ); | ||
| } | ||
|
|
||
| export function BottomExtrasMenu() { | ||
| const [open, setOpen] = useState(false); | ||
| const commandRef = useRef<HTMLDivElement>(null); | ||
|
|
||
| const { isCurrentSpaceLight } = useSpaces(); | ||
| const spaceInjectedClasses = cn(isCurrentSpaceLight ? "" : "dark"); | ||
|
|
||
| const onActivate = useCallback((index: number) => { | ||
| if (index === 0) { | ||
| flow.tabs.newTab("flow://history", true); | ||
| } else if (index === 1) { | ||
| const onItemSelected = useCallback((url: string) => { | ||
| if (url === "internal://settings") { | ||
| flow.windows.openSettingsWindow(); | ||
| } else { | ||
| flow.tabs.newTab(url, true); | ||
| } | ||
| setOpen(false); | ||
| }, []); | ||
|
|
||
| const listbox = usePopoverListbox({ | ||
| open, | ||
| itemCount: EXTRA_ITEM_COUNT, | ||
| ariaLabel: "Sidebar extras", | ||
| getOptionId: (i) => `bottom-extra-${i}`, | ||
| onActivate, | ||
| initialHighlightedIndex: EXTRA_ITEM_COUNT - 1 | ||
| }); | ||
|
|
||
| const { isCurrentSpaceLight } = useSpaces(); | ||
| const spaceInjectedClasses = cn(isCurrentSpaceLight ? "" : "dark"); | ||
| return ( | ||
| <PortalPopover.Root open={open} onOpenChange={setOpen}> | ||
| <PopoverTrigger asChild> | ||
| <Button size="icon" className="size-8 bg-transparent hover:bg-black/10 dark:hover:bg-white/10"> | ||
| <Popover open={open} onOpenChange={setOpen}> | ||
| <Button size="icon" className="size-8 bg-transparent hover:bg-black/10 dark:hover:bg-white/10" asChild> | ||
| <PopoverTrigger nativeButton={true}> | ||
| <ArchiveIcon strokeWidth={2} className="w-4 h-4 text-black/80 dark:text-white/80" /> | ||
| </Button> | ||
| </PopoverTrigger> | ||
| <PortalPopover.Content className={cn("w-56 p-2 select-none", spaceInjectedClasses)} {...listbox.contentProps}> | ||
| <PopoverListboxList listbox={listbox}> | ||
| <PopoverListboxItem index={0}> | ||
| <HistoryIcon className="w-4 h-4 shrink-0" /> | ||
| <span>History</span> | ||
| </PopoverListboxItem> | ||
| <PopoverListboxItem index={1}> | ||
| <SettingsIcon className="w-4 h-4 shrink-0" /> | ||
| <span>Settings</span> | ||
| </PopoverListboxItem> | ||
| </PopoverListboxList> | ||
| </PortalPopover.Content> | ||
| </PortalPopover.Root> | ||
| </PopoverTrigger> | ||
| </Button> | ||
| <PopoverContent className={cn("w-56 p-2 select-none")} positionerClassName={spaceInjectedClasses}> | ||
| <Command ref={commandRef} loop> | ||
| <BubbleEvent targetRef={commandRef} eventType="keydown" /> | ||
| <CommandList> | ||
| <BottomExtrasMenuItem | ||
| id="history" | ||
| Icon={HistoryIcon} | ||
| label="History" | ||
| url="flow://history" | ||
| onItemSelected={onItemSelected} | ||
| /> | ||
| <BottomExtrasMenuItem | ||
| id="settings" | ||
| Icon={SettingsIcon} | ||
| label="Settings" | ||
| url="internal://settings" | ||
| onItemSelected={onItemSelected} | ||
| /> | ||
| </CommandList> | ||
| </Command> | ||
| </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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep this list A–Z sorted.
@base-ui/reactwas appended after@chenglou/pretext, so the renderer dependency section no longer matches the ordering rule documented at the top of this file.🤖 Prompt for AI Agents