File size: 1,125 Bytes
3b53c8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
edbf29d
3b53c8a
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# remotes::install_github("jrosell/ambhtmx", force = TRUE)
library(ambhtmx)
# devtools::load_all()

card_3d_demo <- \() {  
  card <- "card"
  tryCatch(
    expr = {
      # Original python code credit: https://fastht.ml/
      # Design credit: https://codepen.io/markmiro/pen/wbqMPa
      bgurl <- "https://ucarecdn.com/35a0e8a7-fcc5-48af-8a3f-70bb96ff5c48/-/preview/750x1000/"
      card_styles <- "font-family: 'Arial Black', 'Arial Bold', Gadget, sans-serif; perspective: 1500px;"
      card_3d <- \(text, bgurl, amt, left_align) {
        align <- ifelse(left_align, 'left', 'right')
        scr <- script_from_js_tpl('card3d.js', amt = amt)	      
        sty <- style_from_css_tpl(
          'card3d.css', bgurl = glue('url({bgurl})'), align = align
        )   
        div(text, div(), scr, sty, align = align)
      }
      card <- card_3d("Mouseover me", bgurl, amt = 1.5, left_align = T)
    },
    error = \(e) print(e)
  )
  div(card, style = card_styles)
}

app <- ambhtmx_app(host = "0.0.0.0", port = "7860", protocol ="http")$app

app$get("/", \(req, res) {
  card_3d_demo() |> send_page(res)
})

app$start()