Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 74 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,56 @@ on:
branches: [main, master]
pull_request:
branches: [main, master]
types: [opened, reopened, synchronize, closed]
delete:
release:
types: [published]
workflow_dispatch:

name: pkgdown

permissions:
contents: write
pull-requests: write # comment the preview URL

env:
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}

jobs:
# PR preview domain (<owner>-<repo>-pr-<N>.surge.sh), shared by the jobs below.
preview:
runs-on: ubuntu-latest
outputs:
domain: ${{ steps.domain.outputs.domain }}
steps:
- id: domain
env:
GH_TOKEN: ${{ github.token }}
REF: ${{ github.event.ref }}
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
num="${{ github.event.pull_request.number }}"
elif [ "${{ github.event_name }}" = "delete" ]; then
num=$(gh pr list --repo "${{ github.repository }}" --state all \
--head "$REF" --json number --jq '.[0].number // empty')
fi
if [ -n "$num" ]; then
name=$(echo "${{ github.repository }}-pr-$num" |
tr 'A-Z' 'a-z' | tr -c 'a-z0-9\n' '-')
echo "domain=$name.surge.sh" >> "$GITHUB_OUTPUT"
fi

pkgdown:
needs: preview
# Skip closed PRs and branch deletions (see teardown).
if: github.event_name != 'delete' && github.event.action != 'closed'
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
PREVIEW_DOMAIN: ${{ needs.preview.outputs.domain }}
steps:
- uses: actions/checkout@v4

Expand All @@ -39,10 +73,48 @@ jobs:
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

# Fork PRs cannot read the secret or comment, so skip them.
- name: Deploy PR preview to surge
if: >-
github.event_name == 'pull_request' && env.SURGE_TOKEN != '' &&
github.event.pull_request.head.repo.full_name == github.repository
run: |
npm install -g surge
surge ./docs "$PREVIEW_DOMAIN"

- name: Comment preview URL
if: >-
github.event_name == 'pull_request' && env.SURGE_TOKEN != '' &&
github.event.pull_request.head.repo.full_name == github.repository
uses: marocchino/sticky-pull-request-comment@v3
with:
header: surge-preview
message: |
Site preview: https://${{ env.PREVIEW_DOMAIN }}

Updates on every push; removed when this PR closes.

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
folder: docs

# Remove a PR preview. Branch deletion is the main trigger (deleting at merge
# cancels `closed` runs); `closed` covers kept branches. Idempotent.
teardown:
needs: preview
if: >-
github.event.action == 'closed' ||
(github.event_name == 'delete' && github.event.ref_type == 'branch')
runs-on: ubuntu-latest
env:
PREVIEW_DOMAIN: ${{ needs.preview.outputs.domain }}
steps:
- name: Teardown preview
if: env.SURGE_TOKEN != '' && env.PREVIEW_DOMAIN != ''
run: |
npm install -g surge
surge teardown "$PREVIEW_DOMAIN" || true
11 changes: 5 additions & 6 deletions R/ae_forestly.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
#' @param max_page A numeric value of max page number shown in the table.
#' @param download_button A logical value to display download button.
#' @param width Table container width, a number (interpreted as pixels) or any
#' CSS width value. If `NULL` (default), the table takes its natural width; a
#' value fixes the container width. Either way the width is capped at the
#' viewport, and a wider table scrolls inside rather than widening the page.
#' CSS width value. If `NULL` (default), the container fills its parent; a
#' value fixes the container width. A wider table scrolls inside rather than
#' widening the page, and the container can be resized by dragging its corner.
#'
#' @section Searching and filtering:
#' The interactive table has a search box for each column (and, in the
Expand Down Expand Up @@ -459,9 +459,8 @@ ae_forestly <- function(outdata,
# forestly-ae on lt's container scopes cell styles and sizes the table (see
# inst/css/forestly-widgets.css); per-column widths from format_lt_forestly() kept.
built$x <- lt::lt_wrap(built$x, class = "forestly-ae")
# A user-specified width fixes the container (still capped at the viewport by
# the `.forestly-ae` CSS, so a wide table scrolls inside rather than widening
# the page). A number is pixels.
# A user-specified width fixes the container; a wider table scrolls inside
# rather than widening the page. A number is pixels.
if (!is.null(width)) {
width <- if (is.numeric(width)) paste0(width, "px") else width
built$x <- lt::lt_wrap(built$x, style = paste0("width:", width))
Expand Down
11 changes: 3 additions & 8 deletions inst/css/forestly-widgets.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
.forestly-ae {
/* Natural table width, centered (margin-left:50% + translateX back half its
width), capped below the viewport so a wider table breaks out of a narrow
parent yet still scrolls inside `.lt-wrap` rather than adding a page
scrollbar. 40px slack ~ scrollbar + gutter; CSS can't read the real width. */
width: max-content;
max-width: calc(100vw - 40px);
margin-left: 50%;
transform: translateX(-50%);
/* Parent's width by default (a wider table scrolls inside `.lt-wrap`); the
user can drag the corner to resize. */
resize: horizontal;

/* One line per body-data cell, clipped with an ellipsis, full text on hover;
skip figure (svg) cells. Header (thead), footer (tfoot) and drill-down
Expand Down
6 changes: 3 additions & 3 deletions man/ae_forestly.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion pkgdown/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@ footer {
position: relative;
top: 0;
}
}
}
/* Bootstrap sets `display: block` on tables; restore it for the forest table
so it sizes as a normal table inside `.lt-wrap`. */
.forestly-ae table {
display: table;
}
Loading