/* The chip input, static/chips.js: a box drawn as the rail's text fields * (`.rail-fields input[type="text"]` in app.css), with the picks inside it * as the rail's pressed tags and the suggestions in a list under it, as wide * as the box, so it stays inside the rail. Only app.css's custom properties, * so light and dark come with them. * * The rail styles every button with `#rail button:not(.linky)`, an id's * weight, which would square the chips and clear their colour. `:not(#_)` * matches everything and gives the chip rules an id's weight too, so they * hold in the rail and anywhere else without naming it. */ .chip-input { position: relative; margin: 0 .3rem; } .chip-box { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; min-height: 2rem; padding: .2rem .3rem; border: 1px solid var(--line); border-radius: 3px; background: var(--panel); color: var(--fg); cursor: text; } /* The field's focus ring, on the box, since the box is what looks like the field. Not `:focus-within`: a focused chip draws its own. */ .chip-box:has(.chip-text:focus) { outline: 2px solid var(--accent); outline-offset: 1px; } /* Three classes to outweigh `.rail-fields input[type="text"]`, which would give the text its own border and margin inside the box. */ .chip-input .chip-box input.chip-text { flex: 1 1 4rem; width: auto; min-width: 3rem; min-height: 1.5rem; margin: 0; padding: 0 .15rem; border: 0; outline: none; background: none; color: inherit; font: inherit; font-size: .84rem; line-height: normal; } /* A pick: the pressed tag of app.css's `#rail .tag[aria-pressed="true"]`, the × in the colour of its count. The whole chip is the remove button, as on the agent form's chips. */ .chip-input:not(#_) .chip-box button.chip { display: inline-flex; align-items: center; gap: .3rem; max-width: 100%; min-width: 0; min-height: 0; padding: .06rem .55rem; margin: 0; font: inherit; font-size: .8rem; line-height: 1.45; color: var(--panel); background: var(--accent); border: 1px solid var(--accent); border-radius: 999px; cursor: pointer; } .chip .chip-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .chip .chip-x { flex: none; color: var(--accent-weak); } @media (hover: hover) { .chip-input:not(#_) .chip-box button.chip:hover { color: var(--panel); background: var(--accent); } .chip:hover .chip-x { color: var(--panel); } } .chip-list { position: absolute; z-index: 3; left: 0; right: 0; top: calc(100% + 2px); margin: 0; padding: .2rem 0; list-style: none; max-height: min(16rem, 50vh); overflow-y: auto; overscroll-behavior: contain; background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 3px; box-shadow: 0 8px 24px rgb(0 0 0 / 18%); } .chip-option { display: flex; align-items: baseline; gap: .5rem; padding: .3rem .55rem; font-size: .84rem; line-height: 1.35; cursor: pointer; } .chip-option-label { flex: 1; min-width: 0; overflow-wrap: anywhere; } .chip-option-hint { flex: none; margin-left: auto; font-size: .76rem; color: var(--faint); font-variant-numeric: tabular-nums; } /* The highlighted option: the rail's pressed row. */ .chip-option[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); } /* Sizes for a finger, after app.css's own coarse block. 16px text so iOS does not zoom in on focus. */ @media (pointer: coarse) { .chip-box { min-height: 2.75rem; } .chip-input .chip-box input.chip-text { font-size: 16px; min-height: 2.25rem; } .chip-input:not(#_) .chip-box button.chip { min-height: 2.25rem; padding: .2rem .8rem; font-size: .88rem; } .chip-option { align-items: center; min-height: 2.75rem; padding-block: .4rem; font-size: .92rem; } }