Docs

Install

From npm, then import it once anywhere in your app:

npm install eacapability
import 'eacapability';

Or from a CDN, with no build step:

<script type="module" src="https://cdn.jsdelivr.net/npm/eacapability/dist/index.js"></script>

Importing it defines <ea-capability-map>. It's safe to import during server rendering: the element is only defined in the browser.

Describe your model

Nest capabilities with children. The layout comes from how deep the model goes: the capabilities at the bottom are cards, their parents panels, the level above columns, then group labels, then sections.

{
  "title": "Higher education capability model",
  "capabilities": [
    {
      "name": "Student Lifecycle",
      "description": "Bringing students in and supporting them",
      "children": [
        { "name": "Admissions" },
        { "name": "Enrollment", "href": "/capabilities/enrollment" }
      ]
    }
  ]
}

Or list them flat with id and parent, as an export from another tool would be:

{
  "capabilities": [
    { "id": "1", "name": "Student Lifecycle" },
    { "id": "1.1", "name": "Admissions", "parent": "1" }
  ]
}
FieldWhat it does
nameRequired.
idUnique in the map. Optional when nesting: the path of names is used.
descriptionShown on hover and read by screen readers.
heatColours the capability by the legend entry with this value.
countA number beside the name, such as how many applications support it.
hrefMakes the capability a link.

Add a heat map

Give the map a legend, then a heat value on each capability. The legend's labels are shown and read out with each capability, so colour is never the only signal. Choosing a legend entry narrows the map to it.

{
  "legend": [
    { "value": "high", "label": "At risk", "color": "#d63939" },
    { "value": "ok", "label": "Healthy", "color": "#2fb344" }
  ],
  "capabilities": [
    { "name": "Admissions", "heat": "high", "count": 4 },
    { "name": "Enrollment", "heat": "ok" }
  ]
}

Give it data

Attributes

AttributeWhat it does
srcA JSON file to load.
themelight (default), dark, or auto to follow the visitor's system.
selectableCapabilities without an href become buttons that fire ea-select.
no-legendHides the legend.

Events

Eventdetail
ea-select{ id, name, path, heat, count } for the capability chosen. Needs selectable.
ea-loadNone. Fired once the data is drawn.
ea-error{ message } when data can't be loaded or drawn.

In React

Set data through a ref once the element is on the page, and listen for its events the same way:

import { useEffect, useRef } from 'react';
import 'eacapability';
import type { EaCapabilityMap, MapData } from 'eacapability';

export function Map({ data }: { data: MapData }) {
  const ref = useRef<EaCapabilityMap>(null);
  useEffect(() => {
    if (ref.current) ref.current.data = data;
  }, [data]);
  return <ea-capability-map ref={ref} theme="auto" />;
}

Styling

Colours, fonts and sizes are CSS custom properties on the element:

ea-capability-map {
  --ea-font: "Inter", sans-serif;
  --ea-heading-font: Georgia, serif;
  --ea-surface: #ffffff;
  --ea-ink: #1f2328;
  --ea-card-min: 12rem;
  --ea-column-min: 16rem;
}

The others are --ea-muted, --ea-panel-from, --ea-panel-to, --ea-line, --ea-focus and --ea-radius. For anything more, style its parts: map, legend, legend-item, section, group, column, panel, cards, card, row, count, message, and the titles section-title, group-title, column-title and panel-title.

ea-capability-map::part(card) { border-radius: 0; }