Skip to content

Commit

Permalink
update f7Bock
Browse files Browse the repository at this point in the history
  • Loading branch information
DivadNojnarg committed Mar 15, 2024
1 parent 2310b22 commit 9b11d62
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 140 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
- `multiCollapse` has been removed in Framework7.
- `f7AddMessages()` is definitely removed. Deprecated from other releases.
- `f7Appbar()` has been removed in Framework7. We have no alternative to replace it.
- `f7Block()`:
- `hairlines` is deprecated since removed from Framework7.

## Minor change
- `f7Messages()`: the corresponding input is now a list of lists, each item
being a single `f7Message()`. The previous setting was not optimal R,the JS binding was returning a array of objects, which can't be easily translated to R.
We now return an object of objects which becomes a list of lists.
- `f7Block()` gains an `outline` parameter (add grey border).

# shinyMobile 1.0.1

Expand Down
150 changes: 83 additions & 67 deletions R/f7Block.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,111 +4,127 @@
#'
#' @param ... Block content. Also for \link{f7BlockHeader} and \link{f7BlockFooter}.
#' @param hairlines Whether to allow hairlines. TRUE by default.
#' @param strong Whether to put the text in bold. FALSE by default.
#' @param strong Add white background so that text is highlighted. FALSE by default.
#' @param inset Whether to set block inset. FALSE by default. Works only if strong is TRUE.
#' @param tablet Whether to make block inset only on large screens. FALSE by default.
#' @param outline Block border. Default to FALSE.
#'
#' @rdname block
#' @examples
#' if(interactive()){
#' library(shiny)
#' library(shinyMobile)
#'
#' shinyApp(
#' ui = f7Page(
#' title = "Blocks",
#' f7SingleLayout(
#' navbar = f7Navbar(title = "f7Block"),
#' f7BlockTitle(title = "A large title", size = "large"),
#' f7Block(
#' f7BlockHeader(text = "Header"),
#' "Here comes paragraph within content block.
#' if (interactive()) {
#' library(shiny)
#' library(shinyMobile)
#'
#' shinyApp(
#' ui = f7Page(
#' title = "Blocks",
#' f7SingleLayout(
#' navbar = f7Navbar(title = "f7Block"),
#' f7BlockTitle(title = "A large title", size = "large"),
#' f7Block(
#' f7BlockHeader(text = "Header"),
#' "Here comes paragraph within content block.
#' Donec et nulla auctor massa pharetra
#' adipiscing ut sit amet sem. Suspendisse
#' molestie velit vitae mattis tincidunt.
#' Ut sit amet quam mollis, vulputate
#' turpis vel, sagittis felis.",
#' f7BlockFooter(text = "Footer")
#' ),
#'
#' f7BlockTitle(title = "A medium title", size = "medium"),
#' f7Block(
#' strong = TRUE,
#' f7BlockHeader(text = "Header"),
#' "Here comes paragraph within content block.
#' f7BlockFooter(text = "Footer")
#' ),
#' f7BlockTitle(title = "A medium title", size = "medium"),
#' f7Block(
#' strong = TRUE,
#' outline = TRUE,
#' f7BlockHeader(text = "Header"),
#' "Here comes paragraph within content block.
#' Donec et nulla auctor massa pharetra
#' adipiscing ut sit amet sem. Suspendisse
#' molestie velit vitae mattis tincidunt.
#' Ut sit amet quam mollis, vulputate
#' turpis vel, sagittis felis.",
#' f7BlockFooter(text = "Footer")
#' ),
#'
#' f7BlockTitle(title = "A normal title", size = NULL),
#' f7Block(
#' inset = TRUE,
#' strong = TRUE,
#' f7BlockHeader(text = "Header"),
#' "Here comes paragraph within content block.
#' f7BlockFooter(text = "Footer")
#' ),
#' f7BlockTitle(title = "A normal title", size = NULL),
#' f7Block(
#' inset = TRUE,
#' strong = TRUE,
#' f7BlockHeader(text = "Header"),
#' "Here comes paragraph within content block.
#' Donec et nulla auctor massa pharetra
#' adipiscing ut sit amet sem. Suspendisse
#' molestie velit vitae mattis tincidunt.
#' Ut sit amet quam mollis, vulputate
#' turpis vel, sagittis felis.",
#' f7BlockFooter(text = "Footer")
#' ),
#' f7Block(
#' tablet = TRUE,
#' strong = TRUE,
#' f7BlockHeader(text = "Header"),
#' "Here comes paragraph within content block.
#' f7BlockFooter(text = "Footer")
#' ),
#' f7Block(
#' inset = TRUE,
#' tablet = TRUE,
#' strong = TRUE,
#' f7BlockHeader(text = "Header"),
#' "Here comes paragraph within content block.
#' Donec et nulla auctor massa pharetra
#' adipiscing ut sit amet sem. Suspendisse
#' molestie velit vitae mattis tincidunt.
#' Ut sit amet quam mollis, vulputate
#' turpis vel, sagittis felis.",
#' f7BlockFooter(text = "Footer")
#' ),
#' f7Block(
#' inset = TRUE,
#' strong = TRUE,
#' hairlines = FALSE,
#' f7BlockHeader(text = "Header"),
#' "Here comes paragraph within content block.
#' f7BlockFooter(text = "Footer")
#' ),
#' f7Block(
#' inset = TRUE,
#' strong = TRUE,
#' outline = TRUE,
#' f7BlockHeader(text = "Header"),
#' "Here comes paragraph within content block.
#' Donec et nulla auctor massa pharetra
#' adipiscing ut sit amet sem. Suspendisse
#' molestie velit vitae mattis tincidunt.
#' Ut sit amet quam mollis, vulputate
#' turpis vel, sagittis felis.",
#' f7BlockFooter(text = "Footer")
#' )
#' )
#' ),
#' server = function(input, output) {}
#' )
#' f7BlockFooter(text = "Footer")
#' )
#' )
#' ),
#' server = function(input, output) {}
#' )
#' }
#'
#' @author David Granjon, \email{dgranjon@@ymail.com}
#'
#' @export
f7Block <- function(..., hairlines = TRUE, strong = FALSE, inset = FALSE,
tablet = FALSE) {

tablet = FALSE, outline = FALSE) {
blockCl <- "block"
if (!hairlines) blockCl <- paste0(blockCl, " no-hairlines")

lifecycle::deprecate_warn(
when = "1.1.0",
what = "f7Block(hairlines)",
details = "hairlines has been
removed from Framework7 and will be removed from shinyMobile
in the next release."
)

if (!inset && tablet) {
stop("inset must be TRUE when tablet is TRUE")
}

if (!strong && inset) {
stop("inset requires strong to be TRUE")
}

if (strong) {
if (inset) {
blockCl <- paste0(blockCl, " block-strong inset")
} else {
blockCl <- paste0(blockCl, " block-strong")
blockCl <- paste(blockCl, "block-strong")
if (inset && !tablet) {
blockCl <- paste(blockCl, "inset")
}
}
if (tablet) blockCl <- paste0(blockCl, " tablet-inset")
if (tablet) blockCl <- paste(blockCl, "medium-inset")
if (outline) blockCl <- paste(blockCl, "block-outline")

shiny::tags$div(
class = blockCl,
...
)
shiny::tags$div(
class = blockCl,
...
)
}


Expand All @@ -123,7 +139,7 @@ f7Block <- function(..., hairlines = TRUE, strong = FALSE, inset = FALSE,
#' @author David Granjon, \email{dgranjon@@ymail.com}
#'
#' @export
f7BlockTitle <- function(title = NULL, size = NULL) {
f7BlockTitle <- function(title, size = NULL) {
titleCl <- "block-title"
if (!is.null(size)) {
if (size == "large") {
Expand All @@ -147,7 +163,7 @@ f7BlockTitle <- function(title = NULL, size = NULL) {
#' @rdname block
#'
#' @export
f7BlockHeader <- function(text = NULL) {
f7BlockHeader <- function(text) {
shiny::tags$div(class = "block-header", text)
}

Expand All @@ -161,6 +177,6 @@ f7BlockHeader <- function(text = NULL) {
#' @author David Granjon, \email{dgranjon@@ymail.com}
#'
#' @export
f7BlockFooter <- function(text = NULL) {
f7BlockFooter <- function(text) {
shiny::tags$div(class = "block-footer", text)
}
6 changes: 1 addition & 5 deletions inst/examples/gallery/tabs/tabCards.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ tabCards <- f7Tab(
tabName = "Cards",
icon = f7Icon("rectangle_stack", f7Badge(8, color = "green")),
active = FALSE,

f7BlockTitle(title = "f7Block") %>% f7Align(side = "center"),
f7Block(
f7BlockHeader(text = "Header"),
Expand All @@ -16,7 +15,6 @@ tabCards <- f7Tab(
f7BlockFooter(text = "Footer")
),
br(),

f7BlockTitle(title = "f7Block with wrapper") %>% f7Align(side = "center"),
f7Block(
strong = TRUE,
Expand All @@ -30,11 +28,11 @@ tabCards <- f7Tab(
f7BlockFooter(text = "Footer")
),
br(),

f7BlockTitle(title = "f7Block with wrapper and inset") %>% f7Align(side = "center"),
f7Block(
inset = TRUE,
strong = TRUE,
outline = TRUE,
f7BlockHeader(text = "Header"),
"Here comes paragraph within content block.
Donec et nulla auctor massa pharetra
Expand All @@ -44,7 +42,6 @@ tabCards <- f7Tab(
turpis vel, sagittis felis.",
f7BlockFooter(text = "Footer")
),

br(),

# classic card without header nor footer
Expand Down Expand Up @@ -111,7 +108,6 @@ tabCards <- f7Tab(
f7BlockTitle(title = "f7MediaCard") %>% f7Align(side = "center"),
f7Card(
title = "A card with media:",

f7List(
mode = "media",
lapply(1:2, function(j) {
Expand Down
Loading

0 comments on commit 9b11d62

Please sign in to comment.