Skip to content

Commit 538b8cd

Browse files
committed
Tweak layout and behaviour of tab bar
1 parent 004093a commit 538b8cd

File tree

4 files changed

+44
-10
lines changed

4 files changed

+44
-10
lines changed

src/frontend/components/AddFileButton.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class AddFileButton extends PapyrosElement {
2424
.add-btn {
2525
padding: 0.375rem 0.5rem;
2626
border: none;
27+
border-bottom: 2px solid var(--md-sys-color-outline-variant);
2728
border-radius: 0.375rem 0.375rem 0 0;
2829
cursor: pointer;
2930
font-size: 1rem;
@@ -63,8 +64,20 @@ export class AddFileButton extends PapyrosElement {
6364
this.invalid = !isValidFileName(value) || this.papyros.io.files.some((f) => f.name === value);
6465
}
6566

67+
private onBlur(): void {
68+
if (!this.adding) return;
69+
const name = this.addInputRef.value?.value.trim() ?? "";
70+
if (name.length > 0) {
71+
this.confirmAdd();
72+
if (this.adding) this.cancelAdd();
73+
} else {
74+
this.cancelAdd();
75+
}
76+
}
77+
6678
private onAddKeydown(e: KeyboardEvent): void {
6779
if (e.key === "Enter") {
80+
e.preventDefault();
6881
this.confirmAdd();
6982
} else if (e.key === "Escape") {
7083
this.cancelAdd();
@@ -85,10 +98,15 @@ export class AddFileButton extends PapyrosElement {
8598
placeholder=${this.t("Papyros.add_file_placeholder")}
8699
@input=${this.onAddInput}
87100
@keydown=${this.onAddKeydown}
88-
@blur=${this.cancelAdd}
101+
@blur=${this.onBlur}
89102
/>`;
90103
}
91-
return html`<button class="add-btn" aria-label=${this.t("Papyros.add_file")} @click=${this.startAdding}>
104+
return html`<button
105+
class="add-btn"
106+
title=${this.t("Papyros.add_file")}
107+
aria-label=${this.t("Papyros.add_file")}
108+
@click=${this.startAdding}
109+
>
92110
+
93111
</button>`;
94112
}

src/frontend/components/EditorTab.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ export class EditorTab extends PapyrosElement {
4545
opacity: 0.6;
4646
}
4747
48-
button:hover .rename-btn,
49-
button:hover .close-btn,
50-
button:focus-within .rename-btn,
51-
button:focus-within .close-btn,
5248
button.active .rename-btn,
5349
button.active .close-btn {
5450
display: inline-flex;
@@ -76,6 +72,7 @@ export class EditorTab extends PapyrosElement {
7672

7773
private closeFile(e: Event): void {
7874
e.stopPropagation();
75+
if (!confirm(this.t("Papyros.close_file_confirm"))) return;
7976
this.papyros.io.removeFile(this.file.name);
8077
void this.papyros.runner.deleteFile(this.file.name);
8178
}
@@ -187,14 +184,28 @@ export class EditorTab extends PapyrosElement {
187184
class="rename-btn"
188185
role="button"
189186
tabindex="0"
187+
title=${this.t("Papyros.rename_file_tab")}
190188
aria-label=${this.t("Papyros.rename_file_tab")}
191189
@click=${this.onRenameClick}
192190
@keydown=${this.onRenameBtnKeydown}
193-
></span
194-
><span
191+
>
192+
<svg
193+
xmlns="http://www.w3.org/2000/svg"
194+
viewBox="0 0 24 24"
195+
width="12"
196+
height="12"
197+
fill="currentColor"
198+
>
199+
<path
200+
d="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z"
201+
/>
202+
</svg>
203+
</span>
204+
<span
195205
class="close-btn"
196206
role="button"
197207
tabindex="0"
208+
title=${this.t("Papyros.close_file_tab")}
198209
aria-label=${this.t("Papyros.close_file_tab")}
199210
@click=${this.closeFile}
200211
@keydown=${this.onCloseBtnKeydown}

src/frontend/components/shared-styles.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const tabButtonStyles: CSSResult = css`
44
button {
55
padding: 0.375rem 0.75rem;
66
border: none;
7+
border-bottom: 2px solid var(--md-sys-color-outline-variant);
78
border-radius: 0.375rem 0.375rem 0 0;
89
cursor: pointer;
910
font-size: 0.875rem;
@@ -18,6 +19,8 @@ export const tabButtonStyles: CSSResult = css`
1819
button.active {
1920
background-color: var(--md-sys-color-surface);
2021
color: var(--md-sys-color-on-surface);
22+
font-weight: 600;
23+
border-bottom: 2px solid var(--md-sys-color-primary);
2124
}
2225
2326
button:hover:not(.active) {

src/frontend/state/Translations.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ export const ENGLISH_TRANSLATION = {
7171
stop: "Stop debugging",
7272
},
7373
editor_tab_code: "Code",
74-
close_file_tab: "Close file",
74+
close_file_tab: "Remove file",
75+
close_file_confirm: "Are you sure you want to remove this file?",
7576
rename_file_tab: "Rename file",
7677
add_file: "Add file",
7778
add_file_placeholder: "filename\u2026",
@@ -166,7 +167,8 @@ export const DUTCH_TRANSLATION = {
166167
stop: "Stop debugger",
167168
},
168169
editor_tab_code: "Code",
169-
close_file_tab: "Bestand sluiten",
170+
close_file_tab: "Bestand verwijderen",
171+
close_file_confirm: "Weet je zeker dat je dit bestand wilt verwijderen?",
170172
rename_file_tab: "Bestand hernoemen",
171173
add_file: "Bestand toevoegen",
172174
add_file_placeholder: "bestandsnaam\u2026",

0 commit comments

Comments
 (0)