Skip to content

Commit 0102a0f

Browse files
committed
callout - better margins for collapsed and contentless callouts
1 parent 1cca2cf commit 0102a0f

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/resources/filters/customnodes/callout.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function _callout_main()
4040
-- the first heading is the title
4141
local div = pandoc.Div({})
4242
local c = quarto.utils.as_blocks(node.content)
43+
local has_content = #c > 0
4344
if pandoc.utils.type(c) == "Blocks" then
4445
div.content:extend(c)
4546
else
@@ -100,6 +101,10 @@ function _callout_main()
100101
local imgPlaceholder = pandoc.Plain({pandoc.RawInline("html", "<i class='callout-icon" .. noicon .. "'></i>")});
101102
local imgDiv = pandoc.Div({imgPlaceholder}, pandoc.Attr("", {"callout-icon-container"}));
102103

104+
if not has_content then
105+
calloutDiv.attr.classes:insert("callout-empty-content")
106+
end
107+
103108
-- show a titled callout
104109
if title ~= nil and (pandoc.utils.type(title) == "string" or next(title) ~= nil) then
105110

@@ -123,6 +128,7 @@ function _callout_main()
123128
local expandedAttrVal = "true"
124129
if collapse == "true" or collapse == true then
125130
expandedAttrVal = "false"
131+
headerDiv.attr.classes:insert("collapsed")
126132
end
127133

128134
-- create the collapse button

src/resources/formats/html/bootstrap/_bootstrap-rules.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,8 @@ kbd,
13811381
.callout.callout-style-simple .callout-body {
13821382
font-size: 0.9rem;
13831383
font-weight: 400;
1384+
margin-bottom: -0.4em;
1385+
margin-top: 0.5em;
13841386
}
13851387

13861388
.callout.callout-style-default .callout-body {
@@ -1397,6 +1399,15 @@ kbd,
13971399
margin-bottom: -0.2em;
13981400
}
13991401

1402+
.callout.callout-empty-content > .callout-header {
1403+
margin-bottom: 0em;
1404+
border-bottom-right-radius: add($border-radius, -1px);
1405+
}
1406+
1407+
.callout > .callout-header.collapsed {
1408+
border-bottom-right-radius: add($border-radius, -1px);
1409+
}
1410+
14001411
.callout.callout-style-simple > div.callout-header {
14011412
border-bottom: none;
14021413
font-size: 0.9rem;
@@ -1411,6 +1422,7 @@ kbd,
14111422
font-size: 0.9rem;
14121423
padding-left: 0.5em;
14131424
padding-right: 0.5em;
1425+
border-top-right-radius: add($border-radius, -1px);
14141426
}
14151427

14161428
.callout.callout-style-default .callout-body {

0 commit comments

Comments
 (0)