Skip to content

Commit

Permalink
Work on layout chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Mar 1, 2021
1 parent 005cc95 commit 05052b3
Show file tree
Hide file tree
Showing 24 changed files with 99 additions and 78 deletions.
163 changes: 95 additions & 68 deletions action-layout.Rmd

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion basic-case-study.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ Here I decided to have one row for the inputs (accepting that I'm probably going
```{r code = section_get("neiss/prototype.R", "ui")}
```

Note the use of `setNames()` in the `selectInput()` `choices`: this shows the product name in the UI and returns the product code to the server.
We haven't talked about `fluidRow()` and `column()` yet, but you should be able to guess what they do from the context, and we'll come back to talk about them in Section \@ref(multi-row).
Also note the use of `setNames()` in the `selectInput()` `choices`: this shows the product name in the UI and returns the product code to the server.

The server function is relatively straightforward.
I first convert the `selected` and `summary` variables created in the previous section to reactive expressions.
Expand Down
1 change: 1 addition & 0 deletions basic-reactivity.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ A Shiny app is a great way to do this because it lets you avoid tediously modify
Below I wrap the pieces into a Shiny app where I can interactively tweak the inputs.

Let's start with the UI.
We'll come back to exactly what `fluidRow()` and `column()` do in Section \@ref(multi-row); but you can guess their purpose from their names 😄.
The first row has three columns for input controls (distribution 1, distribution 2, and plot controls).
The second row has a wide column for the plot, and a narrow column for the hypothesis test.

Expand Down
4 changes: 1 addition & 3 deletions basic-ui.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ You don't yet have many ways to stitch the inputs and outputs together, but we'l

Here I'll mostly stick to the inputs and outputs built into Shiny itself.
However, there is a rich and vibrant community of extension packages, like [shinyWidgets](https://github.com/dreamRs/shinyWidgets), [colorpicker](https://github.com/daattali/colourpicker), and [sorttable](https://rstudio.github.io/sortable/).
You can find a comprehensive, actively-maintained list of other packages at [<https://github.com/nanxstats/awesome-shiny-extensions>](https://github.com/nanxstats/awesome-shiny-extensions){.uri}, maintained by [Nan Xiao](https://nanx.me/).
You can find a comprehensive, actively-maintained list of other packages at <https://github.com/nanxstats/awesome-shiny-extensions>, maintained by [Nan Xiao](https://nanx.me/).

As usual, we'll begin by loading the shiny package:

Expand Down Expand Up @@ -161,7 +161,6 @@ ui <- fluidPage(
```{r, echo = FALSE, out.width = NULL, message = FALSE}
demo <- demoApp$new("basic-ui/radio-icon", ui)
demo$takeScreenshot()
resourcePathReset()
```

Dropdowns created with `selectInput()` take up the same amount of space, regardless of the number of options, making them more suitable for longer options.
Expand Down Expand Up @@ -242,7 +241,6 @@ ui <- fluidPage(
```{r, echo = FALSE, out.width = NULL, message = FALSE}
demo <- demoApp$new("basic-ui/action", ui)
demo$takeScreenshot()
resourcePathReset()
```

Actions links and buttons are most naturally paired with `observeEvent()` or `eventReactive()` in your server function.
Expand Down
6 changes: 0 additions & 6 deletions demo.R
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,4 @@ screenshot_dpi <- function() {
}
}

resourcePathReset <- function() {
for (prefix in names(shiny::resourcePaths())) {
shiny::removeResourcePath(prefix)
}
}

is_ci <- function() isTRUE(as.logical(Sys.getenv("CI")))
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes

0 comments on commit 05052b3

Please sign in to comment.