-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.R
67 lines (58 loc) · 1.24 KB
/
app.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
# This app demonstrates some of the functionality of this package.
# See ?shiny::loadSupport
options(shiny.autoload.r = FALSE)
pkgload::load_all(
export_all = FALSE,
helpers = FALSE,
attach_testthat = FALSE,
quiet = TRUE
)
ui <- shiny::fluidPage(
shinyfocus_js_dependency(),
shiny::column(
2,
shiny::textInput("name", "Name:"),
shiny::textInput("title", "Title:")
),
shiny::column(
2,
shiny::textOutput("explanation")
)
)
server <- function(input, output, session) {
on_focus(
"name",
output$explanation <- shiny::renderText({
"Enter the name you want me to call you. It will be converted to Title Case."
})
)
on_focus(
"title",
output$explanation <- shiny::renderText({
"Describe your role in 10 characters or fewer."
})
)
on_blur(
"name",
shiny::updateTextInput(
inputId = "name",
value = stringr::str_to_title(shiny::isolate(input$name))
)
)
on_blur(
"title",
{
if (nchar(input$title) > 10) {
shiny::updateTextInput(
inputId = "title",
value = paste(
"Typer of",
nchar(input$title),
"Characters"
)
)
}
}
)
}
shiny::shinyApp(ui, server)