Skip to content

Commit 03cf687

Browse files
Feat: Mobile-responsive callouts + txt-s adjustments (#89)
* adjust txt-s to target all descendants - also increase line-height slightly from 1rem to 1.2rem * Feat: mobile-responsive callouts + line-height fix - Callouts by default will have their `float` property unset on mobile, and will stretch to 100% width. - adding `|fixed` callout metadata will force a callout to maintain its float on mobile, for exceptional situations where it is important to float a (preferably small) element even with limited screen space (i.e., mobile). - adjustments to `txt-s` line-height for `<sup>` elements (i.e., footnotes) so they don't push line-height up. Slightly increased line-height as compromise to improve readability. Quartz-only; not needed for Obsidian. - reduced line-height of table `<td>` for infobox callouts - updated docs
1 parent 36ccc3f commit 03cf687

File tree

5 files changed

+55
-36
lines changed

5 files changed

+55
-36
lines changed

mmw-content/.obsidian/snippets/mmw-callout-adjustments.css

+10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111
margin-left: 8px;
1212
}
1313

14+
@media screen and (max-width: 767px) {
15+
.callout.callout.callout.callout[data-callout-metadata~=right]:not(.callout[data-callout-metadata~=fixed]), .callout.callout.callout.callout[data-callout-metadata~=left]:not(.callout[data-callout-metadata~=fixed]) {
16+
float: unset;
17+
margin: auto;
18+
width: 100%;
19+
max-width: 100%;
20+
/* floating callouts lose float and expand to full width on mobile */
21+
}
22+
}
23+
1424
.callout.callout.callout[data-callout-metadata~=center] {
1525
display: block;
1626
margin: auto;

mmw-content/.obsidian/snippets/mmw-infobox-callout.css

+1
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,5 @@
8585
padding-left: 12px;
8686
padding-right: 0px;
8787
vertical-align: top;
88+
line-height: 1.6rem;
8889
}

mmw-content/contributing/custom-formatting-features.md

+20-34
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ MMW borrows a large number of [Callout Adjustments](https://publish.obsidian.md/
7575
| Abbr. | Full Title | Description |
7676
| ------ | ----------------- | ----------------------------------------------------------- |
7777
| | `embed` | Remove callout padding to expand embed |
78-
| | `clean` | Remove callout Styling |
78+
| | `clean` | Remove callout styling |
7979
| | `collapse` | Remove all padding and margins for ultra compact look |
8080
| `nbrd` | `no-border` | Borderless callout |
8181
| | `clear` | Move any other floating elements near to under this callout |
@@ -91,15 +91,16 @@ MMW borrows a large number of [Callout Adjustments](https://publish.obsidian.md/
9191

9292
### Callout Positioning
9393

94-
| Attribute | Description |
95-
| --------- | -------------------------- |
96-
| `left` | Float callout to the left |
97-
| `right` | Float callout to the right |
98-
| `center` | Center the callout |
94+
| Attribute | Description |
95+
| --------- | ---------------------------------------------- |
96+
| `left` | Float callout to the left |
97+
| `right` | Float callout to the right |
98+
| `center` | Center the callout |
99+
| `fixed` | Maintains a callout's float position on mobile |
99100

100101
### Callout Sizing
101102

102-
Callouts can be resized using the keywords below.
103+
Callouts can be resized using the keywords below (sizing is the same as [[custom-formatting-features#SIRvb's Image Adjustments|SIRvb's Image Adjustments]])
103104

104105
The sizing is a percentage, relative to the callout's parent. Using `|wmed` as an example:
105106

@@ -108,33 +109,18 @@ The sizing is a percentage, relative to the callout's parent. Using `|wmed` as a
108109

109110
Sizing can be made to use pixels instead of percentage by adding `|static`.
110111

111-
> [!column|flex 2]
112-
>
113-
> > [!note|clean no-t]
114-
> >
115-
> > |Attributes|Callout Width `%`|Callout Width `px`|
116-
> > |---|:-:|:-:|
117-
> > |`wmicro`|10%|50px|
118-
> > |`wtiny`|20%|100px|
119-
> > |`wsmall`|30%|200px|
120-
> > |`ws-med`|40%|300px|
121-
> > |`wm-sm`|50%|400px|
122-
> > |`wmed`|60%|500px|
123-
> > |`wm-tl`|80%|600px|
124-
> > |`wtall`|95%|700px|
125-
> > |`wfull`|100%||
126-
> > |`wfit`|Auto|Auto|
127-
>
128-
> > [!note|clean no-t]
129-
> >
130-
> > > [!note] Add `|static` for sizing with pixels
131-
> > >
132-
> > > Callout sizing uses percentages by default. `|static` switches to pixels to use static sizing.
133-
> >
134-
> > > [!tip]
135-
> > >
136-
> > > Callout sizing is the same as [[custom-formatting-features#SIRvb's Image Adjustments|SIRvb's Image Adjustments]]
137-
112+
|Attributes|Callout Width `%`|Callout Width `px`|
113+
|---|:-:|:-:|
114+
|`wmicro`|10%|50px|
115+
|`wtiny`|20%|100px|
116+
|`wsmall`|30%|200px|
117+
|`ws-med`|40%|300px|
118+
|`wm-sm`|50%|400px|
119+
|`wmed`|60%|500px|
120+
|`wm-tl`|80%|600px|
121+
|`wtall`|95%|700px|
122+
|`wfull`|100%||
123+
|`wfit`|Auto|Auto|
138124

139125
---
140126

quartz/styles/custom/callout-adjustments.scss

+23-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
margin-left: 8px;
1717
}
1818

19+
@media screen and (max-width: $mobileBreakpoint) {
20+
.callout.callout.callout.callout[data-callout-metadata~=right]:not(.callout[data-callout-metadata~=fixed]), .callout.callout.callout.callout[data-callout-metadata~=left]:not(.callout[data-callout-metadata~=fixed]) {
21+
float: unset;
22+
margin: auto;
23+
width: 100%;
24+
max-width: 100%;
25+
/* floating callouts lose float and expand to full width on mobile */
26+
}
27+
}
28+
1929
.callout.callout.callout[data-callout-metadata~=center] {
2030
display: block;
2131
margin: auto;
@@ -214,9 +224,20 @@
214224
}
215225

216226
.callout.callout:is([data-callout-metadata~=text-small],
217-
[data-callout-metadata~=txt-s]) > .callout-content > * {
227+
[data-callout-metadata~=txt-s]) > .callout-content * {
218228
font-size: 0.8rem;
219-
line-height: 1rem;
229+
line-height: 1.3rem;
230+
}
231+
232+
.callout.callout.callout:is([data-callout-metadata~=text-small],
233+
[data-callout-metadata~=txt-s]) > .callout-content sup:has(a), .callout.callout.callout:is([data-callout-metadata~=text-small],
234+
[data-callout-metadata~=txt-s]) > .callout-content sup a {
235+
/* prevents sup elements like footnotes from pushing up line-height. Quartz-only; not needed for Obsidian */
236+
font-size: 0.6rem;
237+
line-height: 0;
238+
position: relative;
239+
vertical-align: baseline;
240+
top: -0.3em;
220241
}
221242

222243
.callout:is([data-callout-metadata~=n-th],

quartz/styles/custom/infobox-callout.scss

+1
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,5 @@
9393
padding-left: 12px;
9494
padding-right: 0px;
9595
vertical-align: top;
96+
line-height: 1.6rem;
9697
}

0 commit comments

Comments
 (0)