Skip to main content

euv_ui/style/css/
const.rs

1/// Raw stylesheet for rendered markdown bodies ([`crate::euv_markdown`]).
2///
3/// `class!` cannot express descendant selectors, so markdown typography is
4/// injected once at startup through `Css::inject_css`. All colors reference
5/// the theme CSS variables, so light/dark switching works unchanged.
6pub const EUV_MD_CSS: &str = r#"
7.md-body {
8    line-height: 1.7;
9    font-size: var(--font-base);
10    word-wrap: break-word;
11}
12.md-body h1, .md-body h2, .md-body h3, .md-body h4, .md-body h5, .md-body h6 {
13    position: relative;
14    font-weight: 700;
15    letter-spacing: -0.01em;
16    margin-top: 1.8em;
17    margin-bottom: 0.6em;
18    scroll-margin-top: 72px;
19    line-height: 1.3;
20}
21.md-body h1 {
22    font-size: var(--font-3xl);
23    margin-top: 0;
24    padding-bottom: 0.4em;
25    border-bottom: 1px solid var(--border);
26}
27.md-body h2 {
28    font-size: var(--font-2xl);
29    padding-bottom: 0.3em;
30    border-bottom: 1px dashed var(--border);
31}
32.md-body h3 { font-size: var(--font-xl); }
33.md-body h4 { font-size: var(--font-lg); }
34.md-body h5, .md-body h6 { font-size: var(--font-base); }
35.md-body .header-anchor {
36    float: left;
37    margin-left: -0.9em;
38    padding-right: 0.2em;
39    opacity: 0;
40    color: var(--muted-foreground);
41    font-weight: 400;
42    transition: opacity 0.15s ease-out;
43    user-select: none;
44}
45.md-body h1:hover .header-anchor,
46.md-body h2:hover .header-anchor,
47.md-body h3:hover .header-anchor,
48.md-body h4:hover .header-anchor,
49.md-body h5:hover .header-anchor,
50.md-body h6:hover .header-anchor {
51    opacity: 1;
52}
53/* On narrow viewports the negative `margin-left: -0.9em` pushes the `#`
54   sign past the left edge of the viewport (anchor x ≈ -11px on a 380px
55   viewport), so hover-revealed anchors get clipped. On mobile we drop
56   the float + negative margin and make the anchor a small inline
57   prefix instead, with a regular left margin so it stays inside the
58   content box. */
59@media (max-width: 767px) {
60    .md-body .header-anchor {
61        float: none;
62        margin-left: 0;
63        margin-right: 0.3em;
64        padding-right: 0;
65        padding-left: 0;
66        display: inline-block;
67    }
68}
69.md-body p, .md-body ul, .md-body ol, .md-body blockquote, .md-body pre, .md-body table {
70    margin: 1em 0;
71}
72.md-body ul, .md-body ol {
73    padding-left: 1.4em;
74}
75.md-body ul { list-style: disc; }
76.md-body ol { list-style: decimal; }
77.md-body ul ul, .md-body ul ol, .md-body ol ul, .md-body ol ol {
78    margin: 0.25em 0;
79}
80.md-body li { margin: 0.25em 0; }
81.md-body li input[type="checkbox"] {
82    margin-right: 0.4em;
83    accent-color: var(--accent);
84}
85.md-body a {
86    color: var(--accent);
87    font-weight: 500;
88    text-decoration: underline;
89    text-underline-offset: 3px;
90    text-decoration-style: dashed;
91    text-decoration-color: var(--border);
92}
93.md-body a:hover {
94    text-decoration-style: solid;
95    text-decoration-color: var(--accent);
96}
97.md-body strong { font-weight: 700; }
98.md-body em { font-style: italic; }
99.md-body del { opacity: 0.6; }
100.md-body hr {
101    border: none;
102    border-top: 1px dashed var(--border);
103    margin: 2em 0;
104}
105.md-body blockquote {
106    margin: 1em 0;
107    padding: 0.4em 1em;
108    border-left: 4px solid var(--border);
109    color: var(--muted-foreground);
110}
111.md-body blockquote p { margin: 0.4em 0; }
112.md-body code {
113    font-family: ui-monospace, monospace;
114    font-size: 0.875em;
115    padding: 0.15em 0.4em;
116    background: var(--accent-muted);
117    border: 1px solid var(--border);
118    /* Inline <code> that wraps to multiple lines must keep its border
119       on every fragment, otherwise the first line loses its right border
120       and subsequent lines lose their left border.
121
122       box-decoration-break: clone alone is not enough in practice: the
123       per-fragment borders stack against the next fragment's background
124       and the visual gap between fragments collapses, making the right
125       border of one line look like the left border of the next (and
126       neither looks fully closed). Making the element inline-block
127       guarantees each fragment draws its own box with its own four
128       borders, exactly the same trick used by euv_tag. */
129    -webkit-box-decoration-break: clone;
130    box-decoration-break: clone;
131    display: inline-block;
132    vertical-align: text-top;
133    line-height: 1.4;
134}
135.md-body pre {
136    padding: 1em 1.2em;
137    overflow-x: auto;
138    border: 1px solid var(--border);
139    background: var(--accent-muted);
140}
141.md-body pre code {
142    padding: 0;
143    border: none;
144    background: transparent;
145    font-size: 0.875rem;
146    line-height: 1.6;
147}
148.md-body table {
149    width: 100%;
150    border-collapse: collapse;
151    font-size: var(--font-sm);
152    display: block;
153    overflow-x: auto;
154}
155.md-body table thead { border-bottom: 2px solid var(--border); }
156.md-body table th, .md-body table td {
157    padding: 0.5em 0.9em;
158    border: 1px solid var(--border);
159    text-align: left;
160}
161.md-body table th { font-weight: 700; }
162.md-body table tbody tr:nth-child(2n) { background: var(--accent-muted); }
163.md-body img { max-width: 100%; }
164.md-body .docs-container {
165    margin: 1.2em 0;
166    padding: 0.1em 1.2em;
167    border-left: 4px solid var(--foreground);
168    background: var(--accent-muted);
169}
170.md-body .docs-container .docs-container-title {
171    font-weight: 700;
172    font-size: var(--font-sm);
173    letter-spacing: 0.04em;
174    text-transform: uppercase;
175    margin: 0.8em 0 0.4em;
176}
177.md-body .docs-container.tip { border-left-style: solid; }
178.md-body .docs-container.warning { border-left-style: dashed; }
179.md-body .docs-container.danger {
180    border-left: 4px double var(--foreground);
181}
182.md-body .docs-container.details {
183    border-left: 1px solid var(--border);
184    background: transparent;
185}
186.md-body .footnote-definition { font-size: var(--font-sm); color: var(--muted-foreground); }
187"#;