1<!DOCTYPE html> 2 3<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> 4 5<head> 6 <meta charset="utf-8"/> 7 <meta name="viewport" content="width=device-width, initial-scale=1"/> 8 <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/> 9 <meta name="generator" content="distill" /> 10 11 <style type="text/css"> 12 /* Hide doc at startup (prevent jankiness while JS renders/transforms) */ 13 body { 14 visibility: hidden; 15 } 16 </style> 17 18 <!--radix_placeholder_import_source--> 19 <!--/radix_placeholder_import_source--> 20 21<style type="text/css">code{white-space: pre;}</style> 22<style type="text/css" data-origin="pandoc"> 23pre > code.sourceCode { white-space: pre; position: relative; } 24pre > code.sourceCode > span { display: inline-block; line-height: 1.25; } 25pre > code.sourceCode > span:empty { height: 1.2em; } 26.sourceCode { overflow: visible; } 27code.sourceCode > span { color: inherit; text-decoration: inherit; } 28div.sourceCode { margin: 1em 0; } 29pre.sourceCode { margin: 0; } 30@media screen { 31div.sourceCode { overflow: auto; } 32} 33@media print { 34pre > code.sourceCode { white-space: pre-wrap; } 35pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; } 36} 37pre.numberSource code 38 { counter-reset: source-line 0; } 39pre.numberSource code > span 40 { position: relative; left: -4em; counter-increment: source-line; } 41pre.numberSource code > span > a:first-child::before 42 { content: counter(source-line); 43 position: relative; left: -1em; text-align: right; vertical-align: baseline; 44 border: none; display: inline-block; 45 -webkit-touch-callout: none; -webkit-user-select: none; 46 -khtml-user-select: none; -moz-user-select: none; 47 -ms-user-select: none; user-select: none; 48 padding: 0 4px; width: 4em; 49 color: #aaaaaa; 50 } 51pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; } 52div.sourceCode 53 { } 54@media screen { 55pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; } 56} 57code span.al { color: #ad0000; } /* Alert */ 58code span.an { color: #5e5e5e; } /* Annotation */ 59code span.at { color: #20794d; } /* Attribute */ 60code span.bn { color: #ad0000; } /* BaseN */ 61code span.bu { } /* BuiltIn */ 62code span.cf { color: #007ba5; } /* ControlFlow */ 63code span.ch { color: #20794d; } /* Char */ 64code span.cn { color: #8f5902; } /* Constant */ 65code span.co { color: #5e5e5e; } /* Comment */ 66code span.cv { color: #5e5e5e; font-style: italic; } /* CommentVar */ 67code span.do { color: #5e5e5e; font-style: italic; } /* Documentation */ 68code span.dt { color: #ad0000; } /* DataType */ 69code span.dv { color: #ad0000; } /* DecVal */ 70code span.er { color: #ad0000; } /* Error */ 71code span.ex { } /* Extension */ 72code span.fl { color: #ad0000; } /* Float */ 73code span.fu { color: #4758ab; } /* Function */ 74code span.im { } /* Import */ 75code span.in { color: #5e5e5e; } /* Information */ 76code span.kw { color: #007ba5; } /* Keyword */ 77code span.op { color: #5e5e5e; } /* Operator */ 78code span.ot { color: #007ba5; } /* Other */ 79code span.pp { color: #ad0000; } /* Preprocessor */ 80code span.sc { color: #20794d; } /* SpecialChar */ 81code span.ss { color: #20794d; } /* SpecialString */ 82code span.st { color: #20794d; } /* String */ 83code span.va { color: #111111; } /* Variable */ 84code span.vs { color: #20794d; } /* VerbatimString */ 85code span.wa { color: #5e5e5e; font-style: italic; } /* Warning */ 86</style> 87 88 <!--radix_placeholder_meta_tags--> 89<title>Elizabeth Stanny: Create a banner and buttons with R</title> 90 91<meta property="description" itemprop="description" content="with a few lines of code."/> 92 93<link rel="canonical" href="https://estannydotcom.netlify.com/posts/create-a-banner-and-buttons-with-r/"/> 94 95<!-- https://schema.org/Article --> 96<meta property="article:published" itemprop="datePublished" content="2021-06-07"/> 97<meta property="article:created" itemprop="dateCreated" content="2021-06-07"/> 98 99<!-- https://developers.facebook.com/docs/sharing/webmasters#markup --> 100<meta property="og:title" content="Elizabeth Stanny: Create a banner and buttons with R"/> 101<meta property="og:type" content="article"/> 102<meta property="og:description" content="with a few lines of code."/> 103<meta property="og:url" content="https://estannydotcom.netlify.com/posts/create-a-banner-and-buttons-with-r/"/> 104<meta property="og:image" content="https://estannydotcom.netlify.com/posts/create-a-banner-and-buttons-with-r/index_files/figure-html5/unnamed-chunk-3-1.png"/> 105<meta property="og:image:width" content="1248"/> 106<meta property="og:image:height" content="768"/> 107<meta property="og:locale" content="en_US"/> 108<meta property="og:site_name" content="Elizabeth Stanny"/> 109 110<!-- https://dev.twitter.com/cards/types/summary --> 111<meta property="twitter:card" content="summary_large_image"/> 112<meta property="twitter:title" content="Elizabeth Stanny: Create a banner and buttons with R"/> 113<meta property="twitter:description" content="with a few lines of code."/> 114<meta property="twitter:url" content="https://estannydotcom.netlify.com/posts/create-a-banner-and-buttons-with-r/"/> 115<meta property="twitter:image" content="https://estannydotcom.netlify.com/posts/create-a-banner-and-buttons-with-r/index_files/figure-html5/unnamed-chunk-3-1.png"/> 116<meta property="twitter:image:width" content="1248"/> 117<meta property="twitter:image:height" content="768"/> 118 119<!--/radix_placeholder_meta_tags--> 120 <!--radix_placeholder_rmarkdown_metadata--> 121
122<script type="text/json" id="radix-rmarkdown-metadata"> 123{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["title","description","date","output","preview","categories","citation_url","canonical_url"]}},"value":[{"type":"character","attributes":{},"value":["Create a banner and buttons with R"]},{"type":"character","attributes":{},"value":["with a few lines of code."]},{"type":"character","attributes":{},"value":["06-07-2021"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["distill::distill_article"]}},"value":[{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["toc","self_contained","highlight","highlight_downlit"]}},"value":[{"type":"logical","attributes":{},"value":[false]},{"type":"logical","attributes":{},"value":[false]},{"type":"character","attributes":{},"value":["default"]},{"type":"logical","attributes":{},"value":[true]}]}]},{"type":"character","attributes":{},"value":["preview.png"]},{"type":"character","attributes":{},"value":["jasmines","tidyverse","magick"]},{"type":"character","attributes":{},"value":["https://estannydotcom.netlify.com/posts/create-a-banner-and-buttons-with-r/"]},{"type":"character","attributes":{},"value":["https://estannydotcom.netlify.com/posts/create-a-banner-and-buttons-with-r/"]}]} 124</script>
124 125<!--/radix_placeholder_rmarkdown_metadata--> 126 127
127<script type="text/json" id="radix-resource-manifest"> 128 {"type":"character","attributes":{},"value":["audit_banner.png","banner.png","index_files/anchor-4.2.2/anchor.min.js","index_files/bowser-1.9.3/bowser.min.js","index_files/distill-2.2.21/template.v2.js","index_files/figure-html5/unnamed-chunk-10-1.png","index_files/figure-html5/unnamed-chunk-3-1.png","index_files/figure-html5/unnamed-chunk-6-1.png","index_files/figure-html5/unnamed-chunk-8-1.png","index_files/figure-html5/unnamed-chunk-9-1.png","index_files/header-attrs-2.8/header-attrs.js","index_files/jquery-1.11.3/jquery.min.js","index_files/popper-2.6.0/popper.min.js","index_files/tippy-6.2.7/tippy-bundle.umd.min.js","index_files/tippy-6.2.7/tippy-light-border.css","index_files/tippy-6.2.7/tippy.css","index_files/tippy-6.2.7/tippy.umd.min.js","index_files/webcomponents-2.0.0/webcomponents.js"]} 129 </script>
129 130 <!--radix_placeholder_navigation_in_header--> 131<meta name="distill:offset" content="../.."/> 132
133<script type="application/javascript"> 134 135 window.headroom_prevent_pin = false; 136 137 window.document.addEventListener("DOMContentLoaded", function (event) { 138 139 // initialize headroom for banner 140 var header = $('header').get(0); 141 var headerHeight = header.offsetHeight; 142 var headroom = new Headroom(header, { 143 tolerance: 5, 144 onPin : function() { 145 if (window.headroom_prevent_pin) { 146 window.headroom_prevent_pin = false; 147 headroom.unpin(); 148 } 149 } 150 }); 151 headroom.init(); 152 if(window.location.hash) 153 headroom.unpin(); 154 $(header).addClass('headroom--transition'); 155 156 // offset scroll location for banner on hash change 157 // (see: https://github.com/WickyNilliams/headroom.js/issues/38) 158 window.addEventListener("hashchange", function(event) { 159 window.scrollTo(0, window.pageYOffset - (headerHeight + 25)); 160 }); 161 162 // responsive menu 163 $('.distill-site-header').each(function(i, val) { 164 var topnav = $(this); 165 var toggle = topnav.find('.nav-toggle'); 166 toggle.on('click', function() { 167 topnav.toggleClass('responsive'); 168 }); 169 }); 170 171 // nav dropdowns 172 $('.nav-dropbtn').click(function(e) { 173 $(this).next('.nav-dropdown-content').toggleClass('nav-dropdown-active'); 174 $(this).parent().siblings('.nav-dropdown') 175 .children('.nav-dropdown-content').removeClass('nav-dropdown-active'); 176 }); 177 $("body").click(function(e){ 178 $('.nav-dropdown-content').removeClass('nav-dropdown-active'); 179 }); 180 $(".nav-dropdown").click(function(e){ 181 e.stopPropagation(); 182 }); 183 }); 184</script>
184 185 186<style type="text/css"> 187 188/* Theme (user-documented overrideables for nav appearance) */ 189 190.distill-site-nav { 191 color: rgba(255, 255, 255, 0.8); 192 background-color: #0F2E3D; 193 font-size: 15px; 194 font-weight: 300; 195} 196 197.distill-site-nav a { 198 color: inherit; 199 text-decoration: none; 200} 201 202.distill-site-nav a:hover { 203 color: white; 204} 205 206@media print { 207 .distill-site-nav { 208 display: none; 209 } 210} 211 212.distill-site-header { 213 214} 215 216.distill-site-footer { 217 218} 219 220 221/* Site Header */ 222 223.distill-site-header { 224 width: 100%; 225 box-sizing: border-box; 226 z-index: 3; 227} 228 229.distill-site-header .nav-left { 230 display: inline-block; 231 margin-left: 8px; 232} 233 234@media screen and (max-width: 768px) { 235 .distill-site-header .nav-left { 236 margin-left: 0; 237 } 238} 239 240 241.distill-site-header .nav-right { 242 float: right; 243 margin-right: 8px; 244} 245 246.distill-site-header a, 247.distill-site-header .title { 248 display: inline-block; 249 text-align: center; 250 padding: 14px 10px 14px 10px; 251} 252 253.distill-site-header .title { 254 font-size: 18px; 255 min-width: 150px; 256} 257 258.distill-site-header .logo { 259 padding: 0; 260} 261 262.distill-site-header .logo img { 263 display: none; 264 max-height: 20px; 265 width: auto; 266 margin-bottom: -4px; 267} 268 269.distill-site-header .nav-image img { 270 max-height: 18px; 271 width: auto; 272 display: inline-block; 273 margin-bottom: -3px; 274} 275 276 277 278@media screen and (min-width: 1000px) { 279 .distill-site-header .logo img { 280 display: inline-block; 281 } 282 .distill-site-header .nav-left { 283 margin-left: 20px; 284 } 285 .distill-site-header .nav-right { 286 margin-right: 20px; 287 } 288 .distill-site-header .title { 289 padding-left: 12px; 290 } 291} 292 293 294.distill-site-header .nav-toggle { 295 display: none; 296} 297 298.nav-dropdown { 299 display: inline-block; 300 position: relative; 301} 302 303.nav-dropdown .nav-dropbtn { 304 border: none; 305 outline: none; 306 color: rgba(255, 255, 255, 0.8); 307 padding: 16px 10px; 308 background-color: transparent; 309 font-family: inherit; 310 font-size: inherit; 311 font-weight: inherit; 312 margin: 0;
313 margin-top: 1px; 314 z-index: 2; 315} 316 317.nav-dropdown-content { 318 display: none; 319 position: absolute; 320 background-color: white; 321 min-width: 200px; 322 border: 1px solid rgba(0,0,0,0.15); 323 border-radius: 4px; 324 box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.1); 325 z-index: 1; 326 margin-top: 2px; 327 white-space: nowrap; 328 padding-top: 4px; 329 padding-bottom: 4px; 330} 331 332.nav-dropdown-content hr { 333 margin-top: 4px; 334 margin-bottom: 4px; 335 border: none; 336 border-bottom: 1px solid rgba(0, 0, 0, 0.1); 337} 338 339.nav-dropdown-active { 340 display: block; 341} 342 343.nav-dropdown-content a, .nav-dropdown-content .nav-dropdown-header { 344 color: black; 345 padding: 6px 24px; 346 text-decoration: none; 347 display: block; 348 text-align: left; 349} 350 351.nav-dropdown-content .nav-dropdown-header { 352 display: block; 353 padding: 5px 24px; 354 padding-bottom: 0; 355 text-transform: uppercase; 356 font-size: 14px; 357 color: #999999; 358 white-space: nowrap; 359} 360 361.nav-dropdown:hover .nav-dropbtn { 362 color: white; 363} 364 365.nav-dropdown-content a:hover { 366 background-color: #ddd; 367 color: black; 368} 369 370.nav-right .nav-dropdown-content { 371 margin-left: -45%; 372 right: 0; 373} 374 375@media screen and (max-width: 768px) { 376 .distill-site-header a, .distill-site-header .nav-dropdown {display: none;} 377 .distill-site-header a.nav-toggle { 378 float: right; 379 display: block; 380 } 381 .distill-site-header .title { 382 margin-left: 0; 383 } 384 .distill-site-header .nav-right { 385 margin-right: 0; 386 } 387 .distill-site-header { 388 overflow: hidden; 389 } 390 .nav-right .nav-dropdown-content { 391 margin-left: 0; 392 } 393} 394 395 396@media screen and (max-width: 768px) { 397 .distill-site-header.responsive {position: relative; min-height: 500px; } 398 .distill-site-header.responsive a.nav-toggle { 399 position: absolute; 400 right: 0; 401 top: 0; 402 } 403 .distill-site-header.responsive a, 404 .distill-site-header.responsive .nav-dropdown { 405 display: block; 406 text-align: left; 407 } 408 .distill-site-header.responsive .nav-left, 409 .distill-site-header.responsive .nav-right { 410 width: 100%; 411 } 412 .distill-site-header.responsive .nav-dropdown {float: none;} 413 .distill-site-header.responsive .nav-dropdown-content {position: relative;} 414 .distill-site-header.responsive .nav-dropdown .nav-dropbtn { 415 display: block; 416 width: 100%; 417 text-align: left; 418 } 419} 420 421/* Site Footer */ 422 423.distill-site-footer { 424 width: 100%; 425 overflow: hidden; 426 box-sizing: border-box; 427 z-index: 3; 428 margin-top: 30px; 429 padding-top: 30px; 430 padding-bottom: 30px; 431 text-align: center; 432} 433 434/* Headroom */ 435 436d-title { 437 padding-top: 6rem; 438} 439 440@media print { 441 d-title { 442 padding-top: 4rem; 443 } 444} 445 446.headroom { 447 z-index: 1000; 448 position: fixed; 449 top: 0; 450 left: 0; 451 right: 0; 452} 453 454.headroom--transition { 455 transition: all .4s ease-in-out; 456} 457 458.headroom--unpinned { 459 top: -100px; 460} 461 462.headroom--pinned { 463 top: 0; 464} 465 466/* adjust viewport for navbar height */ 467/* helps vertically center bootstrap (non-distill) content */ 468.min-vh-100 { 469 min-height: calc(100vh - 100px) !important; 470} 471 472</style> 473
474<script src="../../site_libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
474 475<link href="../../site_libs/font-awesome-5.1.0/css/all.css" rel="stylesheet"/> 476<link href="../../site_libs/font-awesome-5.1.0/css/v4-shims.css" rel="stylesheet"/>
477<script src="../../site_libs/headroom-0.9.4/headroom.min.js"></script>
vendor: 1 bytes, line 477
477
478<script src="../../site_libs/autocomplete-0.37.1/autocomplete.min.js"></script>
vendor: 1 bytes, line 478
478
479<script src="../../site_libs/fuse-6.4.1/fuse.min.js"></script>
479 480
481<script type="application/javascript"> 482 483function getMeta(metaName) { 484 var metas = document.getElementsByTagName('meta'); 485 for (let i = 0; i < metas.length; i++) { 486 if (metas[i].getAttribute('name') === metaName) { 487 return metas[i].getAttribute('content'); 488 } 489 } 490 return ''; 491} 492 493function offsetURL(url) { 494 var offset = getMeta('distill:offset'); 495 return offset ? offset + '/' + url : url; 496} 497 498function createFuseIndex() { 499 500 // create fuse index 501 var options = { 502 keys: [ 503 { name: 'title', weight: 20 }, 504 { name: 'categories', weight: 15 }, 505 { name: 'description', weight: 10 }, 506 { name: 'contents', weight: 5 }, 507 ], 508 ignoreLocation: true, 509 threshold: 0 510 }; 511 var fuse = new window.Fuse([], options); 512 513 // fetch the main search.json 514 return fetch(offsetURL('search.json')) 515 .then(function(response) { 516 if (response.status == 200) { 517 return response.json().then(function(json) { 518 // index main articles 519 json.articles.forEach(function(article) { 520 fuse.add(article); 521 }); 522 // download collections and index their articles 523 return Promise.all(json.collections.map(function(collection) { 524 return fetch(offsetURL(collection)).then(function(response) { 525 if (response.status === 200) { 526 return response.json().then(function(articles) { 527 articles.forEach(function(article) { 528 fuse.add(article); 529 }); 530 }) 531 } else { 532 return Promise.reject( 533 new Error('Unexpected status from search index request: ' + 534 response.status) 535 ); 536 } 537 }); 538 })).then(function() { 539 return fuse; 540 }); 541 }); 542 543 } else { 544 return Promise.reject( 545 new Error('Unexpected status from search index request: ' + 546 response.status) 547 ); 548 } 549 }); 550} 551 552window.document.addEventListener("DOMContentLoaded", function (event) { 553 554 // get search element (bail if we don't have one) 555 var searchEl = window.document.getElementById('distill-search'); 556 if (!searchEl) 557 return; 558 559 createFuseIndex() 560 .then(function(fuse) { 561 562 // make search box visible 563 searchEl.classList.remove('hidden'); 564 565 // initialize autocomplete 566 var options = { 567 autoselect: true, 568 hint: false, 569 minLength: 2, 570 }; 571 window.autocomplete(searchEl, options, [{ 572 source: function(query, callback) { 573 const searchOptions = { 574 isCaseSensitive: false, 575 shouldSort: true, 576 minMatchCharLength: 2, 577 limit: 10, 578 }; 579 var results = fuse.search(query, searchOptions); 580 callback(results 581 .map(function(result) { return result.item; }) 582 ); 583 }, 584 templates: { 585 suggestion: function(suggestion) { 586 var img = suggestion.preview && Object.keys(suggestion.preview).length > 0 587 ? `<img src="${offsetURL(suggestion.preview)}"</img>` 588 : ''; 589 var html = ` 590 <div class="search-item"> 591 <h3>${suggestion.title}</h3> 592 <div class="search-item-description"> 593 ${suggestion.description || ''} 594 </div> 595 <div class="search-item-preview"> 596 ${img} 597 </div> 598 </div> 599 `; 600 return html; 601 } 602 } 603 }]).on('autocomplete:selected', function(event, suggestion) { 604 window.location.href = offsetURL(suggestion.path); 605 }); 606 // remove inline display style on autocompleter (we want to 607 // manage responsive display via css) 608 $('.algolia-autocomplete').css("display", ""); 609 }) 610 .catch(function(error) { 611 console.log(error); 612 }); 613 614}); 615 616</script>
616 617 618<style type="text/css"> 619 620.nav-search { 621 font-size: x-small; 622} 623 624/* Algolioa Autocomplete */ 625 626.algolia-autocomplete { 627 display: inline-block; 628 margin-left: 10px; 629 vertical-align: sub; 630 background-color: white; 631 color: black; 632 padding: 6px; 633 padding-top: 8px; 634 padding-bottom: 0; 635 border-radius: 6px; 636 border: 1px #0F2E3D solid; 637 width: 180px; 638} 639 640 641@media screen and (max-width: 768px) { 642 .distill-site-nav .algolia-autocomplete { 643 display: none; 644 visibility: hidden; 645 } 646 .distill-site-nav.responsive .algolia-autocomplete { 647 display: inline-block; 648 visibility: visible; 649 } 650 .distill-site-nav.responsive .algolia-autocomplete .aa-dropdown-menu { 651 margin-left: 0; 652 width: 400px; 653 max-height: 400px; 654 } 655} 656 657.algolia-autocomplete .aa-input, .algolia-autocomplete .aa-hint { 658 width: 90%; 659 outline: none; 660 border: none; 661} 662 663.algolia-autocomplete .aa-hint { 664 color: #999; 665} 666.algolia-autocomplete .aa-dropdown-menu { 667 width: 550px; 668 max-height: 70vh; 669 overflow-x: visible; 670 overflow-y: scroll; 671 padding: 5px; 672 margin-top: 3px; 673 margin-left: -150px; 674 background-color: #fff; 675 border-radius: 5px; 676 border: 1px solid #999; 677 border-top: none; 678} 679 680.algolia-autocomplete .aa-dropdown-menu .aa-suggestion { 681 cursor: pointer; 682 padding: 5px 4px; 683 border-bottom: 1px solid #eee; 684} 685 686.algolia-autocomplete .aa-dropdown-menu .aa-suggestion:last-of-type { 687 border-bottom: none; 688 margin-bottom: 2px; 689} 690 691.algolia-autocomplete .aa-dropdown-menu .aa-suggestion .search-item { 692 overflow: hidden; 693 font-size: 0.8em; 694 line-height: 1.4em; 695} 696 697.algolia-autocomplete .aa-dropdown-menu .aa-suggestion .search-item h3 { 698 font-size: 1rem; 699 margin-block-start: 0; 700 margin-block-end: 5px; 701} 702 703.algolia-autocomplete .aa-dropdown-menu .aa-suggestion .search-item-description { 704 display: inline-block; 705 overflow: hidden; 706 height: 2.8em; 707 width: 80%; 708 margin-right: 4%; 709} 710 711.algolia-autocomplete .aa-dropdown-menu .aa-suggestion .search-item-preview { 712 display: inline-block; 713 width: 15%; 714} 715 716.algolia-autocomplete .aa-dropdown-menu .aa-suggestion .search-item-preview img { 717 height: 3em; 718 width: auto; 719 display: none; 720} 721 722.algolia-autocomplete .aa-dropdown-menu .aa-suggestion .search-item-preview img[src] { 723 display: initial; 724} 725 726.algolia-autocomplete .aa-dropdown-menu .aa-suggestion.aa-cursor { 727 background-color: #eee; 728} 729.algolia-autocomplete .aa-dropdown-menu .aa-suggestion em { 730 font-weight: bold; 731 font-style: normal; 732} 733 734</style> 735 736 737<!--/radix_placeholder_navigation_in_header--> 738 <!--radix_placeholder_distill--> 739 740<style type="text/css"> 741 742body { 743 background-color: white; 744} 745 746.pandoc-table { 747 width: 100%; 748} 749 750.pandoc-table>caption { 751 margin-bottom: 10px; 752} 753 754.pandoc-table th:not([align]) { 755 text-align: left; 756} 757 758.pagedtable-footer { 759 font-size: 15px; 760} 761 762d-byline .byline { 763 grid-template-columns: 2fr 2fr; 764} 765 766d-byline .byline h3 { 767 margin-block-start: 1.5em; 768} 769 770d-byline .byline .authors-affiliations h3 { 771 margin-block-start: 0.5em; 772} 773 774.authors-affiliations .orcid-id { 775 width: 16px; 776 height:16px; 777 margin-left: 4px; 778 margin-right: 4px; 779 vertical-align: middle; 780 padding-bottom: 2px; 781} 782 783d-title .dt-tags { 784 margin-top: 1em; 785 grid-column: text; 786} 787 788.dt-tags .dt-tag { 789 text-decoration: none; 790 display: inline-block; 791 color: rgba(0,0,0,0.6); 792 padding: 0em 0.4em; 793 margin-right: 0.5em; 794 margin-bottom: 0.4em; 795 font-size: 70%; 796 border: 1px solid rgba(0,0,0,0.2); 797 border-radius: 3px; 798 text-transform: uppercase; 799 font-weight: 500; 800} 801 802d-article table.gt_table td, 803d-article table.gt_table th { 804 border-bottom: none; 805 font-size: 100%; 806} 807 808.html-widget { 809 margin-bottom: 2.0em; 810} 811 812.l-screen-inset { 813 padding-right: 16px; 814} 815 816.l-screen .caption { 817 margin-left: 10px; 818} 819 820.shaded { 821 background: rgb(247, 247, 247); 822 padding-top: 20px; 823 padding-bottom: 20px; 824 border-top: 1px solid rgba(0, 0, 0, 0.1); 825 border-bottom: 1px solid rgba(0, 0, 0, 0.1); 826} 827 828.shaded .html-widget { 829 margin-bottom: 0; 830 border: 1px solid rgba(0, 0, 0, 0.1); 831} 832 833.shaded .shaded-content { 834 background: white; 835} 836 837.text-output { 838 margin-top: 0; 839 line-height: 1.5em; 840} 841 842.hidden { 843 display: none !important; 844} 845 846d-article { 847 padding-top: 2.5rem; 848 padding-bottom: 30px; 849} 850 851d-appendix { 852 padding-top: 30px; 853} 854 855d-article>p>img { 856 width: 100%; 857} 858 859d-article h2 { 860 margin: 1rem 0 1.5rem 0; 861} 862 863d-article h3 { 864 margin-top: 1.5rem; 865} 866 867d-article iframe { 868 border: 1px solid rgba(0, 0, 0, 0.1); 869 margin-bottom: 2.0em; 870 width: 100%; 871} 872 873/* Tweak code blocks */ 874 875d-article div.sourceCode code, 876d-article pre code {
877 font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; 878} 879 880d-article pre, 881d-article div.sourceCode, 882d-article div.sourceCode pre { 883 overflow: auto; 884} 885 886d-article div.sourceCode { 887 background-color: white; 888} 889 890d-article div.sourceCode pre { 891 padding-left: 10px; 892 font-size: 12px; 893 border-left: 2px solid rgba(0,0,0,0.1); 894} 895 896d-article pre { 897 font-size: 12px; 898 color: black; 899 background: none; 900 margin-top: 0; 901 text-align: left; 902 white-space: pre; 903 word-spacing: normal; 904 word-break: normal; 905 word-wrap: normal; 906 line-height: 1.5; 907 908 -moz-tab-size: 4; 909 -o-tab-size: 4; 910 tab-size: 4; 911 912 -webkit-hyphens: none; 913 -moz-hyphens: none; 914 -ms-hyphens: none; 915 hyphens: none; 916} 917 918d-article pre a { 919 border-bottom: none; 920} 921 922d-article pre a:hover { 923 border-bottom: none; 924 text-decoration: underline; 925} 926 927d-article details { 928 grid-column: text; 929 margin-bottom: 0.8em; 930} 931 932@media(min-width: 768px) { 933 934d-article pre, 935d-article div.sourceCode, 936d-article div.sourceCode pre { 937 overflow: visible !important; 938} 939 940d-article div.sourceCode pre { 941 padding-left: 18px; 942 font-size: 14px; 943} 944 945d-article pre { 946 font-size: 14px; 947} 948 949} 950 951figure img.external { 952 background: white; 953 border: 1px solid rgba(0, 0, 0, 0.1); 954 box-shadow: 0 1px 8px rgba(0, 0, 0, 0.1); 955 padding: 18px; 956 box-sizing: border-box; 957} 958 959/* CSS for d-contents */ 960 961.d-contents { 962 grid-column: text; 963 color: rgba(0,0,0,0.8); 964 font-size: 0.9em; 965 padding-bottom: 1em; 966 margin-bottom: 1em; 967 padding-bottom: 0.5em; 968 margin-bottom: 1em; 969 padding-left: 0.25em; 970 justify-self: start; 971} 972 973@media(min-width: 1000px) { 974 .d-contents.d-contents-float { 975 height: 0; 976 grid-column-start: 1; 977 grid-column-end: 4; 978 justify-self: center; 979 padding-right: 3em; 980 padding-left: 2em; 981 } 982} 983 984.d-contents nav h3 { 985 font-size: 18px; 986 margin-top: 0; 987 margin-bottom: 1em; 988} 989 990.d-contents li { 991 list-style-type: none 992} 993 994.d-contents nav > ul { 995 padding-left: 0; 996} 997 998.d-contents ul { 999 padding-left: 1em 1000} 1001 1002.d-contents nav ul li { 1003 margin-top: 0.6em; 1004 margin-bottom: 0.2em; 1005} 1006 1007.d-contents nav a { 1008 font-size: 13px; 1009 border-bottom: none; 1010 text-decoration: none 1011 color: rgba(0, 0, 0, 0.8); 1012} 1013 1014.d-contents nav a:hover { 1015 text-decoration: underline solid rgba(0, 0, 0, 0.6) 1016} 1017 1018.d-contents nav > ul > li > a { 1019 font-weight: 600; 1020} 1021 1022.d-contents nav > ul > li > ul { 1023 font-weight: inherit; 1024} 1025 1026.d-contents nav > ul > li > ul > li { 1027 margin-top: 0.2em; 1028} 1029 1030 1031.d-contents nav ul { 1032 margin-top: 0; 1033 margin-bottom: 0.25em; 1034} 1035 1036.d-article-with-toc h2:nth-child(2) { 1037 margin-top: 0; 1038} 1039 1040 1041/* Figure */ 1042 1043.figure { 1044 position: relative; 1045 margin-bottom: 2.5em; 1046 margin-top: 1.5em; 1047} 1048 1049.figure .caption { 1050 color: rgba(0, 0, 0, 0.6); 1051 font-size: 12px; 1052 line-height: 1.5em; 1053} 1054 1055.figure img.external { 1056 background: white; 1057 border: 1px solid rgba(0, 0, 0, 0.1); 1058 box-shadow: 0 1px 8px rgba(0, 0, 0, 0.1); 1059 padding: 18px; 1060 box-sizing: border-box; 1061} 1062 1063.figure .caption a { 1064 color: rgba(0, 0, 0, 0.6); 1065} 1066 1067.figure .caption b, 1068.figure .caption strong, { 1069 font-weight: 600; 1070 color: rgba(0, 0, 0, 1.0); 1071} 1072 1073/* Citations */ 1074 1075d-article .citation { 1076 color: inherit; 1077 cursor: inherit; 1078} 1079 1080div.hanging-indent{ 1081 margin-left: 1em; text-indent: -1em; 1082} 1083 1084/* Citation hover box */ 1085 1086.tippy-box[data-theme~=light-border] { 1087 background-color: rgba(250, 250, 250, 0.95); 1088} 1089 1090.tippy-content > p { 1091 margin-bottom: 0; 1092 padding: 2px; 1093} 1094 1095 1096/* Tweak 1000px media break to show more text */ 1097 1098@media(min-width: 1000px) { 1099 .base-grid, 1100 distill-header, 1101 d-title, 1102 d-abstract, 1103 d-article, 1104 d-appendix, 1105 distill-appendix, 1106 d-byline, 1107 d-footnote-list, 1108 d-citation-list, 1109 distill-footer { 1110 grid-template-columns: [screen-start] 1fr [page-start kicker-start] 80px [middle-start] 50px [text-start kicker-end] 65px 65px 65px 65px 65px 65px 65px 65px [text-end gutter-start] 65px [middle-end] 65px [page-end gutter-end] 1fr [screen-end]; 1111 grid-column-gap: 16px; 1112 } 1113 1114 .grid { 1115 grid-column-gap: 16px; 1116 } 1117 1118 d-article { 1119 font-size: 1.06rem; 1120 line-height: 1.7em; 1121 } 1122 figure .caption, .figure .caption, figure figcaption { 1123 font-size: 13px; 1124 } 1125} 1126 1127@media(min-width: 1180px) { 1128 .base-grid, 1129 distill-header, 1130 d-title, 1131 d-abstract, 1132 d-article, 1133 d-appendix, 1134 distill-appendix, 1135 d-byline, 1136 d-footnote-list, 1137 d-citation-list, 1138 distill-footer { 1139 grid-template-columns: [screen-start] 1fr [page-start kicker-start] 60px [middle-start] 60px [text-start kicker-end] 60px 60px 60px 60px 60px 60px 60px 60px [text-end gutter-start] 60px [middle-end] 60px [page-end gutter-end] 1fr [screen-end]; 1140 grid-column-gap: 32px; 1141 } 1142 1143 .grid { 1144 grid-column-gap: 32px; 1145 } 1146} 1147 1148 1149/* Get the citation styles for the appendix (not auto-injected on render since 1150 we do our own rendering of the citation appendix) */ 1151 1152d-appendix .citation-appendix, 1153.d-appendix .citation-appendix { 1154 font-size: 11px; 1155 line-height: 15px; 1156 border-left: 1px solid rgba(0, 0, 0, 0.1); 1157 padding-left: 18px; 1158 border: 1px solid rgba(0,0,0,0.1); 1159 background: rgba(0, 0, 0, 0.02); 1160 padding: 10px 18px; 1161 border-radius: 3px; 1162 color: rgba(150, 150, 150, 1); 1163 overflow: hidden; 1164 margin-top: -12px; 1165 white-space: pre-wrap; 1166 word-wrap: break-word; 1167} 1168 1169/* Include appendix styles here so they can be overridden */ 1170 1171d-appendix { 1172 contain: layout style; 1173 font-size: 0.8em; 1174 line-height: 1.7em; 1175 margin-top: 60px; 1176 margin-bottom: 0; 1177 border-top: 1px solid rgba(0, 0, 0, 0.1); 1178 color: rgba(0,0,0,0.5); 1179 padding-top: 60px; 1180 padding-bottom: 48px; 1181} 1182 1183d-appendix h3 { 1184 grid-column: page-start / text-start; 1185 font-size: 15px; 1186 font-weight: 500; 1187 margin-top: 1em; 1188 margin-bottom: 0; 1189 color: rgba(0,0,0,0.65); 1190} 1191 1192d-appendix h3 + * { 1193 margin-top: 1em; 1194} 1195 1196d-appendix ol { 1197 padding: 0 0 0 15px; 1198} 1199 1200@media (min-width: 768px) { 1201 d-appendix ol { 1202 padding: 0 0 0 30px; 1203 margin-left: -30px; 1204 } 1205} 1206 1207d-appendix li { 1208 margin-bottom: 1em; 1209} 1210 1211d-appendix a { 1212 color: rgba(0, 0, 0, 0.6); 1213} 1214 1215d-appendix > * { 1216 grid-column: text; 1217} 1218 1219d-appendix > d-footnote-list, 1220d-appendix > d-citation-list, 1221d-appendix > distill-appendix { 1222 grid-column: screen; 1223} 1224 1225/* Include footnote styles here so they can be overridden */ 1226 1227d-footnote-list { 1228 contain: layout style; 1229} 1230 1231d-footnote-list > * { 1232 grid-column: text; 1233} 1234
1235d-footnote-list a.footnote-backlink { 1236 color: rgba(0,0,0,0.3); 1237 padding-left: 0.5em; 1238} 1239 1240 1241 1242/* Anchor.js */ 1243 1244.anchorjs-link { 1245 /*transition: all .25s linear; */ 1246 text-decoration: none; 1247 border-bottom: none; 1248} 1249*:hover > .anchorjs-link { 1250 margin-left: -1.125em !important; 1251 text-decoration: none; 1252 border-bottom: none; 1253} 1254 1255/* Social footer */ 1256 1257.social_footer { 1258 margin-top: 30px; 1259 margin-bottom: 0; 1260 color: rgba(0,0,0,0.67); 1261} 1262 1263.disqus-comments { 1264 margin-right: 30px; 1265} 1266 1267.disqus-comment-count { 1268 border-bottom: 1px solid rgba(0, 0, 0, 0.4); 1269 cursor: pointer; 1270} 1271 1272#disqus_thread { 1273 margin-top: 30px; 1274} 1275 1276.article-sharing a { 1277 border-bottom: none; 1278 margin-right: 8px; 1279} 1280 1281.article-sharing a:hover { 1282 border-bottom: none; 1283} 1284 1285.sidebar-section.subscribe { 1286 font-size: 12px; 1287 line-height: 1.6em; 1288} 1289 1290.subscribe p { 1291 margin-bottom: 0.5em; 1292} 1293 1294 1295.article-footer .subscribe { 1296 font-size: 15px; 1297 margin-top: 45px; 1298} 1299 1300 1301.sidebar-section.custom { 1302 font-size: 12px; 1303 line-height: 1.6em; 1304} 1305 1306.custom p { 1307 margin-bottom: 0.5em; 1308} 1309 1310/* Styles for listing layout (hide title) */ 1311.layout-listing d-title, .layout-listing .d-title { 1312 display: none; 1313} 1314 1315/* Styles for posts lists (not auto-injected) */ 1316 1317 1318.posts-with-sidebar { 1319 padding-left: 45px; 1320 padding-right: 45px; 1321} 1322 1323.posts-list .description h2, 1324.posts-list .description p { 1325 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif; 1326} 1327 1328.posts-list .description h2 { 1329 font-weight: 700; 1330 border-bottom: none; 1331 padding-bottom: 0; 1332} 1333 1334.posts-list h2.post-tag { 1335 border-bottom: 1px solid rgba(0, 0, 0, 0.2); 1336 padding-bottom: 12px; 1337} 1338.posts-list { 1339 margin-top: 60px; 1340 margin-bottom: 24px; 1341} 1342 1343.posts-list .post-preview { 1344 text-decoration: none; 1345 overflow: hidden; 1346 display: block; 1347 border-bottom: 1px solid rgba(0, 0, 0, 0.1); 1348 padding: 24px 0; 1349} 1350 1351.post-preview-last { 1352 border-bottom: none !important; 1353} 1354 1355.posts-list .posts-list-caption { 1356 grid-column: screen; 1357 font-weight: 400; 1358} 1359 1360.posts-list .post-preview h2 { 1361 margin: 0 0 6px 0; 1362 line-height: 1.2em; 1363 font-style: normal; 1364 font-size: 24px; 1365} 1366 1367.posts-list .post-preview p { 1368 margin: 0 0 12px 0; 1369 line-height: 1.4em; 1370 font-size: 16px; 1371} 1372 1373.posts-list .post-preview .thumbnail { 1374 box-sizing: border-box; 1375 margin-bottom: 24px; 1376 position: relative; 1377 max-width: 500px; 1378} 1379.posts-list .post-preview img { 1380 width: 100%; 1381 display: block; 1382} 1383 1384.posts-list .metadata { 1385 font-size: 12px; 1386 line-height: 1.4em; 1387 margin-bottom: 18px; 1388} 1389 1390.posts-list .metadata > * { 1391 display: inline-block; 1392} 1393 1394.posts-list .metadata .publishedDate { 1395 margin-right: 2em; 1396} 1397 1398.posts-list .metadata .dt-authors { 1399 display: block; 1400 margin-top: 0.3em; 1401 margin-right: 2em; 1402} 1403 1404.posts-list .dt-tags { 1405 display: block; 1406 line-height: 1em; 1407} 1408 1409.posts-list .dt-tags .dt-tag { 1410 display: inline-block; 1411 color: rgba(0,0,0,0.6); 1412 padding: 0.3em 0.4em; 1413 margin-right: 0.2em; 1414 margin-bottom: 0.4em; 1415 font-size: 60%; 1416 border: 1px solid rgba(0,0,0,0.2); 1417 border-radius: 3px; 1418 text-transform: uppercase; 1419 font-weight: 500; 1420} 1421 1422.posts-list img { 1423 opacity: 1; 1424} 1425 1426.posts-list img[data-src] { 1427 opacity: 0; 1428} 1429 1430.posts-more { 1431 clear: both; 1432} 1433 1434 1435.posts-sidebar { 1436 font-size: 16px; 1437} 1438 1439.posts-sidebar h3 { 1440 font-size: 16px; 1441 margin-top: 0; 1442 margin-bottom: 0.5em; 1443 font-weight: 400; 1444 text-transform: uppercase; 1445} 1446 1447.sidebar-section { 1448 margin-bottom: 30px; 1449} 1450 1451.categories ul { 1452 list-style-type: none; 1453 margin: 0; 1454 padding: 0; 1455} 1456 1457.categories li { 1458 color: rgba(0, 0, 0, 0.8); 1459 margin-bottom: 0; 1460} 1461 1462.categories li>a { 1463 border-bottom: none; 1464} 1465 1466.categories li>a:hover { 1467 border-bottom: 1px solid rgba(0, 0, 0, 0.4); 1468} 1469 1470.categories .active { 1471 font-weight: 600; 1472} 1473 1474.categories .category-count { 1475 color: rgba(0, 0, 0, 0.4); 1476} 1477 1478 1479@media(min-width: 768px) { 1480 .posts-list .post-preview h2 { 1481 font-size: 26px; 1482 } 1483 .posts-list .post-preview .thumbnail { 1484 float: right; 1485 width: 30%; 1486 margin-bottom: 0; 1487 } 1488 .posts-list .post-preview .description { 1489 float: left; 1490 width: 45%; 1491 } 1492 .posts-list .post-preview .metadata { 1493 float: left; 1494 width: 20%; 1495 margin-top: 8px; 1496 } 1497 .posts-list .post-preview p { 1498 margin: 0 0 12px 0; 1499 line-height: 1.5em; 1500 font-size: 16px; 1501 } 1502 .posts-with-sidebar .posts-list { 1503 float: left; 1504 width: 75%; 1505 } 1506 .posts-with-sidebar .posts-sidebar { 1507 float: right; 1508 width: 20%; 1509 margin-top: 60px; 1510 padding-top: 24px; 1511 padding-bottom: 24px; 1512 } 1513} 1514 1515 1516/* Improve display for browsers without grid (IE/Edge <= 15) */ 1517 1518.downlevel { 1519 line-height: 1.6em; 1520 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif; 1521 margin: 0; 1522} 1523 1524.downlevel .d-title { 1525 padding-top: 6rem; 1526 padding-bottom: 1.5rem; 1527} 1528 1529.downlevel .d-title h1 { 1530 font-size: 50px; 1531 font-weight: 700; 1532 line-height: 1.1em; 1533 margin: 0 0 0.5rem; 1534} 1535 1536.downlevel .d-title p { 1537 font-weight: 300; 1538 font-size: 1.2rem; 1539 line-height: 1.55em; 1540 margin-top: 0; 1541} 1542 1543.downlevel .d-byline { 1544 padding-top: 0.8em; 1545 padding-bottom: 0.8em; 1546 font-size: 0.8rem; 1547 line-height: 1.8em; 1548} 1549 1550.downlevel .section-separator { 1551 border: none; 1552 border-top: 1px solid rgba(0, 0, 0, 0.1); 1553} 1554 1555.downlevel .d-article { 1556 font-size: 1.06rem; 1557 line-height: 1.7em; 1558 padding-top: 1rem; 1559 padding-bottom: 2rem; 1560} 1561 1562 1563.downlevel .d-appendix { 1564 padding-left: 0; 1565 padding-right: 0; 1566 max-width: none; 1567 font-size: 0.8em; 1568 line-height: 1.7em; 1569 margin-bottom: 0; 1570 color: rgba(0,0,0,0.5); 1571 padding-top: 40px; 1572 padding-bottom: 48px; 1573} 1574 1575.downlevel .footnotes ol { 1576 padding-left: 13px; 1577} 1578 1579.downlevel .base-grid, 1580.downlevel .distill-header, 1581.downlevel .d-title, 1582.downlevel .d-abstract, 1583.downlevel .d-article, 1584.downlevel .d-appendix, 1585.downlevel .distill-appendix, 1586.downlevel .d-byline, 1587.downlevel .d-footnote-list, 1588.downlevel .d-citation-list, 1589.downlevel .distill-footer, 1590.downlevel .appendix-bottom, 1591.downlevel .posts-container { 1592 padding-left: 40px; 1593 padding-right: 40px; 1594} 1595 1596@media(min-width: 768px) { 1597 .downlevel .base-grid, 1598 .downlevel .distill-header, 1599 .downlevel .d-title, 1600 .downlevel .d-abstract, 1601 .downlevel .d-article, 1602 .downlevel .d-appendix, 1603 .downlevel .distill-appendix, 1604 .downlevel .d-byline, 1605 .downlevel .d-footnote-list, 1606 .downlevel .d-citation-list, 1607 .downlevel .distill-footer, 1608 .downlevel .appendix-bottom, 1609 .downlevel .posts-container { 1610 padding-left: 150px; 1611 padding-right: 150px; 1612 max-width: 900px; 1613} 1614} 1615 1616.downlevel pre code { 1617 display: block; 1618 border-left: 2px solid rgba(0, 0, 0, .1); 1619 padding: 0 0 0 20px; 1620 font-size: 14px; 1621} 1622 1623.downlevel code, .downlevel pre { 1624 color: black; 1625 background: none;
1626 font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; 1627 text-align: left; 1628 white-space: pre; 1629 word-spacing: normal; 1630 word-break: normal; 1631 word-wrap: normal; 1632 line-height: 1.5; 1633 1634 -moz-tab-size: 4; 1635 -o-tab-size: 4; 1636 tab-size: 4; 1637 1638 -webkit-hyphens: none; 1639 -moz-hyphens: none; 1640 -ms-hyphens: none; 1641 hyphens: none; 1642} 1643 1644.downlevel .posts-list .post-preview { 1645 color: inherit; 1646} 1647 1648 1649 1650</style> 1651
1652<script type="application/javascript"> 1653 1654function is_downlevel_browser() { 1655 if (bowser.isUnsupportedBrowser({ msie: "12", msedge: "16"}, 1656 window.navigator.userAgent)) { 1657 return true; 1658 } else { 1659 return window.load_distill_framework === undefined; 1660 } 1661} 1662 1663// show body when load is complete 1664function on_load_complete() { 1665 1666 // add anchors 1667 if (window.anchors) { 1668 window.anchors.options.placement = 'left'; 1669 window.anchors.add('d-article > h2, d-article > h3, d-article > h4, d-article > h5'); 1670 } 1671 1672 1673 // set body to visible 1674 document.body.style.visibility = 'visible'; 1675 1676 // force redraw for leaflet widgets 1677 if (window.HTMLWidgets) { 1678 var maps = window.HTMLWidgets.findAll(".leaflet"); 1679 $.each(maps, function(i, el) { 1680 var map = this.getMap(); 1681 map.invalidateSize(); 1682 map.eachLayer(function(layer) { 1683 if (layer instanceof L.TileLayer) 1684 layer.redraw(); 1685 }); 1686 }); 1687 } 1688 1689 // trigger 'shown' so htmlwidgets resize 1690 $('d-article').trigger('shown'); 1691} 1692 1693function init_distill() { 1694 1695 init_common(); 1696 1697 // create front matter 1698 var front_matter = $('<d-front-matter></d-front-matter>'); 1699 $('#distill-front-matter').wrap(front_matter); 1700 1701 // create d-title 1702 $('.d-title').changeElementType('d-title'); 1703 1704 // create d-byline 1705 var byline = $('<d-byline></d-byline>'); 1706 $('.d-byline').replaceWith(byline); 1707 1708 // create d-article 1709 var article = $('<d-article></d-article>'); 1710 $('.d-article').wrap(article).children().unwrap(); 1711 1712 // move posts container into article 1713 $('.posts-container').appendTo($('d-article')); 1714 1715 // create d-appendix 1716 $('.d-appendix').changeElementType('d-appendix'); 1717 1718 // flag indicating that we have appendix items 1719 var appendix = $('.appendix-bottom').children('h3').length > 0; 1720 1721 // replace footnotes with <d-footnote> 1722 $('.footnote-ref').each(function(i, val) { 1723 appendix = true; 1724 var href = $(this).attr('href'); 1725 var id = href.replace('#', ''); 1726 var fn = $('#' + id); 1727 var fn_p = $('#' + id + '>p'); 1728 fn_p.find('.footnote-back').remove(); 1729 var text = fn_p.html(); 1730 var dtfn = $('<d-footnote></d-footnote>'); 1731 dtfn.html(text); 1732 $(this).replaceWith(dtfn); 1733 }); 1734 // remove footnotes 1735 $('.footnotes').remove(); 1736 1737 // move refs into #references-listing 1738 $('#references-listing').replaceWith($('#refs')); 1739 1740 $('h1.appendix, h2.appendix').each(function(i, val) { 1741 $(this).changeElementType('h3'); 1742 }); 1743 $('h3.appendix').each(function(i, val) { 1744 var id = $(this).attr('id'); 1745 $('.d-contents a[href="#' + id + '"]').parent().remove(); 1746 appendix = true; 1747 $(this).nextUntil($('h1, h2, h3')).addBack().appendTo($('d-appendix')); 1748 }); 1749 1750 // show d-appendix if we have appendix content 1751 $("d-appendix").css('display', appendix ? 'grid' : 'none'); 1752 1753 // localize layout chunks to just output 1754 $('.layout-chunk').each(function(i, val) { 1755 1756 // capture layout 1757 var layout = $(this).attr('data-layout'); 1758 1759 // apply layout to markdown level block elements 1760 var elements = $(this).children().not('details, div.sourceCode, pre, script'); 1761 elements.each(function(i, el) { 1762 var layout_div = $('<div class="' + layout + '"></div>'); 1763 if (layout_div.hasClass('shaded')) { 1764 var shaded_content = $('<div class="shaded-content"></div>'); 1765 $(this).wrap(shaded_content); 1766 $(this).parent().wrap(layout_div); 1767 } else { 1768 $(this).wrap(layout_div); 1769 } 1770 }); 1771 1772 1773 // unwrap the layout-chunk div 1774 $(this).children().unwrap(); 1775 }); 1776 1777 // remove code block used to force highlighting css 1778 $('.distill-force-highlighting-css').parent().remove(); 1779 1780 // remove empty line numbers inserted by pandoc when using a 1781 // custom syntax highlighting theme 1782 $('code.sourceCode a:empty').remove(); 1783 1784 // load distill framework 1785 load_distill_framework(); 1786 1787 // wait for window.distillRunlevel == 4 to do post processing 1788 function distill_post_process() { 1789 1790 if (!window.distillRunlevel || window.distillRunlevel < 4) 1791 return; 1792 1793 // hide author/affiliations entirely if we have no authors 1794 var front_matter = JSON.parse($("#distill-front-matter").html()); 1795 var have_authors = front_matter.authors && front_matter.authors.length > 0; 1796 if (!have_authors) 1797 $('d-byline').addClass('hidden'); 1798 1799 // article with toc class 1800 $('.d-contents').parent().addClass('d-article-with-toc'); 1801 1802 // strip links that point to # 1803 $('.authors-affiliations').find('a[href="#"]').removeAttr('href'); 1804 1805 // add orcid ids 1806 $('.authors-affiliations').find('.author').each(function(i, el) {
1807 var orcid_id = front_matter.authors[i].orcidID; 1808 if (orcid_id) { 1809 var a = $('<a></a>'); 1810 a.attr('href', 'https://orcid.org/' + orcid_id); 1811 var img = $('<img></img>'); 1812 img.addClass('orcid-id'); 1813 img.attr('alt', 'ORCID ID'); 1814 img.attr('src','data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo1N0NEMjA4MDI1MjA2ODExOTk0QzkzNTEzRjZEQTg1NyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDozM0NDOEJGNEZGNTcxMUUxODdBOEVCODg2RjdCQ0QwOSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDozM0NDOEJGM0ZGNTcxMUUxODdBOEVCODg2RjdCQ0QwOSIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1IE1hY2ludG9zaCI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkZDN0YxMTc0MDcyMDY4MTE5NUZFRDc5MUM2MUUwNEREIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjU3Q0QyMDgwMjUyMDY4MTE5OTRDOTM1MTNGNkRBODU3Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+84NovQAAAR1JREFUeNpiZEADy85ZJgCpeCB2QJM6AMQLo4yOL0AWZETSqACk1gOxAQN+cAGIA4EGPQBxmJA0nwdpjjQ8xqArmczw5tMHXAaALDgP1QMxAGqzAAPxQACqh4ER6uf5MBlkm0X4EGayMfMw/Pr7Bd2gRBZogMFBrv01hisv5jLsv9nLAPIOMnjy8RDDyYctyAbFM2EJbRQw+aAWw/LzVgx7b+cwCHKqMhjJFCBLOzAR6+lXX84xnHjYyqAo5IUizkRCwIENQQckGSDGY4TVgAPEaraQr2a4/24bSuoExcJCfAEJihXkWDj3ZAKy9EJGaEo8T0QSxkjSwORsCAuDQCD+QILmD1A9kECEZgxDaEZhICIzGcIyEyOl2RkgwAAhkmC+eAm0TAAAAABJRU5ErkJggg=='); 1815 a.append(img); 1816 $(this).append(a); 1817 } 1818 }); 1819 1820 // hide elements of author/affiliations grid that have no value 1821 function hide_byline_column(caption) { 1822 $('d-byline').find('h3:contains("' + caption + '")').parent().css('visibility', 'hidden'); 1823 } 1824 1825 // affiliations 1826 var have_affiliations = false; 1827 for (var i = 0; i<front_matter.authors.length; ++i) { 1828 var author = front_matter.authors[i]; 1829 if (author.affiliation !== " ") { 1830 have_affiliations = true; 1831 break; 1832 } 1833 } 1834 if (!have_affiliations) 1835 $('d-byline').find('h3:contains("Affiliations")').css('visibility', 'hidden'); 1836 1837 // published date 1838 if (!front_matter.publishedDate) 1839 hide_byline_column("Published"); 1840 1841 // document object identifier 1842 var doi = $('d-byline').find('h3:contains("DOI")'); 1843 var doi_p = doi.next().empty(); 1844 if (!front_matter.doi) { 1845 // if we have a citation and valid citationText then link to that 1846 if ($('#citation').length > 0 && front_matter.citationText) { 1847 doi.html('Citation'); 1848 $('<a href="#citation"></a>') 1849 .text(front_matter.citationText) 1850 .appendTo(doi_p); 1851 } else { 1852 hide_byline_column("DOI"); 1853 } 1854 } else { 1855 $('<a></a>') 1856 .attr('href', "https://doi.org/" + front_matter.doi) 1857 .html(front_matter.doi) 1858 .appendTo(doi_p); 1859 } 1860 1861 // change plural form of authors/affiliations 1862 if (front_matter.authors.length === 1) { 1863 var grid = $('.authors-affiliations'); 1864 grid.children('h3:contains("Authors")').text('Author'); 1865 grid.children('h3:contains("Affiliations")').text('Affiliation'); 1866 } 1867 1868 // remove d-appendix and d-footnote-list local styles 1869 $('d-appendix > style:first-child').remove(); 1870 $('d-footnote-list > style:first-child').remove(); 1871 1872 // move appendix-bottom entries to the bottom 1873 $('.appendix-bottom').appendTo('d-appendix').children().unwrap(); 1874 $('.appendix-bottom').remove(); 1875 1876 // hoverable references 1877 $('span.citation[data-cites]').each(function() { 1878 const citeChild = $(this).children()[0]
1879 // Do not process if @xyz has been used without escaping and without bibliography activated 1880 // https://github.com/rstudio/distill/issues/466 1881 if (citeChild === undefined) return true 1882 1883 if (citeChild.nodeName == "D-FOOTNOTE") { 1884 var fn = citeChild 1885 $(this).html(fn.shadowRoot.querySelector("sup")) 1886 $(this).id = fn.id 1887 fn.remove() 1888 } 1889 var refs = $(this).attr('data-cites').split(" "); 1890 var refHtml = refs.map(function(ref) { 1891 // Could use CSS.escape too here, we insure backward compatibility in navigator 1892 return "<p>" + $('div[id="ref-' + ref + '"]').html() + "</p>"; 1893 }).join("\n"); 1894 window.tippy(this, { 1895 allowHTML: true, 1896 content: refHtml, 1897 maxWidth: 500, 1898 interactive: true, 1899 interactiveBorder: 10, 1900 theme: 'light-border', 1901 placement: 'bottom-start' 1902 }); 1903 }); 1904 1905 // fix footnotes in tables (#411) 1906 // replacing broken distill.pub feature 1907 $('table d-footnote').each(function() { 1908 // we replace internal showAtNode methode which is triggered when hovering a footnote 1909 this.hoverBox.showAtNode = function(node) { 1910 // ported from https://github.com/distillpub/template/pull/105/files 1911 calcOffset = function(elem) { 1912 let x = elem.offsetLeft; 1913 let y = elem.offsetTop; 1914 // Traverse upwards until an `absolute` element is found or `elem` 1915 // becomes null. 1916 while (elem = elem.offsetParent && elem.style.position != 'absolute') { 1917 x += elem.offsetLeft; 1918 y += elem.offsetTop; 1919 } 1920 1921 return { left: x, top: y }; 1922 } 1923 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetTop 1924 const bbox = node.getBoundingClientRect(); 1925 const offset = calcOffset(node); 1926 this.show([offset.left + bbox.width, offset.top + bbox.height]); 1927 } 1928 }) 1929 1930 // clear polling timer 1931 clearInterval(tid); 1932 1933 // show body now that everything is ready 1934 on_load_complete(); 1935 } 1936 1937 var tid = setInterval(distill_post_process, 50); 1938 distill_post_process(); 1939 1940} 1941 1942function init_downlevel() { 1943 1944 init_common(); 1945 1946 // insert hr after d-title 1947 $('.d-title').after($('<hr class="section-separator"/>')); 1948 1949 // check if we have authors 1950 var front_matter = JSON.parse($("#distill-front-matter").html()); 1951 var have_authors = front_matter.authors && front_matter.authors.length > 0; 1952
1953 // manage byline/border 1954 if (!have_authors) 1955 $('.d-byline').remove(); 1956 $('.d-byline').after($('<hr class="section-separator"/>')); 1957 $('.d-byline a').remove(); 1958 1959 // remove toc 1960 $('.d-contents').remove(); 1961 1962 // move appendix elements 1963 $('h1.appendix, h2.appendix').each(function(i, val) { 1964 $(this).changeElementType('h3'); 1965 }); 1966 $('h3.appendix').each(function(i, val) { 1967 $(this).nextUntil($('h1, h2, h3')).addBack().appendTo($('.d-appendix')); 1968 }); 1969 1970 1971 // inject headers into references and footnotes 1972 var refs_header = $('<h3></h3>'); 1973 refs_header.text('References'); 1974 $('#refs').prepend(refs_header); 1975 1976 var footnotes_header = $('<h3></h3'); 1977 footnotes_header.text('Footnotes'); 1978 $('.footnotes').children('hr').first().replaceWith(footnotes_header); 1979 1980 // move appendix-bottom entries to the bottom 1981 $('.appendix-bottom').appendTo('.d-appendix').children().unwrap(); 1982 $('.appendix-bottom').remove(); 1983 1984 // remove appendix if it's empty 1985 if ($('.d-appendix').children().length === 0) 1986 $('.d-appendix').remove(); 1987 1988 // prepend separator above appendix 1989 $('.d-appendix').before($('<hr class="section-separator" style="clear: both"/>')); 1990 1991 // trim code 1992 $('pre>code').each(function(i, val) { 1993 $(this).html($.trim($(this).html())); 1994 }); 1995 1996 // move posts-container right before article 1997 $('.posts-container').insertBefore($('.d-article')); 1998 1999 $('body').addClass('downlevel'); 2000 2001 on_load_complete(); 2002} 2003 2004 2005function init_common() { 2006 2007 // jquery plugin to change element types 2008 (function($) { 2009 $.fn.changeElementType = function(newType) { 2010 var attrs = {}; 2011 2012 $.each(this[0].attributes, function(idx, attr) { 2013 attrs[attr.nodeName] = attr.nodeValue; 2014 }); 2015 2016 this.replaceWith(function() { 2017 return $("<" + newType + "/>", attrs).append($(this).contents()); 2018 }); 2019 }; 2020 })(jQuery); 2021 2022 // prevent underline for linked images 2023 $('a > img').parent().css({'border-bottom' : 'none'}); 2024 2025 // mark non-body figures created by knitr chunks as 100% width 2026 $('.layout-chunk').each(function(i, val) { 2027 var figures = $(this).find('img, .html-widget'); 2028 // ignore leaflet img layers (#106) 2029 figures = figures.filter(':not(img[class*="leaflet"])') 2030 if ($(this).attr('data-layout') !== "l-body") { 2031 figures.css('width', '100%'); 2032 } else { 2033 figures.css('max-width', '100%'); 2034 figures.filter("[width]").each(function(i, val) { 2035 var fig = $(this); 2036 fig.css('width', fig.attr('width') + 'px'); 2037 }); 2038 2039 } 2040 }); 2041 2042 // auto-append index.html to post-preview links in file: protocol 2043 // and in rstudio ide preview 2044 $('.post-preview').each(function(i, val) { 2045 if (window.location.protocol === "file:") 2046 $(this).attr('href', $(this).attr('href') + "index.html"); 2047 }); 2048 2049 // get rid of index.html references in header 2050 if (window.location.protocol !== "file:") { 2051 $('.distill-site-header a[href]').each(function(i,val) { 2052 $(this).attr('href', $(this).attr('href').replace(/^index[.]html/, "./")); 2053 }); 2054 } 2055 2056 // add class to pandoc style tables 2057 $('tr.header').parent('thead').parent('table').addClass('pandoc-table'); 2058 $('.kable-table').children('table').addClass('pandoc-table'); 2059 2060 // add figcaption style to table captions 2061 $('caption').parent('table').addClass("figcaption"); 2062 2063 // initialize posts list 2064 if (window.init_posts_list) 2065 window.init_posts_list(); 2066 2067 // implmement disqus comment link 2068 $('.disqus-comment-count').click(function() { 2069 window.headroom_prevent_pin = true; 2070 $('#disqus_thread').toggleClass('hidden'); 2071 if (!$('#disqus_thread').hasClass('hidden')) { 2072 var offset = $(this).offset(); 2073 $(window).resize(); 2074 $('html, body').animate({ 2075 scrollTop: offset.top - 35 2076 }); 2077 } 2078 }); 2079} 2080 2081document.addEventListener('DOMContentLoaded', function() { 2082 if (is_downlevel_browser()) 2083 init_downlevel(); 2084 else 2085 window.addEventListener('WebComponentsReady', init_distill); 2086}); 2087 2088</script>
2088 2089 2090<style type="text/css"> 2091/* base variables */ 2092 2093/* Edit the CSS properties in this file to create a custom 2094 Distill theme. Only edit values in the right column 2095 for each row; values shown are the CSS defaults. 2096 To return any property to the default, 2097 you may set its value to: unset 2098 All rows must end with a semi-colon. */ 2099 2100/* Optional: embed custom fonts here with `@import` */ 2101/* This must remain at the top of this file. */ 2102 2103 2104 2105html { 2106 /*-- Main font sizes --*/ 2107 --title-size: 50px; 2108 --body-size: 1.06rem; 2109 --code-size: 14px; 2110 --aside-size: 12px; 2111 --fig-cap-size: 13px; 2112 /*-- Main font colors --*/ 2113 --title-color: #000000; 2114 --header-color: rgba(0, 0, 0, 0.8); 2115 --body-color: rgba(0, 0, 0, 0.8); 2116 --aside-color: rgba(0, 0, 0, 0.6); 2117 --fig-cap-color: rgba(0, 0, 0, 0.6); 2118 /*-- Specify custom fonts ~~~ must be imported above --*/ 2119 --heading-font: sans-serif; 2120 --mono-font: monospace; 2121 --body-font: sans-serif; 2122 --navbar-font: sans-serif; /* websites + blogs only */ 2123} 2124 2125/*-- ARTICLE METADATA --*/ 2126d-byline { 2127 --heading-size: 0.6rem; 2128 --heading-color: rgba(0, 0, 0, 0.5); 2129 --body-size: 0.8rem; 2130 --body-color: rgba(0, 0, 0, 0.8); 2131} 2132 2133/*-- ARTICLE TABLE OF CONTENTS --*/ 2134.d-contents { 2135 --heading-size: 18px; 2136 --contents-size: 13px; 2137} 2138 2139/*-- ARTICLE APPENDIX --*/ 2140d-appendix { 2141 --heading-size: 15px; 2142 --heading-color: rgba(0, 0, 0, 0.65); 2143 --text-size: 0.8em; 2144 --text-color: rgba(0, 0, 0, 0.5); 2145} 2146 2147/*-- WEBSITE HEADER + FOOTER --*/ 2148/* These properties only apply to Distill sites and blogs */ 2149 2150.distill-site-header { 2151 --title-size: 18px; 2152 --text-color: rgba(255, 255, 255, 0.8); 2153 --text-size: 15px; 2154 --hover-color: white; 2155 --bkgd-color: #0F2E3D; 2156} 2157 2158.distill-site-footer { 2159 --text-color: rgba(255, 255, 255, 0.8); 2160 --text-size: 15px; 2161 --hover-color: white; 2162 --bkgd-color: #0F2E3D; 2163} 2164 2165/*-- Additional custom styles --*/ 2166/* Add any additional CSS rules below */ 2167</style> 2168<style type="text/css"> 2169/* base variables */ 2170 2171/* Edit the CSS properties in this file to create a custom 2172 Distill theme. Only edit values in the right column 2173 for each row; values shown are the CSS defaults. 2174 To return any property to the default, 2175 you may set its value to: unset 2176 All rows must end with a semi-colon. */ 2177 2178/* Optional: embed custom fonts here with `@import` */ 2179/* This must remain at the top of this file. */ 2180 2181 2182 2183html { 2184 /*-- Main font sizes --*/ 2185 --title-size: 50px; 2186 --body-size: 1.06rem; 2187 --code-size: 14px; 2188 --aside-size: 12px; 2189 --fig-cap-size: 13px; 2190 /*-- Main font colors --*/ 2191 --title-color: #000000; 2192 --header-color: rgba(0, 0, 0, 0.8); 2193 --body-color: rgba(0, 0, 0, 0.8); 2194 --aside-color: rgba(0, 0, 0, 0.6); 2195 --fig-cap-color: rgba(0, 0, 0, 0.6); 2196 /*-- Specify custom fonts ~~~ must be imported above --*/ 2197 --heading-font: sans-serif; 2198 --mono-font: monospace; 2199 --body-font: sans-serif; 2200 --navbar-font: sans-serif; /* websites + blogs only */ 2201} 2202 2203/*-- ARTICLE METADATA --*/ 2204d-byline { 2205 --heading-size: 0.6rem; 2206 --heading-color: rgba(0, 0, 0, 0.5); 2207 --body-size: 0.8rem; 2208 --body-color: rgba(0, 0, 0, 0.8); 2209} 2210 2211/*-- ARTICLE TABLE OF CONTENTS --*/ 2212.d-contents { 2213 --heading-size: 18px; 2214 --contents-size: 13px; 2215} 2216 2217/*-- ARTICLE APPENDIX --*/ 2218d-appendix { 2219 --heading-size: 15px; 2220 --heading-color: rgba(0, 0, 0, 0.65); 2221 --text-size: 0.8em; 2222 --text-color: rgba(0, 0, 0, 0.5); 2223} 2224 2225/*-- WEBSITE HEADER + FOOTER --*/ 2226/* These properties only apply to Distill sites and blogs */ 2227 2228.distill-site-header { 2229 --title-size: 18px; 2230 --text-color: rgba(255, 255, 255, 0.8); 2231 --text-size: 15px; 2232 --hover-color: white; 2233 --bkgd-color: #908FB6; 2234 /*--bkgd-color: #0F2E3D;*/ 2235} 2236 2237.distill-site-footer { 2238 --text-color: rgba(255, 255, 255, 0.8); 2239 --text-size: 12px; 2240 --hover-color: white; 2241 --bkgd-color: #908FB6; 2242} 2243 2244/*-- Additional custom styles --*/ 2245/* Add any additional CSS rules below */ 2246</style> 2247<style type="text/css"> 2248/* base style */ 2249 2250/* FONT FAMILIES */ 2251 2252:root { 2253 --heading-default: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif;
2254 --mono-default: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; 2255 --body-default: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif; 2256} 2257 2258body, 2259.posts-list .post-preview p, 2260.posts-list .description p { 2261 font-family: var(--body-font), var(--body-default); 2262} 2263 2264h1, h2, h3, h4, h5, h6, 2265.posts-list .post-preview h2, 2266.posts-list .description h2 { 2267 font-family: var(--heading-font), var(--heading-default); 2268} 2269 2270d-article div.sourceCode code, 2271d-article pre code { 2272 font-family: var(--mono-font), var(--mono-default); 2273} 2274 2275 2276/*-- TITLE --*/ 2277d-title h1, 2278.posts-list > h1 { 2279 color: var(--title-color, black); 2280} 2281 2282d-title h1 { 2283 font-size: var(--title-size, 50px); 2284} 2285 2286/*-- HEADERS --*/ 2287d-article h1, 2288d-article h2, 2289d-article h3, 2290d-article h4, 2291d-article h5, 2292d-article h6 { 2293 color: var(--header-color, rgba(0, 0, 0, 0.8)); 2294} 2295 2296/*-- BODY --*/ 2297d-article > p, /* only text inside of <p> tags */ 2298d-article > ul, /* lists */ 2299d-article > ol { 2300 color: var(--body-color, rgba(0, 0, 0, 0.8)); 2301 font-size: var(--body-size, 1.06rem); 2302} 2303 2304 2305/*-- CODE --*/ 2306d-article div.sourceCode code, 2307d-article pre code { 2308 font-size: var(--code-size, 14px); 2309} 2310 2311/*-- ASIDE --*/ 2312d-article aside { 2313 font-size: var(--aside-size, 12px); 2314 color: var(--aside-color, rgba(0, 0, 0, 0.6)); 2315} 2316 2317/*-- FIGURE CAPTIONS --*/ 2318figure .caption, 2319figure figcaption, 2320.figure .caption { 2321 font-size: var(--fig-cap-size, 13px); 2322 color: var(--fig-cap-color, rgba(0, 0, 0, 0.6)); 2323} 2324 2325/*-- METADATA --*/ 2326d-byline h3 { 2327 font-size: var(--heading-size, 0.6rem); 2328 color: var(--heading-color, rgba(0, 0, 0, 0.5)); 2329} 2330 2331d-byline { 2332 font-size: var(--body-size, 0.8rem); 2333 color: var(--body-color, rgba(0, 0, 0, 0.8)); 2334} 2335 2336d-byline a, 2337d-article d-byline a { 2338 color: var(--body-color, rgba(0, 0, 0, 0.8)); 2339} 2340 2341/*-- TABLE OF CONTENTS --*/ 2342.d-contents nav h3 { 2343 font-size: var(--heading-size, 18px); 2344} 2345 2346.d-contents nav a { 2347 font-size: var(--contents-size, 13px); 2348} 2349 2350/*-- APPENDIX --*/ 2351d-appendix h3 { 2352 font-size: var(--heading-size, 15px); 2353 color: var(--heading-color, rgba(0, 0, 0, 0.65)); 2354} 2355 2356d-appendix { 2357 font-size: var(--text-size, 0.8em); 2358 color: var(--text-color, rgba(0, 0, 0, 0.5)); 2359} 2360 2361d-appendix d-footnote-list a.footnote-backlink { 2362 color: var(--text-color, rgba(0, 0, 0, 0.5)); 2363} 2364 2365/*-- WEBSITE HEADER + FOOTER --*/ 2366.distill-site-header .title { 2367 font-size: var(--title-size, 18px); 2368 font-family: var(--navbar-font), var(--heading-default); 2369} 2370 2371.distill-site-header a, 2372.nav-dropdown .nav-dropbtn { 2373 font-family: var(--navbar-font), var(--heading-default); 2374} 2375 2376.nav-dropdown .nav-dropbtn { 2377 color: var(--text-color, rgba(255, 255, 255, 0.8)); 2378 font-size: var(--text-size, 15px); 2379} 2380 2381.distill-site-header a:hover, 2382.nav-dropdown:hover .nav-dropbtn { 2383 color: var(--hover-color, white); 2384} 2385 2386.distill-site-header { 2387 font-size: var(--text-size, 15px); 2388 color: var(--text-color, rgba(255, 255, 255, 0.8)); 2389 background-color: var(--bkgd-color, #0F2E3D); 2390} 2391 2392.distill-site-footer { 2393 font-size: var(--text-size, 15px); 2394 color: var(--text-color, rgba(255, 255, 255, 0.8)); 2395 background-color: var(--bkgd-color, #0F2E3D); 2396} 2397 2398.distill-site-footer a:hover { 2399 color: var(--hover-color, white); 2400}</style> 2401<!--/radix_placeholder_distill--> 2402
2402<script src="../../site_libs/header-attrs-2.8/header-attrs.js"></script>
2402 2403
2403<script src="../../site_libs/jquery-1.11.3/jquery.min.js"></script>
2403 2404
2404<script src="../../site_libs/popper-2.6.0/popper.min.js"></script>
2404 2405 <link href="../../site_libs/tippy-6.2.7/tippy.css" rel="stylesheet" /> 2406 <link href="../../site_libs/tippy-6.2.7/tippy-light-border.css" rel="stylesheet" /> 2407
2407<script src="../../site_libs/tippy-6.2.7/tippy.umd.min.js"></script>
2407 2408
2408<script src="../../site_libs/anchor-4.2.2/anchor.min.js"></script>
2408 2409
2409<script src="../../site_libs/bowser-1.9.3/bowser.min.js"></script>
2409 2410
2410<script src="../../site_libs/webcomponents-2.0.0/webcomponents.js"></script>
2410 2411
2411<script src="../../site_libs/distill-2.2.21/template.v2.js"></script>
2411 2412 <!--radix_placeholder_site_in_header--> 2413<!--/radix_placeholder_site_in_header--> 2414 2415 2416</head> 2417 2418<body> 2419 2420<!--radix_placeholder_front_matter--> 2421
2422<script id="distill-front-matter" type="text/json"> 2423{"title":"Create a banner and buttons with R","description":"with a few lines of code.","authors":[],"publishedDate":"2021-06-07T00:00:00.000-07:00"} 2424</script>
2424 2425 2426<!--/radix_placeholder_front_matter--> 2427<!--radix_placeholder_navigation_before_body--> 2428<header class="header header--fixed" role="banner"> 2429<nav class="distill-site-nav distill-site-header"> 2430<div class="nav-left"> 2431<a class="logo"> 2432<img src="../../img/favicon.png" alt="Logo"/> 2433</a> 2434<a class='title' href='/'>Elizabeth Stanny</a> 2435<input id="distill-search" class="nav-search hidden" type="text" placeholder="Search..."/> 2436</div> 2437<div class="nav-right"> 2438<a href='/'>Home</a> 2439<a href='/about'>About</a> 2440<div class="nav-dropdown"> 2441<button class="nav-dropbtn"> 2442Courses 2443 2444<span class="down-arrow">▾</span> 2445</button> 2446<div class="nav-dropdown-content"> 2447<a href='/data-analysis-fa-22'>Data Analysis - Fall 2022</a> 2448<hr/> 2449<a href='/intermediate_accounting_sum'>Intermediate Accounting I- Summer 2022</a> 2450<hr/> 2451<a href='/intermediate_accounting_ii_sum'>Intermediate Accounting II - Summer 2022</a> 2452<hr/> 2453<a href='/financial-accounting-sp-22'>Financial Accounting - Spring 2022</a> 2454<hr/> 2455<a href='/data-analysis-sp-22'>Data Analysis - Spring 2022</a> 2456<hr/> 2457<a href='/slides'>BUS 320 Slides</a> 2458</div> 2459</div> 2460<a href='/advising'>Advising</a> 2461<a href="javascript:void(0);" class="nav-toggle">☰</a> 2462</div> 2463</nav> 2464</header> 2465<!--/radix_placeholder_navigation_before_body--> 2466<!--radix_placeholder_site_before_body--> 2467<!--/radix_placeholder_site_before_body--> 2468 2469<div class="d-title"> 2470<h1>Create a banner and buttons with R</h1> 2471<!--radix_placeholder_categories--> 2472<div class="dt-tags"> 2473 <a class='dt-tag' href='/#category:jasmines'>jasmines</a> 2474 <a class='dt-tag' href='/#category:tidyverse'>tidyverse</a> 2475 <a class='dt-tag' href='/#category:magick'>magick</a> 2476</div> 2477<!--/radix_placeholder_categories--> 2478<p><p>with a few lines of code.</p></p> 2479</div> 2480 2481 2482<div class="d-article"> 2483<ol start="0" type="1"> 2484<li>Load the packages we will need.</li> 2485</ol> 2486<div class="layout-chunk" data-layout="l-body"> 2487<div class="sourceCode"> 2488<pre class="sourceCode r"><code class="sourceCode r"><span class='fu'>pacman</span><span class='fu'>::</span><span class='fu'><a href='https://rdrr.io/pkg/pacman/man/p_load.html'>p_load</a></span><span class='op'>(</span><span class='va'>tidyverse</span>, <span class='va'>jasmines</span>, <span class='va'>magick</span>, <span class='va'>here</span><span class='op'>)</span> 2489</code></pre> 2490</div> 2491</div> 2492<ol type="1"> 2493<li>Creating a background for my banner and buttons for my Canvas course provided the opportunity to try out the <a href="https://jasmines.djnavarro.net">jasmines package</a>.</li> 2494</ol> 2495<p>Using the excellent <a href="https://jasmines.djnavarro.net">examples</a> as a guide, I created a background by modifying a few lines.</p> 2496<div class="layout-chunk" data-layout="l-body"> 2497<div class="sourceCode"> 2498<pre class="sourceCode r"><code class="sourceCode r"><span class='fu'>entity_lissajous</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>%>%</span> 2499 <span class='fu'>unfold_tempest</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>%>%</span> 2500 <span class='fu'>style_ribbon</span><span class='op'>(</span>background <span class='op'>=</span> <span class='st'>"thistle2"</span><span class='op'>)</span> 2501</code></pre> 2502</div> 2503<p><img src="index_files/figure-html5/unnamed-chunk-3-1.png" width="624" /></p> 2504</div> 2505<ol start="2" type="1"> 2506<li>Save the background to banner.png</li> 2507</ol> 2508<div class="layout-chunk" data-layout="l-body"> 2509<div class="sourceCode"> 2510<pre class="sourceCode r"><code class="sourceCode r"><span class='fu'>entity_lissajous</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>%>%</span> 2511 <span class='fu'>unfold_tempest</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>%>%</span> 2512 <span class='fu'>style_ribbon</span><span class='op'>(</span>background <span class='op'>=</span> <span class='st'>"thistle2"</span><span class='op'>)</span> <span class='op'>%>%</span> 2513 <span class='fu'>export_image</span><span class='op'>(</span><span class='fu'>here</span><span class='op'>(</span> 2514 <span class='st'>"_posts"</span>, <span class='st'>
2514"create-a-banner-and-buttons-with-r"</span>, <span class='st'>"banner.png"</span><span class='op'>)</span><span class='op'>)</span> 2515</code></pre> 2516</div> 2517</div> 2518<ol start="3" type="1"> 2519<li>Read the image back in as a magick object to modify it</li> 2520</ol> 2521<div class="layout-chunk" data-layout="l-body"> 2522<div class="sourceCode"> 2523<pre class="sourceCode r"><code class="sourceCode r"><span class='va'>banner_png</span> <span class='op'><-</span> <span class='fu'>image_read</span><span class='op'>(</span><span class='fu'>here</span><span class='op'>(</span> 2524 <span class='st'>"_posts"</span>, <span class='st'>"create-a-banner-and-buttons-with-r"</span>, <span class='st'>"banner.png"</span><span class='op'>)</span><span class='op'>)</span> 2525</code></pre> 2526</div> 2527</div> 2528<ol start="4" type="1"> 2529<li>Resize it and add my course name, âAuditingâ, to the banner</li> 2530</ol> 2531<div class="layout-chunk" data-layout="l-body"> 2532<div class="sourceCode"> 2533<pre class="sourceCode r"><code class="sourceCode r"><span class='va'>banner_png</span> <span class='op'>%>%</span> 2534 <span class='fu'>image_resize</span><span class='op'>(</span> 2535 <span class='fu'>geometry_size_pixels</span><span class='op'>(</span>width <span class='op'>=</span> <span class='fl'>1000</span>, 2536 height <span class='op'>=</span> <span class='fl'>200</span>, 2537 preserve_aspect <span class='op'>=</span><span class='cn'>FALSE</span> <span class='op'>)</span><span class='op'>)</span> <span class='op'>%>%</span> 2538 <span class='fu'>image_annotate</span><span class='op'>(</span><span class='st'>"Auditing"</span>, 2539 location <span class='op'>=</span> <span class='fu'>geometry_point</span><span class='op'>(</span>x <span class='op'>=</span> <span class='fl'>350</span>, y <span class='op'>=</span> <span class='fl'>50</span><span class='op'>)</span>, 2540 size <span class='op'>=</span> <span class='fl'>50</span>, font <span class='op'>=</span> <span class='st'>"Comic Sans"</span><span class='op'>)</span> 2541</code></pre> 2542</div> 2543<p><img src="index_files/figure-html5/unnamed-chunk-6-1.png" width="500" /></p> 2544</div> 2545<ol start="5" type="1"> 2546<li>Save the banner with text as audit_banner.png</li> 2547</ol> 2548<div class="layout-chunk" data-layout="l-body"> 2549<div class="sourceCode"> 2550<pre class="sourceCode r"><code class="sourceCode r"><span class='va'>banner_png</span> <span class='op'>%>%</span> 2551 <span class='fu'>image_resize</span><span class='op'>(</span> 2552 <span class='fu'>geometry_size_pixels</span><span class='op'>(</span>width <span class='op'>=</span> <span class='fl'>1000</span>, 2553 height <span class='op'>=</span> <span class='fl'>200</span>, 2554 preserve_aspect <span class='op'>=</span><span class='cn'>FALSE</span> <span class='op'>)</span><span class='op'>)</span> <span class='op'>%>%</span> 2555 <span class='fu'>image_annotate</span><span class='op'>(</span><span class='st'>"Auditing"</span>, 2556 location <span class='op'>=</span> <span class='fu'>geometry_point</span><span class='op'>(</span>x <span class='op'>=</span> <span class='fl'>350</span>, y <span class='op'>=</span> <span class='fl'>50</span><span class='op'>)</span>, 2557 size <span class='op'>=</span> <span class='fl'>50</span>, font <span class='op'>=</span> <span class='st'>"Comic Sans"</span><span class='op'>)</span> <span class='op'>%>%</span> 2558 <span class='fu'>image_write</span><span class='op'>(</span> 2559 <span class='fu'>here</span><span class='op'>(</span> 2560 <span class='st'>"_posts"</span>, 2561 <span class='st'>"create-a-banner-and-buttons-with-r"</span>,<span class='st'>"audit_banner.png"</span><span class='op'>)</span> 2562 <span class='op'>)</span> 2563</code></pre> 2564</div> 2565</div> 2566<ol start="6" type="1"> 2567<li>Start with the banner background and size for a button</li> 2568</ol> 2569<div class="layout-chunk" data-layout="l-body"> 2570<div class="sourceCode"> 2571<pre class="sourceCode r"><code class="sourceCode r"><span class='va'>banner_png</span> <span class='op'>%>%</span> 2572 <span class='fu'>image_resize</span><span class='op'>(</span> 2573 <span class='fu'>geometry_size_pixels</span><span class='op'>(</span>width <span class='op'>=</span> <span class='fl'>150</span>, 2574 height <span class='op'>=</span> <span class='fl'>75</span>, 2575 preserve_aspect <span class='op'>=</span><span class='cn'>FALSE</span> <span class='op'>)</span><span class='op'>)</span> <span class='op'>-></span> <span class='va'>button</span> 2576<span class='va'>button</span> 2577</code></pre> 2578</div> 2579<p><img src="index_files/figure-html5/unnamed-chunk-8-1.png" width="75" /></p> 2580</div> 2581<ol start="7" type="1"> 2582<li>Start with the button and add text</li> 2583</ol> 2584<div class="layout-chunk" data-layout="l-body"> 2585<div class="sourceCode"> 2586<pre class="sourceCode r"><code class="sourceCode r"><span class='va'>button</span> <span class='op'>%>%</span> <span class='fu'>image_annotate</span><span class='op'>(</span><span class='st'>"Syllabus"</span>, 2587 location <span class='op'>=</span> <span class='fu'>geometry_point</span><span class='op'>(</span>x <span class='op'>=</span> <span class='fl'>15</span>, y <span class='op'>=</span> <span class='fl'>10</span><span class='op'>)</span>, 2588 size <span class='op'>=</span> <span class='fl'>30</span>, font <span class='op'>=</span> <span class='st'>"Comic Sans"</span><span class='op'>)</span> <span class='op'>%>%</span> 2589 <span class='fu'>
2589image_border</span><span class='op'>(</span><span class='st'>"black"</span>, <span class='st'>"4x4"</span><span class='op'>)</span> 2590</code></pre> 2591</div> 2592<p><img src="index_files/figure-html5/unnamed-chunk-9-1.png" width="79" /></p> 2593</div> 2594<div class="layout-chunk" data-layout="l-body"> 2595<div class="sourceCode"> 2596<pre class="sourceCode r"><code class="sourceCode r"><span class='va'>button</span> <span class='op'>%>%</span> <span class='fu'>image_annotate</span><span class='op'>(</span><span class='st'>"Modules"</span>, 2597 location <span class='op'>=</span> <span class='fu'>geometry_point</span><span class='op'>(</span>x <span class='op'>=</span> <span class='fl'>15</span>, y <span class='op'>=</span> <span class='fl'>10</span><span class='op'>)</span>, 2598 size <span class='op'>=</span> <span class='fl'>30</span>, font <span class='op'>=</span> <span class='st'>"Comic Sans"</span><span class='op'>)</span> <span class='op'>%>%</span> 2599 <span class='fu'>image_border</span><span class='op'>(</span><span class='st'>"black"</span>, <span class='st'>"4x4"</span><span class='op'>)</span> 2600</code></pre> 2601</div> 2602<p><img src="index_files/figure-html5/unnamed-chunk-10-1.png" width="79" /></p> 2603</div> 2604<ol start="8" type="1"> 2605<li>Write the buttons to png files</li> 2606</ol> 2607<div class="layout-chunk" data-layout="l-body"> 2608<div class="sourceCode"> 2609<pre class="sourceCode r"><code class="sourceCode r"><span class='va'>button</span> <span class='op'>%>%</span> <span class='fu'>image_annotate</span><span class='op'>(</span><span class='st'>"Syllabus"</span>, 2610 location <span class='op'>=</span> <span class='fu'>geometry_point</span><span class='op'>(</span>x <span class='op'>=</span> <span class='fl'>15</span>, y <span class='op'>=</span> <span class='fl'>10</span><span class='op'>)</span>, 2611 size <span class='op'>=</span> <span class='fl'>30</span>, font <span class='op'>=</span> <span class='st'>"Comic Sans"</span><span class='op'>)</span> <span class='op'>%>%</span> 2612 <span class='fu'>image_border</span><span class='op'>(</span><span class='st'>"black"</span>, <span class='st'>"4x4"</span><span class='op'>)</span> <span class='op'>%>%</span> 2613 <span class='fu'>image_write</span><span class='op'>(</span><span class='fu'>here</span><span class='op'>(</span> 2614 <span class='st'>"_posts"</span>, 2615 <span class='st'>"create-a-banner-and-buttons-with-r"</span>,<span class='st'>"syllabus_btn.png"</span><span class='op'>)</span> 2616<span class='op'>)</span> 2617 2618 2619 2620<span class='va'>button</span> <span class='op'>%>%</span> <span class='fu'>image_annotate</span><span class='op'>(</span><span class='st'>"Modules"</span>, 2621 location <span class='op'>=</span> <span class='fu'>geometry_point</span><span class='op'>(</span>x <span class='op'>=</span> <span class='fl'>15</span>, y <span class='op'>=</span> <span class='fl'>10</span><span class='op'>)</span>, 2622 size <span class='op'>=</span> <span class='fl'>30</span>, font <span class='op'>=</span> <span class='st'>"Comic Sans"</span><span class='op'>)</span> <span class='op'>%>%</span> 2623 <span class='fu'>image_border</span><span class='op'>(</span><span class='st'>"black"</span>, <span class='st'>"4x4"</span><span class='op'>)</span> <span class='op'>%>%</span> 2624 <span class='fu'>image_write</span><span class='op'>(</span><span class='fu'>here</span><span class='op'>(</span> 2625 <span class='st'>"_posts"</span>, 2626 <span class='st'>"create-a-banner-and-buttons-with-r"</span>,<span class='st'>"modules_btn.png"</span><span class='op'>)</span> 2627 <span class='op'>)</span> 2628</code></pre> 2629</div> 2630</div> 2631<p><em>Note: for a banner and buttons that are not in a Canvas course you probably donât want to add the text.</em></p> 2632<div class="sourceCode" id="cb1"><pre class="sourceCode r distill-force-highlighting-css"><code class="sourceCode r"></code></pre></div> 2633<!--radix_placeholder_article_footer--> 2634<!--/radix_placeholder_article_footer--> 2635</div> 2636 2637<div class="d-appendix"> 2638</div> 2639 2640 2641<!--radix_placeholder_site_after_body--> 2642<!--/radix_placeholder_site_after_body--> 2643<!--radix_placeholder_appendices--> 2644<div class="appendix-bottom"></div> 2645<!--/radix_placeholder_appendices--> 2646<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> 2647<!--radix_placeholder_navigation_after_body--><html><body> 2648<div class="distill-site-nav distill-site-footer"> 2649<p>© Copyright 2021-2022 Elizabeth Stanny. Website template is by <a href="https://distill.pub/about/">Distill.pub</a> and <a href="https://www.rstudio.com">RStudio, Inc</a>.</p> 2650</div> 2651<!--/radix_placeholder_navigation_after_body--> 2652</body></html> 2653 2654 2655</body> 2656 2657</html>
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.