Creating multiple adjacent shrinking sections

Problem

I’m working on a TW-based page that includes breadcrumbs above the tiddler title, showing Document > Chapter > Section > Subsection > Sub-subsection or some initial subset of those. I want these to remain on one line, regardless of whether certain of the titles happen to be quite long. I have a technique that’s working reasonably well, using the CSS text-overflow: ellipsis; But I do this by restricting each section to max-width: 40% (Only two of these sections have dynamic sized text.) This means that at times the content is cut off by an ellipsis, even if there is enough total horizontal space on the line to show the whole thing. I’m wondering if anyone has a technique (TW or plain CSS) to address this. I want the various sections to start to shrink when there’s not enough total room, but I would prefer for them not to shrink if the total space is large enough for them all.

Demo

I don’t know how clear this is:

video1-small

But a larger version is at

http://scott.sauyet.com/Tiddlywiki/WIP/Charter/video.gif.

Better, though, you can test it directly at

http://scott.sauyet.com/Tiddlywiki/WIP/Charter/v1/.

Open up one of the sections with longer titles, perhaps 606H, on a desktop browser and notice the ellipsis in the top breadcrumbs. Resize the page (possibly hiding the sidebar) to show how those change.

Code

The relevant CSS, applied to a section marked up as

<nav class="breadcrumbs">
  <a class="tc-tiddlylink tc-tiddlylink-resolves" href="#Charter" title="Full Charter">Charter</a> 
  <a class="tc-tiddlylink tc-tiddlylink-resolves" href="#Chapter10" title="Chapter X. TRANSITION AND MISCELLANEOUS PROVISIONS"> &gt; Chapter X. TRANSITION AND MISCELLANEOUS PROVISIONS</a>
  <a class="tc-tiddlylink tc-tiddlylink-resolves" href="#Section1013" title="Section 1013. Transition —"> &gt; Section 1013. Transition —</a>
  <a class="tc-tiddlylink tc-tiddlylink-resolves" href="#Section1013J" title="Section 1013J"> &gt; Section 1013J</a>
</nav>

(I know, I know, that should probably be an <OL>. I’ll get there!)

looks like this:

nav.breadcrumbs {
  opacity: 50%; 
  a {
    display: inline-block;
    max-width: 40%;
    height: 1.5em;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}

The breadcrumb-generating code is at $:/_/atc/core/ui/ViewTemplate/body/breadcrumbs

Question

Does anyone know of a technique to do this, that is to shrink more than one block with an ellipsis in such a manner that if there is enough total horizontal space, nothing will be collapsed?

The Wiki

This is really not a wiki, just a web page. I am using TiddlyWiki because of the ability to transclude various parts and show things at every level. OK, I’m also using it because of the Golden Hammer Syndrome; sue me! But in the end it’s a static site, simply delivered through the mechanisms of TW.

I’m trying to get my town to not depend on a scanned PDF version of the recently updated Town Charter, but to have a version which is searchable and linkable. This version was created by running OCR on that PDF, chopping the results into tiddlers, and wrapping a few templates around them. Because of the OCR and the cutting/pasting, there are likely still transcriptions errors. I’ll get to that too.

The main – read-only – version of this is at https://charter2024.andoverct.info/. In any version you can toggle read-only on and off with CTRL-SHIFT-/. (I think @pmario has mentioned that this isn’t available on German keyboards, and I’d love to hear alternative suggestions.)

That’s right. Most of the “special” characters can not be used since they produce different key-codes between German and English keyboards.

Most German laptops use the T2 layout. See the links for the differences. IMO CTLR-SHIFT-1 -2 -3 and so on may be an option.

Quick thought: It might be wise to have the titles be short when possible (Chapter I) and let the additional details be provided only by a description (INCORPORATION AND GENERAL POWERS) that displays wherever that description is helpful…

Alternately, keep the long tiddler title but have a short version of each title in caption field.

You could use CSS to hide the verbosity (description/long title) depending on story river width vs approx length of string…?

I’d love to. But I’m trying to mimic a legal document in every detail but the means of presentation. I’ve even kept in some spurious characters in titles from the PDF. I didn’t mention that the full titles are title fields for those breadcrumb links, so one should be able to hover them to see the full title.

I’m doing that. What’s being shown are the captions. The titles are short forms useful in permalink URLs. The tiddlers look like this:

title: Chapter2
tags: Chapter Charter
caption: Chapter II. ELECTIONS
chapter: 2

<<sections 2>>
title: Section203
tags: Section Chapter2
caption: Section 203. Town Officers - General Election 
chapter: 2
section: 203

<<subsections 203>>
title: Section203C
tags: Subsection
caption: Section 203C
chapter: 2
section: 203
subsection: C

At the biennial town election to be held on the first Tuesday after the first
Monday in November, 2025 and every two (2} years thereafter, there shall be
elected members to the following boards, commissions and agencies for the
terms specified herein. Except as otherwise provided in this Charter, such boards,
commissions and agencies shall have powers and duties as are provided in the
Connecticut General Statutes. Electors may vote for, and a political party may
nominate, as many candidates as there are available seats to be filled on the
following boards and commissions, specifically including the Board of Assessment
Appeals and the Board of Education, provided however, that the minority
representation requirements of Conn. Gen. Stat. § 
[[9-204b|https://www.cga.ct.gov/current/pub/chap_146.htm#sec_9-204b]]
shall apply:

<<sub-subsections 203 C>>
title: Section203C(1)
tags: Sub-subsection
caption: Section 203C(1)
chapter: 2
section: 203
subsection: C
sub-subsection: 1

A Board of Finance, consisting of seven voting members, which shall serve four.
(4) year overlapping terms; plus an additional non-voting member (ex-officio) to
be designated by the Capital Improvement Plan Committee.

… with specific procedures to display sections, subsections, and sub-subsections.

That’s what I’m doing now. I’m just hoping to do it a bit better!

I added a new version at http://scott.sauyet.com/Tiddlywiki/WIP/Charter/v2/, which adds a second option for toggling read-only, CTRL-SHIFT-1. @pmario: If you have a minute free, could you check that this works on your keyboard layout?

Thinking about this again, I suppose that since the breadcrumbs are not in the original document, I can choose to do with them what I like. But I prefer having as much of the titles available there. My ideal situation would be for the full titles to be visible if there is enough space for them, but as that space tightens up, one after another, from longest title to shortest, they start reducing to partial titles with ellipses. I’m not terribly far off, but I don’t know how to make progress.

1 Like

CTRL-SHIFT-1 works for me on Windows 11, FF 135

Thank you for checking!

Solved it. I ended up using a flexbox. It’s not perfect, but it will do for now. The result is at http://scott.sauyet.com/Tiddlywiki/WIP/Charter/v3/.

The generated markup changed a bit:

<nav class="breadcrumbs">
  <div class="crumb"><a class="tc-tiddlylink tc-tiddlylink-resolves" href="#Charter" title="Full Charter">Charter</a></div> 
  <div class="sep">&gt;</div>
  <div class="crumb"><a class="tc-tiddlylink tc-tiddlylink-resolves" href="#Chapter6" title="Chapter VI. APPOINTED OFFICERS, BOARDS, COMMISSIONS, COMMITTEES AND AGENCIES">Chapter VI. APPOINTED OFFICERS, BOARDS, COMMISSIONS, COMMITTEES AND AGENCIES</a></div>
  <div class="sep">&gt;</div>
  <div class="crumb"><a class="tc-tiddlylink tc-tiddlylink-resolves" href="#Section606" title="Section 606. Appointed Town Boards.">Section 606. Appointed Town Boards.</a></div>  
</nav>

Any I’m applying this CSS:

nav.breadcrumbs {
  opacity: 50%; 
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  min-width: 0;
  div.sep {padding: 0 .5em 0 0; min-width: 0;}
  div.crumb {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    min-width: 0;
  }
}

Thank you, folks, for the feedback.

1 Like