euv-docs 0.36.1

A documentation site generator powered by euv + euv-ui (Rust/WASM).
use super::*;

class! {
    // The figure owns the only frame; its children remain unframed.
    pub c_docs_code {
        margin: format!("{} 0", var!(space-lg));
        border: format!("{} solid {}", var!(border-width), var!(border));
        border-radius: var!(radius-lg);
        background: var!(muted);
        overflow: "hidden";
        min-width: "0";
    }

    // Class-local tag qualification outranks markdown's pre/code selectors.
    pub c_docs_code_pre {
        :is(pre.c_docs_code_pre) {
            margin: "0";
            padding: var!(space-lg);
            border: "none";
            border-radius: "0";
            box-shadow: "none";
            background: "transparent";
            color: var!(foreground);
            font-family: var!(font-family-mono);
            font-size: var!(font-xs);
            line-height: "1.6";
            white-space: "pre";
            overflow-wrap: "normal";
            overflow-x: "auto";
        }
    }

    pub c_docs_code_content {
        :is(code.c_docs_code_content) {
            display: "block";
            margin: "0";
            padding: "0";
            border: "none";
            border-radius: "0";
            box-shadow: "none";
            background: "transparent";
            color: "inherit";
            font-family: "inherit";
            font-size: "inherit";
            line-height: "inherit";
            white-space: "pre";
            overflow-wrap: "normal";
        }
    }

    // The toolbar above the code: the language on the left, the copy
    // button on the right.
    pub c_docs_code_header {
        display: "flex";
        align-items: "center";
        justify-content: "space-between";
        gap: var!(space-sm);
        padding: format!("{} {}", var!(space-xs), var!(space-sm));
        border: "none";
        background: var!(muted);
        color: var!(muted-foreground);
        font-family: var!(font-family-mono);
        font-size: var!(font-xs);
        line-height: "1.5";
    }

    // The language label of the toolbar.
    pub c_docs_code_lang {
        font-weight: var!(font-weight-medium);
        overflow: "hidden";
        text-overflow: "ellipsis";
        white-space: "nowrap";
    }

    // The copy button of the toolbar.
    pub c_docs_code_copy {
        display: "inline-flex";
        align-items: "center";
        flex-shrink: "0";
        gap: var!(space-xs);
        padding: format!("{} {}", var!(space-2xs), var!(space-sm));
        border: "none";
        border-radius: var!(radius-sm);
        background: "transparent";
        color: var!(foreground);
        font-family: "inherit";
        font-size: var!(font-xs);
        line-height: "1.5";
        cursor: "pointer";

        :hover {
            background: var!(accent);
            color: var!(accent-foreground);
        }
    }

    // The visible label of the copy button.
    pub c_docs_code_label {
        display: "inline";
    }

    // The label of the copy button while it is not on screen. The
    // button carries one label per outcome and swaps them by class, so
    // an outcome never has to rewrite the text of a node.
    pub c_docs_code_label_hidden {
        display: "none";
    }
}

/// The label of the copy button while the code has not been copied.
pub(crate) const COPY_LABEL: &str = "Copy";

/// The class of the label that is on screen.
pub(crate) const COPY_LABEL_CLASS: &str = "c_docs_code_label";

/// The class of the label that is off screen.
pub(crate) const HIDDEN_LABEL_CLASS: &str = "c_docs_code_label_hidden";

/// The selector that finds every label of the copy button.
pub(crate) const LABEL_SELECTOR: &str = ".c_docs_code_label, .c_docs_code_label_hidden";

/// The selector that finds the copy button.
pub(crate) const COPY_BUTTON_SELECTOR: &str = ".c_docs_code_copy";

/// The state of a button that is waiting for a press.
pub(crate) const RESTING_STATE: u8 = 0;

/// The state of a button that has just copied the code.
pub(crate) const COPY_STATE: u8 = 1;

/// The state of a button whose copy was refused by the browser.
pub(crate) const FAILED_STATE: u8 = 2;

/// How long the copy button keeps reporting the copy, in milliseconds.
///
/// The reference copy button shows its confirmation for about two
/// seconds before it returns to its resting label.
pub(crate) const COPY_FEEDBACK_MILLIS: u32 = 2000;

/// The label of the copy button right after a successful copy.
pub(crate) const COPIED_LABEL: &str = "Copied";

/// The label of the copy button when the browser refused the copy.
///
/// A write that is rejected must not look like a write that never
/// happened: the reader pressed the button, and the button has to say
/// what came of it.
pub(crate) const FAILED_LABEL: &str = "Failed";

/// The accessible name of the copy button.
pub(crate) const COPY_BUTTON_LABEL: &str = "Copy code to clipboard";