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
17 changes: 4 additions & 13 deletions app/src/artifact-print/print.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
@import "shadcn/tailwind.css";
@import "@fontsource-variable/figtree";
@import "../theme.css";
/* A document's words are set as on screen: typeset, tuned as the app tunes it. */
@import "../typeset.css";
@import "../bot-markdown.css";

/* Streamdown draws the Markdown; Tailwind only ships classes it can see used (see styles.css). */
@source "../../node_modules/streamdown/dist/*.js";
Expand Down Expand Up @@ -119,19 +122,7 @@ thead {
display: none;
}

/* A Markdown table reads like a component table (renderers/table.tsx), a row never split. */
.print-markdown [data-streamdown="table-header"] {
@apply bg-muted/50;
}

.print-markdown [data-streamdown="table-header-cell"] {
@apply px-3 py-2 text-xs font-medium text-muted-foreground;
}

.print-markdown [data-streamdown="table-cell"] {
@apply px-3 py-2;
}

/* A Markdown table on paper is drawn as on screen (lib/markdown-table.tsx), a row never split. */
.print-markdown [data-streamdown="table-row"] {
break-inside: avoid;
}
Expand Down
7 changes: 2 additions & 5 deletions app/src/artifact-print/renderers/registry.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { DashboardFilter } from "@openbot/shared/artifacts/kinds";
import { IconFilter } from "@/components/icons";
import type { ComponentType } from "react";
import {
ArtifactThemeScope,
Expand All @@ -11,6 +10,7 @@ import {
SlideCanvas,
} from "@/components/artifacts/kinds";
import { HEADING_FONT } from "@/components/artifacts/kinds/theme";
import { IconFilter } from "@/components/icons";
import {
DASHBOARD_WIDTH,
type PrintableContentByKind,
Expand Down Expand Up @@ -92,10 +92,7 @@ export function filterLine(
function PrintDashboard({ title, content }: PrintRendererProps<"dashboard">) {
const filters = filterLine(content.filters);
return (
<ArtifactThemeScope
className="bg-background px-10 py-10"
theme={content.theme}
>
<ArtifactThemeScope className="bg-card px-10 py-10" theme={content.theme}>
<div data-print-page="dashboard" style={{ width: DASHBOARD_WIDTH - 80 }}>
<header className="mb-6">
<h1
Expand Down
178 changes: 178 additions & 0 deletions app/src/bot-markdown.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
/*
* How a Bot's Markdown is set wherever it is drawn: a conversation's reply, a document artifact on
* screen and on paper (artifact-print/print.css imports this too). Read after typeset.css.
*/

/*
* A Bot's reply in a conversation, set by shadcn/typeset (`replyMarkdownComponents` in
* lib/markdown.tsx draws the prose bare so typeset reaches it). Tuned for a chat column: the
* conversation's size, the one its messages and the composer use, on every window (typeset would set
* it 1.125 times larger on a narrow one, an article's choice that a phone's chat does not need), the
* leading and paragraph spacing of a long read, and headings on the chat's own smaller scale rather
* than an article's.
*/
@layer components {
.typeset-reply {
--typeset-size: var(--text-conversation);
--typeset-leading: 1.7;
--typeset-flow: 1em;
font-size: var(--typeset-size);
}

.typeset-reply :where(h1) {
font-size: 1.35em;
}

.typeset-reply :where(h2) {
font-size: 1.2em;
}

.typeset-reply :where(h3) {
font-size: 1.08em;
}

/*
* Blocks Streamdown draws as components of its own, which typeset does not know: the same space
* above as a paragraph.
*/
.typeset-reply
> :where(
[data-streamdown="code-block"],
[data-streamdown="table-wrapper"],
[data-streamdown="mermaid-block"],
.katex-display
) {
margin-block-start: var(--typeset-flow);
}

/*
* Streamdown's code block is a component with its own `pre`, and typeset's code rules (a muted
* ground, padding, a smaller size) would set what its utilities leave unset. Inside one, code is
* drawn as if typeset were not there.
*/
.typeset-reply
:is([data-streamdown="code-block"], [data-streamdown="mermaid-block"])
:is(pre, code) {
all: revert-layer;
}
}

/*
* A document artifact, set by the same rules as a reply (`.typeset-reply`), as a page rather than a
* message: headings on a page's scale.
*/
@layer components {
.typeset-document :where(h1) {
font-size: 1.75em;
line-height: 1.25;
letter-spacing: -0.01em;
}

.typeset-document :where(h2) {
font-size: 1.3em;
margin-block-start: 2em;
}

.typeset-document :where(h3) {
font-size: 1.125em;
margin-block-start: 1.75em;
}

/*
* On paper a table may break between its rows (each row stays whole: print.css). Typeset keeps a
* table on one page, so a long one left the page before it all but empty.
*/
@media print {
.typeset-document :where(table) {
break-inside: auto;
}
}
}

/*
* Streamdown spaces a reply's blocks with `space-y-4` and the like, utilities, which outrank typeset.
* The blocks' margins go back to what the layers below give them: typeset's, and the block rule just
* above. A first block still starts flush (Streamdown's `[&>*:first-child]:mt-0` is more specific).
*/
@layer utilities {
.typeset-reply > * {
margin-block: revert-layer;
}
}

/*
* A code block in a Bot's words, wherever they are drawn (a reply, a document, a card): one surface,
* its body on the block's own ground and its buttons in the header, not a box in a box. Streamdown
* draws the block and its parts; these keep its look to ours. A table's look is its own component's
* (`lib/markdown-table.tsx`).
*/
[data-streamdown="code-block"] {
background: var(--card);
gap: 0;
padding: 0;
}

[data-streamdown="code-block-header"],
[data-streamdown="code-block"]
> div:has(> [data-streamdown="code-block-actions"]) {
height: 2.5rem;
padding-inline: 0.75rem;
}

/* Streamdown positions its sticky toolbar over a padded header. Match the header
* height here so the toolbar stays centered when the outer padding is removed. */
[data-streamdown="code-block"]
> div:has(> [data-streamdown="code-block-actions"]) {
margin-block-start: -2.5rem;
}

[data-streamdown="code-block-body"] {
background: transparent;
border: 0;
}

[data-streamdown="code-block-actions"] {
background: var(--card);
border: 0;
gap: 0.25rem;
padding: 0;
backdrop-filter: none;
}

[data-streamdown="code-block-actions"] button:has(> svg) {
display: inline-grid;
min-width: 1.75rem;
min-height: 1.75rem;
place-items: center;
}

[data-streamdown="code-block-actions"] button {
border-radius: var(--radius-md);
}

[data-streamdown="code-block-actions"] button:focus-visible {
outline: 2px solid var(--ring);
}

/*
* A code block's Download and Copy show while the pointer is on the block or focus is in it, as a
* table's do (lib/markdown-table.tsx), and always where there is no hover (a touch screen). They fade
* rather than leave, so nothing moves, and they stay in the tab order.
*/
@media (hover: hover) {
[data-streamdown="code-block-actions"] {
opacity: 0;
transition: opacity 150ms;
}

[data-streamdown="code-block"]:is(:hover, :focus-within)
[data-streamdown="code-block-actions"] {
opacity: 1;
}
}

@media (prefers-reduced-motion: reduce) {
[data-streamdown="code-block-actions"] {
transition: none;
}
}
17 changes: 6 additions & 11 deletions app/src/components/artifacts/comments/comments-panel.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { useMutation, useQuery } from "@tanstack/react-query";
import { useEffect, useState } from "react";
import { IconMessageCircle } from "@/components/icons";
import { PageEmpty } from "@/components/layout/page-shell";
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { onArtifactActivity, onArtifactResync } from "@/lib/artifacts/activity";
import { createCommentThreadMutationOptions } from "@/lib/artifacts/comments/mutations";
Expand Down Expand Up @@ -161,16 +159,13 @@ export function CommentsPanel({
)}
</p>
) : threads.data.length === 0 ? (
<PageEmpty
icon={IconMessageCircle}
title={
filter === "resolved" ? "No resolved comments" : "No comments yet"
}
>
// One quiet line, not the app's framed empty state: beside an artifact, a box with a pattern
// was one more surface competing with the artifact for the eye.
<p className="px-1 text-muted-foreground text-sm">
{filter === "resolved"
? "Threads show here once they're resolved."
: "Select something in the artifact to comment on it, or write about the whole thing above."}
</PageEmpty>
? "Resolved threads show here."
: "No comments yet. Select something in the artifact to comment on it."}
</p>
) : (
<div className="flex flex-col gap-3">
{threads.data.map((thread) => (
Expand Down
Loading
Loading