Skip to content

Commit 6bc12bc

Browse files
committed
Add support for opting out action buttons from the drop down on mobile
+ by default making the page picker opt out
1 parent dbcef9e commit 6bc12bc

File tree

6 files changed

+33
-16
lines changed

6 files changed

+33
-16
lines changed

client/components/top_bar.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type ActionButton = {
99
callback: () => void;
1010
href?: string;
1111
mobile?: boolean;
12+
dropdown?: boolean;
1213
};
1314

1415
function pageNameClass(
@@ -221,10 +222,23 @@ export function TopBar({
221222
percentage={progressPercentage}
222223
type={progressType}
223224
/>
224-
<ActionButtons
225-
buttons={actionButtons}
226-
mobileMenuStyle={mobileMenuStyle}
227-
/>
225+
{mobileMenuStyle
226+
? (
227+
<>
228+
<ActionButtons
229+
buttons={actionButtons.filter((b) =>
230+
b.dropdown === false
231+
)}
232+
/>
233+
<ActionButtons
234+
buttons={actionButtons.filter((b) =>
235+
b.dropdown !== false
236+
)}
237+
mobileMenuStyle={mobileMenuStyle}
238+
/>
239+
</>
240+
)
241+
: <ActionButtons buttons={actionButtons} />}
228242
</div>
229243
</div>
230244
</div>

client/editor_ui.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ export class MainUI {
489489
return {
490490
icon: mdiIcon ? mdiIcon : featherIcon,
491491
description: button.description || "",
492+
dropdown: button.dropdown,
492493
callback:
493494
button.run ||
494495
(() => {
@@ -523,10 +524,12 @@ export class MainUI {
523524
cssClass={(client.currentPageMeta()?.pageDecoration?.cssClasses ?? [])
524525
.join(" ")
525526
.replaceAll(/[^a-zA-Z0-9-_ ]/g, "")}
526-
mobileMenuStyle={client.config.get<string>(
527-
"mobileMenuStyle",
528-
"hamburger",
529-
)}
527+
mobileMenuStyle={viewState.isMobile
528+
? client.config.get<string>(
529+
"mobileMenuStyle",
530+
"hamburger",
531+
)
532+
: undefined}
530533
readOnly={
531534
viewState.uiOptions.forcedROMode || client.bootConfig.readOnly
532535
}
@@ -616,6 +619,7 @@ type ActionButton = {
616619
icon: string;
617620
description?: string;
618621
mobile?: boolean;
622+
dropdown?: boolean;
619623
priority?: number;
620624
run: () => void;
621625
};

client/styles/top.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,7 @@
132132
position: relative;
133133
}
134134

135-
#sb-top .sb-sync-progress:has(~ .hamburger) {
136-
margin-right: 1.8em;
137-
}
138-
139135
#sb-top .sb-actions.hamburger {
140-
position: absolute;
141-
142-
top: 3px;
143-
right: 20px;
144136
border-radius: 5px;
145137
border: 1px solid #444;
146138
width: 2.8rem;

libraries/Library/Std/APIs/Action Button.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Keys to define:
1414
* `description` (optional): description of button (appears on hover)
1515
* `priority` (optional): determines priority of button (the higher, the earlier in the list)
1616
* `mobile`: when set to `true` this button will only appear on mobile devices
17+
* `dropdown` (optional): when set to `false`, the button stays visible outside the dropdown menu on mobile (default: `true`)
1718

1819
# Example
1920
```lua

libraries/Library/Std/Config.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ config.define("actionButtons", {
363363
type = "boolean",
364364
description = "Optional boolean indicating if the action button is applicable for mobile"
365365
},
366+
dropdown = {
367+
type = "boolean",
368+
description = "Optional: set to false to keep this button outside the dropdown menu on mobile (default: true)"
369+
},
366370
run = schema.func(),
367371
},
368372
required = {"icon", "run"},
@@ -397,6 +401,7 @@ config.set {
397401
icon = "book",
398402
description = "Open page",
399403
priority = 2,
404+
dropdown = false,
400405
run = function()
401406
editor.invokeCommand "Navigate: Page Picker"
402407
end

website/CONFIG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ config.set {
4242
{
4343
icon = "book",
4444
description = "Open page",
45+
dropdown = false,
4546
run = function()
4647
editor.invokeCommand("Navigate: Page Picker")
4748
end

0 commit comments

Comments
 (0)