Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9e3fcaf

Browse files
committedApr 13, 2025
style: 🚸 indicate frontmatter template validty with colored border
in addition to the error message, ibdicate with a colored border when frontmatter is not valid.
1 parent 9c484ed commit 9e3fcaf

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed
 

‎src/ui/settings-tab.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,15 +1060,12 @@ export default class ReadwiseMirrorSettingTab extends PluginSettingTab {
10601060
.addTextArea((text) => {
10611061
const initialRows = 12;
10621062
text.inputEl.addClass('settings-template-input');
1063+
text.inputEl.id = 'frontmatter-template';
10631064
text.inputEl.rows = initialRows;
10641065
text.inputEl.cols = 50;
10651066

10661067
const container = containerEl.createDiv();
10671068

1068-
text.inputEl.addClass('settings-template-input');
1069-
text.inputEl.rows = 12;
1070-
text.inputEl.cols = 50;
1071-
10721069
// Create preview elements below textarea
10731070
const previewContainer = container.createDiv('template-preview');
10741071
const previewTitle = previewContainer.createDiv({
@@ -1110,19 +1107,18 @@ export default class ReadwiseMirrorSettingTab extends PluginSettingTab {
11101107
if (!result.isValid) {
11111108
errorNotice.setText('Your Frontmatter contains invalid YAML');
11121109
errorDetails.setText(result.error);
1113-
errorDetails.show();
11141110

11151111
if (result.preview) {
11161112
previewContent.setText(result.preview);
1117-
previewContainer.show();
11181113
}
1119-
return;
1114+
} else {
1115+
errorNotice.setText('');
1116+
errorDetails.setText('');
11201117
}
11211118

1122-
errorNotice.setText('');
1123-
errorDetails.setText('');
1124-
errorDetails.hide();
1125-
previewContainer.hide();
1119+
text.inputEl.toggleClass('invalid-template', !result.isValid);
1120+
errorDetails.toggle(!result.isValid);
1121+
previewContainer.toggle(!result.isValid && result.preview !== '');
11261122
};
11271123

11281124
// Display rendered template on load

‎src/ui/styles/styles.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@
7777
.settings-tab-content {
7878
padding-top: 1rem;
7979
}
80+
81+
#frontmatter-template.invalid-template {
82+
color: var(--text-danger);
83+
}

0 commit comments

Comments
 (0)
Failed to load comments.