-
Notifications
You must be signed in to change notification settings - Fork 4
ENG-592 Replace Send feedback button with a FAB (Floating Action Button) containing DG logo #337
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
Merged
maparent
merged 7 commits into
main
from
ENG-592-replace-send-feedback-button-with-a-fab-floating-action
Aug 16, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
096af22
Create a floating button with a submenu.
maparent 3fd66f0
coderabbit nits
maparent d205f99
more coderabbit suggestions
maparent 6f28856
respond to comments; positioning; separate menu and button theme
maparent 9fe300c
coderabbit suggestions
maparent 96be324
hide the floating menu
maparent 5e66144
coderabbit nits
maparent 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| import React from "react"; | ||
| import ReactDOM from "react-dom"; | ||
| import { OnloadArgs } from "roamjs-components/types"; | ||
| import { | ||
| Popover, | ||
| Menu, | ||
| MenuItem, | ||
| Button, | ||
| Intent, | ||
| Position, | ||
| PopoverInteractionKind, | ||
| } from "@blueprintjs/core"; | ||
| import { FeedbackWidget } from "./BirdEatsBugs"; | ||
|
|
||
| type DiscourseFloatingMenuProps = { | ||
| // CSS placement class | ||
| position: "top-left" | "top-right" | "bottom-left" | "bottom-right"; | ||
| theme: string; // e.g., "bp3-light" | "bp3-dark" | ||
| buttonTheme?: string; // e.g., "bp3-light" | "bp3-dark" | ||
| }; | ||
|
|
||
| const ANCHOR_ID = "dg-floating-menu-anchor"; | ||
|
|
||
| export const DiscourseFloatingMenu = (props: DiscourseFloatingMenuProps) => ( | ||
| <div | ||
| id="discourse-floating-menu" | ||
| className={`${props.position} ${props.theme}`} | ||
| > | ||
| <Popover | ||
maparent marked this conversation as resolved.
Show resolved
Hide resolved
maparent marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| autoFocus={false} | ||
| content={ | ||
| <Menu> | ||
| <MenuItem | ||
| text="Send feedback" | ||
| icon="send-message" | ||
| onClick={() => { | ||
| try { | ||
| (window.birdeatsbug as FeedbackWidget | undefined)?.trigger?.(); | ||
| } catch (error) { | ||
| console.error("Failed to trigger feedback widget:", error); | ||
| } | ||
| }} | ||
| /> | ||
| <MenuItem | ||
| text="Docs" | ||
| icon="document-open" | ||
| href="https://discoursegraphs.com/docs/roam" | ||
| rel="noopener noreferrer" | ||
| target="_blank" | ||
| /> | ||
| <MenuItem | ||
| text="Community" | ||
| icon="people" | ||
| href="https://join.slack.com/t/discoursegraphs/shared_invite/zt-37xklatti-cpEjgPQC0YyKYQWPNgAkEg" | ||
| rel="noopener noreferrer" | ||
| target="_blank" | ||
maparent marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /> | ||
| </Menu> | ||
| } | ||
| position={Position.TOP} | ||
| className="bp3-popover-content-sizing" | ||
| interactionKind={PopoverInteractionKind.HOVER} | ||
| boundary="viewport" | ||
| modifiers={{ | ||
| arrow: { | ||
| enabled: false, | ||
| }, | ||
| }} | ||
| > | ||
| <Button | ||
| intent={Intent.PRIMARY} | ||
| text="Discourse Graphs" | ||
| id="dg-floating-menu-button" | ||
| aria-label="Open Discourse Graphs menu" | ||
| className={props.buttonTheme} | ||
| /> | ||
| </Popover> | ||
| </div> | ||
| ); | ||
|
|
||
| export const hideDiscourseFloatingMenu = () => { | ||
| const anchor = document.getElementById(ANCHOR_ID); | ||
| anchor?.classList.add("hidden"); | ||
| }; | ||
|
|
||
| export const showDiscourseFloatingMenu = () => { | ||
| const anchor = document.getElementById(ANCHOR_ID); | ||
| anchor?.classList.remove("hidden"); | ||
| }; | ||
|
|
||
| export const installDiscourseFloatingMenu = ( | ||
| extensionAPI: OnloadArgs["extensionAPI"], | ||
| props: DiscourseFloatingMenuProps = { | ||
| position: "bottom-right", | ||
| theme: "bp3-light", | ||
| buttonTheme: "bp3-dark", | ||
| }, | ||
maparent marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) => { | ||
| let floatingMenuAnchor = document.getElementById(ANCHOR_ID); | ||
| if (!floatingMenuAnchor) { | ||
| floatingMenuAnchor = document.createElement("div"); | ||
| floatingMenuAnchor.id = ANCHOR_ID; | ||
| document.getElementById("app")?.appendChild(floatingMenuAnchor); | ||
| } | ||
| if (extensionAPI.settings.get("hide-feedback-button") as boolean) { | ||
| floatingMenuAnchor.classList.add("hidden"); | ||
| } | ||
| ReactDOM.render( | ||
| <DiscourseFloatingMenu | ||
| position={props.position} | ||
| theme={props.theme} | ||
| buttonTheme={props.buttonTheme} | ||
| />, | ||
| floatingMenuAnchor, | ||
| ); | ||
| }; | ||
|
|
||
| export const removeDiscourseFloatingMenu = () => { | ||
| const anchor = document.getElementById(ANCHOR_ID); | ||
| if (anchor) { | ||
| try { | ||
| ReactDOM.unmountComponentAtNode(anchor); | ||
| } catch (e) { | ||
| // no-op: unmount best-effort | ||
| } | ||
| anchor.remove(); | ||
| } | ||
| }; | ||
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
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.