Skip to content

Commit d1a07f6

Browse files
Feature: Update [!caption] callout to utilize metadata
- consolidated the three existing caption callouts into one `[!caption]` callout. Float can be applied using callout metadata now. - Updated `MMW Design & Planning/Custom Formatting Features.md` to reflect changes. - Renamed `MMW_Caption_Callouts` plural to `MMW_Caption_Callout` singular.
1 parent 0d4ff6f commit d1a07f6

File tree

4 files changed

+71
-186
lines changed

4 files changed

+71
-186
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*Captions*/
2+
.callout.callout[data-callout~=caption] {
3+
background: transparent;
4+
text-align: center;
5+
box-shadow: none;
6+
border: 0;
7+
padding: 0;
8+
margin: 0;
9+
--callout-content-padding: 0;
10+
max-width: 30vh;
11+
}
12+
.callout.callout[data-callout~=caption] > .callout-content {
13+
overflow: hidden;
14+
}
15+
.callout.callout[data-callout~=caption] > .callout-content > p :is(.image-embed, img) + br {
16+
display: none;
17+
}
18+
.callout.callout[data-callout~=caption] > .callout-content img {
19+
display: block;
20+
margin: auto;
21+
}
22+
.callout.callout[data-callout~=caption] > .callout-title {
23+
display: none;
24+
}
25+
.callout.callout[data-callout~=caption] p {
26+
margin-block-start: 0;
27+
margin-block-end: 0;
28+
color: var(--text-faint);
29+
}
30+
.callout.callout[data-callout~=caption]:is([data-callout-metadata~=sban], [data-callout-metadata~=banner]) .image-embed img {
31+
width: 100%;
32+
}

content/.obsidian/snippets/MMW_Caption_Callouts.css

-93
This file was deleted.

content/MMW Design & Planning/Custom Formatting Features.md

+15-7
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,26 @@ In addition to the default [Obsidian Callouts](https://help.obsidian.md/Editing+
188188
189189
### Captions
190190
191-
> [!caption_right]
191+
> [!caption|right]
192192
>
193193
> ![[PuzzleBoxOnly.png|wsmall]]
194194
>
195-
> `[!caption_right]` callout
195+
> `[!caption|right]` callout
196196
197-
Three callouts for adding captions to images. The callout title is hidden and text size reduced, similar to how Wikipedia and other wikis format their article image captions.
197+
A borderless callout for adding captions to images.
198198
199-
**Types:**
200-
- `[!caption_left]` - floats to the left of the page
201-
- `[!caption_right]` - floats to the right of the page
202-
- `[!caption]` - centered in the middle of the page
199+
Use [[Custom Formatting Features#Callout Positioning|Callout Positioning]] metadata to float these left or right for wiki-style article image captions
200+
201+
```markdown title="syntax"
202+
> [!caption]
203+
>
204+
> ![[image.png]]
205+
>
206+
> Image caption.
207+
208+
```
209+
210+
<br>
203211

204212
### Infobox
205213

quartz/styles/custom.scss

+24-86
Original file line numberDiff line numberDiff line change
@@ -280,103 +280,41 @@ img:active:not(.Logo) {
280280
/* First-child needs a margin-top of 16 to match the margin-top of other grid items - except codeblocks */
281281
}
282282

283-
/*----Caption Callouts----*/
283+
/*----Caption Callout----*/
284284

285-
/*---caption left callout---*/
286-
.callout[data-callout="caption_left"] {
287-
--color: rgb(0, 176, 255);
288-
--border: rgba(0, 176, 255, 0.44);
289-
--bg: rgba(0, 176, 255, 0.1);
290-
float: left;
291-
max-width: 40%;
292-
padding: 6px;
293-
margin: 2px 12px 2px 0px;
294-
}
295-
296-
.callout[data-callout="caption_left"] > .callout-title {
297-
display: none;
298-
}
299-
300-
.callout[data-callout="caption_left"] img {
301-
display: block;
302-
margin: auto;
303-
max-width: 100%;
304-
}
305-
306-
.callout[data-callout="caption_left"] p {
307-
text-align: left;
308-
padding: 2px;
309-
margin: auto;
310-
font-size: 0.875em;
311-
}
312-
313-
/* mobile breakpoint */
314-
@media (max-width: 767px) {
315-
.callout[data-callout="caption_left"] {
316-
max-width: 50%;
317-
}
285+
.callout.callout[data-callout~=caption] {
286+
background: transparent;
287+
text-align: center;
288+
box-shadow: none;
289+
border: 0;
290+
padding: 0;
291+
margin: 0;
292+
--callout-content-padding: 0;
293+
max-width: 30vh;
318294
}
319-
320-
/*---caption center callout---*/
321-
.callout[data-callout="caption"] {
322-
--color: rgb(0, 176, 255);
323-
--border: rgba(0, 176, 255, 0.44);
324-
--bg: rgba(0, 176, 255, 0.1);
325-
padding: 6px;
326-
max-width: 80%;
327-
margin: auto;
295+
.callout.callout[data-callout~=caption] > .callout-content {
296+
overflow: hidden;
328297
}
329-
330-
.callout[data-callout="caption"] > .callout-title {
298+
/*. callout.callout[data-callout~=caption] > .callout-content > p :is(.image-embed, img) + br {
331299
display: none;
332-
}
300+
} */
333301

334-
.callout[data-callout="caption"] img {
335-
display: block;
336-
margin: auto;
337-
max-width: 100%;
338-
}
302+
/*unneeded as `.image-embed` relates to image embedding in Reading Mode vs Live Preview */
339303

340-
.callout[data-callout="caption"] p {
341-
text-align: center;
342-
padding: 2px;
304+
.callout.callout[data-callout~=caption] > .callout-content img {
305+
display: block;
343306
margin: auto;
344-
font-size: 0.875em;
345-
}
346-
347-
/*---caption right callout---*/
348-
.callout[data-callout="caption_right"] {
349-
--color: rgb(0, 176, 255);
350-
--border: rgba(0, 176, 255, 0.44);
351-
--bg: rgba(0, 176, 255, 0.1);
352-
float: right;
353-
max-width: 40%;
354-
padding: 6px;
355-
margin: 2px 0px 2px 12px;
356307
}
357-
358-
.callout[data-callout="caption_right"] > .callout-title {
308+
.callout.callout[data-callout~=caption] > .callout-title {
359309
display: none;
360310
}
361-
362-
.callout[data-callout="caption_right"] img {
363-
display: block;
364-
margin: auto;
365-
max-width: 100%;
366-
}
367-
368-
.callout[data-callout="caption_right"] p {
369-
text-align: left;
370-
padding: 2px;
371-
margin: auto;
372-
font-size: 0.875em;
311+
.callout.callout[data-callout~=caption] p {
312+
margin-block-start: 0;
313+
margin-block-end: 0;
314+
color: var(--gray);
373315
}
374-
375-
/* mobile breakpoint */
376-
@media (max-width: 767px) {
377-
.callout[data-callout="caption_right"] {
378-
max-width: 50%;
379-
}
316+
.callout.callout[data-callout~=caption]:is([data-callout-metadata~=sban], [data-callout-metadata~=banner]) .image-embed img {
317+
width: 100%;
380318
}
381319

382320
/*----infobox callout----*/

0 commit comments

Comments
 (0)