Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lab2godata: godataR logo appearing oversized in readme file #13

Closed
AmyMikhail opened this issue Sep 29, 2022 · 0 comments
Closed

lab2godata: godataR logo appearing oversized in readme file #13

AmyMikhail opened this issue Sep 29, 2022 · 0 comments
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@AmyMikhail
Copy link
Contributor

Reported by:

@sarahollis

Problem statement:

After transferring the readme information to an Rmd file for better rendering, the logo appeared greatly oversized and centre instead of right-justified.

Proposed solution:

The logo has to be 64-bit encoded to a html file with the relevant height and width (as a percentage of the total) specified in css code. The html file then has to be appended to the title by mentioning it in the YAML header.

This is done in two steps as follows:

  1. Run the below R chunk (now added to the top of README.Rmd) to create the html version of the logo every time you edit any of the logo parameters. Note that this chunk has to be run by itself BEFORE knitting the whole .Rmd to a Github document, as knitting will fail if the YAML header can't find the html file containing the logo.
### Note:
# - If you need to update the size of the logo, edit the width and height below and then run this chunk BEFORE knitting

# Ensures the package "pacman" is installed
if (!require("pacman")) install.packages("pacman")

# Load required libraries:
pacman::p_load(htmltools, 
               here,
               readr)

# Base-64 encode the image file:
img <- htmltools::img(src = knitr::image_uri(f = here::here("inst", 
                                                            "app", 
                                                            "www", 
                                                            "godataR_logo.png")),
                      alt = 'logo',
                      style = 'position:absolute; 
                               width:10%;
                               height:15%;
                               top:10px; 
                               right:1%; 
                               padding:10px; 
                               z-index:200;')

# Create the image file:
htmlhead <- paste0('<script>
                   document.write(\'<div class="logos">', img, '</div>\')
                   </script>')

# Read in the image file:
readr::write_lines(htmlhead, file = "header.html")

  1. Knit the Rmd, which will now incorporate the logo in the title space as specified in the updated YAML header:
---
title: "godataR: easier wrangling with the Go.Data API"
date: "`r format(Sys.time(), '%d %B %Y')`"
output: 
  github_document:
        includes:
          in_header: header.html
---
@AmyMikhail AmyMikhail added bug Something isn't working documentation Improvements or additions to documentation labels Sep 29, 2022
@AmyMikhail AmyMikhail self-assigned this Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant