Skip to content

Commit 70b9fdc

Browse files
committed
Add multiple editor tabs
1 parent 48a10cf commit 70b9fdc

7 files changed

Lines changed: 464 additions & 53 deletions

File tree

index.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
<button class="purple-button btn-format">Format<i class="fa-solid fa-wand-magic-sparkles"></i></button>
7171
<button class="purple-button btn-save">Save<i class="fa-solid fa-floppy-disk"></i></button>
7272
<button class="purple-button btn-save-as">Save As<i class="fa-solid fa-download"></i></button>
73-
<div class="file-path"></div>
7473
<button class="purple-button btn-save-run">Save + Run<i class="fa-solid fa-play"></i></button>
7574
</div>
7675
<div id="mobile-editor-bar">
@@ -82,7 +81,6 @@
8281
</button>
8382
</div>
8483
</div>
85-
<div class="file-path"></div>
8684
<a class="purple-button btn-save-run">Save + Run<i class="fa-solid fa-play"></i></a>
8785
<div class="clear"></div>
8886
<nav id="mobile-menu-contents" role="navigation" class="hidden" aria-expanded="false" aria-label="Mobile Menu">
@@ -95,6 +93,10 @@
9593
</ul>
9694
</nav>
9795
</div>
96+
<div id="editor-tabs-wrapper">
97+
<div id="editor-tabs" role="tablist" aria-label="Open files"></div>
98+
<select id="editor-tab-select" aria-label="Switch open file" hidden></select>
99+
</div>
98100
<div id="editor" tabindex="0"></div>
99101
</div>
100102
<div id="page-separator" class=""></div>

js/layout.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,21 @@ export function showSerial() {
9999
updatePageLayout(UPDATE_TYPE_SERIAL);
100100
}
101101

102+
function updateModeButtons() {
103+
// Match the button state to the panel state to avoid getting out of sync
104+
if (isEditorVisible()) {
105+
btnModeEditor.classList.add('active');
106+
} else {
107+
btnModeEditor.classList.remove('active');
108+
}
109+
110+
if (isSerialVisible()) {
111+
btnModeSerial.classList.add('active');
112+
} else {
113+
btnModeSerial.classList.remove('active');
114+
}
115+
}
116+
102117
// update type is used to indicate which button was clicked
103118
function updatePageLayout(updateType) {
104119
// If both are visible, show the separator
@@ -110,6 +125,7 @@ function updatePageLayout(updateType) {
110125
editorPage.style.flex = null;
111126
serialPage.style.width = null;
112127
serialPage.style.flex = null;
128+
updateModeButtons();
113129
return;
114130
}
115131

@@ -133,18 +149,7 @@ function updatePageLayout(updateType) {
133149
serialPage.style.flex = 'none';
134150
}
135151

136-
// Match the button state to the panel state to avoid getting out of sync
137-
if (isEditorVisible()) {
138-
btnModeEditor.classList.add('active');
139-
} else {
140-
btnModeEditor.classList.remove('active');
141-
}
142-
143-
if (isSerialVisible()) {
144-
btnModeSerial.classList.add('active');
145-
} else {
146-
btnModeSerial.classList.remove('active');
147-
}
152+
updateModeButtons();
148153

149154
if (isSerialVisible()) {
150155
refitTerminal();

0 commit comments

Comments
 (0)