Skip to content

Commit

Permalink
test link
Browse files Browse the repository at this point in the history
  • Loading branch information
DivadNojnarg committed Mar 15, 2024
1 parent cae108a commit c4ad521
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 42 deletions.
55 changes: 27 additions & 28 deletions R/f7Link.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,40 @@
#' @param icon Link icon, if any. Must pass \link{f7Icon}.
#'
#' @examples
#' if(interactive()){
#' library(shiny)
#' library(shinyMobile)
#' if (interactive()) {
#' library(shiny)
#' library(shinyMobile)
#'
#' shinyApp(
#' ui = f7Page(
#' title = "Links",
#' f7SingleLayout(
#' navbar = f7Navbar(title = "f7Link"),
#' f7Link(label = "Google", href = "https://www.google.com"),
#' f7Link(href = "https://www.twitter.com", icon = f7Icon("bolt_fill"))
#' )
#' ),
#' server = function(input, output) {}
#' )
#' shinyApp(
#' ui = f7Page(
#' title = "Links",
#' f7SingleLayout(
#' navbar = f7Navbar(title = "f7Link"),
#' f7Link(label = "Google", href = "https://www.google.com"),
#' f7Link(href = "https://www.twitter.com", icon = f7Icon("bolt_fill"))
#' )
#' ),
#' server = function(input, output) {}
#' )
#' }
#'
#' @author David Granjon, \email{dgranjon@@ymail.com}
#'
#' @export
f7Link <- function(label = NULL, href, icon = NULL) {

linkCl <- "link external"

shiny::a(
href = href,
target = "_blank",
class = linkCl,
if (!is.null(icon)) {
shiny::tagList(
icon,
label
)
} else {
label
}
)
shiny::a(
href = href,
target = "_blank",
class = linkCl,
if (!is.null(icon)) {
shiny::tagList(
icon,
label
)
} else {
label
}
)
}
28 changes: 14 additions & 14 deletions man/f7Link.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/testthat/test-f7Link.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test_that("link works", {
expect_s3_class(f7Link(href = "https://google.com"), "shiny.tag")
expect_identical(f7Link(href = "test")$attribs$class, "link external")
})

0 comments on commit c4ad521

Please sign in to comment.