Skip to content

Commit 007efc8

Browse files
committed
feat: add expand compress button in live preview toolbar
1 parent bb54663 commit 007efc8

5 files changed

Lines changed: 23 additions & 15 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@
182182

183183
.toolbar-button {
184184
background-color: transparent;
185+
color: inherit;
185186
width: 28px;
186187
height: 22px;
187188
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,8 @@ define(function (require, exports, module) {
768768
openInSafari: Strings.LIVE_DEV_OPEN_SAFARI,
769769
openInEdge: Strings.LIVE_DEV_OPEN_EDGE,
770770
openInFirefox: Strings.LIVE_DEV_OPEN_FIREFOX,
771-
clickToPinUnpin: Strings.LIVE_DEV_CLICK_TO_PIN_UNPIN
771+
clickToPinUnpin: Strings.LIVE_DEV_CLICK_TO_PIN_UNPIN,
772+
designModeExpand: Strings.CCB_SWITCH_TO_DESIGN_MODE
772773
};
773774
const PANEL_MIN_SIZE = 50;
774775
const INITIAL_PANEL_SIZE = document.body.clientWidth/2.5;
@@ -839,6 +840,10 @@ define(function (require, exports, module) {
839840
Metrics.countEvent(Metrics.EVENT_TYPE.LIVE_PREVIEW, "settingsBtn", "click");
840841
});
841842

843+
$panel.find("#lpDesignModeBtn").on("click", function () {
844+
CommandManager.execute(Commands.VIEW_TOGGLE_DESIGN_MODE);
845+
});
846+
842847
const popoutSupported = Phoenix.isNativeApp
843848
|| Phoenix.browser.desktop.isChromeBased || Phoenix.browser.desktop.isFirefox;
844849
if(!popoutSupported){

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
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;">
44
<button id="reloadLivePreviewButton" title="{{clickToReload}}" class="btn-alt-quiet toolbar-button reload-icon"></button>
5+
<button id="lpDesignModeBtn" title="{{designModeExpand}}" class="btn-alt-quiet toolbar-button">
6+
<i class="fa-solid fa-expand"></i>
7+
</button>
58
<button id="previewModeLivePreviewButton" title="{{clickToPreview}}" class="btn-alt-quiet toolbar-button">
69
<i class="fa-solid fa-play"></i>
710
</button>

src/index.html

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -913,12 +913,6 @@
913913
<div class="ccb-group">
914914
<a href="#" id="searchNav" class="ccb-btn"><i class="fa-regular fa-magnifying-glass"></i></a>
915915
</div>
916-
<div class="ccb-spacer"></div>
917-
<div class="ccb-group ccb-group-bottom">
918-
<a href="#" id="ccbCollapseEditorBtn" class="ccb-btn" title="Switch to Design Mode">
919-
<i class="fa-solid fa-code"></i>
920-
</a>
921-
</div>
922916
</div>
923917

924918
<div id="sidebar" class="sidebar panel quiet-scrollbars horz-resizable right-resizer collapsible" data-minsize="30" data-maxsize="80%" data-forceleft=".content">

src/view/CentralControlBar.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,18 @@ define(function (require, exports, module) {
208208
}
209209
editorCollapsed = wantCollapsed;
210210
$("body").toggleClass("ccb-editor-collapsed", editorCollapsed);
211-
const $collapseBtn = $("#ccbCollapseEditorBtn");
212-
$collapseBtn.toggleClass("active", editorCollapsed)
213-
.attr("title", editorCollapsed ? Strings.CCB_SWITCH_TO_CODE_EDITOR : Strings.CCB_SWITCH_TO_DESIGN_MODE);
211+
212+
// Update the live preview toolbar expand/contract button
213+
const $lpDesignBtn = $("#lpDesignModeBtn");
214+
if ($lpDesignBtn.length) {
215+
$lpDesignBtn.find("i").attr("class", editorCollapsed
216+
? "fa-solid fa-compress"
217+
: "fa-solid fa-expand");
218+
$lpDesignBtn.attr("title", editorCollapsed
219+
? Strings.CCB_SWITCH_TO_CODE_EDITOR
220+
: Strings.CCB_SWITCH_TO_DESIGN_MODE);
221+
}
222+
214223
if (_toggleDesignModeCommand) {
215224
_toggleDesignModeCommand.setChecked(editorCollapsed);
216225
}
@@ -237,10 +246,7 @@ define(function (require, exports, module) {
237246
}
238247

239248
function _wireButtons() {
240-
$("#ccbCollapseEditorBtn").on("click", function (e) {
241-
e.preventDefault();
242-
CommandManager.execute(Commands.VIEW_TOGGLE_DESIGN_MODE);
243-
});
249+
// Design mode button is now in the live preview toolbar (#lpDesignModeBtn)
244250
}
245251

246252
const _toggleDesignModeCommand = CommandManager.register(Strings.CMD_TOGGLE_DESIGN_MODE,
@@ -254,7 +260,6 @@ define(function (require, exports, module) {
254260
$content = $(".content");
255261

256262
_wireButtons();
257-
$("#ccbCollapseEditorBtn").attr("title", Strings.CCB_SWITCH_TO_DESIGN_MODE);
258263
_syncLeftPositions();
259264

260265
// While the sidebar is being dragged we only reposition .content / main-toolbar.

0 commit comments

Comments
 (0)