History

Add styles for syntax diagrams in Rust reference

Calum Smith committed 1 year ago

Commit bf4e9011 parent 4a786201 file · +69 −0Browse files

Unified · Split

assets/stylesheets/pages/_rust.scss+69−0
@@ -18,4 +18,73 @@ · 17 unmodified lines
1818 float: right;
1919 margin-left: .5rem;
2020 }
21+
22+ .grammar-container { @extend %note, %note-gray; }
23+
24+ /* Railroad styles from:
25+ * https://github.com/rust-lang/reference/blob/f82156b8c3a784158ce609bebfa3a77b5ae8a5ed/theme/reference.css#L683-L734
26+ * Plus CSS variables inheriting from DevDocs variables
27+ */
28+
29+ svg.railroad {
30+ --railroad-background-color: var(--boxBackground);
31+ --railroad-background-image:
32+ linear-gradient(to right, rgb(from currentColor r g b / 0.1) 1px, transparent 1px),
33+ linear-gradient(to bottom, rgb(from currentColor r g b / 0.1) 1px, transparent 1px);
34+ --railroad-path-stroke: currentColor;
35+ --railroad-rect-stroke: currentColor;
36+ --railroad-rect-fill: var(--noteBackground);
37+ --railroad-text-fill: currentColor;
38+
39+ background-color: var(--railroad-background-color);
40+ background-size: 15px 15px;
41+ background-image: var(--railroad-background-image);
42+ }
43+
44+ svg.railroad rect.railroad_canvas {
45+ stroke-width: 0px;
46+ fill: none;
47+ }
48+
49+ svg.railroad path {
50+ stroke-width: 3px;
51+ stroke: var(--railroad-path-stroke);
52+ fill: none;
53+ }
54+
55+ svg.railroad .debug {
56+ stroke-width: 1px;
57+ stroke: red;
58+ }
59+
60+ svg.railroad text {
61+ font: 14px monospace;
62+ text-anchor: middle;
63+ fill: var(--railroad-text-fill);
64+ }
65+
66+ svg.railroad .nonterminal text {
67+ font-weight: bold;
68+ }
69+
70+ svg.railroad text.comment {
71+ font: italic 12px monospace;
72+ }
73+
74+ svg.railroad rect {
75+ stroke-width: 3px;
76+ stroke: var(--railroad-rect-stroke);
77+ fill: var(--railroad-rect-fill);
78+ }
79+
80+ svg.railroad g.labeledbox>rect {
81+ stroke-width: 1px;
82+ stroke: grey;
83+ stroke-dasharray: 5px;
84+ fill: rgba(90, 90, 150, .1);
85+ }
86+
87+ svg.railroad g.exceptbox > rect {
88+ fill:rgba(245, 160, 125, .1);
89+ }
2190 }