Skip to content

Commit 7440d58

Browse files
committed
update image suggester styling and allow it inline
1 parent 417fe82 commit 7440d58

File tree

10 files changed

+48
-13
lines changed

10 files changed

+48
-13
lines changed

exampleVault/Buttons/Button Example.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ label: Run Custom JS
3333
action:
3434
type: js
3535
file: testJsFile.js
36+
args:
37+
greeting: "Meta Bind User"
3638
```
3739

3840
And open internal and external links

exampleVault/Examples.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
slider1: 7
2+
slider1: 3
33
suggest: test
44
toggle1: false
55
Domestic_tasks:
@@ -13,7 +13,7 @@ inlineSelect: 1
1313
nested:
1414
object: test
1515
number1: 2
16-
number2: 14
16+
number2: 4
1717
time:
1818
---
1919

exampleVault/Input Fields/Image Suggester.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
image: Other/Images/img_flower.webp
2+
image: Other/Images/img_butterfly.webp
33
---
44

55
```meta-bind

exampleVault/Input Fields/Inline Select.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
select: b
33
select2: 1
44
select3: 2 hours
5+
select4:
56
---
67

78
```meta-bind
@@ -15,3 +16,7 @@ INPUT[inlineSelect(option(1, a), option(2, b), showcase):select2]
1516
```meta-bind
1617
INPUT[inlineSelect(option(1 hour, a), option(2 hours, b), showcase):select3]
1718
```
19+
20+
```meta-bind
21+
INPUT[inlineSelect(option(null, nothing), option(foo, something), showcase):select4]
22+
```

exampleVault/testJsFile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
console.log(`Hello World from ${context.file.path}!`);
1+
console.log(`Hello ${context.args.greeting} from ${context.file.path}!`);
22
throw new Error('This is an error');

packages/core/src/config/FieldConfigs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export const InputFieldConfigs: Record<InputFieldType, InputFieldConfig> = {
144144
[InputFieldType.IMAGE_SUGGESTER]: {
145145
type: InputFieldType.IMAGE_SUGGESTER,
146146
allowInBlock: true,
147-
allowInline: false,
147+
allowInline: true,
148148
},
149149
[InputFieldType.PROGRESS_BAR]: {
150150
type: InputFieldType.PROGRESS_BAR,

packages/core/src/fields/inputFields/fields/ImageSuggester/ImageSuggesterComponent.svelte

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,19 @@
2121

2222
<div class="mb-image-card">
2323
{#if value}
24-
<img class="mb-image-card-image" src={props.plugin.internal.imagePathToUri(value)} alt={value} />
24+
<img
25+
class="mb-image-card-image"
26+
src={props.plugin.internal.imagePathToUri(value)}
27+
alt={value}
28+
aria-label={value}
29+
/>
2530
{/if}
26-
<div class="mb-image-card-footer">
27-
<span>{value || 'no image selected'}</span>
28-
<Button variant={ButtonStyleType.PLAIN} onclick={openSuggester}>
29-
<Icon iconName="pencil" plugin={props.plugin} />
30-
</Button>
31-
</div>
31+
<Button
32+
variant={ButtonStyleType.PLAIN}
33+
onclick={openSuggester}
34+
classes="mb-image-card-button"
35+
tooltip="Change image"
36+
>
37+
<Icon iconName="pencil" plugin={props.plugin} />
38+
</Button>
3239
</div>

packages/core/src/utils/components/Button.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@
88
variant = ButtonStyleType.DEFAULT,
99
disabled = false,
1010
tooltip = '',
11+
classes = '',
1112
onclick = () => {},
1213
children,
1314
}: {
1415
variant?: ButtonStyleType;
1516
disabled?: boolean;
1617
tooltip?: string;
18+
classes?: string;
1719
onclick?: (e: MouseEvent) => void | Promise<void>;
1820
children: Snippet;
1921
} = $props();
2022
</script>
2123

2224
<button
23-
class="mb-button-inner"
25+
class="mb-button-inner {classes}"
2426
class:mod-cta={variant === ButtonStyleType.PRIMARY}
2527
class:mod-warning={variant === ButtonStyleType.DESTRUCTIVE}
2628
class:mod-plain={variant === ButtonStyleType.PLAIN}

packages/obsidian/src/cm6/Cm6_ViewPlugin.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ export function createMarkdownRenderChildWidgetEditorPlugin(plugin: MetaBindPlug
3737
while (parent !== null) {
3838
if (parent.classList.contains('mb-input')) {
3939
e.stopPropagation();
40+
// Uncommenting this will fix #403
41+
// but it will break date and time inputs
42+
// e.preventDefault();
4043
break;
4144
}
4245

styles.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,10 @@ div.mb-view-wrapper {
443443
gap: var(--size-4-4);
444444
}
445445

446+
.mb-image-card {
447+
position: relative;
448+
}
449+
446450
.mb-image-suggester-modal {
447451
width: 80%;
448452
}
@@ -474,6 +478,18 @@ div.mb-view-wrapper {
474478
}
475479
}
476480

481+
.mb-image-card-button {
482+
position: absolute;
483+
opacity: 0;
484+
top: var(--size-4-2);
485+
right: var(--size-4-2);
486+
transition: opacity 0.2s ease-in-out;
487+
}
488+
489+
.mb-image-card:hover .mb-image-card-button {
490+
opacity: 1;
491+
}
492+
477493
.mb-image-suggest-input {
478494
background: var(--background-secondary);
479495
border-radius: var(--mb-border-radius);

0 commit comments

Comments
 (0)