Skip to content

Commit

Permalink
Add cross-links to UI covered elsewhere
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Sep 16, 2019
1 parent 791e449 commit fc5ccd1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions basic-ui.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,34 @@ ui <- fluidPage(
ui_screenshot(ui, "basic-ui/yes-no")
```

### File uploads and action buttons
### File upload and downloads

We'll come back to two input controls in later chapters:
Allow the user to upload a file with `fileInput()`:

* We'll cover `fileInput()` when we discuss uploading and downloading files
in Chaper XYZ

* We'll cover `actionButton()` when we discuss buttons, controlling
side-effects, and initiating "actions" in Chapter XYZ.
```{r}
ui <- fluidPage(
fileInput("upload2", NULL)
)
```
```{r, echo = FALSE, out.width = NULL}
ui_screenshot(ui, "basic-ui/upload")
```

`fileInput()` requires more work on the server side, and is discussed in detail in Chapter \@ref(action-transfer).

### Action buttons

Perform an action with `actionButton()` or `actionLink()`. These are most naturally paired with `observeEvent()` or `eventReactive()` in the server function. I haven't discussed these functions yet, but we'll come back to them in next chapter.

```{r}
ui <- fluidPage(
actionButton("action1", "Click me!"),
div(actionLink("action2", "Don't click me!"))
)
```
```{r, echo = FALSE, out.width = NULL}
ui_screenshot(ui, "basic-ui/action")
```

### Exercises

Expand Down Expand Up @@ -352,6 +371,10 @@ By default, `plotOutput()` will take up the full width of the element it's embed

Plots are special because they can also act as inputs. `plotOutput()` has a number of arguments like `click`, `dblclick`, and `hover`. If you pass these a string, like `click = "plot_click"`, they'll create a reactive input (`input$plot_click`) that you can use to handle user interaction on the plot. We'll come back to interactive plots in Shiny in Chapter XYZ.

### Downloads

You can let the user download a file with `downloadButton()` or `downloadLink()`. These require new techniques in the server function, so we'll come back to Chapter \@ref(action-transfer).

### Exercises

1. Re-create the Shiny app from the plots section, this time setting height to
Expand Down
Binary file added screenshots/basic-ui/action.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/basic-ui/upload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fc5ccd1

Please sign in to comment.