dioxus-nox-markdown 0.13.2

Headless markdown editor, previewer, and display components for Dioxus
Documentation
/* examples.css — polished demo styles for dioxus-nox-markdown examples.
   Data-attribute selector reference (actual component output):
     [data-md-root]            markdown::Root
     [data-md-editor]          markdown::Editor outer div
     [data-md-preview]         markdown::Preview
     [data-md-splitter]        markdown::Divider
     [data-md-inline-editor]   markdown::InlineEditor (contenteditable)
     [role="tablist"]          markdown::ModeBar
     [role="tab"]              markdown::ModeTab  — data-state="active|inactive"
     [role="toolbar"]          markdown::Toolbar
     [role="toolbar"] button   markdown::ToolbarButton
     [role="toolbar"] [role="separator"]  markdown::ToolbarSeparator
*/

/* ── Reset & tokens ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --bg:        #f8f9fa;
    --surface:   #ffffff;
    --border:    #e1e4e8;
    --border-md: #d0d7de;
    --text:      #1f2328;
    --text-muted:#656d76;
    --accent:    #0969da;
    --accent-bg: #ddf4ff;
    --tab-h:     36px;
    --toolbar-h: 36px;
    --radius:    6px;
    --mono:      ui-monospace, "SFMono-Regular", "Consolas", monospace;
    --sans:      -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

body {
    margin: 0;
    font-family: var(--sans);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ── Root container ───────────────────────────────────────────── */
[data-md-root] {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    margin: 16px;
    border: 1px solid var(--border-md);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
}

/* ── Mode bar (tablist) ───────────────────────────────────────── */
[role="tablist"] {
    display: flex;
    align-items: stretch;
    height: var(--tab-h);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    padding: 0 8px;
    gap: 0;
    flex-shrink: 0;
}

[role="tab"] {
    display: inline-flex;
    align-items: center;
    padding: 0 14px;
    height: 100%;
    border: none;
    background: none;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}

[role="tab"]:hover { color: var(--text); }

[role="tab"][data-state="active"] {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

[role="tab"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-radius: 3px;
}

/* ── Toolbar ──────────────────────────────────────────────────── */
[role="toolbar"] {
    display: flex;
    align-items: center;
    height: var(--toolbar-h);
    padding: 0 8px;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

[role="toolbar"] button {
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    height: 26px;
    border: 1px solid transparent;
    background: none;
    border-radius: 4px;
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: background .1s, border-color .1s, color .1s;
}

[role="toolbar"] button:hover {
    background: var(--border);
    border-color: var(--border-md);
    color: var(--text);
}

[role="toolbar"] button:active {
    background: #dae8f4;
}

[role="toolbar"] [role="separator"] {
    width: 1px;
    height: 18px;
    background: var(--border-md);
    margin: 0 4px;
    flex-shrink: 0;
}

/* ── Split pane wrapper (example helper class) ────────────────── */
.split-pane {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* ── Editor ───────────────────────────────────────────────────── */
[data-md-editor] {
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 0;
}

[data-md-editor] textarea {
    flex: 1;
    width: 100%;
    min-height: 0;
    resize: none;
    border: none;
    outline: none;
    padding: 16px 20px;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
    background: var(--surface);
    caret-color: var(--accent);
}

/* ── Inline editor (contenteditable) ─────────────────────────── */
[data-md-inline-editor] {
    flex: 1;
    min-height: 0;
    outline: none;
    padding: 16px 20px;
    line-height: 1.7;
    color: var(--text);
    overflow-y: auto;
}

/* Prose styles inside the inline editor */
[data-md-inline-editor] h1,
[data-md-inline-editor] h2,
[data-md-inline-editor] h3,
[data-md-inline-editor] h4 {
    margin: 1em 0 .4em;
    line-height: 1.25;
    font-weight: 600;
}
[data-md-inline-editor] h1 { font-size: 1.75em; }
[data-md-inline-editor] h2 { font-size: 1.35em; border-bottom: 1px solid var(--border); padding-bottom: .3em; }
[data-md-inline-editor] h3 { font-size: 1.1em; }
[data-md-inline-editor] p  { margin: .6em 0; }
[data-md-inline-editor] ul,
[data-md-inline-editor] ol { margin: .6em 0; padding-left: 1.8em; }
[data-md-inline-editor] li { margin: .2em 0; }
[data-md-inline-editor] blockquote {
    margin: .6em 0;
    padding: .4em 1em;
    border-left: 3px solid var(--border-md);
    color: var(--text-muted);
}
[data-md-inline-editor] pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: .75em 1em;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: .9em;
    line-height: 1.5;
    margin: .6em 0;
}
[data-md-inline-editor] code {
    font-family: var(--mono);
    font-size: .9em;
    background: var(--accent-bg);
    padding: .1em .35em;
    border-radius: 3px;
}
[data-md-inline-editor] pre code {
    background: none;
    padding: 0;
}

/* Active block (cursor inside) gets a subtle left accent */
[data-md-inline-editor] [data-block-index]:focus-within,
[data-md-inline-editor] [data-block-index]:empty:not(:focus-within) {
    /* no extra style — let cursor position speak for itself */
}

/* ── Divider ──────────────────────────────────────────────────── */
[data-md-splitter] {
    width: 1px;
    background: var(--border);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background .15s;
}

[data-md-splitter]:hover { background: var(--accent); }

/* ── Preview ──────────────────────────────────────────────────── */
[data-md-preview] {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 16px 20px;
    background: var(--surface);
    line-height: 1.7;
}

[data-md-preview] h1,
[data-md-preview] h2,
[data-md-preview] h3 { font-weight: 600; line-height: 1.25; }
[data-md-preview] h1 { font-size: 1.75em; }
[data-md-preview] h2 { font-size: 1.35em; border-bottom: 1px solid var(--border); padding-bottom: .3em; }
[data-md-preview] code {
    font-family: var(--mono);
    font-size: .9em;
    background: var(--accent-bg);
    padding: .1em .35em;
    border-radius: 3px;
}
[data-md-preview] pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: .75em 1em;
    overflow-x: auto;
}
[data-md-preview] pre code { background: none; padding: 0; }
[data-md-preview] blockquote {
    margin: .6em 0;
    padding: .4em 1em;
    border-left: 3px solid var(--border-md);
    color: var(--text-muted);
}

/* ── Hidden inactive panes ────────────────────────────────────── */
[data-md-editor][data-state="inactive"],
[data-md-preview][data-state="inactive"] {
    display: none;
}

/* ── Sidebar (example helper) ─────────────────────────────────── */
aside {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

aside h3 {
    margin: 0 0 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
}

aside ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
}

aside li { color: var(--accent); }