Skip to content

Commit 0f7a30a

Browse files
committed
Changes to error display and calendar icon
1 parent f9b4afc commit 0f7a30a

File tree

7 files changed

+190
-34
lines changed

7 files changed

+190
-34
lines changed

exampleVault/.obsidian/plugins/obsidian-meta-bind-plugin/main.js

Lines changed: 140 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exampleVault/.obsidian/plugins/obsidian-meta-bind-plugin/styles.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@
2929
}
3030

3131
.meta-bind-plugin-error {
32-
color: red;
32+
display: block;
33+
color: #FF0000;
3334
font-weight: bold;
35+
font-family: var(--font-monospace);
36+
}
37+
38+
.meta-bind-code {
39+
color: var(--text-normal);
40+
font-family: var(--font-monospace);
3441
}
3542

3643
.meta-bind-plugin-slider-input-label {

exampleVault/other note.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
title: ""
2+
title: asdasd
33
select: option b
44
multi-select:
55
- option b
66
- option c
7-
date: Tuesday, September 6th 2022
7+
date: Thursday, September 22nd 2022
88
time: 19:20
99
---

src/InputFieldMarkdownRenderChild.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ export class InputFieldMarkdownRenderChild extends MarkdownRenderChild {
1818
uid: number;
1919
inputField: AbstractInputField | undefined;
2020
error: string;
21+
type: InputFieldMarkdownRenderChildType;
2122

23+
fullDeclaration: string;
2224
inputFieldDeclaration: InputFieldDeclaration | undefined;
2325
bindTargetFile: TFile | undefined;
2426
bindTargetMetadataField: string | undefined;
@@ -34,6 +36,8 @@ export class InputFieldMarkdownRenderChild extends MarkdownRenderChild {
3436
this.filePath = filePath;
3537
this.uid = uid;
3638
this.plugin = plugin;
39+
this.type = type;
40+
this.fullDeclaration = fullDeclaration;
3741

3842
this.valueQueue = [];
3943
this.intervalCounter = 0;
@@ -164,13 +168,17 @@ export class InputFieldMarkdownRenderChild extends MarkdownRenderChild {
164168
this.containerEl.addClass('meta-bind-plugin-input');
165169

166170
if (this.error) {
171+
this.containerEl.empty();
172+
const originalText = this.containerEl.createEl('span', {text: this.fullDeclaration, cls: 'meta-bind-code'});
167173
container.innerText = ` -> ERROR: ${this.error}`;
168174
container.addClass('meta-bind-plugin-error');
169175
this.containerEl.appendChild(container);
170176
return;
171177
}
172178

173179
if (!this.inputField) {
180+
this.containerEl.empty();
181+
const originalText = this.containerEl.createEl('span', {text: this.fullDeclaration, cls: 'meta-bind-code'});
174182
container.innerText = ` -> ERROR: ${(new MetaBindInternalError('input field is undefined and error is empty').message)}`;
175183
container.addClass('meta-bind-plugin-error');
176184
this.containerEl.appendChild(container);

src/inputFields/DatePicker/DatePicker.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import Calender from './Calender.svelte';
44
import {getMonthName} from './DatePickerInputSvelteHelpers.js';
55
import {moment} from 'obsidian';
6+
import Icon from './Icon.svelte';
67
78
const dispatch = createEventDispatcher();
89
@@ -79,7 +80,6 @@
7980
border-radius: var(--meta-bind-plugin-border-radius);
8081
border: var(--meta-bind-plugin-border-width) solid var(--background-modifier-border);
8182
padding: 5px 10px;
82-
height: 30px;
8383
cursor: pointer;
8484
width: fit-content;
8585
display: inline-block;
@@ -111,7 +111,10 @@
111111
</style>
112112

113113
<div class="date-picker-input">
114-
<div class="date-picker-text" on:click={() => showDatePicker = true}>{selectedDate.format(dateFormat)}</div>
114+
<div class="date-picker-text" on:click={() => showDatePicker = true}>
115+
{selectedDate.format(dateFormat)}
116+
<Icon iconName="calendar"/>
117+
</div>
115118
{#if showDatePicker}
116119
<div class="date-picker-close-layer" on:click={() => showDatePicker = false}></div>
117120
<div class="date-picker">
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!--adapted from @joethei's code: https://github.com/joethei/obsidian-rss/blob/master/src/view/IconComponent.svelte-->
2+
<!--adapted from @javalent's code: https://discord.com/channels/686053708261228577/840286264964022302/902949764209987654-->
3+
<script lang="ts">
4+
import {setIcon} from 'obsidian';
5+
6+
export let iconName: String = '';
7+
8+
function icon(node: HTMLElement, icon: string) {
9+
setIcon(node, icon);
10+
}
11+
</script>
12+
13+
<style>
14+
15+
</style>
16+
17+
{#if iconName.length > 0}
18+
<span use:icon={iconName} style=""></span>
19+
{/if}

styles.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@
2929
}
3030

3131
.meta-bind-plugin-error {
32-
color: red;
32+
display: block;
33+
color: #FF0000;
3334
font-weight: bold;
35+
font-family: var(--font-monospace);
36+
}
37+
38+
.meta-bind-code {
39+
color: var(--text-normal);
40+
font-family: var(--font-monospace);
3441
}
3542

3643
.meta-bind-plugin-slider-input-label {

0 commit comments

Comments
 (0)