Skip to content

Commit

Permalink
add input layouts defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
hypebright committed Apr 26, 2024
1 parent 44d11c2 commit ca5fe90
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,5 @@ importFrom(jsonlite,toJSON)
importFrom(lifecycle,deprecated)
importFrom(magrittr,"%>%")
importFrom(shiny,registerInputHandler)
importFrom(utils,modifyList)
importFrom(utils,packageVersion)
21 changes: 21 additions & 0 deletions R/f7-inputs.R
Original file line number Diff line number Diff line change
Expand Up @@ -892,17 +892,38 @@ updateF7SmartSelect <- function(inputId, selected = NULL, choices = NULL, multip
session$sendInputMessage(inputId, message)
}

#' Input layout default options
#'
#' @keywords internal
inputLayoutDefaults <- function() {
list(
media = NULL,
description = NULL,
floating = FALSE,
outline = FALSE,
clearable = TRUE
)
}

#' Create common input layout
#'
#' See \url{https://framework7.io/docs/inputs#inputs-layout}.
#'
#' @importFrom utils modifyList
#'
#' @keywords internal
createInputLayout <- function(
..., label = NULL, style, dropdown = FALSE) {

if (style$floating && is.null(label)) {
stop("floating can't be used when label is NULL")
}

# make sure style does contain all defaults
# this prevents an error when the users only provides
# a subset of the style options
style <- modifyList(inputLayoutDefaults(), style)

This comment has been minimized.

Copy link
@DivadNojnarg

DivadNojnarg Apr 26, 2024

Member

Thanks for adding this. I wanted to point this out but you read in my mind :)

This comment has been minimized.

Copy link
@hypebright

hypebright Apr 26, 2024

Author Contributor

Note: I just saw the same with f7Radio, would also need something similar

item <- f7ListItem(
media = style$media, # icon
title = label # label
Expand Down
12 changes: 12 additions & 0 deletions man/inputLayoutDefaults.Rd

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

0 comments on commit ca5fe90

Please sign in to comment.