Skip to content

Commit

Permalink
simplify for use in custom modules
Browse files Browse the repository at this point in the history
  • Loading branch information
hypebright committed May 22, 2024
1 parent d777897 commit 52497db
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ the new router layout. Items must be wrapped in a `shiny::tagList()`.
- `updateF7App` can now also handle changes in app theme (ios or md), dark mode, and color.
- `f7Fabs()` has a new argument `global` that can be used to make FABs persistent across different tabs in `f7TabLayout()`.
- `f7ExpandableCard()` has a new argument `buttonColor` that can be used to control the color of the close button.
- `f7Login()` has a new argument `module` that can, optionally, be set to `FALSE` for more flexibility. For example, this allows you to use `f7Login()` inside your own modules, or without the provided `f7LoginServer()` module.
- Fix various issues in documentation.
- Include new vignettes.

Expand Down
14 changes: 9 additions & 5 deletions R/f7Login.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,25 @@
#' @param startOpen Whether to open the login page at start. Default to TRUE. There
#' are some cases where it is interesting to set up to FALSE, for instance when you want
#' to have authentication only in a specific tab of your app (See example 2).
#' @param module Whether or not to use in combination with \link{f7LoginServer}. Can be
#' set to FALSE if you want to develop your own server functionality, or if you want to
#' use \code{f7Login} inside a module yourself. Defaults to TRUE.
#'
#' @export
#' @rdname authentication
#' @importFrom jsonlite toJSON
#' @example inst/examples/login/app.R
f7Login <- function(..., id, title, label = "Sign In", footer = NULL,
startOpen = TRUE) {
startOpen = TRUE, module = TRUE) {

ns <- shiny::NS(id)

submitBttn <- f7Button(inputId = ns("submit"), label = label)
submitBttn <- f7Button(inputId = ifelse(module, ns("submit"), "submit"), label = label)
submitBttn[[2]]$attribs$class <- "item-link list-button f7-action-button"
submitBttn[[2]]$name <- "a"

shiny::tags$div(
id = ns(id),
id = ifelse(module, ns(id), id),
`data-start-open` = jsonlite::toJSON(startOpen),
class = "login-screen",
shiny::tags$div(
Expand All @@ -49,12 +53,12 @@ f7Login <- function(..., id, title, label = "Sign In", footer = NULL,
shiny::tags$form(
f7List(
f7Text(
inputId = ns("user"),
inputId = ifelse(module, ns("user"), "user"),
label = "Username",
placeholder = "Your name here"
),
f7Password(
inputId = ns("password"),
inputId = ifelse(module, ns("password"), "password"),
label = "Password",
placeholder = "Your password here"
),
Expand Down
14 changes: 13 additions & 1 deletion man/authentication.Rd

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

0 comments on commit 52497db

Please sign in to comment.