Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions app/src/components/channels/composer/frame.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
/**
* The message box's frame, shared by its two layouts (docs/app-guidelines.md, "The look").
*
* At rest it is a card like any other: flat, with a hairline border. While someone is typing in
* it (it has focus and holds text, and the frame carries `data-typing`), it glows in the focus
* color: its border tints, a soft ring of `ring` goes round it and a soft shadow of `ring` sits
* under it. Focus alone is not enough: a conversation keeps the box focused from the moment it
* opens, and a box that always glows is decoration. It is the only thing in the app that glows,
* drawn from `ring` alone, so it has its dark value already. The glow eases in, and with reduced
* motion it simply appears.
* At rest it is a card that sits a little above the page: a hairline ring of `border` round it,
* where a card has its border, and the softest shadow step (`shadow-xs`) under it. Its border is
* kept, transparent, so the glow has a border to tint. While someone is typing in it (it has focus
* and holds text, and the frame carries `data-typing`), it glows in the focus color: its border
* tints, a soft ring of `ring` goes round it and a soft shadow of `ring` sits under it. Focus alone
* is not enough: a conversation keeps the box focused from the moment it opens, and a box that
* always glows is decoration. It is the only thing in the app that glows, drawn from `ring` alone,
* so it has its dark value already. The glow eases in, and with reduced motion it simply appears.
*
* The resting shadow is `shadow-xs` and takes no opacity of its own (no `shadow-lg/5`): the glow's
* `shadow-ring/20` is multiplied by any opacity set at rest, which would all but put it out.
*/
export const MESSAGE_BOX_FRAME =
"rounded-xl border border-border bg-card transition-[border-color,box-shadow] duration-150 ease-out motion-reduce:transition-none focus-within:data-typing:border-ring/60 focus-within:data-typing:ring-4 focus-within:data-typing:ring-ring/15 focus-within:data-typing:shadow-lg focus-within:data-typing:shadow-ring/20";
"rounded-xl border border-transparent bg-card shadow-xs ring-1 ring-border transition-[border-color,box-shadow] duration-150 ease-out motion-reduce:transition-none focus-within:data-typing:border-ring/60 focus-within:data-typing:ring-4 focus-within:data-typing:ring-ring/15 focus-within:data-typing:shadow-lg focus-within:data-typing:shadow-ring/20";
38 changes: 19 additions & 19 deletions app/tests/message-box-frame.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@ import { readFileSync } from "node:fs";
import { MESSAGE_BOX_FRAME } from "@/components/channels/composer/frame";

/*
* The message box (docs/app-guidelines.md, "The look"): a flat card at rest, glowing in the focus
* color only while someone types in it. It is the one thing in the app that glows.
* The message box (docs/app-guidelines.md, "The look", rule 8): at rest a card with a hairline ring
* and the softest shadow, glowing in the focus color only while someone types in it. It is the one
* thing in the app that glows.
*/

const classes = MESSAGE_BOX_FRAME.split(/\s+/).filter(Boolean);

describe("the message box's frame", () => {
test("at rest it is a flat hairline card", () => {
test("at rest it is a card with a hairline ring of the line color and the softest shadow", () => {
expect(classes).toEqual(
expect.arrayContaining([
"rounded-xl",
"border",
"border-border",
"bg-card",
]),
expect.arrayContaining(["rounded-xl", "bg-card", "border"]),
);
const atRest = classes.filter((name) => !name.startsWith("focus-within:"));
expect(atRest.filter((name) => /^(shadow|ring)-/.test(name))).toEqual([]);
// The ring is a line like any other, at the one strength every line has.
expect(
atRest.filter((name) => /^(shadow|ring|border)-/.test(name)),
).toEqual(["border-transparent", "shadow-xs", "ring-1", "ring-border"]);
// No opacity of its own on the resting shadow: the glow's shadow color is multiplied by it.
expect(atRest.some((name) => /^shadow-.*\//.test(name))).toBe(false);
});

test("it glows only while someone is typing in it: focus and text", () => {
expect(classes).toEqual(
expect.arrayContaining([
"focus-within:data-typing:border-ring/60",
"focus-within:data-typing:ring-4",
"focus-within:data-typing:ring-ring/15",
"focus-within:data-typing:shadow-lg",
"focus-within:data-typing:shadow-ring/20",
]),
);
// The glow as it was drawn before the resting ring came: exactly these, nothing added.
expect(classes.filter((name) => name.startsWith("focus-within:"))).toEqual([
"focus-within:data-typing:border-ring/60",
"focus-within:data-typing:ring-4",
"focus-within:data-typing:ring-ring/15",
"focus-within:data-typing:shadow-lg",
"focus-within:data-typing:shadow-ring/20",
]);
// Focus alone does not glow: a conversation keeps the box focused from the moment it opens.
const focusOnly = classes.filter(
(name) =>
Expand Down
3 changes: 2 additions & 1 deletion app/tests/ui-look-guard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ const NOT_READ = [
"components/ui/",
"skins/",
"lib/api/generated/",
// The message box's frame (rule 8): part of the look, kept beside the composer that uses it.
// The message box's frame (rule 8): part of the look, kept beside the composer that uses it. Its
// resting ring, its shadow-xs and its glow are held by message-box-frame.test.ts.
"components/channels/composer/frame.ts",
];

Expand Down
8 changes: 5 additions & 3 deletions docs/app-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ things are drawn, not how big they are.
steps only:
- none for everything in the page: the panel, cards, rows, fields, the sidebar;
- `shadow-xs` for a control pressed on a surface: an outlined button, a switch's knob, the
chosen tab, a checkbox;
chosen tab, a checkbox. The message box at rest has it too (rule 8);
- `shadow-lg` and a border for what opens beside the thing that opened it: menus, selects,
popovers, tooltips, toasts;
- `shadow-2xl` and a border for what sits over the app: dialogs, the command menu, sheets.
Expand All @@ -241,8 +241,10 @@ things are drawn, not how big they are.
writes no size by hand (`h-[43px]`); it uses the nearest Tailwind step, never a smaller one.
7. **Rows.** One card of rows with hairline dividers (`PageRows`). The leading icon is a 16px
glyph in `muted-foreground` on a 32px tile with a hairline ring.
8. **The message box** is a flat card at rest. While someone types in it, it glows in `ring`. It
is the only control that glows.
8. **The message box** at rest is a card with a hairline ring of `border` in place of its border,
and `shadow-xs` under it, so it sits a little above the page. While someone types in it, it
glows in `ring`. It is the only control that glows. The resting shadow takes no opacity of its
own, because the glow's shadow color is multiplied by it.
9. **Icons.** Hugeicons' free set, at their usual sizes, imported from `components/icons` and never
from the set itself. The line is the set's own 1.5, which every glyph carries. An icon that
needs another line says why in a comment.
Expand Down