VB Project Planning

<user-story>

Displays Agile user stories in the classic 'As a / I want / so that' format with priority, status, and story points.

Overview

A web component that renders user stories in the standard Agile format: "As a [persona], I want [action] so that [benefit]." Includes visual badges for priority, status, and story points, plus slotted sections for acceptance criteria, tasks, and notes. Designed for sprint planning boards, backlog views, and design documentation.

Attributes

AttributeValuesDefaultDescription
heading-levelnumber—Level (1–6) of the Acceptance Criteria / Tasks / Notes headings. Default: one below the nearest preceding heading on the page (the slotted title is only shown in minimal mode, which has no sections).
persona-idstring—Links to a user-persona element by id. Without a persona slot, the "As a…" text uses that persona's job-title (live-updating; a legacy non-ARIA role attribute is also read).
priority"critical", "high", "medium", "low"mediumStory priority level
status"backlog", "to-do", "in-progress", "review", "done"backlogWorkflow status
pointsstring—Story point estimate (badge reads "[n] story points" to screen readers)
epicstring—Parent epic label
story-idstring—Ticket or story identifier; sets the HTML id on first connect when none is set
detail"full", "compact", "minimal"fullDetail level. minimal renders a button that opens the full story in a dialog.
compactboolean—Alias for detail=compact
srcstring—URL of a JSON story record. Fetched once per value; a newer value aborts the older request.

Slots

Slot Expected Content Description
persona <span> or text The "As a..." role or persona name (e.g., "Product Manager")
action <span> or text The "I want..." action description
benefit <span> or text The "so that..." benefit. When omitted, the benefit clause is hidden.
acceptance-criteria <ul> or <ol> Definition of done checklist. Displayed with a green accent icon.
tasks <ul> or <ol> Implementation tasks. Displayed with a purple accent icon.
notes <p> or text Additional notes or context. Displayed with an amber accent icon.

Detail Levels

The detail attribute controls how much content the card displays. Three levels support different use cases from dense kanban boards to full documentation.

Value Shows Use Case
full Header, statement, all sections (with empty fallbacks) Documentation pages, standalone story views
compact Header, statement, sections only if populated Story map columns, backlog lists
minimal Story ID + title only. Clickable — opens full detail in a <dialog>. Kanban boards, impact/effort matrix, dense grids

Click to Expand

Minimal cards render as a <button> (named "[story-id]: [title]", with aria-haspopup="dialog"). Clicking it or pressing Enter or Space opens a native modal <dialog> showing the full story, labelled by its <h2> title. Each story owns one dialog: it is removed from the document when it closes or when the story is removed. The dialog uses VB’s built-in dialog CSS for sizing, backdrop, and animation. You can also call story.showDetail() programmatically.

JSON Loading

Load story data from a JSON file using the src attribute. Scalar fields map to attributes; text and list fields create the slotted persona, action, benefit, title, acceptance criteria, tasks, and notes children (authored children are kept). The file is fetched once — moving the card (for example between kanban columns) does not refetch — and user-story:ready fires after the data renders.

Slot-Based Authoring

Content values — persona, action, and benefit — are provided as named slots. State attributes like priority, status, points, and story-id remain on the element. This separation keeps content in the DOM and metadata in attributes.

Priority Variants

The priority attribute controls the colored badge in the story header. Here are three stories showing different priority and status combinations in compact mode.

Value Label Color
critical Critical #dc2626 (red)
high High #ea580c (orange)
medium Medium #ca8a04 (amber)
low Low #16a34a (green)

Status Variants

The status attribute controls the workflow badge in the story header.

Value Label Color
backlog Backlog #6b7280 (gray)
to-do To Do #3b82f6 (blue)
in-progress In Progress #8b5cf6 (purple)
review Review #f59e0b (amber)
done Done #22c55e (green)

JavaScript API

The component exposes two methods for programmatic status and priority updates. Both update the attribute and dispatch a corresponding event. The un-namespaced names used before 0.3.0 (status-changed, priority-changed, story-ready) still fire as deprecated aliases throughout 0.3.x.

Method Argument Description
updateStatus(status) One of: backlog, to-do, in-progress, review, done Updates the status badge and fires user-story:status-changed
updatePriority(priority) One of: critical, high, medium, low Updates the priority badge and fires user-story:priority-changed

Property API (JS-first)

The whole story — state and slotted content — can be set in one assignment, useful when a reactive framework or kanban-board owns the data.

PropertyTypeDescription
.data{ storyId?, personaId?, priority?, status?, points?, epic?, detail?, persona?, action?, benefit?, title?, acceptanceCriteria?, tasks?, notes? }Sets state attributes and creates slotted children for any fields not already present (authored content wins). Idempotent.
showDetail()methodOpen this story at full detail in a modal dialog (see Click to Expand).
updateStatus(status) / updatePriority(priority)methodSet the attribute and fire user-story:status-changed / user-story:priority-changed. Unknown values are ignored.

Reading .data back returns the current shape. See the Data API concepts guide.

Assigning .data fires user-story:data-changed; frameworks should wait for user-story:upgraded first. All events are listed under Events below.

CSS Custom Properties

Variable Default Description
--user-story-bg #ffffff / #1e1e1e Card background color
--user-story-text #1a1a1a / #e8e8e8 Primary text color
--user-story-muted #666666 / #888888 Secondary/muted text color
--user-story-border #e0e0e0 / #333333 Card and section border color
--user-story-accent #0066cc / #6b9fff Accent color for keywords and epic badge
--user-story-card-bg #f8f9fa / #252525 Header background color
--user-story-highlight rgba(0, 102, 204, 0.08) / rgba(107, 159, 255, 0.15) Persona text highlight and epic badge background
--user-story-radius 12px Outer card border radius

Events

EventDetailDescription
user-story:ready{ id, persona, action, benefit, priority, status, points }Once per element, after the first render. With src, after the fetched data renders (not fired if the fetch fails). Not re-fired by attribute changes or moves. For the 0.3.x line the deprecated un-namespaced alias story-ready is dispatched right after, with the same detail.
user-story:status-changed{ status, storyId }Fired when updateStatus() is called with a known status. For the 0.3.x line the deprecated un-namespaced alias status-changed is dispatched right after, with the same detail.
user-story:priority-changed{ priority, storyId }Fired when updatePriority() is called with a known priority. For the 0.3.x line the deprecated un-namespaced alias priority-changed is dispatched right after, with the same detail.
user-story:upgraded—Once, in a microtask after first connect. Wait for this before assigning .data from a framework.
user-story:data-changed{ data, source: 'property' }After .data is assigned

Accessibility

  • The full and compact card is an <article> with aria-label="User story: [story-id]" (or "User story" without an id)
  • The minimal card is a real <button> named "[story-id]: [title]" with aria-haspopup="dialog"; Enter and Space open the detail dialog
  • On a board (a minimal card directly inside a <drag-surface>, as in <kanban-board>, <story-map> or <impact-effort>) the card itself is the single tab stop and the inner button leaves the tab order. Enter opens the detail dialog; Space grabs the card for keyboard reordering; while grabbed, the arrow keys move it, Space or Enter drops it and Escape cancels. A click opens the dialog.
  • Priority and status badges use color plus text labels — never color alone
  • The story points badge shows the number and includes visually hidden text, so it reads as "[n] story points"
  • The Acceptance Criteria, Tasks, and Notes sections each have a visible <h3> heading for screen reader navigation
  • Respects prefers-reduced-motion: reduce by disabling hover transitions
  • Responsive layout stacks header badges vertically at narrow viewports (<480px)

Related

↑