|
| 1 | +/* |
| 2 | + * Right-to-left (Arabic, Hebrew) layout for the Shibuya theme. |
| 3 | + * |
| 4 | + * partials/extra-head.html sets <html dir="rtl"> for RTL builds. The page body |
| 5 | + * (.sy-page) is a flexbox row [left sidebar | main | right TOC], so dir="rtl" |
| 6 | + * already mirrors the column order automatically -- the nav tree moves to the |
| 7 | + * right and the "on this page" panel to the left. These rules fix the |
| 8 | + * remaining details that use *physical* left/right and therefore do not follow |
| 9 | + * dir on their own, and -- importantly -- keep code blocks and API signatures |
| 10 | + * left-to-right. |
| 11 | + * |
| 12 | + * This file is loaded for every language but every rule is scoped to |
| 13 | + * [dir="rtl"], so it is completely inert for left-to-right builds. |
| 14 | + * |
| 15 | + * STATUS: parked / future work. The RTL layout is currently DISABLED via |
| 16 | + * RTL_ENABLED = False in conf.py, so <html dir="rtl"> is never emitted and none |
| 17 | + * of these rules apply. See the "Right-to-left layout ... DISABLED" note in |
| 18 | + * conf.py for why. Kept here so re-enabling is a one-line change. |
| 19 | + */ |
| 20 | + |
| 21 | +/* ── Keep code and API signatures left-to-right ────────────────────────── |
| 22 | + Source code, REPL output, and Python signatures are always LTR, even on an |
| 23 | + RTL page. Inline <code> inside prose is left alone; the bidi algorithm |
| 24 | + already renders it correctly within the right-to-left text run. */ |
| 25 | +[dir="rtl"] .highlight, |
| 26 | +[dir="rtl"] .highlight pre, |
| 27 | +[dir="rtl"] pre, |
| 28 | +[dir="rtl"] .highlighttable, |
| 29 | +[dir="rtl"] .doctest, |
| 30 | +[dir="rtl"] .sig { |
| 31 | + direction: ltr; |
| 32 | + text-align: left; |
| 33 | +} |
| 34 | +/* Signature hanging-indent is authored for LTR; restore its physical paddings. */ |
| 35 | +[dir="rtl"] .sig { |
| 36 | + text-indent: -2.4rem; |
| 37 | + padding: 0.25rem 0.5rem 0.25rem 3rem; |
| 38 | +} |
| 39 | + |
| 40 | +/* ── List indentation moves to the inline-start (right) side ─────────────── */ |
| 41 | +[dir="rtl"] .yue ul, |
| 42 | +[dir="rtl"] .yue ol { |
| 43 | + padding-left: 0; |
| 44 | + padding-right: 1.625em; |
| 45 | +} |
| 46 | +[dir="rtl"] .yue ol > li, |
| 47 | +[dir="rtl"] .yue ul > li { |
| 48 | + padding-left: 0; |
| 49 | + padding-right: 0.375em; |
| 50 | +} |
| 51 | + |
| 52 | +/* ── Admonitions: accent border + title bar on the right edge ────────────── */ |
| 53 | +[dir="rtl"] .admonition { |
| 54 | + border-left: 0; |
| 55 | + border-right: 4px solid var(--color-3); |
| 56 | +} |
| 57 | +[dir="rtl"] .admonition-title { |
| 58 | + margin-left: -1rem; |
| 59 | + margin-right: -19px; |
| 60 | +} |
| 61 | +[dir="rtl"] .admonition.deprecated::before, |
| 62 | +[dir="rtl"] .deprecated::before { |
| 63 | + left: auto; |
| 64 | + right: -12px; |
| 65 | +} |
| 66 | + |
| 67 | +/* ── Block quotes: quote bar on the right ────────────────────────────────── */ |
| 68 | +[dir="rtl"] blockquote { |
| 69 | + border-left: 0; |
| 70 | + border-right: 0.25rem solid var(--yue-c-quote-border); |
| 71 | + padding-left: 0; |
| 72 | + padding-right: 1rem; |
| 73 | +} |
| 74 | + |
| 75 | +/* ── Left navigation tree: expand chevron + its reserved gutter flip ──────── */ |
| 76 | +[dir="rtl"] .globaltoc li > button { |
| 77 | + right: auto; |
| 78 | + left: 0; |
| 79 | +} |
| 80 | +[dir="rtl"] .globaltoc li:has(> button) > a { |
| 81 | + padding-right: 0; |
| 82 | + padding-left: 1.6rem; |
| 83 | +} |
| 84 | + |
| 85 | +/* ── Horizontal chevrons point the other way ───────────────────────────── |
| 86 | + The prev/next page navigation uses chevron-left (Previous) and |
| 87 | + chevron-right (Next); in RTL "previous" is to the right and "next" to the |
| 88 | + left, so mirror these horizontal chevrons. Vertical chevrons (down/up, used |
| 89 | + by dropdowns and the sidebar expanders) are left alone. */ |
| 90 | +[dir="rtl"] .i-lucide.chevron-left, |
| 91 | +[dir="rtl"] .i-lucide.chevron-right { |
| 92 | + transform: scaleX(-1); |
| 93 | +} |
| 94 | + |
| 95 | +/* ── "Copy page" dropdown + button align to the inline-start edge ─────────── */ |
| 96 | +[dir="rtl"] #copy-page-content { |
| 97 | + right: auto; |
| 98 | + left: 0; |
| 99 | +} |
| 100 | +[dir="rtl"] .copy-page-wrapper.lg\:absolute { |
| 101 | + right: auto; |
| 102 | + left: 1.5rem; |
| 103 | +} |
| 104 | +/* The H1 reserves space for the copy-page button with padding-right (button |
| 105 | + on the right in LTR). In RTL the button is on the left, so reserve there |
| 106 | + instead or the right-aligned title runs underneath it. */ |
| 107 | +[dir="rtl"] .copy-page-wrapper + .yue > section > h1:first-of-type { |
| 108 | + padding-right: 0; |
| 109 | + padding-left: 180px; |
| 110 | +} |
| 111 | +/* Dropdown rows: the icon's gap is authored as margin-right (icon-on-left); |
| 112 | + in RTL the icon is on the right, so move the gap to its inline-start side |
| 113 | + or the label collides with the icon. Same for the trailing external-link. */ |
| 114 | +[dir="rtl"] #copy-page-content .iconify-icon, |
| 115 | +[dir="rtl"] #copy-page-content iconify-icon { |
| 116 | + margin-right: 0; |
| 117 | + margin-left: 0.5rem; |
| 118 | +} |
| 119 | +[dir="rtl"] #copy-page-content a::after { |
| 120 | + margin-left: 0; |
| 121 | + margin-right: 0.1rem; |
| 122 | +} |
| 123 | + |
| 124 | +/* ── Search box: the keyboard-shortcut hint moves to the inline-start edge ── |
| 125 | + It is pinned right:0, which is where the right-aligned RTL query text |
| 126 | + starts, so the text runs under it. Move it to the left in RTL. */ |
| 127 | +[dir="rtl"] .searchbox kbd, |
| 128 | +[dir="rtl"] .searchbox button, |
| 129 | +[dir="rtl"] .searchform input[name="q"] + button { |
| 130 | + right: auto; |
| 131 | + left: 0; |
| 132 | +} |
| 133 | + |
| 134 | +/* ── Mobile off-canvas drawers come in from the mirrored side ───────────── |
| 135 | + Scoped to the mobile breakpoint only. On desktop these sidebars are static |
| 136 | + flex items that dir="rtl" already mirrors, so touching their transform/ |
| 137 | + position here would push them off-canvas. */ |
| 138 | +@media (max-width: 1279px) { |
| 139 | + [dir="rtl"] #lside { |
| 140 | + left: auto; |
| 141 | + right: 0; |
| 142 | + transform: translate(100%); |
| 143 | + } |
| 144 | + [dir="rtl"] #rside { |
| 145 | + right: auto; |
| 146 | + left: 0; |
| 147 | + transform: translate(-110%); |
| 148 | + box-shadow: 12px 0 16px var(--gray-a1); |
| 149 | + } |
| 150 | + /* Open state: slide the drawer in. The theme's #lside[aria-hidden=false] |
| 151 | + rule has the same specificity as our closed-state rule above and, being |
| 152 | + loaded first, would lose by source order -- leaving the drawer off-screen |
| 153 | + (a visible overlay but no content). Re-assert the open transform here. */ |
| 154 | + [dir="rtl"] #lside[aria-hidden="false"], |
| 155 | + [dir="rtl"] #rside[aria-hidden="false"] { |
| 156 | + transform: translate(0); |
| 157 | + } |
| 158 | + [dir="rtl"] .rside-close { |
| 159 | + right: auto; |
| 160 | + left: 16px; |
| 161 | + } |
| 162 | +} |
0 commit comments