The-Strategy-Unit / The-Strategy-Unit/open-plan-docs

Make functional areas table clickable

Open
#77 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

UX
Dominant language
HTML
Stars
3
Forks
1
Avg merge
1d 21h
Merged PRs (30d)
14

Description

It would be nice if the rows of the tables in the functional area catalogue, when clicked, took you to the functional area details page.

I'll need to

  1. Add URL to the CSV
  2. Wrap the column in the link syntax
  3. Make the entire row clickable using javascript

Link syntax

Something like...

markdown{% set df = pd_read_csv("docs/data/fun_area_catalog.csv").fillna("") %}
{% set df = df.assign(Name=df.apply(lambda r: "[" + r["Name"] + "](" + r["url"] + ")", axis=1)) %}
{{ df | convert_to_md_table }}

Clickable tables

docs/javascripts/clickable-rows.js
jsdocument$.subscribe(function () {
  document.querySelectorAll("article table tbody tr").forEach(function (row) {
    const link = row.querySelector("a");
    if (!link) return;
    row.style.cursor = "pointer";
    row.addEventListener("click", function (e) {
      if (e.target.closest("a")) return; // let the real link behave normally
      window.location.href = link.getAttribute("href");
    });
  });
});

docs/stylesheets/clickable-rows.css:

cssarticle table tbody tr:hover {
  background-color: var(--md-default-fg-color--lightest);
}

And reference them in the zensical.toml

extra_javascript = ["javascripts/clickable-rows.js"]
extra_css = ["stylesheets/clickable-rows.css"]

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with docs/data/fun_area_catalog.csv, docs/javascripts/clickable-rows.js, docs/stylesheets/clickable-rows.css, and zensical.toml to understand how the catalogue table is generated and assets are loaded. Confirm that each functional-area row navigates to its detail page, direct links still behave normally, and the row hover styling appears.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, javascript, python
Domain
documentation, frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.