{
 "id": "donut-breakdown",
 "name": "Spend breakdown donut",
 "purpose": "Spend split into four categories as a donut with the total in the middle, and a legend that lists each amount and share.",
 "use_when": [
  "for showing how a total splits into a few categories",
  "a billing or usage page that needs the total and each category's amount and share side by side"
 ],
 "avoid_when": [
  "more than four categories, or values to compare over time: use bar-chart",
  "a few headline numbers with no part-of-a-whole split: use kpi-strip",
  "spending against limits per category: use budget-meters"
 ],
 "type": "chart",
 "style": "quiet",
 "width": "medium",
 "tags": {
  "audience": "work",
  "industries": [
   "saas",
   "finance",
   "devtools",
   "any"
  ],
  "keywords": [
   "donut",
   "breakdown",
   "categories",
   "share",
   "legend"
  ]
 },
 "root": ".odl-donut-breakdown",
 "parts": [
  {
   "name": "title",
   "selector": "h3",
   "what": "what is being split, the one heading",
   "slot": "text"
  },
  {
   "name": "period",
   "selector": ".odl-sub",
   "what": "the date range",
   "slot": "text"
  },
  {
   "name": "ring",
   "selector": "figure",
   "what": "the donut, one segment per category, hidden from screen readers",
   "slot": "none"
  },
  {
   "name": "total",
   "selector": ".odl-total",
   "what": "the rounded total in the middle, with a short caption",
   "slot": "number"
  },
  {
   "name": "legend",
   "selector": "ul > li",
   "what": "one category: colour dot, name with a usage note, amount and share; hovering it lifts its segment",
   "slot": "list"
  },
  {
   "name": "foot",
   "selector": ".odl-foot",
   "what": "a note under the chart, such as credits or a trend",
   "slot": "text"
  }
 ],
 "data": {
  "type": "object",
  "required": [
   "title",
   "total",
   "categories"
  ],
  "properties": {
   "title": {
    "type": "string",
    "maxLength": 32,
    "part": "title"
   },
   "period": {
    "type": "string",
    "maxLength": 32,
    "part": "period"
   },
   "total": {
    "type": "object",
    "part": "total",
    "required": [
     "value"
    ],
    "properties": {
     "value": {
      "type": "string",
      "maxLength": 10
     },
     "caption": {
      "type": "string",
      "maxLength": 20
     }
    }
   },
   "categories": {
    "type": "array",
    "minItems": 2,
    "maxItems": 4,
    "part": "legend",
    "items": {
     "type": "object",
     "required": [
      "name",
      "amount",
      "share"
     ],
     "properties": {
      "name": {
       "type": "string",
       "maxLength": 24
      },
      "note": {
       "type": "string",
       "maxLength": 20
      },
      "amount": {
       "type": "string",
       "maxLength": 12
      },
      "share": {
       "type": "number",
       "minimum": 0,
       "maximum": 100
      }
     }
    }
   },
   "foot": {
    "type": "string",
    "maxLength": 120,
    "part": "foot"
   },
   "total_caption": {
    "type": "string",
    "maxLength": 80
   }
  }
 },
 "states": {
  "shown": [
   "hover row highlights its segment"
  ],
  "edge": {
   "empty": {
    "status": "handled",
    "evidence": "data-od-list",
    "how": "the Smart UI renderer puts one plain 'Nothing to show yet.' line in an empty list"
   },
   "loading": {
    "status": "handled",
    "evidence": "data-od-slot",
    "how": "the Smart UI renderer draws each marked slot as a quiet block of its size while the data arrives; the static file shows the filled part"
   },
   "error": {
    "status": "not_built",
    "how": "if the numbers fail to load, keep the heading and put an alert-banners line in place of the chart and legend"
   },
   "disabled": {
    "status": "not_built",
    "how": "the chart has no controls; to mark stale data, lower the ring's opacity and say so in the foot"
   },
   "overflow": {
    "status": "handled",
    "how": "below about 480px the ring sits above the legend instead of beside it, and shrinks further on phones",
    "evidence": "@container (min-width: 30rem)"
   },
   "long_text": {
    "status": "handled",
    "how": "a long category name wraps in its own column while amount and share keep their width",
    "evidence": "grid-template-columns: var(--ds-space-12) minmax(0, 1fr) auto 5ch"
   },
   "missing_image": {
    "status": "none",
    "how": "the part has no photo"
   }
  }
 },
 "tokens": [
  "--ds-border-width-default",
  "--ds-color-bg-accent-bold",
  "--ds-color-bg-neutral-subtle",
  "--ds-color-bg-warning-bold",
  "--ds-color-border-strong",
  "--ds-color-border-subtle",
  "--ds-color-surface-raised",
  "--ds-color-text-primary",
  "--ds-color-text-secondary",
  "--ds-color-text-tertiary",
  "--ds-elevation-raised",
  "--ds-motion-duration-short",
  "--ds-motion-easing-standard",
  "--ds-radius-container",
  "--ds-radius-full",
  "--ds-radius-nested",
  "--ds-size-control-lg",
  "--ds-size-target-min",
  "--ds-space-12",
  "--ds-space-2",
  "--ds-space-inline-md",
  "--ds-space-inset-lg",
  "--ds-space-inset-sm",
  "--ds-space-inset-xl",
  "--ds-space-inset-xs",
  "--ds-space-stack-lg",
  "--ds-space-stack-xl",
  "--ds-space-stack-xs",
  "--ds-text-body-md",
  "--ds-text-label-md",
  "--ds-text-numeric-lg",
  "--ds-text-title-md"
 ],
 "a11y": {
  "summary": "The drawing is hidden from screen readers; the legend list carries every category, amount and share, and its label gives the total.",
  "roles": [
   "list",
   "region"
  ],
  "keyboard": [],
  "controls": {
   "button": 0,
   "input": 0,
   "link": 0,
   "select": 0,
   "textarea": 0,
   "summary": 0
  },
  "focus_visible": false,
  "reduced_motion": true,
  "min_target": true
 },
 "files": {
  "html": "components/donut-breakdown/component.html",
  "bytes": 10225,
  "script": true
 },
 "source": null,
 "photos": 0,
 "urls": {
  "html": "https://opendesigner.dev/library/donut-breakdown.html",
  "json": "https://opendesigner.dev/library/donut-breakdown.json",
  "page": "https://opendesigner.dev/library/donut-breakdown/"
 },
 "get": {
  "curl": "curl -fsSLo donut-breakdown.html https://opendesigner.dev/library/donut-breakdown.html",
  "opendesigner": "python3 path/to/skills/opendesigner/scripts/library.py add donut-breakdown --from https://opendesigner.dev",
  "prompt": "Add the OpenDesigner component donut-breakdown to this project: https://opendesigner.dev/library/donut-breakdown.html. Keep its markup and states; map its --ds-* variables to my tokens."
 }
}
