Skip to content

Commit f81f1b5

Browse files
authored
Add startup CSS ID & clarify examples (#111)
* Add IDs for startup message & COOP/COEP header status * Directly show the disable option * Cut the amount of output on packages displayed. * Update template * Add documentation for the header classes * Add release note * Bump version * Add test cases for disablign startup status in HTML and RevealJS
1 parent ba318e9 commit f81f1b5

11 files changed

+74
-15
lines changed

_extensions/webr/_extension.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: webr
22
title: Embedded webr code cells
33
author: James Joseph Balamuta
4-
version: 0.4.0-dev.1
4+
version: 0.4.0-dev.2
55
quarto-required: ">=1.2.198"
66
contributes:
77
filters:

_extensions/webr/monaco-editor-init.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script src="https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/loader.js"></script>
2-
<script type="module" id="webr-monaco-editor-init">
2+
<script type="module" id="qwebr-monaco-editor-init">
33

44
// Configure the Monaco Editor's loader
55
require.config({

_extensions/webr/template.qmd

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ title: "WebR-enabled code cell"
33
format: html
44
engine: knitr
55
#webr:
6-
# show-startup-message: false # Display status of webR initialization
7-
# show-header-message: false # Check to see if COOP&COEP headers are set for speed.
6+
# show-startup-message: false # Disable display of webR initialization state
7+
# show-header-message: true # Display whether COOP&COEP headers are set for speed.
88
# packages: ['ggplot2', 'dplyr'] # Pre-install dependencies
9+
# autoload-packages: false # Disable automatic library calls on R packages specified in packages.
10+
# channel-type: 'post-message' # Specify a specific communication channel type.
911
# home-dir: "/home/rstudio" # Customize where the working directory is
1012
# base-url: '' # Base URL used for downloading R WebAssembly binaries
1113
# service-worker-url: '' # URL from where to load JavaScript worker scripts when loading webR with the ServiceWorker communication channel.

_extensions/webr/webr-init.html

+6-3
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,23 @@
133133

134134
// Create the first inner div element
135135
const firstInnerDiv = document.createElement("div");
136+
firstInnerDiv.setAttribute("id", "qwebr-status-message-area");
136137

137138
// Create the second inner div element for "WebR Status" heading and contents
138139
const secondInnerDiv = document.createElement("div");
140+
secondInnerDiv.setAttribute("id", "qwebr-status-message-title");
139141
secondInnerDiv.classList.add("quarto-title-meta-heading");
140142
secondInnerDiv.innerText = "WebR Status";
141143

142144
// Create another inner div for contents
143145
const secondInnerDivContents = document.createElement("div");
146+
secondInnerDivContents.setAttribute("id", "qwebr-status-message-body");
144147
secondInnerDivContents.classList.add("quarto-title-meta-contents");
145148

146149
// Describe the WebR state
147150
var startupMessageWebR = document.createElement("p");
148151
startupMessageWebR.innerText = "🟡 Loading...";
149-
startupMessageWebR.setAttribute("id", "startup");
152+
startupMessageWebR.setAttribute("id", "qwebr-status-message-text");
150153
// Add `aria-live` to auto-announce the startup status to screen readers
151154
startupMessageWebR.setAttribute("aria-live", "assertive");
152155

@@ -157,7 +160,7 @@
157160
if (showHeaderMessage) {
158161
const crossOriginMessage = document.createElement("p");
159162
crossOriginMessage.innerText = `${crossOriginIsolated ? '🟢' : '🟡'} COOP & COEP Headers`;
160-
crossOriginMessage.setAttribute("id", "coop-coep-header");
163+
crossOriginMessage.setAttribute("id", "qwebr-coop-coep-header");
161164
secondInnerDivContents.appendChild(crossOriginMessage);
162165
}
163166

@@ -175,7 +178,7 @@
175178
headerRevealJS.appendChild(firstInnerDiv);
176179
} else {
177180
// If neither headerHTML nor headerRevealJS is found, insert after "webr-monaco-editor-init" script
178-
const monacoScript = document.getElementById("webr-monaco-editor-init");
181+
const monacoScript = document.getElementById("qwebr-monaco-editor-init");
179182
const header = document.createElement("header");
180183
header.setAttribute("id", "title-block-header");
181184
header.appendChild(quartoTitleMeta);

docs/qwebr-meta-options.qmd

+5-4
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ To fine-tune webR to the specific needs of a document, place inside your documen
2424

2525
```yaml
2626
---
27-
title: WebR in Quarto HTML Documents
27+
title: webR in Quarto HTML Documents
2828
format: html
2929
engine: knitr
3030
webr:
31-
show-startup-message: false
32-
packages: ['ggplot2', 'dplyr']
31+
show-startup-message: false # Disable displaying status of webR initialization
32+
packages: ['ggplot2', 'dplyr'] # Install R packages on document open
3333
filters:
3434
- webr
3535
---
@@ -49,7 +49,8 @@ book:
4949

5050
# Set default options for every bookpage that may or may not include webR.
5151
webr:
52-
show-startup-message: false # Display status of webR initialization
52+
show-startup-message: false # Disable displaying status of webR initialization
53+
packages: ['ggplot2', 'dplyr'] # Install R packages on document open
5354

5455
# Attach webR extension for the project
5556
filters:

docs/qwebr-release-notes.qmd

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@ format:
1212

1313
## Features
1414

15+
16+
## Changes
17+
18+
- Added new CSS IDs governing the webR initialization state. ([#110](https://github.com/coatless/quarto-webr/issues/110))
19+
1520
## Bugfixes
1621

17-
- Fix text added after code cell in RevealJS appearing off the page ([#102](https://github.com/coatless/quarto-webr/issues/102), [#106](https://github.com/coatless/quarto-webr/issues/106))
22+
- Fixed display of text found after a code cell in RevealJS appearing off the page ([#102](https://github.com/coatless/quarto-webr/issues/102), [#106](https://github.com/coatless/quarto-webr/issues/106))
1823

1924
## Documentation
2025

26+
- Modified the RevealJS presentation YAML to include an option to disable the webR status message header ([#110](https://github.com/coatless/quarto-webr/issues/110))
2127
- Minor documentation tweaks.
2228

2329
## Deployment

docs/qwebr-theming.qmd

+12-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,18 @@ On this page, we delve into the world of web design to enhance the visual aesthe
2020

2121
## CSS Class and ID Identifiers
2222

23-
To effectively style web-based documents created with the extension, you'll need to understand the unique `id` and `class` attributes associated with different content areas. There are two primary context types where content is displayed to users:
23+
To effectively style web-based documents created with the extension, you'll need to understand the unique `id` and `class` attributes associated with different content areas. There are two key areas to every Quarto document that uses the `quarto-webr` extension: header and code cells. The header is where status and debug information can be found whereas the code cell portion is where R code is actively run using webR.
24+
25+
Let's turn our attention to the document's header. By default, the webR initialization state is displayed in the header. This can be turned off by setting the [`show-startup-message: false` meta option.](qwebr-meta-options.qmd).
26+
27+
- **Status Area**: This represents the area we dynamic add to the document using JavaScript and stores the **Status Title** and **Status Message**
28+
- `id`: `#qwebr-status-message-area`
29+
- **Status Title**: This element contains the header of the status text.
30+
- `id`: `#qwebr-status-message-title`
31+
- **Status Message**: This element is updated with the document status updates.
32+
- `id`: `#qwebr-status-message-body`
33+
34+
With this in mind, we next focus on improving how content is being displayed through **code cells**. There are two primary context types where code content is displayed to users:
2435

2536
- **Interactive Area**: This area encompasses the **Code Editor**, **Code Output**, and the **Graph Output Area** under the `interactive` context.
2637
- `id`: `#qwebr-interactive-area-{{ID}}`

docs/qwebr-using-r-packages.qmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ cat("There are current", n_webr_pkgs,
3636
"available to use with webR!\n")
3737
3838
# Only view the first 6, there's a lot available!
39-
head(webr_info)
39+
head(webr_info[, c("Version", "License")])
4040
```
4141

4242
Alternatively, you can navigate to the webR binary R repository [here](https://repo.r-wasm.org/) for package listings.

examples/revealjs/index.qmd

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
title: "quarto-webr Demo RevealJS Document"
33
format: revealjs
44
webr:
5-
packages: ['ggplot2']
5+
packages: ['ggplot2', 'dplyr'] # Install R packages on document open
6+
# autoload-packages: false # Disable automatic loading of packages
7+
# show-startup-message: false # Disable displaying status of webR initialization
68
filters:
79
- webr
810
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: "Test: No Startup Status Present in HTML Documents"
3+
format: html
4+
engine: knitr
5+
webr:
6+
show-startup-message: false
7+
filters:
8+
- webr
9+
---
10+
11+
Ensure that the webR code cell initializes even if the webR status bar is disabled.
12+
13+
```{webr-r}
14+
print("Hello hidden title world!")
15+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: "Test: No Startup Status Present in RevealJS Presentations"
3+
subtitle: "Examining State"
4+
authors: "Presentation Lead"
5+
format: revealjs
6+
engine: knitr
7+
webr:
8+
show-startup-message: false
9+
filters:
10+
- webr
11+
---
12+
13+
## webR in RevealJS
14+
15+
Ensure that the webR code cell initializes even if the webR status bar is disabled.
16+
17+
```{webr-r}
18+
print("Hello hidden title world!")
19+
```

0 commit comments

Comments
 (0)