Skip to content

Commit 627e280

Browse files
committed
feat: use only chevron icon instead of full text for edit mode dropdown
1 parent 9a61c08 commit 627e280

3 files changed

Lines changed: 75 additions & 54 deletions

File tree

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

Lines changed: 55 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -370,50 +370,78 @@
370370
color: rgba(100, 180, 255, 0.8);
371371
}
372372

373-
#livePreviewModeBtn {
374-
min-width: fit-content;
373+
.lp-mode-btn-group {
375374
display: flex;
376375
align-items: center;
376+
flex-shrink: 0;
377377
margin: 0 4px 0 3px;
378-
max-width: 80%;
379-
text-overflow: ellipsis;
380-
overflow: hidden;
381-
white-space: nowrap;
382-
cursor: pointer;
383-
background: transparent;
384-
box-shadow: none;
385378
border: 1px solid transparent;
379+
border-radius: 3px;
386380
box-sizing: border-box;
381+
}
382+
383+
.lp-mode-btn-group:hover {
384+
border-color: rgba(255, 255, 255, 0.1);
385+
}
386+
387+
.lp-mode-icon {
388+
display: flex;
389+
align-items: center;
390+
justify-content: center;
391+
width: 22px;
392+
height: 22px;
393+
cursor: pointer;
394+
background: transparent;
395+
box-shadow: none !important;
396+
border: none;
387397
color: #a0a0a0;
388-
font-size: 14px;
389-
font-weight: normal;
390-
padding: 0 0.35em;
398+
padding: 0;
399+
margin: 0;
391400
}
392401

393-
#livePreviewModeBtn:hover,
394-
#livePreviewModeBtn:focus,
395-
#livePreviewModeBtn:active {
402+
#live-preview-plugin-toolbar .lp-mode-icon:hover,
403+
#live-preview-plugin-toolbar .lp-mode-icon:focus,
404+
#live-preview-plugin-toolbar .lp-mode-icon:active {
396405
background: transparent !important;
397-
border: 1px solid rgba(255, 255, 255, 0.1) !important;
406+
border: none !important;
398407
box-shadow: none !important;
399408
}
400409

401-
#livePreviewModeBtn.btn-dropdown::after {
402-
position: static;
403-
margin-top: 2px;
404-
margin-left: 5px;
410+
.lp-mode-icon.selected {
411+
color: #FBB03B;
405412
}
406413

407-
#reloadLivePreviewButton {
414+
.lp-mode-dropdown-chevron {
415+
display: flex;
416+
align-items: center;
417+
justify-content: center;
418+
cursor: pointer;
419+
background: transparent;
420+
box-shadow: none !important;
421+
border: none;
422+
border-left: 1px solid transparent;
423+
border-radius: 0 3px 3px 0;
408424
color: #a0a0a0;
409-
margin-left: 3px;
410-
margin-top: 0;
411-
width: 30px;
425+
padding: 0 4px;
426+
margin: 0;
412427
height: 22px;
413-
flex-shrink: 0;
428+
font-size: 10px;
414429
}
415430

416-
#designModeToggleLivePreviewButton {
431+
.lp-mode-btn-group:hover .lp-mode-dropdown-chevron {
432+
border-left-color: rgba(255, 255, 255, 0.1);
433+
}
434+
435+
#live-preview-plugin-toolbar .lp-mode-dropdown-chevron:hover,
436+
#live-preview-plugin-toolbar .lp-mode-dropdown-chevron:focus,
437+
#live-preview-plugin-toolbar .lp-mode-dropdown-chevron:active {
438+
background: transparent !important;
439+
border: none !important;
440+
border-left: 1px solid rgba(255, 255, 255, 0.1) !important;
441+
box-shadow: none !important;
442+
}
443+
444+
#reloadLivePreviewButton {
417445
color: #a0a0a0;
418446
margin-left: 3px;
419447
margin-top: 0;
@@ -422,7 +450,7 @@
422450
flex-shrink: 0;
423451
}
424452

425-
#previewModeLivePreviewButton {
453+
#designModeToggleLivePreviewButton {
426454
color: #a0a0a0;
427455
margin-left: 3px;
428456
margin-top: 0;
@@ -431,10 +459,6 @@
431459
flex-shrink: 0;
432460
}
433461

434-
#previewModeLivePreviewButton.selected{
435-
color: #FBB03B;
436-
}
437-
438462
.live-preview-status-overlay {
439463
display: flex;
440464
flex-direction: row;

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

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ define(function (require, exports, module) {
169169
$firefoxButtonBallast,
170170
$panelTitle,
171171
$modeBtn,
172+
$modeBtnGroup,
172173
$previewBtn,
173174
$designModeBtn;
174175

@@ -343,26 +344,19 @@ define(function (require, exports, module) {
343344
*/
344345
function _updateLPControlsForMdviewer() {
345346
const inDesignMode = WorkspaceManager.isInDesignMode && WorkspaceManager.isInDesignMode();
347+
const showPen = !_isMdviewrActive;
348+
// Dropdown is also hidden in design mode (see $designModeBtn wiring in
349+
// _createExtensionPanel) because the preview-mode options are moot
350+
// when the editor is fully collapsed.
351+
const showChevron = !_isMdviewrActive && !inDesignMode;
346352
if ($previewBtn) {
347-
$previewBtn.toggle(!_isMdviewrActive);
353+
$previewBtn.toggle(showPen);
348354
}
349355
if ($modeBtn) {
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);
356+
$modeBtn.toggle(showChevron);
354357
}
355-
}
356-
357-
function _updateModeButton(mode) {
358-
if ($modeBtn) {
359-
if (mode === "highlight") {
360-
$modeBtn[0].textContent = Strings.LIVE_PREVIEW_MODE_HIGHLIGHT;
361-
} else if (mode === "edit") {
362-
$modeBtn[0].textContent = Strings.LIVE_PREVIEW_MODE_EDIT;
363-
} else {
364-
$modeBtn[0].textContent = Strings.LIVE_PREVIEW_MODE_PREVIEW;
365-
}
358+
if ($modeBtnGroup && $modeBtnGroup.length) {
359+
$modeBtnGroup.toggle(showPen || showChevron);
366360
}
367361
}
368362

@@ -371,14 +365,12 @@ define(function (require, exports, module) {
371365

372366
// Pencil button lights up only when edit mode is active; preview /
373367
// highlight modes leave it un-tinted. Click toggles between edit
374-
// and preview.
368+
// and preview. The chevron next to it opens the full mode dropdown.
375369
if (currentMode === LiveDevelopment.CONSTANTS.LIVE_EDIT_MODE) {
376370
$previewBtn.addClass('selected');
377371
} else {
378372
$previewBtn.removeClass('selected');
379373
}
380-
381-
_updateModeButton(currentMode);
382374
}
383375

384376
function _showModeSelectionDropdown(event) {
@@ -809,6 +801,7 @@ define(function (require, exports, module) {
809801
$panelTitle = $panel.find("#panel-live-preview-title");
810802
$settingsIcon = $panel.find("#livePreviewSettingsBtn");
811803
$modeBtn = $panel.find("#livePreviewModeBtn");
804+
$modeBtnGroup = $panel.find("#lpModeBtnGroup");
812805
$previewBtn = $panel.find("#previewModeLivePreviewButton");
813806
$designModeBtn = $panel.find("#designModeToggleLivePreviewButton");
814807

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
<button id="designModeToggleLivePreviewButton" title="{{switchToDesignMode}}" class="btn-alt-quiet toolbar-button">
88
<i class="fa-solid fa-expand"></i>
99
</button>
10-
<button id="previewModeLivePreviewButton" title="{{clickToToggleEdit}}" class="btn-alt-quiet toolbar-button">
11-
<i class="fa-solid fa-pencil"></i>
12-
</button>
13-
<button id="livePreviewModeBtn" title="{{livePreviewConfigureModes}}" class="btn-alt-quiet toolbar-button btn-dropdown btn"><!-- Content will come here dynamically --></button>
10+
<span id="lpModeBtnGroup" class="lp-mode-btn-group">
11+
<button id="previewModeLivePreviewButton" title="{{clickToToggleEdit}}" class="btn-alt-quiet lp-mode-icon">
12+
<i class="fa-solid fa-pencil"></i>
13+
</button>
14+
<button id="livePreviewModeBtn" title="{{livePreviewConfigureModes}}" class="btn-alt-quiet lp-mode-dropdown-chevron">
15+
<i class="fa-solid fa-caret-down"></i>
16+
</button>
17+
</span>
1418
</div>
1519
<div style="width: fit-content;min-width: 60%;display: flex;justify-content: center; align-items: center;">
1620
<!-- these are buttons that are always invisible to help central align the panel title-->

0 commit comments

Comments
 (0)