Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add labels option to calendar range #375

Open
wants to merge 1 commit into
base: ryszard.support_for_calendar_ranges
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion R/calendar_range.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
#' @param end_placeholder Text visible in the end calendar input when nothing is inputted.
#' @param min Minimum allowed value in both calendars.
#' @param max Maximum allowed value in both calendars.
#' @param start_label Label text in the start calendar.
#' @param end_label Label text in the end calendar.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about changing the descriptions to 'Label to be displayed with the start calendar' and 'Label to be displayed with the end calendar'?

#'
#' @rdname calendar_range
#' @export
#'
calendar_range <- function(input_id, type = "date", start_value = NULL, end_value = NULL,
start_placeholder = NULL, end_placeholder = NULL, min = NA, max = NA) {
start_placeholder = NULL, end_placeholder = NULL, min = NA, max = NA,
start_label = NULL, end_label = NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've checked that in the majority of inputs we keep the order of arguments the same as in basic shiny inputs, this is: id, label, value/choices. How about putting the labels after the input_id argument?

if (!is.null(start_value)) start_value <- format(as.Date(start_value), "%Y/%m/%d")
if (!is.null(end_value)) end_value <- format(as.Date(end_value), "%Y/%m/%d")
if (!is.na(min)) min <- format(as.Date(min), "%Y/%m/%d")
Expand Down Expand Up @@ -73,10 +76,12 @@ calendar_range <- function(input_id, type = "date", start_value = NULL, end_valu
class = "two fields",
div(
class = "field",
tags$label(start_label),
start_cal_widget
),
div(
class = "field",
tags$label(end_label),
end_cal_widget
)
)
Expand Down
4 changes: 3 additions & 1 deletion examples/calendar_range/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ ui <- semanticPage(
min = "2020-01-01",
max = "2020-12-01",
start_placeholder = "Select range start",
end_placeholder = "Select range end"
end_placeholder = "Select range end",
start_label = "Start Date",
end_label = "End Date"
),
div(
class = "two fields",
Expand Down
8 changes: 7 additions & 1 deletion man/calendar_range.Rd

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