diff --git a/_extensions/closeread/closeread.css b/_extensions/closeread/closeread.css index d2dc5f4..b900578 100644 --- a/_extensions/closeread/closeread.css +++ b/_extensions/closeread/closeread.css @@ -11,6 +11,11 @@ grid-template-rows: 1fr; background-color: var(--cr-section-background-color); } +.cr-section.cr-column-screen { + grid-column: screen-start/screen-end !important; + z-index: 998; + opacity: 0.999; +} .cr-section .narrative-col { grid-row: 1; font-family: var(--cr-narrative-font-family); diff --git a/_extensions/closeread/closeread.js b/_extensions/closeread/closeread.js index 4c71d72..5bfa88e 100644 --- a/_extensions/closeread/closeread.js +++ b/_extensions/closeread/closeread.js @@ -28,7 +28,15 @@ document.addEventListener("DOMContentLoaded", () => { document.body.classList.add("cr-removeheaderspace") } - // define ojs variables if the connector module is available + // attach layout classes to direct parents of `.cr-section`s + /* this replicates quarto <= 1.6 functionality: + https://github.com/quarto-dev/quarto-cli/blob/ + d85467627aae71c96e3d1e9718a3b47289329cde/src/format/html/ + format-html-bootstrap.ts#L1163C1-L1186C7 */ + const crSections = Array.from(document.querySelectorAll(".cr-section")) + crSections.map( + el => el.parentElement.classList.add("page-columns", "page-full")) + const ojsModule = window._ojs?.ojsConnector?.mainModule const ojsStickyName = ojsModule?.variable() const ojsTriggerIndex = ojsModule?.variable() diff --git a/_extensions/closeread/closeread.lua b/_extensions/closeread/closeread.lua index 539e5f6..f263498 100644 --- a/_extensions/closeread/closeread.lua +++ b/_extensions/closeread/closeread.lua @@ -118,10 +118,10 @@ function make_section_layout(div) end end - -- todo: identify quarto layout to use in section + -- todo: identify quarto layout to use in section --local quarto_layouts = {"column-body", "column-outset", "column-page", - -- "column-page-inset", "column-screen-inset", "column-margin"} - local quarto_layout = "column-screen" -- default + -- "column-page-inset", "column-screen-inset", "column-margin"} + local quarto_layout = "cr-column-screen" -- default --if list_includes_any(div.classes, quarto_layouts) then -- quarto_layout = "" --end diff --git a/_extensions/closeread/closeread.scss b/_extensions/closeread/closeread.scss index 5fd6c70..e75450a 100644 --- a/_extensions/closeread/closeread.scss +++ b/_extensions/closeread/closeread.scss @@ -17,6 +17,15 @@ grid-template-rows: 1fr; background-color: var(--cr-section-background-color); + // used to mimic quarto's layout class but exempt the section from some of the + // behaviours that come with quarto responding to that class + // see https://github.com/qmd-lab/closeread/issues/81 + &.cr-column-screen { + grid-column: screen-start / screen-end !important; + z-index: 998; + opacity: .999; + } + .narrative-col { grid-row: 1; diff --git a/docs/gallery/demos/sticky-blocks/index.qmd b/docs/gallery/demos/sticky-blocks/index.qmd new file mode 100644 index 0000000..c47a90a --- /dev/null +++ b/docs/gallery/demos/sticky-blocks/index.qmd @@ -0,0 +1,64 @@ +--- +title: Sticky Block Types +format: + closeread-html: + code-tools: true + toc: true +keep-md: true +--- + +Just about any type of element that can be included in a Quarto doc can be flagged as a sticky. This demo shows many examples. + +The current fix allows `.cr-section` to work, provided it's a "first level" child of the `main` content. For example: + +::::{.cr-section} + +This is an image that includes a caption. @cr-inline-working + +:::{#cr-inline-working} +This works: ![a caption](trees.png) +::: + +This does too! @cr-nocaption-working + +:::{#cr-nocaption-working} +![](trees.png) +::: + +Does this one, which has a caption but no content? @cr-caption-working + +:::{#cr-caption-working} +![Look at this tree!](trees.png) +::: + +:::: + +## This header becomes a section + +We've reimplemented `.column-screen` so that we can even make `.cr-section` work if you've used an `h2` (which puts parts of the doc inside a `section`): + +::::{.cr-section} + +This is an image that includes a caption. @cr-inline-working2 + +:::{#cr-inline-working2} +This works: ![a caption](trees.png) +::: + +This does too! @cr-nocaption-working2 + +:::{#cr-nocaption-working2} +![](trees.png) +::: + +Does this one, which has a caption but no content? @cr-caption-working2 + +:::{#cr-caption-working2} +![Look at this tree!](trees.png) +::: + +:::: + +## Another section + +{{< lipsum 1 >}} diff --git a/docs/gallery/demos/sticky-blocks/trees.png b/docs/gallery/demos/sticky-blocks/trees.png new file mode 100644 index 0000000..8b96752 Binary files /dev/null and b/docs/gallery/demos/sticky-blocks/trees.png differ