Merge main: read state and tags meet per-agent votes and affinity
The per-agent migration becomes v6 behind main's v5. A vote still stamps the role's read_at, tag counts hide the agent's hidden companies, and /api/filters takes the agent like /api/roles. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
commit
c69fb0b6c4
23 files changed
+2270
-717
No files matched your search
+548
-122
@@ -25,11 +25,25 @@
|
||||
--warn: #b45309;
|
||||
--error: #b91c1c;
|
||||
|
||||
--faint: #6d7883;
|
||||
--accent-weak: #a9c4bf;
|
||||
|
||||
/* How tall the header is, and every sticky offset on the Roles page is
|
||||
measured from it: the rail, the reader, the scrim. static/roles.js
|
||||
measures the header and writes the answer here; this is only the value
|
||||
before the first measurement lands. */
|
||||
--chrome: 3.4rem;
|
||||
|
||||
--radius: 10px;
|
||||
--gap: 1rem;
|
||||
--font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto,
|
||||
"Helvetica Neue", Arial, sans-serif;
|
||||
--mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
|
||||
/* newsdesk's second face: what is read -- a title, an excerpt, a posting --
|
||||
runs in a serif with a big x-height, which is what makes a wall of text
|
||||
scannable; the chrome stays in the UI face. */
|
||||
--read: Charter, "Bitstream Charter", "Iowan Old Style", "Source Serif 4",
|
||||
Georgia, Cambria, "Palatino Linotype", serif;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
@@ -38,9 +52,11 @@
|
||||
--panel: #1b2126;
|
||||
--fg: #e3e7ea;
|
||||
--dim: #a8b2ba;
|
||||
--faint: #8b959d;
|
||||
--line: #2a3238;
|
||||
--accent: #4fb3a3;
|
||||
--accent-fg: #14181c;
|
||||
--accent-weak: #35544f;
|
||||
--good: #4ade80;
|
||||
--warn: #fbbf24;
|
||||
--error: #f87171;
|
||||
@@ -326,111 +342,370 @@ textarea:focus-visible {
|
||||
|
||||
.count { color: var(--dim); font-size: .85rem; margin: .75rem 0 .5rem; }
|
||||
|
||||
/* == roles, the read page, applications ================================== */
|
||||
/* The feed row and the reader are news's (`newsdesk/web/static/app.css`):
|
||||
* the row a grid with a bottom rule and no card, the actions on the right
|
||||
* dropping under the text at 640px, a cast vote filled rather than tinted.
|
||||
* Drawn by static/roles.js, static/role.js and static/judge.js; the phone
|
||||
* and touch rules for all of it are at the end of this section rather than
|
||||
* in the phone section below, so the section is one piece. */
|
||||
/* == roles: the rail, the feed and the reader ============================ */
|
||||
/* newsdesk's feed and reader (`newsdesk/web/static/app.css` in ../news),
|
||||
* ported with its comments: the shell grid, the rail, the `.row` with its
|
||||
* score gutter, the reader as a third column, and at the end of this section
|
||||
* the phone and touch rules for all of it. newsdesk's names for the colours
|
||||
* map onto this file's: `--ink` is `--fg`, `--muted` is `--dim`, `--rule` is
|
||||
* `--line`, `--signal` is `--accent`, `--down` is `--error`. Drawn by
|
||||
* static/roles.js and static/judge.js. */
|
||||
|
||||
/* The filter bar: the order, the search box, and Filters on one row at any
|
||||
width. Filters is a `<details>` whose summary is lifted into that row, so
|
||||
the panel it opens sits in the flow under the row and pushes the list
|
||||
down instead of covering it. */
|
||||
.roles-filters { display: block; position: relative; }
|
||||
.filter-line { display: flex; gap: .5rem; align-items: center; margin-right: 6.75rem; }
|
||||
.filter-line select { flex: 0 1 auto; max-width: 45%; }
|
||||
.filter-line input[type="search"] { flex: 1 1 8rem; }
|
||||
.filter-more > summary {
|
||||
position: absolute; top: .75rem; right: .75rem;
|
||||
display: flex; align-items: center; justify-content: center; min-width: 6rem;
|
||||
padding: .4rem .6rem; line-height: 1.2;
|
||||
border: 1px solid var(--line); border-radius: .3rem;
|
||||
color: var(--fg); background: var(--bg); cursor: pointer;
|
||||
list-style: none; white-space: nowrap;
|
||||
}
|
||||
.filter-more > summary::-webkit-details-marker { display: none; }
|
||||
.filter-more[open] > summary { border-color: var(--accent); color: var(--accent); }
|
||||
.filter-active { margin-left: .3rem; color: var(--accent); font-weight: 600; }
|
||||
.filter-panel {
|
||||
display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
|
||||
margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--line);
|
||||
}
|
||||
.filter-panel select { flex: 1 1 9rem; }
|
||||
/* -- the header, on the Roles page -- */
|
||||
|
||||
/* The feed. */
|
||||
.roles {
|
||||
list-style: none; margin: 0; padding: 0;
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line); border-radius: var(--radius);
|
||||
/* The tabs and the cog sit at the right on every page, where newsdesk keeps
|
||||
its own controls, so they do not move when the Roles page puts its burger
|
||||
and search box between them and the brand. */
|
||||
.top nav { margin-left: auto; }
|
||||
|
||||
#search {
|
||||
flex: 0 1 22rem; min-width: 12rem;
|
||||
font: inherit; font-size: .88rem;
|
||||
padding: .3rem .55rem;
|
||||
color: var(--fg); background: var(--bg);
|
||||
border: 1px solid var(--line); border-radius: 3px;
|
||||
}
|
||||
.roles:empty { display: none; }
|
||||
.roles-end { height: 1px; }
|
||||
.role {
|
||||
display: grid; grid-template-columns: minmax(0, 1fr) auto;
|
||||
|
||||
/* With the rail shut and the pill row gone -- which is every narrow screen --
|
||||
this button is the only thing left that can say a filter is on. So it says
|
||||
how many, in words.
|
||||
|
||||
It was a number in a filled circle, which is the badge every application
|
||||
uses for unread mail: it reads as "two new things" on the one control that
|
||||
means two things are being left out. "2 filters" cannot be read the wrong
|
||||
way round, and it costs four characters on the narrowest screen there is. */
|
||||
#rail-toggle {
|
||||
display: inline-flex; align-items: center; gap: .4em;
|
||||
padding: .3rem .6rem; font-size: .88rem;
|
||||
color: var(--dim); background: none;
|
||||
border: 1px solid transparent; border-radius: 3px;
|
||||
}
|
||||
@media (hover: hover) {
|
||||
#rail-toggle:hover { color: var(--fg); background: var(--bg); }
|
||||
}
|
||||
.rail-toggle-label { white-space: nowrap; }
|
||||
#rail-toggle[aria-label*="filter"] .rail-toggle-label {
|
||||
color: var(--accent); font-weight: 600;
|
||||
}
|
||||
|
||||
/* Three lines, drawn rather than typed: the hamburger is the one glyph a
|
||||
phone user does not have to read to recognise, and at this size an emoji
|
||||
or a box-drawing character lands differently in every font. */
|
||||
.burger {
|
||||
display: block; position: relative;
|
||||
width: 1em; height: 2px; background: currentColor; border-radius: 2px;
|
||||
}
|
||||
.burger::before, .burger::after {
|
||||
content: ''; position: absolute; left: 0;
|
||||
width: 100%; height: 2px; background: currentColor; border-radius: 2px;
|
||||
}
|
||||
.burger::before { top: -5px; }
|
||||
.burger::after { top: 5px; }
|
||||
|
||||
/* Behind the rail when the rail is an overlay, never otherwise. Dimming
|
||||
`main` said "this is in front of that" but left the feed holding the tap
|
||||
that means "put it away"; a scrim does both jobs. */
|
||||
#scrim {
|
||||
display: none;
|
||||
position: fixed; inset: var(--chrome) 0 0 0; z-index: 8;
|
||||
background: color-mix(in srgb, var(--fg) 36%, transparent);
|
||||
}
|
||||
|
||||
/* -- the shell -- */
|
||||
|
||||
/* Two columns: a filter rail that collapses to nothing, and the feed. */
|
||||
.shell {
|
||||
display: grid;
|
||||
grid-template-columns: 15rem minmax(0, 1fr);
|
||||
gap: 1.6rem;
|
||||
max-width: 76rem; margin: 0 auto; padding: 0 1.1rem;
|
||||
}
|
||||
/* One column when the rail is hidden -- not a zero-width first column, which
|
||||
would leave `main` sitting in it once the aside stops being a grid item. */
|
||||
body[data-rail="shut"] .shell { grid-template-columns: minmax(0, 1fr); gap: 0; }
|
||||
body[data-rail="shut"] #rail { display: none; }
|
||||
|
||||
/* Reading opens a third column and the shell goes full width: the list keeps
|
||||
a narrow lane on the left, the role takes the rest. */
|
||||
body[data-reader="open"] .shell {
|
||||
grid-template-columns: 15rem 21rem minmax(0, 1fr);
|
||||
max-width: none; gap: 1.2rem;
|
||||
}
|
||||
body[data-reader="open"][data-rail="shut"] .shell {
|
||||
grid-template-columns: 21rem minmax(0, 1fr);
|
||||
}
|
||||
|
||||
/* -- the rail -- */
|
||||
|
||||
#rail {
|
||||
position: sticky; top: var(--chrome); align-self: start;
|
||||
max-height: calc(100vh - var(--chrome)); overflow-y: auto;
|
||||
padding: 1rem 0 3rem;
|
||||
}
|
||||
#rail section + section { margin-top: 1.4rem; }
|
||||
#rail h3 {
|
||||
display: flex; align-items: baseline; justify-content: space-between;
|
||||
margin: 0 0 .45rem; padding: 0 .3rem;
|
||||
font-size: .76rem; font-weight: 650; letter-spacing: .06em;
|
||||
text-transform: uppercase; color: var(--faint);
|
||||
}
|
||||
/* The rail's buttons are quiet: every one of them is a filter, and filters
|
||||
are quiet by definition. */
|
||||
#rail button:not(.linky) {
|
||||
font: inherit; font-size: .88rem;
|
||||
color: var(--dim); background: none;
|
||||
border: 1px solid transparent; border-radius: 3px;
|
||||
padding: .28rem .6rem;
|
||||
}
|
||||
@media (hover: hover) {
|
||||
#rail button:not(.linky):hover { color: var(--fg); background: var(--panel); }
|
||||
}
|
||||
#rail .count { color: var(--faint); font-size: .8rem; margin: 0 0 0 .3em; }
|
||||
|
||||
.rail-row {
|
||||
display: flex; align-items: baseline; gap: .35rem;
|
||||
width: 100%; text-align: left;
|
||||
}
|
||||
#rail .rail-row { padding: .26rem .4rem; }
|
||||
.rail-row > span:nth-last-child(2) { flex: 1; min-width: 0;
|
||||
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.rail-row .count { margin-left: auto; white-space: nowrap; }
|
||||
/* Tinted with the accent rather than `--bg`: on desktop the rail sits on `--bg`,
|
||||
so a selected row in that colour was invisible. */
|
||||
#rail .rail-row[aria-pressed="true"] {
|
||||
background: color-mix(in srgb, var(--accent) 14%, transparent);
|
||||
color: var(--accent); font-weight: 600;
|
||||
box-shadow: inset 3px 0 0 var(--accent);
|
||||
}
|
||||
.rail-row[aria-pressed="true"] .count { color: var(--accent); }
|
||||
|
||||
/* Tags are chips, not rows: they're multi-select, and seeing them wrap into a
|
||||
block makes the "pick two" affordance obvious. */
|
||||
#tags { display: flex; flex-wrap: wrap; gap: .25rem; padding: 0 .3rem; }
|
||||
.tag, #rail .tag {
|
||||
font: inherit; cursor: pointer;
|
||||
color: var(--dim); background: none;
|
||||
border: 1px solid var(--line); border-radius: 999px;
|
||||
padding: .14rem .6rem; font-size: .82rem;
|
||||
}
|
||||
.tag[aria-pressed="true"], #rail .tag[aria-pressed="true"] {
|
||||
color: var(--panel); background: var(--accent); border-color: var(--accent);
|
||||
}
|
||||
#rail .tag[aria-pressed="true"] .count { color: var(--accent-weak); }
|
||||
.tag.mini {
|
||||
padding: 0 .42rem; font-size: .76rem; line-height: 1.5;
|
||||
color: var(--faint); border-color: var(--line);
|
||||
}
|
||||
.tag.mini[aria-pressed="true"] { color: var(--panel); }
|
||||
|
||||
.rail-note {
|
||||
margin: .6rem .3rem 0; font-size: .8rem; color: var(--faint);
|
||||
line-height: 1.45;
|
||||
}
|
||||
.rail-stats {
|
||||
margin: 1.4rem 0 0; padding: .7rem .3rem 0; border-top: 1px solid var(--line);
|
||||
font-size: .8rem; color: var(--faint); font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.rail-keys {
|
||||
margin: .6rem .3rem 0; font-size: .74rem; line-height: 1.9; color: var(--faint);
|
||||
}
|
||||
kbd {
|
||||
font: inherit; font-size: .74rem;
|
||||
border: 1px solid var(--line); border-bottom-width: 2px;
|
||||
border-radius: 3px; padding: 0 .3em; margin-right: .1em; color: var(--dim);
|
||||
}
|
||||
|
||||
/* Order and period. `.seg` is a block on its own here and the two halves
|
||||
split the width, so the choice is one target each rather than two words
|
||||
pushed against the edge. */
|
||||
.seg { display: flex; }
|
||||
#sort { padding: 0 .3rem; }
|
||||
#rail .seg button {
|
||||
flex: 1; text-align: center;
|
||||
font-size: .8rem; padding: .18rem .55rem;
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
/* Square everything first; only the ends are ends. Every cell but the first
|
||||
eats its neighbour's border, so the joins are one rule wide rather than two. */
|
||||
.seg > * { border-radius: 0; }
|
||||
#rail .seg > :first-child { border-radius: 3px 0 0 3px; }
|
||||
#rail .seg > :last-child { border-radius: 0 3px 3px 0; }
|
||||
.seg > :not(:first-child) { margin-left: -1px; }
|
||||
#rail .seg button[aria-pressed="true"] {
|
||||
color: var(--panel); background: var(--accent); border-color: var(--accent);
|
||||
}
|
||||
/* Still pressable, so the title can be found; greyed, since it does nothing. */
|
||||
#rail .seg [aria-disabled="true"] { cursor: default; opacity: .55; }
|
||||
|
||||
.rail-field {
|
||||
display: block; margin: .7rem .3rem .25rem;
|
||||
font-size: .78rem; color: var(--faint);
|
||||
}
|
||||
.rail-select, .rail-fields input[type="text"], .rail-fields select {
|
||||
width: calc(100% - .6rem); margin: 0 .3rem;
|
||||
padding: .25rem .4rem; font-size: .84rem;
|
||||
border: 1px solid var(--line); border-radius: 3px;
|
||||
background: var(--panel); color: var(--fg);
|
||||
}
|
||||
#agent { margin-bottom: .1rem; }
|
||||
|
||||
/* The filters that are not the everyday ones: folded, with a count on the
|
||||
summary so a closed fold still says the list is narrowed. */
|
||||
.rail-more > summary {
|
||||
cursor: pointer; list-style: none;
|
||||
padding: 0 .3rem;
|
||||
font-size: .76rem; font-weight: 650; letter-spacing: .06em;
|
||||
text-transform: uppercase; color: var(--faint);
|
||||
}
|
||||
.rail-more > summary::-webkit-details-marker { display: none; }
|
||||
.rail-more > summary::before { content: "▸ "; }
|
||||
.rail-more[open] > summary::before { content: "▾ "; }
|
||||
@media (hover: hover) {
|
||||
.rail-more > summary:hover { color: var(--fg); }
|
||||
}
|
||||
.filter-active { color: var(--accent); }
|
||||
.rail-fields { display: flex; flex-direction: column; gap: .45rem; padding-top: .6rem; }
|
||||
.rail-fields input[type="text"], .rail-fields select { width: auto; }
|
||||
.rail-fields .check { padding: 0 .3rem; white-space: normal; }
|
||||
|
||||
/* -- the feed -- */
|
||||
|
||||
.shell > #list {
|
||||
max-width: none; margin: 0; min-width: 0;
|
||||
padding: 0 0 calc(5rem + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
/* Reading mode: the list becomes a compact index. Score, excerpt and vote
|
||||
buttons all go -- the buttons because they now live in the reader bar, next
|
||||
to the text being judged. */
|
||||
body[data-reader="open"] #list {
|
||||
position: sticky; top: var(--chrome); align-self: start;
|
||||
max-height: calc(100vh - var(--chrome)); overflow-y: auto;
|
||||
padding: 0 .2rem 1rem 0;
|
||||
}
|
||||
body[data-reader="open"] .row { grid-template-columns: 3px minmax(0, 1fr); gap: .6rem; }
|
||||
body[data-reader="open"] #list[data-sort="time"] .row { grid-template-columns: minmax(0, 1fr); }
|
||||
body[data-reader="open"] .score,
|
||||
body[data-reader="open"] .excerpt,
|
||||
body[data-reader="open"] .actions,
|
||||
body[data-reader="open"] .row .tag { display: none; }
|
||||
body[data-reader="open"] .headline { font-size: .96rem; }
|
||||
body[data-reader="open"] .row[data-open="true"] {
|
||||
background: color-mix(in srgb, var(--accent) 10%, transparent);
|
||||
}
|
||||
|
||||
.row {
|
||||
display: grid;
|
||||
grid-template-columns: 4px 2.6rem minmax(0, 1fr) auto;
|
||||
align-items: start; gap: .85rem;
|
||||
padding: .8rem 1rem .85rem;
|
||||
padding: .8rem 0 .85rem;
|
||||
border-bottom: 1px solid var(--line);
|
||||
/* So j/k never scrolls the selected row under the sticky header. */
|
||||
scroll-margin-top: calc(var(--chrome) + .5rem);
|
||||
}
|
||||
.role:last-child { border-bottom: 0; }
|
||||
.role-body { min-width: 0; }
|
||||
.role-title {
|
||||
display: block; max-width: 60ch;
|
||||
.row[data-current="true"] { background: color-mix(in srgb, var(--accent) 7%, transparent); }
|
||||
/* A vote is not a state of the role. The vote belongs on the button that took
|
||||
it, and that is the only place it is shown; a pass dims the text instead,
|
||||
below, since a passed role is one you meant to leave behind. */
|
||||
|
||||
/* The signature element: a gutter bar sized by the ranking's score. */
|
||||
.gutter {
|
||||
align-self: stretch; min-height: 1.9rem;
|
||||
background: var(--line); border-radius: 1px;
|
||||
position: relative; overflow: hidden;
|
||||
}
|
||||
.gutter i {
|
||||
position: absolute; inset: auto 0 0 0;
|
||||
background: var(--accent);
|
||||
display: block;
|
||||
}
|
||||
|
||||
.score {
|
||||
font-size: .82rem; color: var(--dim);
|
||||
padding-top: .2rem; text-align: right;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* Newest first hides the score, because in that order it is not what put the
|
||||
row where it is. Done here rather than in the row template so the markup is
|
||||
the same either way and only the stylesheet knows about the order -- the
|
||||
gutter goes with it, since a bar with no number beside it is a measurement
|
||||
of nothing. The columns go with them, or the text would land in the
|
||||
gutter's 4px. */
|
||||
#list[data-sort="time"] .gutter,
|
||||
#list[data-sort="time"] .score { display: none; }
|
||||
#list[data-sort="time"] .row { grid-template-columns: minmax(0, 1fr) auto; }
|
||||
|
||||
.body { min-width: 0; }
|
||||
|
||||
.headline {
|
||||
font-family: var(--read);
|
||||
color: var(--fg); text-decoration: none;
|
||||
font-size: 1.05rem; font-weight: 600; line-height: 1.35;
|
||||
font-size: 1.12rem; font-weight: 500; line-height: 1.4;
|
||||
display: block; max-width: 60ch;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
@media (hover: hover) {
|
||||
.role-title:hover { text-decoration: underline; text-underline-offset: 2px; }
|
||||
.headline:hover { text-decoration: underline; text-underline-offset: 2px; }
|
||||
}
|
||||
.role-meta, .reader-meta {
|
||||
display: flex; flex-wrap: wrap; gap: .1rem .55rem; align-items: baseline;
|
||||
margin-top: .25rem; font-size: .85rem; color: var(--dim);
|
||||
.row[data-read="true"] .headline { color: var(--dim); }
|
||||
|
||||
.meta, .reader-meta {
|
||||
margin-top: .28rem;
|
||||
font-size: .82rem; color: var(--faint);
|
||||
display: flex; gap: .2rem .55rem; flex-wrap: wrap; align-items: baseline;
|
||||
}
|
||||
/* The company is how you decide whether to read on: weight and full ink. */
|
||||
.role-meta b, .reader-meta b { font-weight: 600; color: var(--fg); }
|
||||
.role-meta > :empty, .reader-meta > :empty { display: none; }
|
||||
.role-meta > * + *::before { content: "· "; }
|
||||
.role-badges { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .35rem; }
|
||||
.role-badges > :empty { display: none; }
|
||||
.role-badges:not(:has(> :not(:empty))) { display: none; }
|
||||
.role-badges .badge {
|
||||
background: transparent; color: var(--dim);
|
||||
border: 1px solid var(--line); border-radius: 1rem;
|
||||
padding: .05rem .55rem; font-size: .78rem;
|
||||
/* The company is the second thing you read after the title -- it is how you
|
||||
decide whether to read on. It gets weight and full ink, not grey. */
|
||||
.meta b { font-weight: 650; color: var(--fg); }
|
||||
.meta .badge, .reader-meta .badge {
|
||||
background: none; color: var(--dim);
|
||||
border: 1px solid var(--line); border-radius: 999px;
|
||||
padding: 0 .45rem; font-size: .76rem; line-height: 1.5;
|
||||
}
|
||||
.role-badges .role-score {
|
||||
color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
|
||||
font-variant-numeric: tabular-nums;
|
||||
.meta .badge.closed, .reader-meta .badge.closed { color: var(--error); border-color: var(--error); }
|
||||
.meta .gated { color: var(--error); }
|
||||
|
||||
.excerpt {
|
||||
font-family: var(--read);
|
||||
margin: .4rem 0 0; max-width: 68ch;
|
||||
font-size: .95rem; line-height: 1.55; color: var(--dim);
|
||||
}
|
||||
.role-gated { color: var(--error); font-size: .8rem; }
|
||||
.role-excerpt {
|
||||
margin: .35rem 0 0; max-width: 68ch;
|
||||
font-size: .9rem; color: var(--dim);
|
||||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||||
}
|
||||
.role-excerpt:empty { display: none; }
|
||||
|
||||
.actions { display: flex; gap: .15rem; }
|
||||
|
||||
/* A pass and a hidden company are dimmed and stay: a stray tap has to be
|
||||
visible to be undone. The buttons keep full contrast, so the undo does. */
|
||||
.role.muted .role-body, .role.passed .role-body { opacity: .55; }
|
||||
.role.gated .role-body { opacity: .7; }
|
||||
.row.muted .body, .row.passed .body { opacity: .55; }
|
||||
.row.gated .body { opacity: .7; }
|
||||
/* The Companies table dims a hidden company's row the same way. */
|
||||
tr.muted { opacity: .55; }
|
||||
|
||||
/* The end of the list, which says which end it is. A list that has run out
|
||||
and a list that is still loading look identical otherwise, and the first
|
||||
one is the answer to "is that everything?". */
|
||||
.feed-end {
|
||||
padding: 1.1rem .4rem 2rem; text-align: center;
|
||||
font-size: .84rem; color: var(--faint);
|
||||
}
|
||||
|
||||
.empty { padding: 4rem 0; max-width: 34rem; color: var(--dim); }
|
||||
.empty h2 { font-size: 1.2rem; font-weight: 600; color: var(--fg); margin: 0 0 .4rem; }
|
||||
|
||||
/* ▲ ● ▼ ★, on a row and in the reader's bar (static/judge.js). */
|
||||
.judge { display: flex; gap: .15rem; align-items: center; }
|
||||
.judge button {
|
||||
padding: .2rem .45rem; font-size: 1rem; line-height: 1;
|
||||
color: var(--dim); background: none;
|
||||
border: 1px solid transparent; border-radius: .3rem;
|
||||
border: 1px solid transparent; border-radius: 3px;
|
||||
}
|
||||
@media (hover: hover) {
|
||||
.judge button:hover { color: var(--fg); border-color: var(--line); }
|
||||
.judge button:hover { color: var(--fg); background: var(--bg); }
|
||||
}
|
||||
/* Filled when cast: a reversed glyph on solid ground reads at arm's length
|
||||
where a tint does not. `--panel` for the glyph because it is the opposite
|
||||
end of the scale from every fill in both schemes. */
|
||||
/* A cast vote is filled, not tinted, and the same button still takes it back.
|
||||
Solid ground under a reversed glyph reads at arm's length where a tint does
|
||||
not. The glyph is `--panel` because it is the opposite end of the scale from
|
||||
every fill in both schemes. */
|
||||
.judge .up[aria-pressed="true"] {
|
||||
color: var(--panel); background: var(--accent); border-color: var(--accent);
|
||||
}
|
||||
@@ -440,7 +715,7 @@ tr.muted { opacity: .55; }
|
||||
/* Neither way is an answer and must be as loud as the other two, or it
|
||||
cannot be told from unjudged; grey, since it is no direction. */
|
||||
.judge .mid[aria-pressed="true"] {
|
||||
color: var(--panel); background: var(--dim); border-color: var(--dim);
|
||||
color: var(--panel); background: var(--faint); border-color: var(--faint);
|
||||
}
|
||||
/* Saved is a different question from judging: amber, and set apart. */
|
||||
.judge .star[aria-pressed="true"] {
|
||||
@@ -448,85 +723,236 @@ tr.muted { opacity: .55; }
|
||||
}
|
||||
.judge .star { margin-left: .35rem; }
|
||||
|
||||
/* The read page. */
|
||||
.reader {
|
||||
/* -- the reader -- */
|
||||
|
||||
/* An author `display` beats the UA's [hidden] rule, so restate it. */
|
||||
#reader[hidden] { display: none; }
|
||||
|
||||
#reader {
|
||||
position: sticky; top: var(--chrome);
|
||||
display: flex; flex-direction: column;
|
||||
height: calc(100vh - var(--chrome) - 1rem);
|
||||
margin-top: .5rem;
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line); border-radius: var(--radius);
|
||||
border: 1px solid var(--line); border-radius: 4px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Pinned, so the keys you actually press stay put however far you scroll. */
|
||||
.reader-bar {
|
||||
position: sticky; top: var(--header-h, 0px); z-index: 4;
|
||||
flex: none;
|
||||
display: flex; align-items: center; gap: .2rem;
|
||||
padding: .35rem .6rem;
|
||||
background: var(--panel);
|
||||
border-bottom: 1px solid var(--line);
|
||||
border-radius: var(--radius) var(--radius) 0 0;
|
||||
}
|
||||
.reader-bar .spacer { flex: 1; }
|
||||
.reader-back, .reader-external {
|
||||
.reader-bar .judge button { font-size: 1rem; line-height: 1; padding: .25rem .5rem; }
|
||||
/* ↗ and ✕ keep to the right, by an auto margin rather than a spacer: when
|
||||
the bar wraps, an auto margin takes the slack on whichever line it lands on. */
|
||||
.reader-external {
|
||||
display: inline-flex; align-items: center; justify-content: center;
|
||||
padding: .2rem .55rem; font-size: 1rem; line-height: 1;
|
||||
min-width: 2.1rem; margin-left: auto;
|
||||
padding: .2rem .45rem; font-size: .95rem; line-height: 1;
|
||||
color: var(--dim); text-decoration: none;
|
||||
border: 1px solid var(--line); border-radius: .3rem;
|
||||
border: 1px solid var(--line); border-radius: 3px;
|
||||
}
|
||||
.reader-back { margin-right: .4rem; }
|
||||
.reader-bar .close {
|
||||
font: inherit; font-size: 1rem; line-height: 1; padding: .25rem .5rem;
|
||||
color: var(--faint); background: none; border: 1px solid transparent; border-radius: 3px;
|
||||
}
|
||||
.reader-external + .close { margin-left: .2rem; }
|
||||
.reader-bar .judge + .close { margin-left: auto; }
|
||||
@media (hover: hover) {
|
||||
.reader-back:hover, .reader-external:hover { color: var(--fg); border-color: var(--dim); }
|
||||
.reader-external:hover, .reader-bar .close:hover { color: var(--fg); background: var(--bg); }
|
||||
}
|
||||
.reader-body { padding: 1.4rem 2rem 2.5rem; overflow-wrap: anywhere; }
|
||||
/* About 70 characters a line at the reading size. */
|
||||
.reader-body > * { max-width: 40rem; margin-inline: auto; }
|
||||
.reader-meta { align-items: center; margin-top: 0; }
|
||||
|
||||
.reader-body {
|
||||
flex: 1; min-height: 0; overflow-y: auto;
|
||||
padding: 1.6rem 2rem 4rem;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
/* ~68 characters a line at the reading size -- past that the eye loses the
|
||||
start of the next line and has to hunt for it. */
|
||||
.reader-body > * { max-width: 36rem; margin-inline: auto; }
|
||||
|
||||
.reader-meta { margin-top: 0; }
|
||||
.reader-meta b { font-weight: 600; color: var(--dim); }
|
||||
.reader-meta .affinity { font-size: .85rem; }
|
||||
.reader h1 { font-size: 1.6rem; line-height: 1.25; margin: .6rem auto .5rem; }
|
||||
.reader .role-badges { margin-top: 0; }
|
||||
.reader-salary { margin: .6rem auto 0; font-weight: 600; }
|
||||
.reader-meta .affinity:empty { display: none; }
|
||||
|
||||
#reader h1 {
|
||||
font-family: var(--read);
|
||||
margin: .6rem auto .15rem;
|
||||
font-size: 1.6rem; font-weight: 600; line-height: 1.25;
|
||||
letter-spacing: -.005em;
|
||||
}
|
||||
.reader-salary { margin: .5rem auto 0; font-weight: 600; }
|
||||
.reader-summary {
|
||||
margin-top: 1.1rem; padding: .7rem .9rem;
|
||||
background: color-mix(in srgb, var(--accent) 7%, var(--panel));
|
||||
border-left: 3px solid var(--accent); border-radius: .3rem;
|
||||
}
|
||||
.reader-summary p { margin: 0; }
|
||||
.reader-summary p { margin: 0; font-family: var(--read); line-height: 1.6; }
|
||||
/* A label over a block rather than the posting's own heading. */
|
||||
.reader-label {
|
||||
margin: 0 0 .3rem; font-size: .72rem; font-weight: 600;
|
||||
letter-spacing: .08em; text-transform: uppercase; color: var(--dim);
|
||||
letter-spacing: .08em; text-transform: uppercase; color: var(--faint);
|
||||
}
|
||||
.reader-tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: 1rem; }
|
||||
.reader-tools:not(:has(> :not([hidden], :empty))) { display: none; }
|
||||
.prose { margin-top: 1.2rem; font-size: 1.02rem; line-height: 1.7; }
|
||||
.prose p { margin: 0 0 1rem; }
|
||||
.reader-tools > :empty { display: none; }
|
||||
.reader-tools:not(:has(> :not(:empty))) { display: none; }
|
||||
.reader-note {
|
||||
color: var(--dim); font-size: .9rem; line-height: 1.55;
|
||||
padding: .75rem .95rem; border-left: 2px solid var(--line); background: var(--bg);
|
||||
}
|
||||
|
||||
.prose {
|
||||
font-family: var(--read);
|
||||
margin-top: 1.3rem; font-size: 1.06rem; line-height: 1.7;
|
||||
}
|
||||
.prose p { margin: 0 0 1.05rem; }
|
||||
.reader-out { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
|
||||
|
||||
/* The step through the list, for the pointer that has no `j` and `k`. At the
|
||||
foot of the pane because that is where a thumb already is. Shown only by
|
||||
the narrow and `pointer: coarse` blocks below. */
|
||||
.reader-foot {
|
||||
flex: none; display: none; gap: .5rem;
|
||||
padding: .5rem .6rem calc(.5rem + env(safe-area-inset-bottom));
|
||||
border-top: 1px solid var(--line); background: var(--panel);
|
||||
}
|
||||
.reader-foot button {
|
||||
flex: 1; min-height: 2.75rem;
|
||||
color: var(--fg); background: none;
|
||||
border: 1px solid var(--line); border-radius: .4rem;
|
||||
}
|
||||
.reader-foot button:disabled { color: var(--faint); opacity: .55; cursor: default; }
|
||||
|
||||
/* Applications: the table is the shared `table.list`. */
|
||||
table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--dim); }
|
||||
|
||||
/* -------------------------------------------------- narrow, and touched
|
||||
|
||||
Two axes, and deliberately not the same one.
|
||||
|
||||
*Width* decides the layout: how many of the three panes -- filters, list,
|
||||
role -- fit at once. Above 60rem they sit side by side. Below it there is
|
||||
room for exactly one, so the rail becomes an overlay and the role replaces
|
||||
the list.
|
||||
|
||||
*Pointer* decides the sizes. A finger needs a 44px target and a mouse does
|
||||
not, and that has nothing to do with how wide the window is: a tablet is
|
||||
wide and touched, a half-screen laptop window is narrow and moused. Size by
|
||||
width and each ends up in the other's clothes -- fat buttons for the mouse,
|
||||
a 26px vote arrow for the thumb. So every touch rule is in `pointer:
|
||||
coarse` and none of them is in a width query.
|
||||
|
||||
Keeping the two apart is also what keeps them out of each other's way:
|
||||
nothing below this line changes what a wide, moused window renders. */
|
||||
|
||||
@media (max-width: 60rem) {
|
||||
/* Narrow: the rail becomes an overlay so the feed keeps the full width. */
|
||||
.shell { grid-template-columns: minmax(0, 1fr); gap: 0; padding-inline: .5rem; }
|
||||
#rail {
|
||||
position: fixed; inset: var(--chrome) auto 0 0; z-index: 9;
|
||||
width: min(19rem, 92vw); max-height: none;
|
||||
padding: .75rem .5rem calc(3rem + env(safe-area-inset-bottom));
|
||||
background: var(--panel); border-right: 1px solid var(--line);
|
||||
/* Not cosmetic: `align-self: start` keeps the sidebar from stretching to
|
||||
the row when it is a grid item, and it is still in force here, where
|
||||
the rail is out of flow. Chrome then self-aligns the box instead of
|
||||
honouring `top` and `bottom` -- the panel lands at the top of the page,
|
||||
behind the header, at its full content height, and scrolls off the
|
||||
bottom of the screen with no way back to what it has run past. */
|
||||
align-self: auto;
|
||||
}
|
||||
/* Before the script has said which, the overlay stays shut: a phone must
|
||||
not open on a panel covering the list. */
|
||||
body:not([data-rail="open"]) #rail { display: none; }
|
||||
body[data-rail="open"] #scrim { display: block; }
|
||||
#rail section + section { margin-top: .9rem; }
|
||||
|
||||
/* The header holds one row, and has to keep holding one: the rail and the
|
||||
reader are measured from its height, so a second row costs a row of the
|
||||
list on every screen. The search field is allowed to shrink rather than
|
||||
push the tabs off the right-hand edge. */
|
||||
#search { min-width: 0; flex: 1 1 6rem; }
|
||||
.top:has(#search) nav { flex: 0 1 auto; margin-left: 0; }
|
||||
|
||||
/* No room for two panes: the role replaces the list rather than squeezing
|
||||
next to it. `esc` brings the list back. Both selectors are restated
|
||||
because the `[data-rail="shut"]` rule above out-specifies a media query,
|
||||
which does nothing for specificity on its own. */
|
||||
body[data-reader="open"] .shell,
|
||||
body[data-reader="open"][data-rail="shut"] .shell {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
body[data-reader="open"] #list { display: none; }
|
||||
body[data-reader="open"] { overflow: hidden; }
|
||||
body[data-reader="open"] .shell { padding: 0; }
|
||||
body[data-reader="open"] #reader {
|
||||
position: fixed; inset: var(--chrome) 0 0;
|
||||
width: 100%; height: auto; margin: 0;
|
||||
border: 0; border-radius: 0;
|
||||
}
|
||||
.reader-body { padding: .9rem .9rem 1.5rem; }
|
||||
.reader-bar { gap: .1rem; padding: .2rem .35rem; flex-wrap: wrap; }
|
||||
.reader-foot { display: flex; padding: .3rem .5rem calc(.3rem + env(safe-area-inset-bottom)); gap: .4rem; }
|
||||
.reader-foot button { min-height: 36px; padding: .2rem; }
|
||||
}
|
||||
|
||||
@media (max-width: 40rem) {
|
||||
.row { grid-template-columns: 4px minmax(0, 1fr) auto; }
|
||||
.score { display: none; }
|
||||
/* The brand goes on the Roles page. On a phone this is the only page open
|
||||
and you know which one it is; the width it was using is the difference
|
||||
between a usable search field and a token one. The burger keeps its word
|
||||
only while it has a count to say. */
|
||||
.top:has(#search) .brand { display: none; }
|
||||
#rail-toggle:not([aria-label*="filter"]) .rail-toggle-label { display: none; }
|
||||
#reader h1 { font-size: 1.3rem; }
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.filter-line { margin-right: 6.25rem; }
|
||||
.filter-more > summary { right: 10px; min-width: 5.5rem; }
|
||||
|
||||
/* Edge to edge, like every panel on a phone. */
|
||||
.roles, .reader { margin-inline: -10px; border-radius: 0; border-inline: 0; }
|
||||
.reader { margin-top: -10px; border-top: 0; }
|
||||
.reader-bar { border-radius: 0; }
|
||||
.role { grid-template-columns: minmax(0, 1fr); gap: .45rem; padding: .75rem 10px; }
|
||||
/* Under the text and to the right, where a thumb is. Two filled blocks
|
||||
side by side need a gap or they read as one control. */
|
||||
.role-actions { justify-content: flex-end; gap: .4rem; }
|
||||
.role-actions button { padding: .25rem .75rem; min-height: 32px; font-size: 1.2rem; }
|
||||
.reader-body { padding: .9rem .75rem 1.5rem; }
|
||||
.reader h1 { font-size: 1.3rem; }
|
||||
.row { grid-template-columns: 4px minmax(0, 1fr); gap: .5rem; padding-inline: .25rem; }
|
||||
.row .actions { grid-column: 2; justify-content: flex-end; gap: .4rem; }
|
||||
#list[data-sort="time"] .row { grid-template-columns: minmax(0, 1fr); }
|
||||
#list[data-sort="time"] .row .actions { grid-column: 1; }
|
||||
/* Two filled blocks side by side need a gap between them or they read as
|
||||
one control, and the arrow inside needs to be big enough to see which
|
||||
way it points at arm's length. */
|
||||
.actions button { padding: .25rem .75rem; min-height: 32px; font-size: 1.2rem; }
|
||||
}
|
||||
|
||||
/* Sizes for a finger. 2.75rem is 44px at the default root size -- the
|
||||
smallest target a thumb hits without aiming -- and nothing in here is
|
||||
conditional on width, for the reason given at the top of the section. */
|
||||
@media (pointer: coarse) {
|
||||
.filter-more > summary { min-height: 2.75rem; }
|
||||
.judge button { padding: .5rem .7rem; font-size: 1.15rem; }
|
||||
#rail-toggle { min-height: 2.75rem; }
|
||||
.actions button { padding: .5rem .7rem; font-size: 1.15rem; }
|
||||
#rail .rail-row { align-items: center; min-height: 2.75rem; }
|
||||
#rail .tag { padding: .45rem .8rem; }
|
||||
#rail .seg button { min-height: 2.75rem; }
|
||||
.rail-select, .rail-fields input[type="text"], .rail-fields select { min-height: 2.75rem; }
|
||||
.rail-more > summary { padding-block: .7rem; }
|
||||
.reader-bar { padding: .3rem .5rem; }
|
||||
.reader-back, .reader-external { min-height: 2.75rem; min-width: 2.75rem; }
|
||||
.reader-bar .judge button, .reader-bar .close, .reader-external { min-height: 2.75rem; min-width: 2.75rem; }
|
||||
.reader-foot { display: flex; }
|
||||
.reader-foot button { min-height: 2.75rem; }
|
||||
/* A tag on a row or in the reader's meta line stays the size of the words
|
||||
around it: the phone section's 44px floor for every button would make
|
||||
each one a line of its own. The rail's chips are the tag targets sized
|
||||
for a thumb. */
|
||||
.meta .tag.mini, .reader-meta .tag.mini { min-height: 0; }
|
||||
/* No keys on a touch screen, so no key hints. */
|
||||
.rail-keys { display: none; }
|
||||
}
|
||||
/* == end of roles, the read page, applications ============================ */
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
* { transition: none !important; animation: none !important; }
|
||||
}
|
||||
/* == end of roles ========================================================= */
|
||||
|
||||
.affinity { display: inline-flex; gap: .15rem; }
|
||||
.role-main .affinity { margin-left: auto; }
|
||||
.affinity button {
|
||||
background: none; border: 1px solid var(--line); border-radius: .3rem;
|
||||
padding: .1rem .4rem; color: var(--dim); font-size: 1rem; line-height: 1.4;
|
||||
|
||||
+29
-1
@@ -1,4 +1,4 @@
|
||||
/* ▲ ● ▼ ★ for one role: the feed row and the read page share them.
|
||||
/* ▲ ● ▼ ★ for one role: the feed row and the reader bar share them.
|
||||
*
|
||||
* news's `voteButtons`, `starButton` and `vote()`, adapted. Three stances and
|
||||
* no stance is four states from three buttons; pressing the stance a role
|
||||
@@ -14,6 +14,13 @@
|
||||
* Both are optimistic: the button changes before the request and changes back
|
||||
* if it fails. `api()` has already toasted the failure by then.
|
||||
*
|
||||
* One role can have two sets of these on screen at once, its feed row's and
|
||||
* the reader bar's, each bound to its own copy of the role. A change in one is
|
||||
* echoed to every other set for the same uid (`echo`), which copies the vote
|
||||
* and the read mark across and repaints it, so the row never shows a stance
|
||||
* the reader has taken back. A vote marks the role read on the server, and the
|
||||
* answer's `read_at` is copied onto the role with the vote.
|
||||
*
|
||||
* await loadTracked();
|
||||
* container.append(judgeButtons(role, (role) => row.classList.toggle(...)));
|
||||
*/
|
||||
@@ -32,6 +39,22 @@
|
||||
return tracked;
|
||||
}
|
||||
|
||||
/** Every set of buttons made, so a change in one repaints the others for
|
||||
the same role. A set whose buttons have left the document is dropped the
|
||||
next time a change is echoed. */
|
||||
const groups = new Set();
|
||||
|
||||
function echo(from) {
|
||||
for (const group of groups) {
|
||||
if (!group.star.isConnected) { groups.delete(group); continue; }
|
||||
if (group.role === from || group.role.uid !== from.uid) continue;
|
||||
group.role.vote = from.vote;
|
||||
group.role.voted_at = from.voted_at;
|
||||
if (from.read_at !== undefined) group.role.read_at = from.read_at;
|
||||
group.paint();
|
||||
}
|
||||
}
|
||||
|
||||
const STANCES = [
|
||||
{ value: 1, cls: "up", glyph: "▲", said: "Like" },
|
||||
{ value: 0, cls: "mid", glyph: "●", said: "Neither way" },
|
||||
@@ -83,6 +106,7 @@
|
||||
const clearing = before === value;
|
||||
role.vote = clearing ? null : value;
|
||||
paint();
|
||||
echo(role);
|
||||
const path = `/api/roles/${encodeURIComponent(role.uid)}/vote`;
|
||||
try {
|
||||
const updated = clearing
|
||||
@@ -90,10 +114,12 @@
|
||||
: await api(path, { method: "POST", body: { value } });
|
||||
role.vote = updated.vote;
|
||||
role.voted_at = updated.voted_at;
|
||||
if (updated.read_at !== undefined) role.read_at = updated.read_at;
|
||||
} catch (err) {
|
||||
role.vote = before;
|
||||
}
|
||||
paint();
|
||||
echo(role);
|
||||
}
|
||||
|
||||
// One request at a time: a second tap while the first is in flight would
|
||||
@@ -122,8 +148,10 @@
|
||||
star.disabled = false;
|
||||
}
|
||||
paint();
|
||||
echo(role);
|
||||
}
|
||||
|
||||
groups.add({ role, star, paint });
|
||||
paint();
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@@ -1,200 +0,0 @@
|
||||
/* The read page of one role, news's reader.
|
||||
*
|
||||
* The bar: back, ▲ ● ▼ ★ (judge.js, the same buttons as the feed row) and ↗
|
||||
* to the posting. Then the company with its ★ ▲ ⊘ control, the one place a
|
||||
* company is judged outside the Companies page; place, badges, salary when
|
||||
* stated; the summary when there is one; the text, which is the fetched
|
||||
* posting when there is one and the board's description otherwise; and the
|
||||
* way out once more at the end.
|
||||
*
|
||||
* A search role's description is a teaser of a couple of hundred characters,
|
||||
* so under 500 of them, with nothing fetched yet, the page offers "Fetch the
|
||||
* posting" (`POST /api/roles/{uid}/text`). "Summarise" is offered while there
|
||||
* is no summary (`POST /api/roles/{uid}/summarise`). Both answer with the
|
||||
* role, and the page is drawn again from it. A summary made by the queue
|
||||
* rather than at once is waited for by asking for the role again.
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
const { api, companies, loadCompanies, affinityControl, judgeButtons, loadTracked } = window;
|
||||
const $ = (sel, root = document) => root.querySelector(sel);
|
||||
|
||||
const uid = $("#role").dataset.uid;
|
||||
const path = `/api/roles/${encodeURIComponent(uid)}`;
|
||||
/** Shorter than this and not fetched: the description is a teaser. */
|
||||
const TEASER = 500;
|
||||
|
||||
/** @type {object|null} the role on screen, updated in place */
|
||||
let role = null;
|
||||
|
||||
function relativeAge(iso) {
|
||||
const minutes = Math.max(0, Math.floor((Date.now() - new Date(iso).getTime()) / 60000));
|
||||
if (minutes < 60) return `${minutes} min ago`;
|
||||
const hours = Math.floor(minutes / 60);
|
||||
if (hours < 24) return `${hours} h ago`;
|
||||
return `${Math.floor(hours / 24)} d ago`;
|
||||
}
|
||||
|
||||
function salary(r) {
|
||||
const n = (v) => new Intl.NumberFormat("en").format(v);
|
||||
const unit = r.currency ? `${r.currency} ` : "";
|
||||
if (r.salary_min && r.salary_max && r.salary_min !== r.salary_max) {
|
||||
return `${unit}${n(r.salary_min)}–${n(r.salary_max)}`;
|
||||
}
|
||||
if (r.salary_min || r.salary_max) {
|
||||
const one = r.salary_min || r.salary_max;
|
||||
return r.salary_min ? `From ${unit}${n(one)}` : `Up to ${unit}${n(one)}`;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function host(url) {
|
||||
try { return new URL(url).host.replace(/^www\./, ""); } catch (e) { return ""; }
|
||||
}
|
||||
|
||||
/* Plain text in paragraphs: a fetched page keeps its line breaks, and a
|
||||
board's description is one long line, which stays one paragraph. */
|
||||
function paragraphs(text) {
|
||||
const box = document.createDocumentFragment();
|
||||
for (const part of text.split(/\n\s*\n|\n/).map((p) => p.trim()).filter(Boolean)) {
|
||||
const p = document.createElement("p");
|
||||
p.textContent = part;
|
||||
box.appendChild(p);
|
||||
}
|
||||
return box;
|
||||
}
|
||||
|
||||
function badge(text) {
|
||||
const span = document.createElement("span");
|
||||
span.className = "badge";
|
||||
span.textContent = text;
|
||||
return span;
|
||||
}
|
||||
|
||||
function renderAffinity() {
|
||||
const slot = $("#role-affinity");
|
||||
const company = companies.get(role.company_key);
|
||||
// A company seen only through a search has no row of its own to judge.
|
||||
if (!company) { slot.replaceChildren(); return; }
|
||||
slot.replaceChildren(affinityControl(role.company_key, company.affinity, renderAffinity));
|
||||
}
|
||||
|
||||
function render() {
|
||||
document.title = `${role.title || "Role"} — roledesk`;
|
||||
$("#role").removeAttribute("aria-busy");
|
||||
|
||||
const out = role.original_url || "";
|
||||
$("#role-out").hidden = !out;
|
||||
if (out) $("#role-out").href = out;
|
||||
const end = $("#role-out-end");
|
||||
end.hidden = !out;
|
||||
if (out) {
|
||||
const a = end.querySelector("a");
|
||||
a.href = out;
|
||||
a.textContent = `Read it on ${host(out) || "the board"} ↗`;
|
||||
}
|
||||
|
||||
$("#role-company").textContent = role.company || "";
|
||||
renderAffinity();
|
||||
$("#role-place").textContent = role.place || "";
|
||||
$("#role-age").textContent = role.first_seen ? relativeAge(role.first_seen) : "";
|
||||
$("#role-title").textContent = role.title || "(untitled)";
|
||||
|
||||
const badges = [role.remote, role.function, role.seniority].filter(Boolean).map(badge);
|
||||
if (role.closed_at) badges.unshift(badge("closed"));
|
||||
$("#role-badges").replaceChildren(...badges);
|
||||
$("#role-badges").hidden = !badges.length;
|
||||
|
||||
const pay = salary(role);
|
||||
$("#role-salary").hidden = !pay;
|
||||
$("#role-salary").textContent = pay;
|
||||
|
||||
const summary = $("#role-summary");
|
||||
summary.hidden = !role.summary;
|
||||
summary.querySelector("p").textContent = role.summary || "";
|
||||
|
||||
const text = (role.article_text || role.description || "").trim();
|
||||
$("#role-text").replaceChildren(text ? paragraphs(text)
|
||||
: Object.assign(document.createElement("p"), {
|
||||
className: "muted", textContent: "The board gave no description for this one.",
|
||||
}));
|
||||
|
||||
$("#role-summarise").hidden = Boolean(role.summary);
|
||||
$("#role-fetch").hidden = Boolean(role.article_text)
|
||||
|| (role.description || "").length >= TEASER;
|
||||
}
|
||||
|
||||
function merge(updated) {
|
||||
if (updated && updated.uid === role.uid) Object.assign(role, updated);
|
||||
render();
|
||||
}
|
||||
|
||||
/* Press, wait, draw again from the answer. A failure is toasted by `api()`
|
||||
(a 404 included, while the route is not there yet) and the button comes
|
||||
back as it was. */
|
||||
async function ask(button, busy, route) {
|
||||
const label = button.textContent;
|
||||
button.disabled = true;
|
||||
button.textContent = busy;
|
||||
try {
|
||||
merge(await api(`${path}/${route}`, { method: "POST" }));
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
button.textContent = label;
|
||||
}
|
||||
}
|
||||
|
||||
async function summarise() {
|
||||
if (!(await ask($("#role-summarise"), "Summarising…", "summarise"))) return;
|
||||
if (role.summary) return;
|
||||
// Queued rather than done: ask again until it is there, for two minutes.
|
||||
const note = $("#role-note");
|
||||
note.textContent = "The summary appears here when it is ready.";
|
||||
$("#role-summarise").hidden = true;
|
||||
for (let i = 0; i < 30 && !role.summary; i++) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 4000));
|
||||
try { merge(await api(path)); } catch (err) { break; }
|
||||
}
|
||||
note.textContent = "";
|
||||
render();
|
||||
}
|
||||
|
||||
/* Back is back when this page was opened from one of this app's lists, so
|
||||
the list keeps its place; a link from anywhere else goes to the roles. */
|
||||
function back(e) {
|
||||
let from = null;
|
||||
try { from = document.referrer ? new URL(document.referrer) : null; } catch (err) { /* */ }
|
||||
if (from && from.origin === location.origin && history.length > 1) {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
}
|
||||
}
|
||||
|
||||
/* The bar sticks under the top bar, whose height is the phone's or the
|
||||
desktop's, and the notch's on a standalone phone. */
|
||||
function measureHeader() {
|
||||
const top = document.querySelector("header.top");
|
||||
if (top) document.documentElement.style.setProperty("--header-h", `${top.offsetHeight}px`);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
measureHeader();
|
||||
window.addEventListener("resize", measureHeader);
|
||||
$("#role-back").addEventListener("click", back);
|
||||
try {
|
||||
[role] = await Promise.all([api(path), loadCompanies(), loadTracked()]);
|
||||
} catch (err) {
|
||||
$("#role-title").textContent = "This role could not be loaded.";
|
||||
return;
|
||||
}
|
||||
$("#role-judge").appendChild(judgeButtons(role));
|
||||
render();
|
||||
$("#role-summarise").addEventListener("click", summarise);
|
||||
$("#role-fetch").addEventListener("click",
|
||||
() => ask($("#role-fetch"), "Fetching…", "text"));
|
||||
});
|
||||
})();
|
||||
+908
-215
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user