hydroxy

Citation popover

Numbered markers after cited text. Hover or focus one to see the source, the quoted passage highlighted, and a link out.

Rust 2024 makes `unsafe extern` blocks required, so every foreign declaration says it trusts the other side.Unsafe extern blocks - The Rust Edition Guidedoc.rust-lang.orgRust 2024 requires extern blocks to be marked with unsafe. This makes it clear that it is the responsibility of the author to ensure the signatures are correct.Open source The `gen` keyword is reserved for generators.gen keyword - The Rust Edition Guidedoc.rust-lang.org The gen keyword has been reserved as part of RFC 3513 to introduce gen blocks in a future release of Rust.Open source Both changes are opt-in per crate through the edition field in Cargo.toml.Unsafe extern blocks - The Rust Edition Guidedoc.rust-lang.orgRust 2024 requires extern blocks to be marked with unsafe. This makes it clear that it is the responsibility of the author to ensure the signatures are correct.Open sourceEditions - The Cargo Bookdoc.rust-lang.orgThe edition key is an optional key that affects which Rust Edition your package is compiled with. Setting it in Cargo.toml opts the whole package in.Open source

Unsafe extern blocksgen keywordEditions

Usage

use hydroxy_leptos::citation_popover::{CitedSpan, CitedText, Source};
use hydroxy_leptos::source_chip::{SourceChip, SourceRow};
use leptos::prelude::*;

const ANSWER: &str = "Rust 2024 makes `unsafe extern` blocks required, so every foreign declaration says it trusts the other side. The `gen` keyword is reserved for generators. Both changes are opt-in per crate through the edition field in Cargo.toml.";

pub fn demo() -> AnyView {
    let sources = vec![
        Source::new(
            "Unsafe extern blocks - The Rust Edition Guide",
            "https://doc.rust-lang.org/edition-guide/rust-2024/unsafe-extern.html",
            "Rust 2024 requires extern blocks to be marked with unsafe. This makes it clear that it is the responsibility of the author to ensure the signatures are correct.",
        )
        .quote("requires extern blocks to be marked with unsafe"),
        Source::new(
            "gen keyword - The Rust Edition Guide",
            "https://doc.rust-lang.org/edition-guide/rust-2024/gen-keyword.html",
            "The gen keyword has been reserved as part of RFC 3513 to introduce gen blocks in a future release of Rust.",
        )
        .quote("The gen keyword has been reserved"),
        Source::new(
            "Editions - The Cargo Book",
            "https://doc.rust-lang.org/cargo/reference/manifest.html#the-edition-field",
            "The edition key is an optional key that affects which Rust Edition your package is compiled with. Setting it in Cargo.toml opts the whole package in.",
        )
        .quote("affects which Rust Edition your package is compiled with"),
    ];
    let spans: Vec<CitedSpan> = [
        ("Rust 2024 makes `unsafe extern` blocks required, so every foreign declaration says it trusts the other side.", vec![0]),
        ("The `gen` keyword is reserved for generators.", vec![1]),
        ("Both changes are opt-in per crate through the edition field in Cargo.toml.", vec![0, 2]),
    ]
    .iter()
    .filter_map(|(s, src)| CitedSpan::find(ANSWER, s, src))
    .collect();
    let chips = sources
        .iter()
        .map(|s| s.title.split(" - ").next().unwrap_or_default().to_string())
        .map(|title| view! { <SourceChip>{title}</SourceChip> })
        .collect_view();

    view! {
        <div style="display: grid; gap: var(--space-4); max-width: 560px;">
            <p style="margin: 0; font: var(--text-body); color: var(--text-1);">
                <CitedText text=ANSWER spans=spans sources=sources />
            </p>
            <SourceRow>{chips}</SourceRow>
        </div>
    }
    .into_any()
}

Anatomy

Componentdata-partRenders
CitedTexttextProse split into runs from byte-offset spans
CitedTextcitedA cited run, dotted underline
CitationMarkermarkerLink to the source, "[n]", named "Source n: title", described by the snippet
CitationMarkercardManual popover anchored to the marker; stays open while hovered or focused
CitationMarkerfaviconThe source's icon, or its host's first letter
CitationMarkersnippetThe passage, with the quote in a <mark>
CitationMarkeropenLink that opens the source in a new tab

Keyboard

KeyDoes
TabFocus a marker to open its card; Tab again reaches Open source
EscapeClose the card and return to the marker
EnterOn the marker: open the source

Props

PropTypeNotes
textStringCitedText. The prose
spansVec<CitedSpan>CitedText. Byte ranges and the sources behind each; CitedSpan::find builds one from a substring
sourcesVec<Source>Title, URL, snippet, optional quote and favicon. Numbered from 1
index / sourceusize / SourceCitationMarker on its own, for custom layouts
Actions
Button
Icon button
Toolbar
Theme menu
Display
Avatar
Badge
Card
Chip
Code block
Markdown
Doc card
Due pill
Kbd
Priority mark
Source chip
Space icon
Status diamond
Tag
Value diff
Carousel
Reveal
Media timeline
QR code
Transcript viewer
Audio waveform
Audio player
Forms
Calendar
Checkbox
Combobox
Date picker
Color picker
Cron builder
Theme editor
Mention input
Signature pad
Image cropper
Date field
Date range picker
Duration field
Quantity stepper
Filter chip
Input
Markdown editor
Radio group
Search field
Segmented control
Select
Slider
Range slider
Rating
Toggle button
File dropzone
Upload queue
Attachment
Switch
Tags input
Number field
Money field
Phone field
Time field
OTP input
Password field
Questionnaire
Availability picker
Voice input
Recording control
Inline edit
Async validated input
Shortcut recorder
Data
Spreadsheet grid
Week scheduler
Virtual list
Stat card
Step track
Kanban board
Sortable list
Filter builder
Data table
Grid
Access editor
File manager
Gantt chart
Log stream
Diff viewer
JSON inspector
Terminal
Node editor
Whiteboard
Navigation
Table of contents
Breadcrumb
Tabs
Wizard
Nav item
Nav section
Tree view
Pagination
Menubar
Navigation menu
Saved views
Layout
Master detail
App shell
Sidebar layout
Resizable panels
Dashboard layout
Dock layout
Feedback
Callout
Check list
Empty state
Progress bar
Toast
Approval card
Skeleton
Notification center
Bars
Bar chart
Diverging bar chart
Span chart
Pictogram chart
Stacked bar chart
Funnel chart
Bullet chart
Waffle chart
Marimekko chart
Dot plot chart
Error bar chart
Pareto chart
Waterfall chart
Lollipop chart
Grouped bar chart
Bar race chart
KPIs and frames
Chart frame
Metric card
Sparkline
Points
Scatter chart
Smith chart
Strip plot
Beeswarm chart
Parallel coordinates
Ternary chart
Bland-Altman chart
Quiver chart
Connected scatter chart
Grids and tables
Heatmap chart
Chart table
Cohort chart
Radial
Radial charts
Radar chart
Polar area chart
Stat ring
Clock chart
Spiral chart
Lines and areas
Bump chart
Slope chart
Line chart
Composed chart
Small multiples
Cycle plot chart
Horizon chart
Stacked area chart
Threshold chart
Split line chart
Linked charts
Confidence band chart
Forecast fan chart
Step chart
Range area chart
Distributions
Contour chart
Histogram
Box plot
Density chart
Ridgeline chart
Violin chart
Q-Q chart
Survival chart
ECDF chart
Raincloud plot
Forest plot
Maps
Geo map
Bubble map
Hexbin map
Cartogram
Flow map
Parts of a whole
Donut chart
Voronoi treemap
Nested donut chart
Treemap chart
Sunburst chart
Bubble pack chart
Icicle chart
Flame graph chart
Pie chart
Word cloud
Relationships
Sankey chart
Network chart
Chord chart
UpSet chart
Venn chart
Alluvial chart
Adjacency matrix chart
Dependency graph chart
Tree chart
Arc diagram
Hive plot
Edge bundling
Finance
Candlestick chart
OHLC chart
Depth chart
Renko chart
Time
Timeline chart
Calendar heatmap chart
Spectrogram chart
Marey chart
Overlays
Tour
Lightbox
Alert dialog
Command palette
Dialog
Menu
Popover
Tooltip
Sheet
Hover card
Context menu
Utilities
Pacer
Hotkeys
Disclosure
Accordion
Collapsible
Chat
Chat bubble
Voice session
Composer
Thread
Thread list
Assistant composer
Assistant MCP
Assistant modal
Assistant thread
Assistant thread list
Message scroller
Insight note
Emoji picker
Tool trace
Model picker
Citation popover
Activity
Activity feed
Comment thread
Timeline
Presence bar
Live cursors
Reaction bar
Guides
Getting started
All components
All charts