Skip to content

Commit 349ae35

Browse files
committed
feat: make the live preview expand button go full screen
The expand icon in the live preview toolbar was just a second copy of the design mode toggle, which is not what the icon says it does. It now expands live preview to full screen, and design mode stays its own thing on the control bar. Renamed the button to fullScreenLivePreviewButton since the old id said design mode, and pointed its icon and tooltip at the full screen change event instead of the design mode one. The mode dropdown chevron keeps hiding in design mode as before, now driven directly by the design mode event.
1 parent 7e0667d commit 349ae35

3 files changed

Lines changed: 20 additions & 23 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,13 @@
370370
}
371371

372372
#reloadLivePreviewButton,
373-
#designModeToggleLivePreviewButton {
373+
#fullScreenLivePreviewButton {
374374
border: 1px solid transparent;
375375
border-radius: 3px;
376376
}
377377

378378
#live-preview-plugin-toolbar #reloadLivePreviewButton:hover,
379-
#live-preview-plugin-toolbar #designModeToggleLivePreviewButton:hover {
379+
#live-preview-plugin-toolbar #fullScreenLivePreviewButton:hover {
380380
border-color: rgba(255, 255, 255, 0.1) !important;
381381
background: transparent !important;
382382
box-shadow: none !important;

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

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ define(function (require, exports, module) {
190190
$modeBtn,
191191
$modeBtnGroup,
192192
$previewBtn,
193-
$designModeBtn;
193+
$fullScreenBtn;
194194

195195
let customLivePreviewBannerShown = false;
196196

@@ -800,7 +800,7 @@ define(function (require, exports, module) {
800800
livePreview: Strings.LIVE_DEV_STATUS_TIP_OUT_OF_SYNC,
801801
clickToReload: Strings.LIVE_DEV_CLICK_TO_RELOAD_PAGE,
802802
clickToToggleEdit: Strings.LIVE_PREVIEW_MODE_TOGGLE_EDIT,
803-
switchToDesignMode: Strings.CCB_SWITCH_TO_DESIGN_MODE,
803+
fullScreenLivePreview: Strings.LIVE_PREVIEW_FULL_SCREEN,
804804
livePreviewSettings: Strings.LIVE_DEV_SETTINGS,
805805
livePreviewConfigureModes: Strings.LIVE_PREVIEW_CONFIGURE_MODES,
806806
clickToPopout: Strings.LIVE_DEV_CLICK_POPOUT,
@@ -833,7 +833,7 @@ define(function (require, exports, module) {
833833
$modeBtn = $panel.find("#livePreviewModeBtn");
834834
$modeBtnGroup = $panel.find("#lpModeBtnGroup");
835835
$previewBtn = $panel.find("#previewModeLivePreviewButton");
836-
$designModeBtn = $panel.find("#designModeToggleLivePreviewButton");
836+
$fullScreenBtn = $panel.find("#fullScreenLivePreviewButton");
837837

838838
// Markdown theme toggle — persist user choice
839839
MarkdownSync.setThemeToggleHandler((theme) => {
@@ -918,28 +918,25 @@ define(function (require, exports, module) {
918918
Metrics.countEvent(Metrics.EVENT_TYPE.LIVE_PREVIEW, "reloadBtn", "click");
919919
});
920920

921-
// Design-mode toggle: mirrors the CCB's pen-nib button so the user can
922-
// enter/exit design mode without moving focus to the sidebar strip.
923-
// Icon swaps between fa-expand (enter) and fa-compress (exit).
924-
function _updateDesignModeButton() {
925-
const on = WorkspaceManager.isInDesignMode && WorkspaceManager.isInDesignMode();
926-
const $icon = $designModeBtn.find("i");
927-
$icon.removeClass("fa-expand fa-compress")
921+
function _updateFullScreenButton() {
922+
const on = WorkspaceManager.isInLPFullScreen && WorkspaceManager.isInLPFullScreen();
923+
$fullScreenBtn.find("i")
924+
.removeClass("fa-expand fa-compress")
928925
.addClass(on ? "fa-compress" : "fa-expand");
929-
$designModeBtn.attr("title",
930-
on ? Strings.CCB_SWITCH_TO_CODE_EDITOR : Strings.CCB_SWITCH_TO_DESIGN_MODE);
931-
if ($modeBtn) {
932-
$modeBtn.toggle(!on && !_isMdviewrActive);
933-
}
926+
$fullScreenBtn.attr("title",
927+
on ? Strings.LIVE_PREVIEW_EXIT_FULL_SCREEN : Strings.LIVE_PREVIEW_FULL_SCREEN);
934928
}
935-
$designModeBtn.click(()=>{
936-
CommandManager.execute(Commands.VIEW_TOGGLE_DESIGN_MODE);
937-
Metrics.countEvent(Metrics.EVENT_TYPE.LIVE_PREVIEW, "designModeBtn", "click");
929+
$fullScreenBtn.click(()=>{
930+
CommandManager.execute(Commands.VIEW_TOGGLE_LP_FULL_SCREEN);
931+
Metrics.countEvent(Metrics.EVENT_TYPE.LIVE_PREVIEW, "fullScreenBtn", "click");
938932
});
939933
WorkspaceManager.off(WorkspaceManager.EVENT_WORKSPACE_DESIGN_MODE_CHANGE + ".livePreview");
940934
WorkspaceManager.on(WorkspaceManager.EVENT_WORKSPACE_DESIGN_MODE_CHANGE + ".livePreview",
941-
_updateDesignModeButton);
942-
_updateDesignModeButton();
935+
_updateLPControlsForMdviewer);
936+
WorkspaceManager.off(WorkspaceManager.EVENT_WORKSPACE_LP_FULL_SCREEN_CHANGE + ".livePreview");
937+
WorkspaceManager.on(WorkspaceManager.EVENT_WORKSPACE_LP_FULL_SCREEN_CHANGE + ".livePreview",
938+
_updateFullScreenButton);
939+
_updateFullScreenButton();
943940

944941
// init the status overlay
945942
_initOverlay();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<button id="reloadLivePreviewButton" title="{{clickToReload}}" class="btn-alt-quiet toolbar-button">
55
<i class="fa-solid fa-arrow-rotate-right"></i>
66
</button>
7-
<button id="designModeToggleLivePreviewButton" title="{{switchToDesignMode}}" class="btn-alt-quiet toolbar-button">
7+
<button id="fullScreenLivePreviewButton" title="{{fullScreenLivePreview}}" class="btn-alt-quiet toolbar-button">
88
<i class="fa-solid fa-expand"></i>
99
</button>
1010
<span id="lpModeBtnGroup" class="lp-mode-btn-group">

0 commit comments

Comments
 (0)