Skip to content

Commit 2332684

Browse files
authored
ENG-745 Update Help FAB + Menu (#349)
* change floating menu button look * Add direct access to settings
1 parent 9c37c55 commit 2332684

File tree

3 files changed

+57
-42
lines changed

3 files changed

+57
-42
lines changed

apps/roam/src/components/DiscourseFloatingMenu.tsx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ import {
1111
PopoverInteractionKind,
1212
} from "@blueprintjs/core";
1313
import { FeedbackWidget } from "./BirdEatsBugs";
14+
import { render as renderSettings } from "~/components/settings/Settings";
1415

1516
type DiscourseFloatingMenuProps = {
1617
// CSS placement class
1718
position: "top-left" | "top-right" | "bottom-left" | "bottom-right";
1819
theme: string; // e.g., "bp3-light" | "bp3-dark"
1920
buttonTheme?: string; // e.g., "bp3-light" | "bp3-dark"
21+
onloadArgs?: OnloadArgs;
2022
};
2123

2224
const ANCHOR_ID = "dg-floating-menu-anchor";
@@ -43,33 +45,47 @@ export const DiscourseFloatingMenu = (props: DiscourseFloatingMenuProps) => (
4345
/>
4446
<MenuItem
4547
text="Docs"
46-
icon="document-open"
48+
icon="book"
4749
href="https://discoursegraphs.com/docs/roam"
4850
rel="noopener noreferrer"
4951
target="_blank"
5052
/>
5153
<MenuItem
5254
text="Community"
53-
icon="people"
55+
icon="social-media"
5456
href="https://join.slack.com/t/discoursegraphs/shared_invite/zt-37xklatti-cpEjgPQC0YyKYQWPNgAkEg"
5557
rel="noopener noreferrer"
5658
target="_blank"
5759
/>
60+
<MenuItem
61+
text="Settings"
62+
icon="cog"
63+
onClick={() => renderSettings({ onloadArgs: props.onloadArgs! })}
64+
rel="noopener noreferrer"
65+
target="_blank"
66+
/>
5867
</Menu>
5968
}
69+
onClosed={() => {
70+
document.getElementById("dg-floating-menu-button")?.blur();
71+
}}
6072
position={Position.TOP}
6173
className="bp3-popover-content-sizing"
62-
interactionKind={PopoverInteractionKind.HOVER}
74+
interactionKind={PopoverInteractionKind.CLICK}
75+
shouldReturnFocusOnClose={true}
6376
boundary="viewport"
6477
modifiers={{
6578
arrow: {
6679
enabled: false,
6780
},
81+
offset: {
82+
enabled: true,
83+
offset: "-70, 15",
84+
},
6885
}}
6986
>
7087
<Button
7188
intent={Intent.PRIMARY}
72-
text="Discourse Graphs"
7389
id="dg-floating-menu-button"
7490
aria-label="Open Discourse Graphs menu"
7591
className={props.buttonTheme}
@@ -89,11 +105,11 @@ export const showDiscourseFloatingMenu = () => {
89105
};
90106

91107
export const installDiscourseFloatingMenu = (
92-
extensionAPI: OnloadArgs["extensionAPI"],
108+
onLoadArgs: OnloadArgs,
93109
props: DiscourseFloatingMenuProps = {
94110
position: "bottom-right",
95111
theme: "bp3-light",
96-
buttonTheme: "bp3-dark",
112+
buttonTheme: "bp3-light",
97113
},
98114
) => {
99115
let floatingMenuAnchor = document.getElementById(ANCHOR_ID);
@@ -102,14 +118,15 @@ export const installDiscourseFloatingMenu = (
102118
floatingMenuAnchor.id = ANCHOR_ID;
103119
document.getElementById("app")?.appendChild(floatingMenuAnchor);
104120
}
105-
if (extensionAPI.settings.get("hide-feedback-button") as boolean) {
121+
if (onLoadArgs.extensionAPI.settings.get("hide-feedback-button") as boolean) {
106122
floatingMenuAnchor.classList.add("hidden");
107123
}
108124
ReactDOM.render(
109125
<DiscourseFloatingMenu
110126
position={props.position}
111127
theme={props.theme}
112128
buttonTheme={props.buttonTheme}
129+
onloadArgs={onLoadArgs}
113130
/>,
114131
floatingMenuAnchor,
115132
);

apps/roam/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export default runExtension(async (onloadArgs) => {
142142
// TODO: REMOVE AFTER TESTING
143143
// await createOrUpdateDiscourseEmbedding(onloadArgs.extensionAPI);
144144

145-
installDiscourseFloatingMenu(onloadArgs.extensionAPI);
145+
installDiscourseFloatingMenu(onloadArgs);
146146

147147
return {
148148
elements: [

apps/roam/src/styles/discourseFloatingMenuStyles.css

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
--gray-650: #2c3443;
1414
--gray-800: #1a202c;
1515
--base-size-step: 4px;
16-
--distance-to-window-edge: calc(6 * var(--base-size-step));
16+
--distance-to-window-edge: calc(8 * var(--base-size-step));
1717
--distance-to-window-edge-horizontal: var(--distance-to-window-edge);
1818
--distance-to-window-edge-vertical: var(--distance-to-window-edge);
1919
--border-radius: var(--base-size-step);
2020
--screen-box-shadow: 0px var(--base-size-step) calc(8 * var(--base-size-step))
2121
rgba(0, 0, 0, 0.5);
22-
--button-primary-bg-color: var(--green-500);
23-
--button-primary-hover-color: #14ce8b;
22+
--button-primary-bg-color: #f7f7f7;
23+
--button-primary-hover-color: #d5dbdf;
2424
--button-primary-text-color: white;
2525
--button-secondary-bg-color: #00ba771a;
2626
--button-secondary-hover-color: #00ba7738;
@@ -51,7 +51,7 @@
5151
--form-input-color: black;
5252
--form-input-placeholder-color: var(--gray-400);
5353
--form-input-bg-color: transparent;
54-
--form-input-focus-border-color: var(--gray-300);
54+
--form-input-focus-border-color: #5c7080;
5555
}
5656

5757
#discourse-floating-menu {
@@ -135,24 +135,6 @@
135135
}
136136
}
137137

138-
#discourse-floating-menu button {
139-
font-family: inherit;
140-
font-size: 100%;
141-
font-weight: inherit;
142-
line-height: inherit;
143-
border: none;
144-
width: fit-content;
145-
margin: 0;
146-
padding: calc(2 * var(--base-size-step)) calc(3 * var(--base-size-step));
147-
border-radius: var(--border-radius);
148-
display: flex;
149-
align-items: center;
150-
justify-content: center;
151-
white-space: nowrap;
152-
cursor: pointer;
153-
-webkit-tap-highlight-color: transparent;
154-
}
155-
156138
@media (pointer: coarse) {
157139
#discourse-floating-menu .bp3-button {
158140
padding: calc(3 * var(--base-size-step)) calc(4 * var(--base-size-step));
@@ -217,11 +199,6 @@
217199

218200
/* Adapted from our custom css code in components/BirdEatsBugs.tsx */
219201

220-
#discourse-floating-menu {
221-
--distance-to-window-edge-vertical: 50px;
222-
--distance-to-window-edge-horizontal: 20px;
223-
}
224-
225202
#discourse-floating-menu .form-error {
226203
font-size: 1.2rem;
227204
}
@@ -238,21 +215,42 @@
238215
--text-color: var(--gray-200);
239216
}
240217

218+
#discourse-floating-menu.bp3-light,
219+
#discourse-floating-menu button.bp3-light {
220+
--button-primary-bg-color: #f8f9fa;
221+
--text-color: var(--gray-200);
222+
}
223+
241224
#discourse-floating-menu button {
242225
font-weight: 600;
243226
font-size: 15px;
244227
}
245228

246-
#discourse-floating-menu button::before {
247-
content: "";
248-
display: inline-block;
249-
width: 20px;
250-
height: 20px;
251-
background-image: url("data:image/svg+xml,%3Csvg width='256' height='264' viewBox='0 0 256 264' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M156.705 252.012C140.72 267.995 114.803 267.995 98.8183 252.012L11.9887 165.182C-3.99622 149.197 -3.99622 123.28 11.9886 107.296L55.4035 63.8807C63.3959 55.8881 76.3541 55.8881 84.3467 63.8807C92.3391 71.8731 92.3391 84.8313 84.3467 92.8239L69.8751 107.296C53.8901 123.28 53.8901 149.197 69.8751 165.182L113.29 208.596C121.282 216.589 134.241 216.589 142.233 208.596C150.225 200.604 150.225 187.646 142.233 179.653L127.761 165.182C111.777 149.197 111.777 123.28 127.761 107.296C143.746 91.3105 143.746 65.3939 127.761 49.4091L113.29 34.9375C105.297 26.9452 105.297 13.9868 113.29 5.99432C121.282 -1.99811 134.241 -1.99811 142.233 5.99434L243.533 107.296C259.519 123.28 259.519 149.197 243.533 165.182L156.705 252.012ZM200.119 121.767C192.127 113.775 179.168 113.775 171.176 121.767C163.184 129.76 163.184 142.718 171.176 150.71C179.168 158.703 192.127 158.703 200.119 150.71C208.112 142.718 208.112 129.76 200.119 121.767Z' fill='%23FFFFFF'/%3E%3C/svg%3E");
252-
background-size: contain;
229+
#dg-floating-menu-button {
230+
align-items: center;
231+
background-color: #f8f9fa;
232+
background-image: url("data:image/svg+xml,%3Csvg width='256' height='264' viewBox='0 0 256 264' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M156.705 252.012C140.72 267.995 114.803 267.995 98.8183 252.012L11.9887 165.182C-3.99622 149.197 -3.99622 123.28 11.9886 107.296L55.4035 63.8807C63.3959 55.8881 76.3541 55.8881 84.3467 63.8807C92.3391 71.8731 92.3391 84.8313 84.3467 92.8239L69.8751 107.296C53.8901 123.28 53.8901 149.197 69.8751 165.182L113.29 208.596C121.282 216.589 134.241 216.589 142.233 208.596C150.225 200.604 150.225 187.646 142.233 179.653L127.761 165.182C111.777 149.197 111.777 123.28 127.761 107.296C143.746 91.3105 143.746 65.3939 127.761 49.4091L113.29 34.9375C105.297 26.9452 105.297 13.9868 113.29 5.99432C121.282 -1.99811 134.241 -1.99811 142.233 5.99434L243.533 107.296C259.519 123.28 259.519 149.197 243.533 165.182L156.705 252.012ZM200.119 121.767C192.127 113.775 179.168 113.775 171.176 121.767C163.184 129.76 163.184 142.718 171.176 150.71C179.168 158.703 192.127 158.703 200.119 150.71C208.112 142.718 208.112 129.76 200.119 121.767Z' fill='%235C7080'/%3E%3C/svg%3E");
253233
background-repeat: no-repeat;
234+
background-size: 18px 18px;
235+
background-position: center;
236+
border-color: "#ccc";
237+
border-radius: 100%;
238+
border-width: 1;
239+
cursor: pointer;
240+
display: inline-block;
241+
font-family: inherit;
242+
font-size: 100%;
243+
font-weight: inherit;
244+
height: 35px;
245+
justify-content: center;
246+
line-height: inherit;
254247
margin-right: 8px;
248+
margin: 0;
249+
padding: 4px;
255250
vertical-align: middle;
251+
white-space: nowrap;
252+
width: 35px;
253+
-webkit-tap-highlight-color: transparent;
256254
}
257255

258256
#discourse-floating-menu .caret {

0 commit comments

Comments
 (0)