- Use
renv::restore()
to install the necessary dependencies. - Enable devmode and run the app.
- Take a look at
app/view/hello.R
. - Add
hello$ui(ns("hello"))
to the UI inmain.R
. - Call
hello$server("hello")
in the server inmain.R
. - See if the app displayes "Hello" text.
Remember:
In the UI, the ID must be wrapped in ns()
,
but in the server the namespace is applied automatically.
Learn more in
Modularizing Shiny app code
- Open
app/view/hello.R
. - Add a
textInput
with label "What is your name?". - See if the input appears in the app.
- Add a
textOutput
to the module UI. - Use
renderText
to greet the user with their name. - Type "Rhino" into the field and check if "Hello Rhino!" appears.
- Import the
logic/const
andview/favorites
modules inmain.R
. - Add the
favorites
module to the app. Usecategory = "fruits"
andchoices = const$fruits
.
Add another instance of the favorites
module.
Use category = "vegetables"
and choices = const$vegetables
this time.
- Add a
checkboxGroupInput
to the UI of the favorites module. - Use the module parameters to define
choices
and a nicelabel
.
- Copy over the files from
IMAGES
directory toapp/static/img
. - Fill in the missing part the in
images()
function. You need to translate imagename
to path with/static/
prefix. - Use
uiOutput()
andrenderUI()
to render theimages()
based on user's selection.
- Define the
app/view/reverse
module. It should let the user type some text and display it with words in reverse order. - Fill in and use the
reverse_words()
function fromapp/logic/reverse
. - Add the module to the app.