ecoquants / findinghal

white abalone recovery & community engagement
http://findinghal.org
MIT License
0 stars 0 forks source link

Abalone ID - bootstrap cards #9

Closed mspector13 closed 3 years ago

mspector13 commented 3 years ago

Hey @bbest,

I've been playing around with bootstrap cards; css is beyond clunky, but I think I've made some progress.

Rather than create an "Abalone ID Key", we can instead use Oriana Poindexter's already-made ID cards! Oriana is a collaborator on this project, and should be in the process of making ID cards for all seven species (currently she has made cards for white and black abalone).

To try and utilize her cards, I've been working in ab_cards.Rmd to mess with layout etc. Here's what I've got so far: Screen Shot 2021-05-11 at 3 50 33 PM

Right now there's still a lot of functionality to build in and play with, but I think I'm up against a wall at this point. For example, it would be great to be able to access each card as a pop-up modal, yet I can't seem to figure out how to make that happen.

Let me know what you think!

bbest commented 3 years ago

There's going to be up to 7 cards, 1 per species.

Want:

References:

bbest commented 3 years ago

Hey @mspector13,

I learned a lot about using Bootstrap Cards recently with Sanctsound. Check out this bs4 branch:

mspector13 commented 3 years ago

Right on, thanks @bbest! I checked 4 out of 6 boxes above after shamelessly adapting this boostrapious gallery example. HTML isn't so scary after all! check out ab_id_cards.Rmd and/or the newly revamped ID card section.

I also really like how you sourced _cards.html in index.Rmd, it really makes HTML easier to work with, so I did the same (_abcards.html)

However, there's one.... very bizarre issue that I can't wrap my head around. The buttons under each card open the corresponding PDF in a new tab. However, go ahead and click on the green abalone image on the top of the card... and then click on literally any of the others (aside from black abalone). You'll see what I mean. Any ideas?

mspector13 commented 3 years ago

Actually @bbest I'm really unsatisfied with how the "download" button looks. They scale with the window's width... but strangly:

Screen Shot 2021-05-19 at 6 11 01 PM

A more narrow view: Screen Shot 2021-05-19 at 6 12 32 PM

I think this is partly how the cards are called ("column") and auto-scaling in the HTML. What do you think?

bbest commented 3 years ago

Looking good @mspector13!

Here's how this is working (with canonical links to capture snapshot now vs changes later):

Here are a few opinionated suggestions (feel free to disregard):

mspector13 commented 3 years ago

Right on, thanks Ben! I changed the file names to exclude "ab", "ID" etc, hopefully the repo looks cleaner.

I also futzed around the html to deal with card-image sizing issues, and I think it looks a lot cleaner. Unfortunately the HTML is a little sloppier; I changed each card's dimensions instead of wrapping it all in a card-deck container due to resizing issues.

Stylistically I prefer this "hybrid" button design as opposed to standard Bootstrap buttons, but I'm open to suggestions.

However, there's still really funky error going on with the card images.

To recap: nothing happens if you click on the black abalone image (nothing should happen). But, if you click on the green abalone image (for example) the black abalone ID card opens! And iteratively down the line (clicking on red opens pink, clicking on white opens red). I have no idea what's going on here... the HTML is all in _cards.html. Any ideas??

bbest commented 3 years ago

<a> funk

Looks like that behavior was an artifact of improperly closing the <a> tag:

funky:

<a href = "./images/ID_cards/ID Guide_Black_05172021.pdf" target="_blank" </a>

correct:

<a href = "./images/ID_cards/ID Guide_Black_05172021.pdf" target="_blank"></a>

class="stretched-link"

You can force the link to span the card with class="stretched-link":

<a href = "./images/ID_cards/ID Guide_Black_05172021.pdf" target="_blank" class="stretched-link"></a>

pmap each card

Since each card has a similar form, I took the liberty of making a new _card.html template per card that can then get substituted with values using knitr::knit_expand(). Then we can setup a csv to have all our unique values and feed it into a function with purrr::pmap(). Finally the html gets escaped with htmltools::HTML().

https://github.com/ecoquants/findinghal/blob/e800d90f14dee7cf088c35db135d8927c231d5f8/cards.Rmd#L26-L33

I'll leave it to you to fill out the rest of cards.csv:

image

Note that you can now match the btn_bkgrnd_color exactly with the pdf's ;)

mspector13 commented 3 years ago

Aaaaa sneaky sneaky! Thanks for finding this so quickly, and for updating the HTML to call cards.csv

I've updated the spreadsheet and pushed the changes. Everything looks good on my end!

I'm having a hard time follow all of the HTML in _card.html but I'm sure i'll be able to figure it out.