Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #23 from nik01010/rel/v1_1_0
Browse files Browse the repository at this point in the history
Version 1.1.0
  • Loading branch information
nik01010 authored Jul 1, 2020
2 parents 55159e1 + ec4a261 commit 94797c9
Show file tree
Hide file tree
Showing 55 changed files with 3,284 additions and 2,242 deletions.
7 changes: 7 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
^.*\.Rproj$
^\.Rproj\.user$
^Makefile$
^Jenkinsfile$
^\.lintr$
^\.travis\.yml$
^codecov\.yml$
^LICENSE\.md$
^cran-comments\.md$
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
inst/doc
.Rproj.user
.Rhistory
.RData
.Ruserdata
inst/doc
doc
Meta
33 changes: 33 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
linters: with_defaults(
object_name_linter(styles = c("CamelCase", "camelCase", "snake_case")),
object_length_linter(30),
line_length_linter(110),
assignment_linter,
object_usage_linter,
open_curly_linter = NULL,
closed_curly_linter(allow_single_line = FALSE),
paren_brace_linter,
commas_linter,
spaces_inside_linter,
spaces_left_parentheses_linter,
commented_code_linter = NULL,
cyclocomp_linter,
equals_na_linter,
function_left_parentheses_linter,
single_quotes_linter = NULL,
pipe_continuation_linter,
seq_linter,
T_and_F_symbol_linter,
trailing_whitespace_linter = NULL,
undesirable_function_linter = NULL,
undesirable_operator_linter = NULL,
todo_comment_linter = NULL
# WIP: add custom lint rules for:
# - parameter names should be specified in functions
# - white space rules for equals signs
# - unit tests should use arrange/act/assert pattern
# - etc
)
exclude: "# Exclude Linting"
exclude_start: "# Begin Exclude Linting"
exclude_end: "# End Exclude Linting"
30 changes: 30 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
language: r

os:
- linux
- osx

r:
- release
- oldrel
- devel

jobs:
exclude:
- r: devel
os: osx

repos:
CRAN: https://cloud.r-project.org

addons:
apt:
packages:
- libv8-dev

cache: packages
latex: false
warnings_are_errors: true

after_success:
- Rscript -e 'covr::codecov()'
23 changes: 16 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
Package: dashboardthemes
Type: Package
Title: Customise the appearance of Shiny dashboard applications using themes
Version: 1.0.6
Version: 1.1.0
Authors@R: person("Nik", "Lilovski", email = "nik.lilovski@outlook.com",
role = c("aut", "cre"))
Maintainer: Nik Lilovski <nik.lilovski@outlook.com>
Description: Allows manual creation of themes and logos to be used in
applications created using the shinydashboard package. Removes the need to
change the underlying css code by wrapping it into a set of convenient R
functions.
Depends: R (>= 3.2.3)
Imports: htmltools (>= 0.3.5)
License: GPL-3
URL: https://github.com/nik01010/dashboardthemes
BugReports: https://github.com/nik01010/dashboardthemes/issues
Depends:
R (>= 3.2.3)
Imports:
htmltools (>= 0.3.5)
Suggests:
testthat,
lintr,
knitr,
rmarkdown,
glue,
covr
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
Suggests: knitr,
rmarkdown
RoxygenNote: 7.1.0
VignetteBuilder: knitr
15 changes: 15 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pipeline {
agent any
stages {
stage('Build') {
steps {
bat 'make build'
}
}
stage('Check') {
steps {
bat 'make check'
}
}
}
}
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2020
COPYRIGHT HOLDER: Nik Lilovski
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# h/t to @jimhester and @yihui for this parse block:
# https://github.com/yihui/knitr/blob/dc5ead7bcfc0ebd2789fe99c527c7d91afb3de4a/Makefile#L1-L4
# Note the portability change as suggested in the manual:
# https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Writing-portable-packages
PKGNAME = `sed -n "s/Package: *\([^ ]*\)/\1/p" DESCRIPTION`
PKGVERS = `sed -n "s/Version: *\([^ ]*\)/\1/p" DESCRIPTION`


all: build check

build:
R CMD build --no-build-vignettes .

check:
R CMD check --as-cran --no-manual $(PKGNAME)_$(PKGVERS).tar.gz

install_deps:
Rscript \
-e 'if (!requireNamespace("remotes")) install.packages("remotes")' \
-e 'remotes::install_deps(dependencies = TRUE)'

install: install_deps build
R CMD INSTALL $(PKGNAME)_$(PKGVERS).tar.gz

clean:
@rm -rf $(PKGNAME)_$(PKGVERS).tar.gz $(PKGNAME).Rcheck
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export(cssGradientThreeColors)
export(logo_blue_gradient)
export(logo_boe_website)
export(logo_flat_red)
export(logo_grey_dark)
export(logo_grey_light)
export(logo_onenote)
Expand All @@ -13,7 +13,7 @@ export(shinyDashboardLogoDIY)
export(shinyDashboardThemeDIY)
export(shinyDashboardThemes)
export(theme_blue_gradient)
export(theme_boe_website)
export(theme_flat_red)
export(theme_grey_dark)
export(theme_grey_light)
export(theme_onenote)
Expand Down
19 changes: 19 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
### dashboardthemes ----------------------------------------

### v1.1.0
* Breaking changes:
- The boe_website theme has been discontinued, please use flat_red instead.
- The following used to be logo objects with hard-coded text, they are now functions, with optional parameters boldText, mainText and badgeText:

logo_blue_gradient, logo_flat_red, logo_grey_light, logo_grey_dark, logo_onenote, logo_poor_mans_flatly, logo_purple_gradient

* Major back-end refactor:
- R source code separated into multiple files.
- Resolved all R CMD CHECK errors, warnings and notes.
- CSS and HTML code generated by functions has been formatted to remove line breaks.
- shinyDashboardLogo function now has boldText, mainText and badgeText optional parameters, rather than hard-coding these values.

* Added back-end quality controls:
- Unit tests for all functions.
- Support for continuous integration on TravisCI and Jenkins.
- Support for test coverage reports on CodeCov.
- Support for linter checks.

### v1.0.6
* Fixed a UI bug where submenu items would incorrectly receive the "selected" colour by default instead of only on selection. (#19)

Expand Down
78 changes: 78 additions & 0 deletions R/CreateCss_cssGradientThreeColors.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Function: cssGradientThreeColors ----------------------------------------------------------------------
#' @title cssGradientThreeColors
#' @description Generates CSS code for a gradient with three colors
#'
#' @param direction String. Direction of the gradient (down/right). Defaults to down.
#' @param colorStart String. Start (top/left) colour of the gradient.
#' @param colorMiddle String. Middle colour of the gradient.
#' @param colorEnd String. End (bottom/right) colour of the gradient.
#' @param colorStartPos Numeric. Position of the start colour. Defaults to 0.
#' @param colorMiddlePos Numeric. Position of the middle colour. Defaults to 50.
#' @param colorEndPos Numeric. Position of the end colour; defaults to 100.
#'
#' @return CSS code. Gradient with three colors.
#' @examples
#' \dontrun{
#' cssGradientThreeColors(
#' direction = "right"
#' ,colorStart = "rgba(44,222,235,1)"
#' ,colorMiddle = "rgba(44,222,235,1)"
#' ,colorEnd = "rgba(0,255,213,1)"
#' ,colorStartPos = 0
#' ,colorMiddlePos = 30
#' ,colorEndPos = 100
#' )
#' }
#' @seealso \code{\link{shinyDashboardThemeDIY}, \link{shinyDashboardLogoDIY}},
#' @export
cssGradientThreeColors <- function(
direction = "down", colorStart, colorMiddle, colorEnd, colorStartPos = 0,
colorMiddlePos = 50, colorEndPos = 100
) {

# handling direction types
if (direction == "down") {
colorStartSide <- "top"
colorStartSideCorner <- "left top"
colorEndSideCorner <- "left bottom"
colorDirection <- "to bottom"
} else if (direction == "right") {
colorStartSide <- "left"
colorStartSideCorner <- "left top"
colorEndSideCorner <- "right top"
colorDirection <- "to right"
} else {
stop("The chosen direction isn't supported.")
}

# building up css code
cssCode <- paste0(
colorStart, ';
background: -moz-linear-gradient(',
colorStartSide, ', ', colorStart, " ", colorStartPos, '%, ', colorMiddle,
" ", colorMiddlePos, '%, ', colorEnd, " ", colorEndPos, '%);
background: -webkit-gradient(',
colorStartSideCorner, ',', colorEndSideCorner, ',
color-stop(', colorStartPos, '%, ', colorStart, '),
color-stop(', colorMiddlePos, '%, ', colorMiddle, '),
color-stop(', colorEndPos, '%, ', colorEnd, '));
background: -webkit-linear-gradient(',
colorStartSide, ', ', colorStart, " ", colorStartPos, '%, ', colorMiddle, " ",
colorMiddlePos, '%, ', colorEnd, " ", colorEndPos, '%);
background: -o-linear-gradient(',
colorStartSide, ', ', colorStart, " ", colorStartPos, '%, ', colorMiddle, " ",
colorMiddlePos, '%, ', colorEnd, " ", colorEndPos, '%);
background: -ms-linear-gradient(',
colorStartSide, ', ', colorStart, " ", colorStartPos, '%, ', colorMiddle, " ",
colorMiddlePos, '%, ', colorEnd, " ", colorEndPos, '%);
background: linear-gradient(',
colorDirection, ', ', colorStart, " ", colorStartPos, '%, ', colorMiddle, " ",
colorMiddlePos, '%, ', colorEnd, " ", colorEndPos, '%)'
)

# removing new line symbols and formatting spacing
cssCode <- gsub(pattern = "\n", replacement = "", x = cssCode)
cssCode <- gsub(pattern = "[[:space:]]{2,3}", replacement = "", x = cssCode)

return(cssCode)
}
79 changes: 79 additions & 0 deletions R/CreateLogo_shinyDashboardLogo.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Function: shinyDashboardLogo --------------------------------------------------------------------------
#' @title shinyDashboardLogo
#' @description Calls a custom logo object created using shinyDashboardLogoDIY
#'
#' @param theme String. Name of theme to be used
#' @param boldText String. Bold text for the logo.
#' @param mainText String. Main text for the logo.
#' @param badgeText String. Text for the logo badge.
#'
#' @return HTML code. Logo for shinydashboard's sidebar.
#' @examples
#' \dontrun{
#' ...
#' ### ui
#' ui <- dashboardPage(
#'
#' ### ui header
#' dashboardHeader(
#'
#' ### changing logo
#' title = shinyDashboardLogo(
#' theme = "blue_gradient",
#' boldText = "Shiny",
#' mainText = "App",
#' badgeText = "v1.1"
#' )
#' ...
#' }
#' @seealso \code{\link{shinyDashboardLogoDIY}, \link{shinyDashboardThemes}}
#' @note This logo design was inspired from \url{http://www.dataseries.org/}.
#' @export
shinyDashboardLogo <- function(theme, boldText = "Shiny", mainText = "App", badgeText = "v1.1") {

if (theme == "blue_gradient") {
return(
dashboardthemes::logo_blue_gradient(boldText = boldText, mainText = mainText, badgeText = badgeText)
)

} else if (theme == "flat_red") {
return(
dashboardthemes::logo_flat_red(boldText = boldText, mainText = mainText, badgeText = badgeText)
)

} else if (theme == "grey_light") {
return(
dashboardthemes::logo_grey_light(boldText = boldText, mainText = mainText, badgeText = badgeText)
)

} else if (theme == "grey_dark") {
return(
dashboardthemes::logo_grey_dark(boldText = boldText, mainText = mainText, badgeText = badgeText)
)

} else if (theme == "onenote") {
return(
dashboardthemes::logo_onenote(boldText = boldText, mainText = mainText, badgeText = badgeText)
)

} else if (theme == "poor_mans_flatly") {
return(
dashboardthemes::logo_poor_mans_flatly(boldText = boldText, mainText = mainText, badgeText = badgeText)
)

} else if (theme == "purple_gradient") {
return(
dashboardthemes::logo_purple_gradient(boldText = boldText, mainText = mainText, badgeText = badgeText)
)

} else if (theme == "boe_website") {

stop("The boe_website theme has been discontinued after v1.1.0, please use flat_red instead.")

} else {

stop("The chosen theme isn't supported.")

}

}
Loading

0 comments on commit 94797c9

Please sign in to comment.