{
  "id": "L01",
  "title": "Single-line list",
  "topic": "lists",
  "use": "A list in which every entry fits on one line. The identifier comes first, the label after it. The identifier is never cut — it is what users search for; the label is cut instead. All rows are the same height, also the ones that carry nothing extra.",
  "decisions": [
    "The identifier comes first and is never cut: it is what users search for, and in payroll the number is the name. The label after it is cut instead — a label can be explained, a number cannot.",
    "The identifier stands in tabular figures, so the numbers form one edge and the labels after them start on another.",
    "One line means no secondary line in any entry: as soon as a single entry needs two lines, the whole list is a two-line list (L02), not a one-line list with gaps.",
    "All rows are the same height, also the ones that carry nothing extra: a list whose rows jump in height reads as unfinished.",
    "A long label is cut with an ellipsis, not wrapped: a wrap makes two lines of one and takes the list its edge. The full text appears in an ed-tooltip on hover, on exactly the labels that are cut."
  ],
  "try": [
    {
      "do": "Read the identifiers from top to bottom",
      "then": "they stand on one edge in tabular figures, and the labels after them start on one edge too"
    },
    {
      "do": "Make the window narrow",
      "then": "the long label is cut with an ellipsis, while every identifier stays whole"
    },
    {
      "do": "Point at the cut label",
      "then": "its full text appears; a label that fits shows nothing on hover"
    },
    {
      "do": "Compare the row heights",
      "then": "every row is the same height, the cut one included"
    }
  ],
  "revision": 2,
  "changes": [
    {
      "revision": 2,
      "change": "The full text of a cut label is an ed-tooltip, not the label's title; it comes and goes with the cut."
    }
  ],
  "reviewed": true,
  "source": "<div class=\"ed-stack ed-gap-4\">\n  <!-- Demo only, not part of the pattern. The screen's title, and whose wage types these are, come from the screen around the pattern; SC01 places them. -->\n\n  <ed-list id=\"l01-wage-types\" label=\"Wage types\">\n    <ed-list-item><div class=\"ed-text-truncate\"><span class=\"ed-text-tabular\">1000</span> Monthly salary</div></ed-list-item>\n    <ed-list-item><div class=\"ed-text-truncate\"><span class=\"ed-text-tabular\">1200</span> Overtime pay</div></ed-list-item>\n    <ed-list-item><div class=\"ed-text-truncate\"><span class=\"ed-text-tabular\">2100</span> Company car benefit in kind</div></ed-list-item>\n    <ed-list-item><div class=\"ed-text-truncate\"><span class=\"ed-text-tabular\">3400</span> Capital-forming benefits, employer contribution under the collective agreement</div></ed-list-item>\n    <ed-list-item><div class=\"ed-text-truncate\"><span class=\"ed-text-tabular\">5200</span> Commuting allowance</div></ed-list-item>\n    <ed-list-item><div class=\"ed-text-truncate\"><span class=\"ed-text-tabular\">6100</span> Vacation pay</div></ed-list-item>\n    <ed-list-item><div class=\"ed-text-truncate\"><span class=\"ed-text-tabular\">9000</span> Garnishment</div></ed-list-item>\n  </ed-list>\n</div>\n\n<script type=\"module\">\n  await customElements.whenDefined('ed-list-item');\n\n  // The full text goes into a tooltip on the labels the width actually cuts, and the tooltip goes\n  // again once they fit: a tooltip that repeats what is already there is noise. The tooltips stand\n  // after the list, not in an entry, whose content they would join.\n  const list = document.getElementById('l01-wage-types');\n  const labels = list.querySelectorAll('.ed-text-truncate');\n  const tooltips = new Map();\n  const markCut = entries => {\n    for (const { target } of entries) {\n      const cut = target.scrollWidth > target.clientWidth;\n      if (cut && !tooltips.has(target)) {\n        const tooltip = document.createElement('ed-tooltip');\n        tooltip.setAttribute('for', target.id);\n        tooltip.textContent = target.textContent.replace(/\\s+/g, ' ').trim();\n        list.after(tooltip);\n        tooltips.set(target, tooltip);\n      } else if (!cut && tooltips.has(target)) {\n        tooltips.get(target).remove();\n        tooltips.delete(target);\n      }\n    }\n  };\n  const observer = new ResizeObserver(markCut);\n  labels.forEach((label, index) => {\n    label.id = `l01-label-${index + 1}`;\n    observer.observe(label);\n  });\n</script>",
  "page": "https://test-apps.eurodata.de/a/eurodata-ui/docs/patterns/lists/l01-single-line-list/",
  "topicPage": "https://test-apps.eurodata.de/a/eurodata-ui/docs/patterns/lists/"
}
