-
Notifications
You must be signed in to change notification settings - Fork 0
/
widgetInPlaceHelp.R
111 lines (96 loc) · 2.49 KB
/
widgetInPlaceHelp.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#'
#' Provides a widget that a help tooltip on hovering
#' Also provides additional methods like creating a text element with help
#'
library(shiny)
library(shinyBS)
#' Creates a text element that shows a help tooltip if hovered
#'
#' @param text Text to display
#' @param helptext The content of the help text
#' @param title The content of the help text
#'
#' @return Shiny UI element
#' @export
#'
#' @examples
helpText <- function(text, helptext, title = "Info") {
return(tags$a(href = "#",
"data-toggle"="popover",
"data-trigger" = "hover",
title = title,
"data-content" = helptext,
text))
}
#' Creates an UI element that shows a help text on hovering the icon
#'
#' @param helptext The content of the help text
#' @param title The title of the help text
#'
#' @return Shiny UI element
#' @export
#'
#' @examples
helpIcon <- function(helptext, title = "Info") {
return(helpText(icon("info-circle"),
helptext,
title))
}
#' Creates an UI element consisting of text and and a help icon next to it
#'
#' @param text Text left to the help icon
#' @param helptext The content of the help text
#' @param title The title of the help text
#'
#' @return Shiny UI element
#' @export
#'
#' @examples
helpIconText <- function(text, helptext, title = "Info") {
return(tags$span( tags$span(text), helpIcon(helptext, title) ))
}
#' Flags a functions with importance
#'
#' @param text
#'
#' @return
#' @export
#'
#' @examples
flaggedDataText <- function(text, icon, helptext = "The input is useful, but not required.", title = "Info") {
return(tags$span(icon(icon),
tags$span(text)))
}
#' Indicates an optional function
#'
#' @param text
#'
#' @return
#' @export
#'
#' @examples
optionalDataText <- function(text, helptext = "The input is useful, but not required.", title = "Info") {
return(flaggedDataText(text, "circle", helptext, title))
}
#' Indicates a recommended function
#'
#' @param text
#'
#' @return
#' @export
#'
#' @examples
recommendedDataText <- function(text, helptext = "We recommend to give an input here.", title = "Info") {
return(flaggedDataText(text, "check-circle", helptext, title))
}
#' Indicates a required function
#'
#' @param text
#'
#' @return
#' @export
#'
#' @examples
requiredDataText <- function(text, helptext = "The input is necessary for other functions.", title = "Info") {
return(flaggedDataText(text, "exclamation-circle", helptext, title))
}