Skip to content

Commit 97ac670

Browse files
committed
feat(lp): fa reload icon + design-mode toggle on the live preview toolbar
- Replace the sprite-backed reload button with fa-arrow-rotate-right so it matches the weight of the other FA buttons in the toolbar. - Add #designModeToggleLivePreviewButton between reload and preview-mode that dispatches VIEW_TOGGLE_DESIGN_MODE, letting the user enter/exit design mode from the live-preview panel itself without reaching to the CCB. Icon swaps fa-expand ↔ fa-compress based on the current design-mode state, title swaps between CCB_SWITCH_TO_DESIGN_MODE and CCB_SWITCH_TO_CODE_EDITOR. - Hide #livePreviewModeBtn (the preview-mode dropdown) while in design mode — its options aren't meaningful when the editor is collapsed.
1 parent 1553d34 commit 97ac670

3 files changed

Lines changed: 50 additions & 3 deletions

File tree

src/extensionsIntegrated/Phoenix-live-preview/live-preview.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,16 @@
202202
}
203203

204204
#reloadLivePreviewButton {
205+
color: #a0a0a0;
206+
margin-left: 3px;
207+
margin-top: 0;
208+
width: 30px;
209+
height: 22px;
210+
flex-shrink: 0;
211+
}
212+
213+
#designModeToggleLivePreviewButton {
214+
color: #a0a0a0;
205215
margin-left: 3px;
206216
margin-top: 0;
207217
width: 30px;

src/extensionsIntegrated/Phoenix-live-preview/main.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ define(function (require, exports, module) {
169169
$firefoxButtonBallast,
170170
$panelTitle,
171171
$modeBtn,
172-
$previewBtn;
172+
$previewBtn,
173+
$designModeBtn;
173174

174175
let customLivePreviewBannerShown = false;
175176

@@ -341,11 +342,15 @@ define(function (require, exports, module) {
341342
* Does not hide in custom server mode (handled by _isMdviewrActive being false).
342343
*/
343344
function _updateLPControlsForMdviewer() {
345+
const inDesignMode = WorkspaceManager.isInDesignMode && WorkspaceManager.isInDesignMode();
344346
if ($previewBtn) {
345347
$previewBtn.toggle(!_isMdviewrActive);
346348
}
347349
if ($modeBtn) {
348-
$modeBtn.toggle(!_isMdviewrActive);
350+
// Also hidden in design mode (see $designModeBtn wiring in
351+
// _createExtensionPanel) because the preview-mode dropdown is moot
352+
// when the editor is fully collapsed.
353+
$modeBtn.toggle(!_isMdviewrActive && !inDesignMode);
349354
}
350355
}
351356

@@ -761,6 +766,7 @@ define(function (require, exports, module) {
761766
livePreview: Strings.LIVE_DEV_STATUS_TIP_OUT_OF_SYNC,
762767
clickToReload: Strings.LIVE_DEV_CLICK_TO_RELOAD_PAGE,
763768
clickToPreview: Strings.LIVE_PREVIEW_MODE_TOGGLE_PREVIEW,
769+
switchToDesignMode: Strings.CCB_SWITCH_TO_DESIGN_MODE,
764770
livePreviewSettings: Strings.LIVE_DEV_SETTINGS,
765771
livePreviewConfigureModes: Strings.LIVE_PREVIEW_CONFIGURE_MODES,
766772
clickToPopout: Strings.LIVE_DEV_CLICK_POPOUT,
@@ -792,6 +798,7 @@ define(function (require, exports, module) {
792798
$settingsIcon = $panel.find("#livePreviewSettingsBtn");
793799
$modeBtn = $panel.find("#livePreviewModeBtn");
794800
$previewBtn = $panel.find("#previewModeLivePreviewButton");
801+
$designModeBtn = $panel.find("#designModeToggleLivePreviewButton");
795802

796803
// Markdown theme toggle — persist user choice
797804
MarkdownSync.setThemeToggleHandler((theme) => {
@@ -871,6 +878,31 @@ define(function (require, exports, module) {
871878
Metrics.countEvent(Metrics.EVENT_TYPE.LIVE_PREVIEW, "reloadBtn", "click");
872879
});
873880

881+
// Design-mode toggle: mirrors the CCB's pen-nib button so the user can
882+
// enter/exit design mode without moving focus to the sidebar strip.
883+
// Icon swaps between fa-expand (enter) and fa-compress (exit); while
884+
// design mode is on, hide #livePreviewModeBtn (the preview-mode dropdown)
885+
// since its options are moot when the editor is fully collapsed.
886+
function _updateDesignModeButton() {
887+
const on = WorkspaceManager.isInDesignMode && WorkspaceManager.isInDesignMode();
888+
const $icon = $designModeBtn.find("i");
889+
$icon.removeClass("fa-expand fa-compress")
890+
.addClass(on ? "fa-compress" : "fa-expand");
891+
$designModeBtn.attr("title",
892+
on ? Strings.CCB_SWITCH_TO_CODE_EDITOR : Strings.CCB_SWITCH_TO_DESIGN_MODE);
893+
if ($modeBtn) {
894+
$modeBtn.toggle(!on && !_isMdviewrActive);
895+
}
896+
}
897+
$designModeBtn.click(()=>{
898+
CommandManager.execute(Commands.VIEW_TOGGLE_DESIGN_MODE);
899+
Metrics.countEvent(Metrics.EVENT_TYPE.LIVE_PREVIEW, "designModeBtn", "click");
900+
});
901+
WorkspaceManager.off(WorkspaceManager.EVENT_WORKSPACE_DESIGN_MODE_CHANGE + ".livePreview");
902+
WorkspaceManager.on(WorkspaceManager.EVENT_WORKSPACE_DESIGN_MODE_CHANGE + ".livePreview",
903+
_updateDesignModeButton);
904+
_updateDesignModeButton();
905+
874906
// init the status overlay
875907
_initOverlay();
876908
}

src/extensionsIntegrated/Phoenix-live-preview/panel.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<div id="panel-live-preview">
22
<div id="live-preview-plugin-toolbar" class="plugin-toolbar" style="display: flex; align-items: center; flex-direction: row;">
33
<div style="width: 20%;display: flex;">
4-
<button id="reloadLivePreviewButton" title="{{clickToReload}}" class="btn-alt-quiet toolbar-button reload-icon"></button>
4+
<button id="reloadLivePreviewButton" title="{{clickToReload}}" class="btn-alt-quiet toolbar-button">
5+
<i class="fa-solid fa-arrow-rotate-right"></i>
6+
</button>
7+
<button id="designModeToggleLivePreviewButton" title="{{switchToDesignMode}}" class="btn-alt-quiet toolbar-button">
8+
<i class="fa-solid fa-expand"></i>
9+
</button>
510
<button id="previewModeLivePreviewButton" title="{{clickToPreview}}" class="btn-alt-quiet toolbar-button">
611
<i class="fa-solid fa-play"></i>
712
</button>

0 commit comments

Comments
 (0)