Skip to content

Commit 37a0952

Browse files
committed
feat: use designer pen-nib SVG for design-mode toggle button
- Inline the SVG in index.html so it renders on first paint without a blank-button flash. - Switch fills/strokes to currentColor so the icon picks up the CCB button color and hover/active states. - Cache the rendered SVG HTML at init; the toggle swaps it with an fa-code icon for design-mode state and restores the cached SVG on return to editor mode. - Size the inline SVG to 15px via CSS to match neighboring FA icons.
1 parent 6c4736d commit 37a0952

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

src/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,10 @@
937937
<div id="centralControlBar" class="no-focus">
938938
<div class="ccb-group ccb-group-top">
939939
<a href="#" id="ccbCollapseEditorBtn" class="ccb-btn" title="Switch to Design Mode">
940-
<i class="fa-solid fa-pen-nib fa-rotate-90"></i>
940+
<svg class="ccb-pen-nib-icon" viewBox="0 0 21 21" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
941+
<path d="M19.8301 13.3181L19.8253 13.2941L17.7493 6.36938C17.461 5.41309 16.7305 4.65382 15.7791 4.33666L3.07815 0.0790007C2.66007 -0.0603584 2.20355 -0.0123035 1.82872 0.199138L9.29645 7.66686C9.48867 7.614 9.68569 7.58998 9.89233 7.58998C11.1658 7.58998 12.199 8.62316 12.199 9.89661C12.199 11.1701 11.1658 12.2032 9.89233 12.2032C8.61888 12.2032 7.5857 11.1701 7.5857 9.89661C7.5857 9.68997 7.61453 9.48814 7.66258 9.30073L0.199661 1.833C-0.0117809 2.20783 -0.0598357 2.65955 0.0795234 3.08243L4.33718 15.7833C4.65435 16.73 5.41362 17.4653 6.36991 17.7536L13.2946 19.8295L13.3186 19.8344L19.8301 13.3229V13.3181Z" fill="currentColor"/>
942+
<line x1="14.1513" y1="20.5938" x2="20.5906" y2="14.1064" stroke="currentColor" stroke-width="1.15332"/>
943+
</svg>
941944
</a>
942945
<a href="#" id="ccbSidebarToggleBtn" class="ccb-btn" title="Toggle sidebar">
943946
<i class="fa-solid fa-angles-left"></i>

src/styles/CentralControlBar.less

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@
101101
/* Nudge the collapse-editor icon up so it visually aligns with titlebar icons */
102102
#ccbCollapseEditorBtn {
103103
margin-top: -2px;
104+
105+
svg {
106+
width: 15px;
107+
height: 15px;
108+
pointer-events: none;
109+
}
104110
}
105111

106112
/* Nav buttons: suppress legacy sprite styles (NavigationProvider toggles enabled/disabled class) */

src/styles/images/pen_nib.svg

Lines changed: 4 additions & 0 deletions
Loading

src/view/CentralControlBar.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ define(function (require, exports, module) {
4040
let livePreviewWasOpen = false;
4141
let savedSidebarMaxSize = null;
4242
let applyingCollapsedLayout = false;
43+
let penNibIconHTML = null;
4344

4445
function _getRenderedSidebarWidth() {
4546
// Use offsetWidth (not jQuery's outerWidth) to force a synchronous reflow
@@ -238,7 +239,7 @@ define(function (require, exports, module) {
238239
const $collapseBtn = $("#ccbCollapseEditorBtn");
239240
$collapseBtn.toggleClass("is-active", editorCollapsed)
240241
.attr("title", editorCollapsed ? Strings.CCB_SWITCH_TO_CODE_EDITOR : Strings.CCB_SWITCH_TO_DESIGN_MODE);
241-
$collapseBtn.find("i").attr("class", editorCollapsed ? "fa-solid fa-code" : "fa-solid fa-pen-nib fa-rotate-90");
242+
$collapseBtn.html(editorCollapsed ? '<i class="fa-solid fa-code"></i>' : penNibIconHTML);
242243
if (_toggleDesignModeCommand) {
243244
_toggleDesignModeCommand.setChecked(editorCollapsed);
244245
}
@@ -303,6 +304,10 @@ define(function (require, exports, module) {
303304
$fileLabel = $("#ccbFileLabel");
304305
$fileName = $fileLabel.find(".ccb-file-name");
305306

307+
// Cache the authored pen-nib SVG from the DOM so the toggle handler
308+
// can restore it after swapping in the fa-code icon for design mode.
309+
penNibIconHTML = $("#ccbCollapseEditorBtn").html();
310+
306311
_wireButtons();
307312
// The HTML titles on the control-bar buttons are fallback English
308313
// strings; set the localized versions up front so the initial render

0 commit comments

Comments
 (0)