Skip to content
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
17 changes: 5 additions & 12 deletions R/shiny-material-button.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
material_button <- function(input_id, label, icon = NULL, depth = NULL, color = NULL) {

if(!is.null(icon)){
empty_label <- label == "" || is.null(label)
icon_tag <-
shiny::HTML(
paste0(
'<i class="material-icons left">',
'<i class="material-icons ', if(!empty_label) "left", '">',
icon,
'</i>')
)
Expand All @@ -36,18 +37,10 @@ material_button <- function(input_id, label, icon = NULL, depth = NULL, color =
shiny::tagList(
shiny::tags$button(
class =
paste0(
paste(
"waves-effect waves-light btn shiny-material-button",
ifelse(
is.null(depth),
"",
paste0(" z-depth-", depth)
),
ifelse(
is.null(color),
"",
paste0(" ", color)
)
if(!is.null(depth)) paste0("z-depth-", depth),
if(!is.null(color)) color
),
id = input_id,
value = 0,
Expand Down
61 changes: 14 additions & 47 deletions R/shiny-material-modal.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,25 @@
material_modal <- function(modal_id, button_text, title, ..., button_icon = NULL, floating_button = FALSE, button_depth = NULL, button_color = NULL, close_button_label = "Close", display_button = TRUE){

if(!is.null(button_icon)){
empty_button_text <- button_text == "" || is.null(button_text)
icon_tag <-
shiny::HTML(
paste0(
'<i class="material-icons left">',
'<i class="material-icons ', if (!empty_button_text) "left", '">',
button_icon,
'</i>')
)
} else {
icon_tag <- NULL
}

button_class <-
paste0(
"waves-effect waves-light shiny-material-modal-trigger modal-trigger",
ifelse(is.null(button_color),
"",
paste0(" ", button_color)
),
ifelse(
is.null(button_depth),
"",
paste0(" z-depth-", button_depth)
)
)

if(!floating_button){
button_class <-
paste0(
button_class,
" btn"
)
} else {
button_class <-
paste0(
button_class,
" btn-floating btn-large waves-effect waves-light z-depth-3"
)
}
button_class <- paste(
"waves-effect waves-light shiny-material-modal-trigger modal-trigger",
if (!is.null(button_color)) button_color,
if (!is.null(button_depth)) paste0("z-depth-", button_depth),
if (floating_button) "btn-floating btn-large waves-effect waves-light z-depth-3"
else "btn shiny-material-button"
)

create_material_object(
js_file =
Expand All @@ -68,32 +49,18 @@ material_modal <- function(modal_id, button_text, title, ..., button_icon = NULL
shiny::tagList(
shiny::tags$div(
class =
ifelse(
floating_button,
"fixed-action-btn",
""
),
if(floating_button) "fixed-action-btn",
shiny::tags$button(
`data-target` = modal_id,
display = ifelse(display_button, "inline-block", "none"),
class = button_class,
style =
paste0(
ifelse(
floating_button,
"background-color:#F06C71;",
""
),
ifelse(display_button,
"",
" display:none;")
paste(
if(floating_button) "background-color:#F06C71;",
if(!display_button) "display:none;"
),
icon_tag,
ifelse(
floating_button,
"",
button_text
)
if(!floating_button) button_text
)
),
shiny::tags$div(
Expand Down