Skip to content

Commit 22b2191

Browse files
committed
feat: replace CCB file label with Show-in-File-Tree button
- Remove the .ccb-group-file block (HTML, JS wiring, LESS). The vertical file name is redundant with the live-preview heading and file tabs. - Drop no-longer-used DocumentManager and MainViewManager requires, plus the _updateFileLabel function and its event subscriptions. - Add #ccbShowInTreeBtn below #searchNav in .ccb-group-nav with the legacy binoculars glyph inlined as SVG using currentColor so it inherits the button color. ViewBox tightened to 16x16 so the artwork fills the rendering box at the same weight as the pen-nib icon. - Button invokes the existing NAVIGATE_SHOW_IN_FILE_TREE command and uses the existing Strings.CMD_SHOW_IN_TREE localized title. - Update control-bar-tests-todo.md: replace the three file-label bullets with checks for the new button.
1 parent 1b7d9b1 commit 22b2191

4 files changed

Lines changed: 22 additions & 96 deletions

File tree

src/index.html

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -964,16 +964,14 @@
964964
<div class="ccb-divider"></div>
965965
<div class="ccb-group ccb-group-nav">
966966
<a href="#" id="searchNav" class="ccb-btn"><i class="fa-solid fa-magnifying-glass"></i></a>
967+
<a href="#" id="ccbShowInTreeBtn" class="ccb-btn" title="Show in File Tree">
968+
<svg class="ccb-binoculars-icon" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
969+
<path fill="currentColor" d="M4.5 1A1.5 1.5 0 0 0 3 2.5V3h4v-.5A1.5 1.5 0 0 0 5.5 1h-1zM7 4v1h2V4h4v.882a.5.5 0 0 0 .276.447l.895.447A1.5 1.5 0 0 1 15 7.118V13H9v-1.5a.5.5 0 0 1 .146-.354l.854-.853V9.5a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5v.793l.854.853A.5.5 0 0 1 7 11.5V13H1V7.118a1.5 1.5 0 0 1 .83-1.342l.894-.447A.5.5 0 0 0 3 4.882V4h4zM1 14v.5A1.5 1.5 0 0 0 2.5 16h3A1.5 1.5 0 0 0 7 14.5V14H1zm8 0v.5a1.5 1.5 0 0 0 1.5 1.5h3a1.5 1.5 0 0 0 1.5-1.5V14H9zm4-11H9v-.5A1.5 1.5 0 0 1 10.5 1h1A1.5 1.5 0 0 1 13 2.5V3z"/>
970+
</svg>
971+
</a>
967972
<a href="#" id="navBackButton" class="ccb-btn"><i class="fa-solid fa-arrow-left"></i></a>
968973
<a href="#" id="navForwardButton" class="ccb-btn"><i class="fa-solid fa-arrow-right"></i></a>
969974
</div>
970-
<div class="ccb-divider"></div>
971-
<div class="ccb-group ccb-group-file">
972-
<div id="ccbFileLabel" class="ccb-file-label">
973-
<span class="ccb-file-dot"></span>
974-
<span class="ccb-file-name"></span>
975-
</div>
976-
</div>
977975
</div>
978976

979977
<!--

src/styles/CentralControlBar.less

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@
4747
flex-direction: column;
4848
align-items: stretch;
4949
gap: 2px;
50-
51-
&.ccb-group-file {
52-
flex: 0 1 auto;
53-
max-height: 220px;
54-
overflow: hidden;
55-
justify-content: flex-start;
56-
padding: 4px 0;
57-
}
5850
}
5951

6052
.ccb-divider {
@@ -81,6 +73,12 @@
8173
pointer-events: none;
8274
}
8375

76+
svg.ccb-binoculars-icon {
77+
width: 15px;
78+
height: 15px;
79+
pointer-events: none;
80+
}
81+
8482
&:hover {
8583
color: @project-panel-text-1;
8684
background-color: rgba(255, 255, 255, 0.08);
@@ -128,49 +126,6 @@
128126
pointer-events: none;
129127
}
130128

131-
/* Vertical filename label — clicking reveals the current file in the
132-
file tree, mirroring the old binoculars button. */
133-
.ccb-file-label {
134-
display: flex;
135-
flex-direction: column;
136-
align-items: center;
137-
gap: 4px;
138-
padding: 4px 0;
139-
color: @project-panel-text-2;
140-
height: 100%;
141-
overflow: hidden;
142-
cursor: pointer;
143-
144-
.ccb-file-dot {
145-
flex: 0 0 auto;
146-
line-height: 1;
147-
color: #f1b84e;
148-
visibility: hidden;
149-
font-size: 1rem;
150-
}
151-
152-
&.is-dirty .ccb-file-dot {
153-
visibility: visible;
154-
}
155-
156-
.ccb-file-name {
157-
flex: 1 1 auto;
158-
min-height: 0;
159-
writing-mode: vertical-rl;
160-
transform: rotate(180deg);
161-
text-orientation: mixed;
162-
white-space: nowrap;
163-
overflow: hidden;
164-
text-overflow: ellipsis;
165-
color: @project-panel-text-1;
166-
font-size: 13px;
167-
font-weight: 500;
168-
}
169-
170-
&:hover .ccb-file-name {
171-
text-decoration: underline;
172-
}
173-
}
174129
}
175130

176131
/* Editor collapse: actual layout handled in JS via .content width/visibility */

src/view/CentralControlBar.js

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ define(function (require, exports, module) {
2323
const AppInit = require("utils/AppInit");
2424
const CommandManager = require("command/CommandManager");
2525
const Commands = require("command/Commands");
26-
const DocumentManager = require("document/DocumentManager");
27-
const MainViewManager = require("view/MainViewManager");
2826
const Strings = require("strings");
2927
const WorkspaceManager = require("view/WorkspaceManager");
3028

@@ -33,8 +31,6 @@ define(function (require, exports, module) {
3331
let $bar;
3432
let $sidebar;
3533
let $content;
36-
let $fileLabel;
37-
let $fileName;
3834
let editorCollapsed = false;
3935
let savedToolbarWidth = null;
4036
let livePreviewWasOpen = false;
@@ -73,27 +69,6 @@ define(function (require, exports, module) {
7369
}
7470
}
7571

76-
function _updateFileLabel() {
77-
if (!$fileLabel) {
78-
return;
79-
}
80-
const doc = DocumentManager.getCurrentDocument();
81-
if (!doc) {
82-
$fileLabel.removeClass("is-dirty");
83-
$fileName.text("");
84-
$fileLabel.attr("title", "");
85-
return;
86-
}
87-
const name = doc.file && doc.file.name ? doc.file.name : "";
88-
const fullPath = doc.file && doc.file.fullPath ? doc.file.fullPath : "";
89-
const displayPath = fullPath && Phoenix && Phoenix.app && Phoenix.app.getDisplayPath
90-
? Phoenix.app.getDisplayPath(fullPath)
91-
: fullPath || name;
92-
$fileName.text(name);
93-
$fileLabel.attr("title", displayPath);
94-
$fileLabel.toggleClass("is-dirty", !!doc.isDirty);
95-
}
96-
9772
function _executeCmd(id) {
9873
CommandManager.execute(id);
9974
}
@@ -286,7 +261,7 @@ define(function (require, exports, module) {
286261
e.preventDefault();
287262
_executeCmd(Commands.VIEW_HIDE_SIDEBAR);
288263
});
289-
$("#ccbFileLabel").on("click", function (e) {
264+
$("#ccbShowInTreeBtn").on("click", function (e) {
290265
e.preventDefault();
291266
_executeCmd(Commands.NAVIGATE_SHOW_IN_FILE_TREE);
292267
});
@@ -301,8 +276,6 @@ define(function (require, exports, module) {
301276
$bar = $("#centralControlBar");
302277
$sidebar = $("#sidebar");
303278
$content = $(".content");
304-
$fileLabel = $("#ccbFileLabel");
305-
$fileName = $fileLabel.find(".ccb-file-name");
306279

307280
// Cache the authored pen-nib SVG from the DOM so the toggle handler
308281
// can restore it after swapping in the fa-code icon for design mode.
@@ -315,6 +288,7 @@ define(function (require, exports, module) {
315288
// navForwardButton get their localized titles from NavigationProvider.)
316289
$("#ccbCollapseEditorBtn").attr("title", Strings.CCB_SWITCH_TO_DESIGN_MODE);
317290
$("#ccbSidebarToggleBtn").attr("title", Strings.CMD_TOGGLE_SIDEBAR);
291+
$("#ccbShowInTreeBtn").attr("title", Strings.CMD_SHOW_IN_TREE);
318292
$("#ccbUndoBtn").attr("title", Strings.CMD_UNDO);
319293
$("#ccbRedoBtn").attr("title", Strings.CMD_REDO);
320294
$("#ccbSaveBtn").attr("title", Strings.CMD_FILE_SAVE);
@@ -428,11 +402,6 @@ define(function (require, exports, module) {
428402
};
429403
}
430404

431-
MainViewManager.on("currentFileChange.ccb", _updateFileLabel);
432-
DocumentManager.on("dirtyFlagChange.ccb", _updateFileLabel);
433-
DocumentManager.on("pathDeleted.ccb fileNameChange.ccb", _updateFileLabel);
434-
435-
_updateFileLabel();
436405
_updateSidebarToggleIcon();
437406
});
438407

test/control-bar-tests-todo.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,15 @@ Keep this file updated as we add coverage; remove lines as suites land.
3333
- [ ] `#ccbSidebarToggleBtn` executes `VIEW_HIDE_SIDEBAR` and the icon flips
3434
`fa-angles-left``fa-angles-right` on panelCollapsed/panelExpanded.
3535
- [ ] The old `#sidebar-toggle-btn` in the menubar is NOT in the DOM.
36-
- [ ] Clicking `#ccbFileLabel` executes `NAVIGATE_SHOW_IN_FILE_TREE` and (if
37-
sidebar was hidden) re-opens the sidebar as part of that command.
38-
- [ ] File label shows the current doc's `file.name` and uses
39-
`Phoenix.app.getDisplayPath` for its tooltip.
40-
- [ ] Dirty indicator dot toggles with `DocumentManager`'s `dirtyFlagChange`.
36+
- [ ] `#ccbShowInTreeBtn` is rendered in `.ccb-group-nav` directly below
37+
`#searchNav` and has a `title` of `Strings.CMD_SHOW_IN_TREE`.
38+
- [ ] Clicking `#ccbShowInTreeBtn` executes `NAVIGATE_SHOW_IN_FILE_TREE` (if
39+
sidebar was hidden, it re-opens as part of the command).
40+
- [ ] Binoculars `<svg>` renders and inherits `.ccb-btn` color
41+
(`currentColor` on the path).
42+
- [ ] Neither `#ccbFileLabel`, `.ccb-group-file`, `.ccb-file-label`,
43+
`.ccb-file-name`, nor `.ccb-file-dot` exists in the DOM or in the
44+
compiled CSS.
4145

4246
## 3. Toggle Design Mode command
4347

0 commit comments

Comments
 (0)