AdvancedComposer
Location: src/components/AdvancedComposer.jsx
Overview
AdvancedComposer is the one post composer (FE-1, ADR-033). It is the popup the header Write button (and the W key) opens over any page (composer/ComposerModal.jsx, mounted by composer/ComposerHost.jsx), and the page at the /compose route, which stays for links and for the clips and storage pages that hand it content in location.state. It has several editor types (simple, longform, drawing, magnetic poetry, quotation, poll, loop), draft management (local auto-save and database-backed drafts), and a confirmation gate before publishing. The inline quick composer (CreatePost) no longer exists.
In the popup the props modal, onClose and onPosted replace navigation: Close, Cancel, Escape and the backdrop ask before dropping words (keep writing, save as draft and close, or discard), and a finished post calls onPosted({ id, post, destination }) and closes; where the post belongs on another page (a circle, or the feed from a room) the person lands there. On the page, Cancel goes back and a finished post navigates to its destination, as before.
Relevant Invariants
- Invariant #4: "Intent Precedes Interpretation" -- The intent badge on the card is chosen before sharing.
- Invariant #10: "Expressive Freedom Is Spatially Contained" -- Rich style customization is contained to the author own posts.
- Invariant #19: "Complexity Must Be Earned" -- Each option is one icon that opens its control only when asked for.
Props
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
session | object | Yes | -- | Supabase auth session |
Editor Types
| ID | Label | Description |
|---|---|---|
simple | Quick Post | Plain text post |
longform | Article | Rich text with formatting |
drawing | Drawing | Canvas-based drawing |
magnetic_poetry | Word Art | Drag-and-drop word tiles |
Style System
The style panel has three tabs:
Appearance (Surface)
light,dark,warm,cool
Typography (Font + Emphasis)
- Font options loaded from
FONT_OPTIONSconstant - Emphasis:
subtle,normal,strong
Effects (Texture)
flat(clean and minimal),paper(subtle texture),soft-card(gentle shadows),ghost(translucent blur)
Advanced Token-Based Styling
In addition to the simple style system (surface/texture/font/emphasis), AdvancedComposer integrates the full PostCustomizer for token-based visual styling:
- "Advanced Style" button in the style panel footer opens a full-screen
PostCustomizeroverlay - Uses the
usePostStylehook to manage token state separately from the simple style - Token data is stored as
style_tokensinside the existingpost_styleJSONB column on posts - An indicator badge appears when advanced style is active, with a "Remove" button to clear it
- Draft saves (auto and manual) include token data
- The
usePostStyleFor(post)hook extracts tokens from stored posts for rendering
Key Behaviors
- Dual Draft System:
useAutoSavepersists to IndexedDB (commonplace_draftsdatabase) on every change;useDraftssaves to thecomposer_draftsSupabase table for cross-device access. - Style Presets: Users can save and load style configurations from the
style_presetstable. - PostConfirmationGate: Before publishing, a modal asks the user to confirm their intent and review the post.
- Navigation State: Receives
content,intent,images,audience,selectedCircleIds,sharingAllowed,contentNote,clipData, andclipIdinuseLocation().statewhen it is the/composepage (the popup starts blank). Note:voiceDatais not passed in; it is initialized asnulland set via the VoiceRecorder component. - Live Preview: Real-time preview panel shows how the post will look with current style settings.
- Content Note: Optional content note input for sensitive content.
- External Clips: Can attach external content cards (URLs) to posts.
Constants
| Constant | Value | Description |
|---|---|---|
MAX_FILE_SIZE | 5242880 (5 MB) | Maximum image file size |
MAX_IMAGES | 10 | Maximum images per post |
ALLOWED_TYPES | [image/jpeg, image/png, image/gif, image/webp] | Accepted image MIME types |
Usage
// Typically navigated to, not rendered directly
import { useNavigate } from 'react-router-dom';
const navigate = useNavigate();
navigate('/compose', {
state: {
intent: 'tell',
content: 'Draft text...',
images: [],
audience: 'public',
selectedCircleIds: [],
sharingAllowed: true,
contentNote: '',
clipData: null,
clipId: null
}
});
Related
- Post -- Displays the styled post output
- VoiceRecorder -- Voice recording integration
- usePostStyle -- Token-based style management hook
PostCustomizer(src/components/customizer/src/components/PostCustomizer.jsx) -- Full-screen token style editor
Last updated: 2026-02-08