Skip to content

Commit

Permalink
version 0.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ericrayanderson authored and cran-robot committed Mar 3, 2019
1 parent fc64bb7 commit 9a8fbd6
Show file tree
Hide file tree
Showing 18 changed files with 240 additions and 35 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: shinymaterial
Type: Package
Title: Implement Material Design in Shiny Applications
Version: 0.5.4
Version: 0.5.5
Authors@R: c(
person("Eric", "Anderson", role = c("aut", "cre"), email = "eric.ray.anderson@gmail.com"),
person("Alvin", "Wang", role = c("ctb", "cph"), comment = "Materialize CSS library"),
Expand All @@ -18,11 +18,11 @@ Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
NeedsCompilation: no
Packaged: 2019-02-02 17:59:17 UTC; ericrayanderson
Packaged: 2019-03-03 17:23:48 UTC; ericrayanderson
Author: Eric Anderson [aut, cre],
Alvin Wang [ctb, cph] (Materialize CSS library),
Alan Chang [ctb, cph] (Materialize CSS library),
Alex Mark [ctb, cph] (Materialize CSS library),
Kevin Louie [ctb, cph] (Materialize CSS library)
Repository: CRAN
Date/Publication: 2019-02-02 18:10:03 UTC
Date/Publication: 2019-03-03 18:00:02 UTC
25 changes: 17 additions & 8 deletions MD5
@@ -1,6 +1,7 @@
01728685db994ccab9e92198ecf1c655 *DESCRIPTION
5a9de3b14c7a00d012c316812b1cd312 *DESCRIPTION
92a1aff9e5fce817842f482bbf41652c *LICENSE
fba50e4740828b86075b21c7fdd7cd36 *NAMESPACE
c890ba43c72116e067e7e611e1c04b2b *NAMESPACE
09270aa0af10a8af8b04aaee957a4f81 *R/close-shiny-material-modal.R
25a8b93f82b012f5130ff361fb0699ca *R/open-shiny-material-modal.R
954c67db0076f7b95391975e49750574 *R/shiny-material-button.R
b72880e59aaac2ca99274baaa84695f0 *R/shiny-material-card.R
Expand All @@ -14,10 +15,10 @@ b72880e59aaac2ca99274baaa84695f0 *R/shiny-material-card.R
c8658e0540ad2d74f9e888648f2c00c3 *R/shiny-material-input.R
ab86ae60a62b684016c9e2dcdc6949f6 *R/shiny-material-modal.R
33e31852e7c532bebcb21e68ccbfcecf *R/shiny-material-number-box.R
599fc7f4aa5185ce17de710360d5a965 *R/shiny-material-page.R
21274c71e10fd27f94b536e29462bfbd *R/shiny-material-page.R
1aa303ea2fa68aecb065d80eed43c24e *R/shiny-material-parallax.R
33fcdb3fd71aed94a3a0370fe220f9ba *R/shiny-material-password-box.R
4c34ef471b57382c4ca97c5543549dc8 *R/shiny-material-radio-button.R
17beb62e7756e66f5784f8a05cc7d613 *R/shiny-material-radio-button.R
b9f341df4479398c3f3f9cdcda8c6de0 *R/shiny-material-row.R
5813c6a56257aedb92b59537de33fced *R/shiny-material-side-nav-tab-content.R
58cc9775830691759a69e895e695f0e3 *R/shiny-material-side-nav-tabs-info.R
Expand All @@ -30,6 +31,7 @@ dc038275e83d2c93f24aee29fefb41b2 *R/shiny-material-tab-content.R
b29ef1c6db0cfeddcfe676b4b924671d *R/shiny-material-tabs.R
14d83ae627b05eb2218d58a74e53bcdf *R/shiny-material-text-box.R
3dff23dc443fa07ec4158b3c4e4bfb25 *R/shiny-material-utils.R
6ef9dedd095402f4502e0cb2611d6b0a *R/update-shiny-material-button.R
b5f27c74e95fd7e57cac74b133468a73 *R/update-shiny-material-checkbox.R
9c539fc38da05529ebe2f9ca61cf15cc *R/update-shiny-material-date-picker.R
e47a588278c58fd5903047b045c8930c *R/update-shiny-material-dropdown.R
Expand All @@ -39,12 +41,15 @@ ee556462ce6f91ede8033561df260306 *R/update-shiny-material-password-box.R
b629b86f9bd1355974b4670f4a95bccb *R/update-shiny-material-slider.R
c45787d8f1f9f73e3a65746a82d787a0 *R/update-shiny-material-switch.R
a58eb21ebaf315900398907dcd147ae6 *R/update-shiny-material-text-box.R
963ec61d4958f9323fd1ef81516aab35 *inst/css/shiny-material-icons.css
f88dd990824845589b9f44774bf648e9 *inst/css/shiny-material-page.css
8541820737a68f2fe4634627f6b08ad2 *inst/css/shiny-material-side-nav-fixed-image.css
45abefc5448d3d0a669744b8a3d303c9 *inst/css/shiny-material-side-nav-fixed.css
d41d8cd98f00b204e9800998ecf8427e *inst/css/shiny-material-side-nav-image.css
b51d1a8b1c8198161a76567c4c6e470a *inst/css/shiny-material-side-nav.css
305f67ef18828a28d927302a4a118692 *inst/css/shiny-material-tabs.css
ed1c57d6fa7f042758fbc8afbb7a336e *inst/doc/shinymaterial.pdf
f48107b13475476d85ec6bdde09096c1 *inst/icons/materialicons/v42/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2
1022da30719d2b382a3d2bfd1e428adc *inst/img/material.png
aa84eddf476b22f0a625d72da981a640 *inst/js/shiny-material-button.js
22e9abe00e07a213b31faca43eee8857 *inst/js/shiny-material-checkbox.js
Expand All @@ -57,7 +62,7 @@ d55a42bc32efafc596774350e24b7b7a *inst/js/shiny-material-number-box.js
6f27f20fb1e512f3434110a4028d6f66 *inst/js/shiny-material-page.js
1b86643be9fff3a99295dd1b92f93dbf *inst/js/shiny-material-parallax.js
63033aab42a38e4c207c2b50929d4bfe *inst/js/shiny-material-password-box.js
b04f2a22170a6890e6409388d9d6d8c5 *inst/js/shiny-material-radio-button.js
c6975fb2be0de0aa2a7316b15ef76d2a *inst/js/shiny-material-radio-button.js
a48912cf11ae24b82a5898e672a9e966 *inst/js/shiny-material-side-nav-fixed.js
9773931a9292d0659cf6689b30d98a2e *inst/js/shiny-material-side-nav-tabs.js
02df9765ba8bde0d4c214868ae3ac8d4 *inst/js/shiny-material-side-nav.js
Expand All @@ -78,6 +83,7 @@ cf4d60bc0b1d4b2314085919a00e1724 *inst/materialize/0.99.0/fonts/roboto/Roboto-Me
44b78f142603eb69f593ed4002ed7a4a *inst/materialize/0.99.0/fonts/roboto/Roboto-Thin.woff
1f35e6a11d27d2e10d28946d42332dc5 *inst/materialize/0.99.0/fonts/roboto/Roboto-Thin.woff2
1f6444a11f64b1f89b4137dc1669e55a *inst/materialize/0.99.0/js/materialize.min.js
8298e55232c8802bd632aed1c2e58070 *man/close_material_modal.Rd
6918ee59dd19ba392f59302078f5ec1f *man/material_button.Rd
cccc4a379c30700c18368d26fd4cc3ce *man/material_card.Rd
c4857022c0d54ec1e7f4bfbb56feb3bb *man/material_checkbox.Rd
Expand All @@ -90,10 +96,10 @@ b14ead19ada82d3e8705d96727d0e20f *man/material_file_input.Rd
deb996ebe75498d425bcdb30332d09c5 *man/material_input.Rd
a1c243a1143380476c0a07a8047aa020 *man/material_modal.Rd
f7d168b13dd6cbe8ee21014a2b9ece33 *man/material_number_box.Rd
7fc8ad1e8cfd98c825d67d511cc9d988 *man/material_page.Rd
b0e46437c8a54207c824c2e0a8750ea9 *man/material_page.Rd
c5b9a30e118cd6fe2db87d557719a006 *man/material_parallax.Rd
544ee035d73593e3dbe6b143ccd8f5c0 *man/material_password_box.Rd
1b9a5335d9f92e8eed955cbcf047de87 *man/material_radio_button.Rd
d052103037e96d118738a63a73963e7b *man/material_radio_button.Rd
522316209c5bf8e599d3f0fad3fc4cff *man/material_row.Rd
fd7209cb3ba7ab8719a32c67d09347f6 *man/material_side_nav.Rd
5407ef9376c88937a35a65ff1f132044 *man/material_side_nav_tab_content.Rd
Expand All @@ -106,6 +112,7 @@ c603e803d60d922ddcdfc59ea54f6782 *man/material_tabs.Rd
b1f8beb0aeee89e3d74092e7c2795874 *man/material_text_box.Rd
e69603135d9cc7d9a5872dd556e90956 *man/open_material_modal.Rd
90eea7a0826f214453e575f57e5417c1 *man/side_nav_tabs_info.Rd
e0d398984b2a9baf90f8630668c20621 *man/update_material_button.Rd
74c3d8e9f1f76e25f5782a69172fa4fd *man/update_material_checkbox.Rd
ddd51b061946afb443ba23106489d008 *man/update_material_date_picker.Rd
d094533aaa71acb35a573242bdf051f6 *man/update_material_dropdown.Rd
Expand All @@ -115,7 +122,7 @@ a0d0f15ab587a83840849a1cb3f9baa4 *man/update_material_number_box.Rd
648ac0e11fcf13ceb053a2e125becc1f *man/update_material_slider.Rd
dfc27c5520415aed0e91fca465164bef *man/update_material_switch.Rd
4ee920d018137a5b10e4940a252adcc6 *man/update_material_text_box.Rd
eb144c2ef430930d3fb116460034bfa0 *tests/app.R
e6ba68c6164f8e73314596501d5d0603 *tests/app.R
006c6b2a6e9696a703a9a943bd3db3e8 *tests/fileInputTest/app.R
eed9aab5449cc9c8430d7d258108f602 *tests/fileInputTest/www/fonts/roboto/Roboto-Bold.woff
c0f1e4a4fdfb8048c72e86aadb2a247d *tests/fileInputTest/www/fonts/roboto/Roboto-Bold.woff2
Expand All @@ -139,6 +146,7 @@ cf4d60bc0b1d4b2314085919a00e1724 *tests/include_font_app/www/fonts/roboto/Roboto
44b78f142603eb69f593ed4002ed7a4a *tests/include_font_app/www/fonts/roboto/Roboto-Thin.woff
1f35e6a11d27d2e10d28946d42332dc5 *tests/include_font_app/www/fonts/roboto/Roboto-Thin.woff2
26c5b264a05cd1885ca8d135d1431c65 *tests/issues/app.R
f48107b13475476d85ec6bdde09096c1 *tests/issues/www/icons/materialicons/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2
24a4af8157cbf8419ff5245cba3d03d1 *tests/no_nav.R
ac898411992904d23807a43ee2afad47 *tests/renderUITest/app.R
eed9aab5449cc9c8430d7d258108f602 *tests/renderUITest/www/fonts/roboto/Roboto-Bold.woff
Expand Down Expand Up @@ -175,3 +183,4 @@ cf4d60bc0b1d4b2314085919a00e1724 *tests/www/fonts/roboto/Roboto-Medium.woff
5136cbe62a63604402f2fedb97f246f8 *tests/www/fonts/roboto/Roboto-Regular.woff2
44b78f142603eb69f593ed4002ed7a4a *tests/www/fonts/roboto/Roboto-Thin.woff
1f35e6a11d27d2e10d28946d42332dc5 *tests/www/fonts/roboto/Roboto-Thin.woff2
f48107b13475476d85ec6bdde09096c1 *tests/www/icons/materialicons/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2
2 changes: 2 additions & 0 deletions NAMESPACE
@@ -1,5 +1,6 @@
importFrom("utils", "capture.output")
export(open_material_modal)
export(close_material_modal)
export(material_button)
export(material_card)
export(material_checkbox)
Expand Down Expand Up @@ -28,6 +29,7 @@ export(material_tab_content)
export(material_tabs)
export(material_text_box)
export(side_nav_tabs_info)
export(update_material_button)
export(update_material_checkbox)
export(update_material_date_picker)
export(update_material_dropdown)
Expand Down
19 changes: 19 additions & 0 deletions R/close-shiny-material-modal.R
@@ -0,0 +1,19 @@
#' Close a material modal programmatically.
#'
#' Close a material modal programmatically (server side).
#' @param session The session object passed to function given to shinyServer.
#' @param modal_id String. The ID of the modal to open.
#' @examples
#' \dontrun{
#' close_material_modal(session, "example_modal")
#' }
close_material_modal <- function(session, modal_id){

js_code <- paste0("$('#", modal_id, "').modal('close');")

session$sendCustomMessage(
type = "shinymaterialJS",
js_code
)

}
38 changes: 35 additions & 3 deletions R/shiny-material-page.R
Expand Up @@ -9,6 +9,7 @@
#' @param font_color String. The title font color. Leave blank for the default color. Visit \url{http://materializecss.com/color.html} for a list of available colors. \emph{Title color requires using word forms of colors (e.g. "deep-purple"). Also, lighten or darken effects do not work on title colors.}
#' @param include_fonts Boolean. Should the material font files be included? (This will place the font sources in a directory 'www', at the same location as the app code.)
#' @param include_nav_bar Boolean. Should the material nav bar be included?
#' @param include_icons Boolean. Should the material icon files be included? (This will place the font sources in a directory 'www', at the same location as the app code.)
#' @examples
#' material_page(
#' title = "Example Title",
Expand All @@ -17,9 +18,10 @@
#' background_color = "blue lighten-4",
#' shiny::tags$h1("Page Content")
#' )
material_page <- function(..., title = "", nav_bar_fixed = FALSE, nav_bar_color = NULL, background_color = "grey lighten-4", font_color = NULL, include_fonts = FALSE, include_nav_bar = TRUE){
material_page <- function(..., title = "", nav_bar_fixed = FALSE, nav_bar_color = NULL, background_color = "grey lighten-4", font_color = NULL, include_fonts = FALSE, include_nav_bar = TRUE, include_icons = FALSE){

materialize_version <- "0.99.0"
materialicons_version <- "v42"

if(include_fonts){

Expand All @@ -43,7 +45,7 @@ material_page <- function(..., title = "", nav_bar_fixed = FALSE, nav_bar_color
system.file(paste0("materialize/", materialize_version, "/fonts/roboto"),
package = "shinymaterial")
)

for(font_file.i in font_files){
file.copy(
from = system.file(paste0("materialize/", materialize_version, "/fonts/roboto/", font_file.i),
Expand All @@ -54,6 +56,36 @@ material_page <- function(..., title = "", nav_bar_fixed = FALSE, nav_bar_color
}
}


if(include_icons){
icons_files <- list.files(
system.file(file.path("icons", "materialicons", materialicons_version),
package = "shinymaterial"),
full.names = TRUE
)


if (!dir.exists("www/icons/materialicons/")) {
message("[shinymaterial] Creating directory: www/icons/materialicons/")
dir.create("www/icons/materialicons/", recursive = TRUE)
}

for (icon_file.i in icons_files) {
file.copy(
from = icon_file.i,
to = "www/icons/materialicons/",
overwrite = TRUE, recursive = TRUE
)
}

icon_css <- system.file("css/shiny-material-icons.css", package = "shinymaterial")

} else {

icon_css <- "https://fonts.googleapis.com/icon?family=Material+Icons"

}

material_nav_bar <- shiny::tags$nav(
class =
ifelse(
Expand Down Expand Up @@ -94,7 +126,7 @@ material_page <- function(..., title = "", nav_bar_fixed = FALSE, nav_bar_color
shiny::tags$head(
# Fonts
shiny::includeCSS(
"https://fonts.googleapis.com/icon?family=Material+Icons"
icon_css
),
# Source Materialize CSS
shiny::includeCSS(
Expand Down
28 changes: 14 additions & 14 deletions R/shiny-material-radio-button.R
Expand Up @@ -4,7 +4,9 @@
#' @param input_id String. The input identifier used to access the value.
#' @param label String. The radio button label.
#' @param choices Named vector. The option names and underyling values.
#' @param selected The initially selected value (if not specified then defaults to the first value).
#' @param color String. The color of the radio buttons. Leave empty for the default color. Visit \url{http://materializecss.com/color.html} for a list of available colors. \emph{This input requires using color hex codes, rather than the word form. E.g., "#ef5350", rather than "red lighten-1".}
#' @param with_gap Boolean. To create a radio button with a gap.
#' @examples
#' material_radio_button(
#' input_id = "example_radio_button",
Expand All @@ -16,7 +18,7 @@
#' ),
#' color = "#ef5350"
#' )
material_radio_button <- function(input_id, label, choices, color = NULL) {
material_radio_button <- function(input_id, label, choices, selected = NULL, color = NULL, with_gap = FALSE) {

if(!is.null(color)){

Expand Down Expand Up @@ -47,28 +49,26 @@ material_radio_button <- function(input_id, label, choices, color = NULL) {
material_radio_choices <- shiny::tagList()

has_names <- !is.null(names(choices))
choices[choices == ""] <- "_shinymaterialradioempty_"
selected <- if (is.null(selected)) choices[[1]] else as.character(selected)
if (length(selected) > 1) stop("The 'selected' argument must be of length 1")
if (! selected %in% choices) stop("The 'selected' argument must be in choices")

for(i in 1:length(choices)){
material_radio_choices[[i]] <-
shiny::tags$p(
shiny::tags$input(
class = if (with_gap) "with-gap",
type = "radio",
name = input_id,
class =
ifelse(
is.null(color),
'',
paste0('shinymaterial-radio-button-', input_id)
),
id = ifelse(choices[i] != "", choices[i], "_shinymaterialradioempty_")
class = if (!is.null(color))
paste0('shinymaterial-radio-button-', input_id),
id = choices[i],
checked = if(choices[i] %in% selected) "checked"
),
shiny::tags$label(
`for` = ifelse(choices[i] != "", choices[i], "_shinymaterialradioempty_"),
ifelse(
has_names,
names(choices[i]),
choices[i]
)
`for` = choices[i],
ifelse(has_names, names(choices[i]), choices[i])
)
)
}
Expand Down
32 changes: 32 additions & 0 deletions R/update-shiny-material-button.R
@@ -0,0 +1,32 @@
#' Change the text, icon of a material_button on the client. Allow to disable.
#'
#' Change the value text, icon of a material_button on the client.
#' Allow to disable the button and then enable.
#' @param session The session object passed to function given to shinyServer.
#' @param input_id The input_id of the material_button.
#' @param label The new label of the material_button.
#' @param icon The new icon of the material_button. If not set, icon disappear.
#' @param enable TRUE if the button is enable, FALSE if disable.
#' @examples
#' \dontrun{
#' update_material_button(
#' session,
#' input_id = "example_button",
#' value = "New Text",
#' icon = "stop",
#' enable = FALSE
#' )
#' }
update_material_button <- function (session, input_id, label = NULL, icon = NULL, enable = TRUE) {

js_code <- paste0("$('#", input_id, "').prop( 'disabled', ", tolower(enable), " )")
session$sendCustomMessage(type = "shinymaterialJS", js_code)

if (!is.null(label)){
if (!is.null(icon))
icon <- paste0('<i class="material-icons left">', icon, '</i>')
js_code <- paste0("$('#", input_id, "').prop( 'innerHTML', '", icon, label, "')")
session$sendCustomMessage(type = "shinymaterialJS", js_code)
}

}
24 changes: 24 additions & 0 deletions inst/css/shiny-material-icons.css
@@ -0,0 +1,24 @@
/* Adapted from https://fonts.googleapis.com/icon?family=Material+Icons */
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(icons/materialicons/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2) format('woff2');
}

.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
-moz-font-feature-settings: 'liga';
-moz-osx-font-smoothing: grayscale;
}

Binary file added inst/doc/shinymaterial.pdf
Binary file not shown.
Binary file not shown.
2 changes: 0 additions & 2 deletions inst/js/shiny-material-radio-button.js
Expand Up @@ -20,6 +20,4 @@ $(document).ready(function () {

Shiny.inputBindings.register(shinyMaterialRadioButton);

$(".shiny-material-radio-button").find("input:first").trigger("click");

});
21 changes: 21 additions & 0 deletions man/close_material_modal.Rd

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

0 comments on commit 9a8fbd6

Please sign in to comment.