Skip to content

Commit 4b894e7

Browse files
committed
Port slide template updates from viz workshop.
1 parent a4425ac commit 4b894e7

File tree

2 files changed

+55
-4
lines changed

2 files changed

+55
-4
lines changed

slides/templates/larger_font/index.html.j2

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ a.anchor-link {
9797
width: 900px;
9898
height: 600px;
9999
}
100+
.jp-Collapser { /* hide that blue collapse button on the side of cells that does nothing */
101+
display: none;
102+
}
100103
.slide-number {
101104
background-color: transparent !important;
102105
color: black !important;
@@ -212,7 +215,8 @@ require(
212215
if (!isNaN(input)) {
213216
const requestedSlideNumber = Math.max(Math.min(input, slides.length) - 1, 0);
214217
const slideIndices = Reveal.getIndices(slides[requestedSlideNumber]);
215-
Reveal.slide(slideIndices.h, slideIndices.v, 100); // set fragment to large number to ensure the full slide is displayed
218+
// set fragment to large number to ensure the full slide is displayed
219+
Reveal.slide(slideIndices.h, slideIndices.v, 100);
216220
}
217221
else if (typeof input === "string" || input instanceof String) {
218222
const slideName = input.replaceAll(' ', '-');
@@ -292,6 +296,26 @@ require(
292296
() => { window.location = `#/${id}`; }
293297
);
294298
}
299+
300+
// fix any collisions in the clip-path introduced from reproducible SVG plots
301+
// that cause plot components not to render (clipPath objects with duplicate IDs)
302+
const clipPathIds = {};
303+
$('clipPath').each((index, element) => {
304+
const oldId = $(element).attr('id');
305+
if (oldId in clipPathIds) {
306+
// change this id and grab the parent SVG
307+
// and then for all the elements with clip-path switch the id
308+
const newId = `${oldId}${clipPathIds[oldId]}`;
309+
$(element).attr('id', newId);
310+
$(element).closest('svg').find('[clip-path]').each((index, item) => {
311+
if ($(item).attr('clip-path') === `url(#${oldId})`) {
312+
$(item).attr('clip-path', `url(#${newId})`);
313+
}
314+
});
315+
clipPathIds[oldId] += 1;
316+
}
317+
else clipPathIds[oldId] = 1;
318+
});
295319
}
296320
);
297321
</script>

slides/templates/regular/index.html.j2

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ a.anchor-link {
8686
.jp-RenderedHTMLCommon.jp-RenderedHTML.jp-OutputArea-output.jp-OutputArea-executeResult {
8787
padding-right: 5px !important; /* padding after lead-in text */
8888
}
89+
.jp-RenderedSVG > svg, .jp-OutputArea-output > svg { /* scale SVG plots */
90+
width: 75%;
91+
}
92+
.jp-Collapser { /* hide that blue collapse button on the side of cells that does nothing */
93+
display: none;
94+
}
8995
.CodeMirror pre {
9096
padding: 0.4em !important;
9197
overflow-x: scroll !important; /* allow scrolling to see full code block */
@@ -97,8 +103,8 @@ a.anchor-link {
97103
right: 5px !important;
98104
bottom: 5px !important;
99105
}
100-
.jp-RenderedSVG > svg, .jp-OutputArea-output > svg { /* scale SVG plots */
101-
width: 75%;
106+
.slides { /* pull slides to left */
107+
margin-left: -20px !important;
102108
}
103109
:root {
104110
--jp-ui-font-size1: 11.5px; /* size of tables in outputs */
@@ -203,7 +209,8 @@ require(
203209
if (!isNaN(input)) {
204210
const requestedSlideNumber = Math.max(Math.min(input, slides.length) - 1, 0);
205211
const slideIndices = Reveal.getIndices(slides[requestedSlideNumber]);
206-
Reveal.slide(slideIndices.h, slideIndices.v, 100); // set fragment to large number to ensure the full slide is displayed
212+
// set fragment to large number (100) to ensure the full slide is displayed
213+
Reveal.slide(slideIndices.h, slideIndices.v, 100);
207214
}
208215
else if (typeof input === "string" || input instanceof String) {
209216
const slideName = input.replaceAll(' ', '-');
@@ -285,6 +292,26 @@ require(
285292
() => { window.location = `#/${id}`; }
286293
);
287294
}
295+
296+
// fix any collisions in the clip-path introduced from reproducible SVG plots
297+
// that cause plot components not to render (clipPath objects with duplicate IDs)
298+
const clipPathIds = {};
299+
$('clipPath').each((index, element) => {
300+
const oldId = $(element).attr('id');
301+
if (oldId in clipPathIds) {
302+
// change this id and grab the parent SVG
303+
// and then for all the elements with clip-path switch the id
304+
const newId = `${oldId}${clipPathIds[oldId]}`;
305+
$(element).attr('id', newId);
306+
$(element).closest('svg').find('[clip-path]').each((index, item) => {
307+
if ($(item).attr('clip-path') === `url(#${oldId})`) {
308+
$(item).attr('clip-path', `url(#${newId})`);
309+
}
310+
});
311+
clipPathIds[oldId] += 1;
312+
}
313+
else clipPathIds[oldId] = 1;
314+
});
288315
}
289316
);
290317
</script>

0 commit comments

Comments
 (0)