1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Unify LTR / RTL CSS for guides

When `main.css` is updated, it is easy for `main.rtl.css` to be
overlooked (see #45423).

This commit eliminates `main.rtl.css` in favor of a unified approach to
LTR / RTL styling in `main.css`.  To accomplish this, the `<body>`
element is rendered with a [`dir` attribute][] (which has the same
effect as setting the CSS `direction` property), and LTR- / RTL-specific
styles are prefixed with `:where(body[dir="..."])` selectors.  (The
[`:where()` pseudo-class][] ensures that selector specificity is not
changed.)

This change also paves the way for automatic detection and application
of LTR / RTL styles when the [`:dir()` pseudo-class][] gains widespread
browser support.

[`dir` attribute]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir
[`:where()` pseudo-class]: https://developer.mozilla.org/en-US/docs/Web/CSS/:where
[`:dir()` pseudo-class]: https://developer.mozilla.org/en-US/docs/Web/CSS/:dir
This commit is contained in:
Jonathan Hefner 2022-06-22 14:43:07 -05:00
parent 21acc7bfb6
commit 23d0cd6f6f
4 changed files with 94 additions and 847 deletions

View file

@ -23,7 +23,8 @@ ol { list-style-type: decimal; }
dl { margin: 0 0 1.5em 0; }
dl dt { font-weight: bold; }
dd { margin-left: 1.5em;}
:where(body[dir="ltr"]) dd { margin-left: 1.5em; }
:where(body[dir="rtl"]) dd { margin-right: 1.5em; }
pre, code {
font-size: 1em;
@ -120,11 +121,12 @@ body {
}
.wrapper {
text-align: left;
margin: 0 auto;
max-width: 960px;
padding: 0 1em;
}
:where(body[dir="ltr"]) .wrapper { text-align: left; }
:where(body[dir="rtl"]) .wrapper { text-align: right; }
.red-button {
display: inline-block;
@ -283,14 +285,14 @@ body {
position: absolute;
z-index: 0;
top: 21px;
right: 0;
background: #FFF;
padding: 1em 1.5em 1em 1.25em;
width: 20em;
font-size: 0.9285em;
line-height: 1.3846;
margin-right: 1em;
}
:where(body[dir="ltr"]) #subCol { right: 0; margin-right: 1em; }
:where(body[dir="rtl"]) #subCol { left: 0; margin-left: 1em; }
@media screen and (max-width: 800px) {
@ -299,8 +301,9 @@ body {
width: inherit;
margin-left: -1em;
margin-right: -1em;
padding-right: 1.25em;
}
:where(body[dir="ltr"]) #subCol { padding-right: 1.25em; }
:where(body[dir="rtl"]) #subCol { padding-left: 1.25em; }
}
#footer {
@ -308,23 +311,31 @@ body {
background: #222 url(../images/footer_tile.gif) repeat-x;
}
#footer .wrapper {
padding-left: 1em;
max-width: 960px;
}
:where(body[dir="ltr"]) #footer .wrapper { padding-left: 1em; }
:where(body[dir="rtl"]) #footer .wrapper { padding-right: 1em; }
#footer p:last-child {
margin-bottom: 0;
}
#header .wrapper, #topNav .wrapper, #feature .wrapper {padding-left: 1em; max-width: 960px;}
#feature .wrapper {max-width: 720px; padding-right: 23em; position: relative; z-index: 0;}
#header .wrapper, #topNav .wrapper { max-width: 960px; }
:where(body[dir="ltr"]) :is(#header .wrapper, #topNav .wrapper) { padding-left: 1em; }
:where(body[dir="rtl"]) :is(#header .wrapper, #topNav .wrapper) { padding-right: 1em; }
#feature .wrapper { max-width: 720px; position: relative; z-index: 0; }
:where(body[dir="ltr"]) #feature .wrapper { padding-left: 1em; padding-right: 23em; }
:where(body[dir="rtl"]) #feature .wrapper { padding-left: 23em; padding-right: 1em; }
@media screen and (max-width: 960px) {
#container .wrapper { padding-right: 23em; }
:where(body[dir="ltr"]) #container .wrapper { padding-right: 23em; }
:where(body[dir="rtl"]) #container .wrapper { padding-left: 23em; }
}
@media screen and (max-width: 800px) {
#feature .wrapper, #container .wrapper { padding-right: 1em; }
:where(body[dir="ltr"]) :is(#feature .wrapper, #container .wrapper) { padding-right: 1em; }
:where(body[dir="rtl"]) :is(#feature .wrapper, #container .wrapper) { padding-left: 1em; }
}
/* Links
@ -349,10 +360,11 @@ a, a:link, a:visited {
margin: 0;
padding: 0;
list-style: none;
float: right;
margin-top: 1.5em;
font-size: 1.2857em;
}
:where(body[dir="ltr"]) .nav { float: right; }
:where(body[dir="rtl"]) .nav { float: left; }
.nav .nav-item {color: #FFF; text-decoration: none;}
.nav .nav-item:hover {text-decoration: underline;}
@ -368,28 +380,34 @@ a, a:link, a:visited {
}
.guides-index .guides-index-item {
background: #980905 url(../images/nav_arrow.gif) no-repeat right top;
padding-right: 1em;
background: #980905 url(../images/nav_arrow.gif) no-repeat;
position: relative;
z-index: 15;
padding-bottom: 0.125em;
}
:where(body[dir="ltr"]) .guides-index .guides-index-item { background-position: right top; padding-right: 1em; }
:where(body[dir="rtl"]) .guides-index .guides-index-item { background-position: left top; padding-left: 1em; }
.guides-index:hover .guides-index-item, .guides-index .guides-index-item:hover {
background-position: right -81px;
.guides-index:hover .guides-index-item {
text-decoration: underline !important;
}
:where(body[dir="ltr"]) .guides-index:hover .guides-index-item { background-position: right -81px; }
:where(body[dir="rtl"]) .guides-index:hover .guides-index-item { background-position: left -81px; }
@media screen and (min-width: 481px) {
.nav {
float: right;
margin-top: 1.5em;
font-size: 1.2857em;
}
:where(body[dir="ltr"]) .nav { float: right; }
:where(body[dir="rtl"]) .nav { float: left; }
.nav>li {
display: inline;
margin-left: 0.5em;
}
:where(body[dir="ltr"]) .nav>li { margin-left: 0.5em; }
:where(body[dir="rtl"]) .nav>li { margin-right: 0.5em; }
.guides-index.guides-index-small {
display: none;
}
@ -426,11 +444,13 @@ a, a:link, a:visited {
}
.guides-index-small .guides-index-item {
font: inherit;
padding-left: .75em;
font-size: .95em;
background-position: 96% 16px;
-webkit-appearance: none;
}
:where(body[dir="ltr"]) .guides-index-small .guides-index-item { padding-left: .75em; }
:where(body[dir="rtl"]) .guides-index-small .guides-index-item { padding-right: .75em; }
.guides-index-small .guides-index-item:hover{
background-position: 96% -65px;
}
@ -446,9 +466,10 @@ a, a:link, a:visited {
position: absolute;
z-index: 10;
top: -0.25em;
right: 0;
padding-top: 2em;
}
:where(body[dir="ltr"]) #guides { right: 0; }
:where(body[dir="rtl"]) #guides { left: 0; }
#guides.visible {
display: block !important;
@ -569,17 +590,20 @@ h6 {
margin: 0 2em 2em 0;
}
#topNav strong {color: #999; margin-right: 0.5em;}
#topNav strong { color: #999; }
:where(body[dir="ltr"]) #topNav strong { margin-right: 0.5em; }
:where(body[dir="rtl"]) #topNav strong { margin-left: 0.5em; }
#topNav strong a {color: #FFF;}
#header h1 {
float: left;
background: url(../images/rails_guides_logo_1x.png) no-repeat;
width: 297px;
text-indent: -9999em;
margin: 0;
padding: 0;
}
:where(body[dir="ltr"]) #header h1 { float: left; }
:where(body[dir="rtl"]) #header h1 { float: right; }
@media
only screen and (-webkit-min-device-pixel-ratio: 2),
@ -617,23 +641,26 @@ only screen and ( min-resolution: 2dppx) {
}
}
#feature ul {margin-left: 0;}
:where(body[dir="ltr"]) #feature ul { margin-left: 0; }
:where(body[dir="rtl"]) #feature ul { margin-right: 0; }
#feature ul li {
list-style: none;
background: url(../images/check_bullet.gif) no-repeat left 0.5em;
background: url(../images/check_bullet.gif) no-repeat;
padding: 0.5em 1.75em 0.5em 1.75em;
font-size: 1.1428em;
font-weight: bold;
}
:where(body[dir="ltr"]) #feature ul li { background-position: left 0.5em }
:where(body[dir="rtl"]) #feature ul li { background-position: right 0.5em }
#mainCol dd, #subCol dd {
padding: 0.25em 0 1em;
border-bottom: 1px solid #CCC;
margin-bottom: 1em;
margin-left: 0;
/*padding-left: 28px;*/
padding-left: 0;
}
:where(body[dir="ltr"]) :is(#mainCol dd, #subCol dd) { margin-left: 0; padding-left: 0; }
:where(body[dir="rtl"]) :is(#mainCol dd, #subCol dd) { margin-right: 0; padding-right: 0; }
#mainCol dt, #subCol dt {
font-size: 1.2857em;
@ -651,25 +678,28 @@ only screen and ( min-resolution: 2dppx) {
background: #fff9d8 url(../images/tab_yellow.gif) no-repeat left top;
border: none;
padding: 1.25em 1em 1.25em 48px;
margin-left: 0;
margin-top: 0.25em;
}
:where(body[dir="ltr"]) :is(#mainCol dd.work-in-progress, #subCol dd.work-in-progress) { margin-left: 0; }
:where(body[dir="rtl"]) :is(#mainCol dd.work-in-progress, #subCol dd.work-in-progress) { margin-right: 0; }
#mainCol dd.kindle, #subCol dd.kindle {
background: #d5e9f6 url(../images/tab_info.gif) no-repeat left top;
border: none;
padding: 1.25em 1em 1.25em 48px;
margin-left: 0;
margin-top: 0.25em;
}
:where(body[dir="ltr"]) :is(#mainCol dd.kindle, #subCol dd.kindle) { margin-left: 0; }
:where(body[dir="rtl"]) :is(#mainCol dd.kindle, #subCol dd.kindle) { margin-right: 0; }
#mainCol div.warning, #subCol dd.warning {
background: #f9d9d8 url(../images/tab_red.gif) no-repeat left top;
border: none;
padding: 1.25em 1.25em 0.25em 48px;
margin-left: 0;
margin-top: 0.25em;
}
:where(body[dir="ltr"]) :is(#mainCol div.warning, #subCol dd.warning) { margin-left: 0; }
:where(body[dir="rtl"]) :is(#mainCol div.warning, #subCol dd.warning) { margin-right: 0; }
#subCol .chapters {color: #980905;}
#subCol .chapters a {font-weight: bold;}
@ -677,44 +707,59 @@ only screen and ( min-resolution: 2dppx) {
#subCol .chapters li {margin-bottom: 0.75em;}
#subCol h3.chapter {margin-top: 0.25em;}
#subCol h3.chapter img {vertical-align: text-bottom;}
#subCol .chapters ul {margin-left: 0; margin-top: 0.5em;}
#subCol .chapters ul { margin-top: 0.5em; }
:where(body[dir="ltr"]) #subCol .chapters ul { margin-left: 0; }
:where(body[dir="rtl"]) #subCol .chapters ul { margin-right: 0; }
#subCol .chapters ul li {
list-style: none;
padding: 0 0 0 1em;
background: url(../images/bullet.gif) no-repeat left 0.45em;
margin-left: 0;
padding: 0;
background: url(../images/bullet.gif) no-repeat;
font-size: 1em;
font-weight: normal;
}
:where(body[dir="ltr"]) #subCol .chapters ul li { background-position: left 0.45em; padding-left: 1em; margin-left: 0; }
:where(body[dir="rtl"]) #subCol .chapters ul li { background-position: right 0.45em; padding-right: 1em; margin-right: 0; }
#subCol li ul, li ol { margin:0 1.5em; }
div.code_container {
background: #EEE url(../images/tab_grey.gif) no-repeat left top;
padding: 0.25em 1em 0.5em 48px;
background: #EEE url(../images/tab_grey.gif) no-repeat;
padding-top: 0.25em;
padding-bottom: 0.5em;
position: relative;
}
:where(body[dir="ltr"]) div.code_container { background-position: left top; padding-right: 1em; padding-left: 48px; }
:where(body[dir="rtl"]) div.code_container { background-position: right top; padding-right: 48px; padding-left: 1em; }
.note {
background: #fff9d8 url(../images/tab_note.gif) no-repeat left top;
background: #fff9d8 url(../images/tab_note.gif) no-repeat;
border: none;
padding: 1em 1em 0.25em 48px;
padding-top: 1em;
padding-bottom: 0.25em;
margin: 0.25em 0 1.5em 0;
}
:where(body[dir="ltr"]) .note { background-position: left top; padding-right: 1em; padding-left: 48px; }
:where(body[dir="rtl"]) .note { background-position: right top; padding-right: 48px; padding-left: 1em; }
.info {
background: #d5e9f6 url(../images/tab_info.gif) no-repeat left top;
background: #d5e9f6 url(../images/tab_info.gif) no-repeat;
border: none;
padding: 1em 1em 0.25em 48px;
padding-top: 1em;
padding-bottom: 0.25em;
margin: 0.25em 0 1.5em 0;
}
:where(body[dir="ltr"]) .info { background-position: left top; padding-right: 1em; padding-left: 48px; }
:where(body[dir="rtl"]) .info { background-position: right top; padding-right: 48px; padding-left: 1em; }
#mainCol div.todo {
background: #fff9d8 url(../images/tab_yellow.gif) no-repeat left top;
background: #fff9d8 url(../images/tab_yellow.gif) no-repeat;
border: none;
padding: 1em 1em 0.25em 48px;
padding-top: 1em;
padding-bottom: 0.25em;
margin: 0.25em 0 1.5em 0;
}
:where(body[dir="ltr"]) #mainCol div.todo { background-position: left top; padding-right: 1em; padding-left: 48px; }
:where(body[dir="rtl"]) #mainCol div.todo { background-position: right top; padding-right: 48px; padding-left: 1em; }
.note code, .info code, .todo code {
background: #fff;
@ -722,10 +767,10 @@ div.code_container {
#mainCol ul li {
list-style:none;
background: url(../images/grey_bullet.gif) no-repeat left 0.5em;
padding-left: 1em;
margin-left: 0;
background: url(../images/grey_bullet.gif) no-repeat;
}
:where(body[dir="ltr"]) #mainCol ul li { background-position: left 0.5em; padding-left: 1em; margin-left: 0; }
:where(body[dir="rtl"]) #mainCol ul li { background-position: right 0.5em; padding-right: 1em; margin-right: 0; }
#subCol .content {
font-size: 0.7857em;

View file

@ -1,791 +0,0 @@
/* Guides.rubyonrails.org */
/* Main.css */
/* Created January 30, 2009 */
/* Modified February 8, 2009
--------------------------------------- */
/* General
--------------------------------------- */
.right {float: right; margin-left: 1em;}
.left {float: left; margin-right: 1em;}
@media screen and (max-width: 480px) {
.right, .left { float: none; }
}
.small {font-size: smaller;}
.large {font-size: larger;}
.hide {display: none;}
ul, ol { margin: 0 1.5em 1.5em 1.5em; }
ul { list-style-type: disc; }
ol { list-style-type: decimal; }
dl { margin: 0 0 1.5em 0; }
dl dt { font-weight: bold; }
dd { margin-right: 1.5em;}
pre, code {
font-size: 1em;
font-family: "Anonymous Pro", "Inconsolata", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
line-height: 1.5;
margin: 1em 0;
overflow: auto;
color: #222;
}
p code, ul code {
background: #eee;
border-radius: 2px;
padding: 1px 3px;
}
pre, tt, code {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
abbr, acronym { border-bottom: 1px dotted #666; }
address { margin: 0 0 1.5em; font-style: italic; }
del { color:#666; }
blockquote { margin: 1.5em; color: #666; font-style: italic; }
strong { font-weight: bold; }
em, dfn { font-style: italic; }
dfn { font-weight: bold; }
sup, sub { line-height: 0; }
p {margin: 0 0 1.5em;}
label { font-weight: bold; }
fieldset { padding:1.4em; margin: 0 0 1.5em 0; border: 1px solid #ccc; }
legend { font-weight: bold; font-size:1.2em; }
input.text, input.title,
textarea, select {
margin:0.5em 0;
border:1px solid #bbb;
}
table {
margin: 0 0 1.5em;
background: #FFF;
border-collapse: collapse;
}
tbody, thead {
border: 2px solid #CCC;
}
table th, table td {
padding: 9px 10px;
border: 1px solid #CCC;
border-collapse: collapse;
}
table th {
border-bottom: 2px solid #CCC;
background: #EEE;
font-weight: bold;
}
@media only screen and (max-width: 480px) {
table {
display: block;
overflow-x: auto;
}
td {
min-width: 7em;
}
}
img {
max-width: 100%;
}
/* Structure and Layout
--------------------------------------- */
body {
text-align: center;
font-family: Helvetica, Arial, sans-serif;
font-size: 87.5%;
line-height: 1.5;
background: #fff;
color: #999;
direction: rtl;
}
.wrapper {
text-align: right;
margin: 0 auto;
max-width: 960px;
padding: 0 1em;
}
.red-button {
display: inline-block;
border-top: 1px solid rgba(255,255,255,.5);
background: #751913;
background: -webkit-gradient(linear, right top, right bottom, from(#c52f24), to(#751913));
background: -webkit-linear-gradient(top, #c52f24, #751913);
background: -moz-linear-gradient(top, #c52f24, #751913);
background: -ms-linear-gradient(top, #c52f24, #751913);
background: -o-linear-gradient(top, #c52f24, #751913);
padding: 9px 18px;
-webkit-border-radius: 11px;
-moz-border-radius: 11px;
border-radius: 11px;
-webkit-box-shadow: rgba(0,0,0,1) 0 1px 0;
-moz-box-shadow: rgba(0,0,0,1) 0 1px 0;
box-shadow: rgba(0,0,0,1) 0 1px 0;
text-shadow: rgba(0,0,0,.4) 0 1px 0;
color: white;
font-size: 15px;
font-family: Helvetica, Arial, Sans-Serif;
text-decoration: none;
vertical-align: middle;
cursor: pointer;
}
.red-button:active {
border-top: none;
padding-top: 10px;
background: -webkit-gradient(linear, right top, right bottom, from(#751913), to(#c52f24));
background: -webkit-linear-gradient(top, #751913, #c52f24);
background: -moz-linear-gradient(top, #751913, #c52f24);
background: -ms-linear-gradient(top, #751913, #c52f24);
background: -o-linear-gradient(top, #751913, #c52f24);
}
#topNav {
padding: 1em 0;
color: #565656;
background: #222;
}
.s-hidden {
display: none;
}
@media screen and (min-width: 1025px) {
.more-info-button {
display: none;
}
.more-info-links {
list-style: none;
display: inline;
margin: 0;
}
.more-info {
display: inline-block;
}
.more-info:after {
content: " |";
color: #8a8a8a;
}
.more-info:last-child:after {
content: "";
}
#topNav a, #footer a {
color: #F1938C;
}
}
@media screen and (max-width: 1024px) {
#topNav .wrapper { text-align: center; }
.more-info-button {
position: relative;
z-index: 25;
}
.more-info-label {
display: none;
}
.more-info-container {
position: absolute;
top: .5em;
z-index: 20;
margin: 0 auto;
right: 0;
left: 0;
width: 20em;
}
.more-info-links {
display: block;
list-style: none;
background-color: #c52f24;
border-radius: 5px;
padding-top: 5.25em;
border: 1px #980905 solid;
}
.more-info-links.s-hidden {
display: none;
}
.more-info {
padding: .75em;
border-top: 1px #980905 solid;
}
.more-info a, .more-info a:link, .more-info a:visited {
display: block;
color: white;
width: 100%;
height: 100%;
text-decoration: none;
text-transform: uppercase;
}
}
.clipboard-button {
background: #dbdbdb;
border: 0;
border-radius: 5px;
padding: 2px 10px;
position: absolute;
bottom: 2px;
right: 2px
}
.clipboard-button:active {
background: #ccc;
}
#header {
background: #c52f24 url(../images/header_tile.gif) repeat-x;
color: #FFF;
padding: 1.5em 0;
z-index: 99;
}
#feature {
background: #d5e9f6 url(../images/feature_tile.gif) repeat-x;
color: #333;
padding: 0.5em 0 1.5em;
}
#container {
color: #333;
padding: 0.5em 0 1.5em 0;
}
#mainCol {
max-width: 630px;
}
#subCol {
position: absolute;
z-index: 0;
top: 21px;
left: 0;
background: #FFF;
padding: 1em 1.5em 1em 1.25em;
width: 20em;
font-size: 0.9285em;
line-height: 1.3846;
margin-left: 1em;
}
@media screen and (max-width: 800px) {
#subCol {
position: static;
width: inherit;
margin-right: -1em;
margin-left: -1em;
padding-left: 1.25em;
}
}
#footer {
padding: 2em 0;
background: #222 url(../images/footer_tile.gif) repeat-x;
}
#footer .wrapper {
padding-right: 1em;
max-width: 960px;
}
#footer p:last-child {
margin-bottom: 0;
}
#header .wrapper, #topNav .wrapper, #feature .wrapper {padding-right: 1em; max-width: 960px;}
#feature .wrapper {max-width: 720px; padding-left: 23em; position: relative; z-index: 0;}
@media screen and (max-width: 960px) {
#container .wrapper { padding-left: 23em; }
}
@media screen and (max-width: 800px) {
#feature .wrapper, #container .wrapper { padding-left: 1em; }
}
/* Links
--------------------------------------- */
a, a:link, a:visited {
color: #ee3f3f;
text-decoration: underline;
}
#mainCol a, #subCol a, #feature a {color: #980905;}
#mainCol a code, #subCol a code, #feature a code {color: #980905;}
#mainCol a.anchorlink, #mainCol a.anchorlink code {color: #333;}
#mainCol a.anchorlink { text-decoration: none; }
#mainCol a.anchorlink:hover { text-decoration: underline; }
/* Navigation
--------------------------------------- */
.nav {
margin: 0;
padding: 0;
list-style: none;
float: left;
margin-top: 1.5em;
font-size: 1.2857em;
}
.nav .nav-item {color: #FFF; text-decoration: none;}
.nav .nav-item:hover {text-decoration: underline;}
.guides-index-large, .guides-index-small .guides-index-item {
padding: 0.5em 1.5em;
border-radius: 1em;
-webkit-border-radius: 1em;
-moz-border-radius: 1em;
background: #980905;
position: relative;
color: white;
}
.guides-index .guides-index-item {
background: #980905 url(../images/nav_arrow.gif) no-repeat left top;
padding-left: 1em;
position: relative;
z-index: 15;
padding-bottom: 0.125em;
}
.guides-index:hover .guides-index-item, .guides-index .guides-index-item:hover {
background-position: left -81px;
text-decoration: underline !important;
}
@media screen and (min-width: 481px) {
.nav {
float: left;
margin-top: 1.5em;
font-size: 1.2857em;
}
.nav>li {
display: inline;
margin-right: 0.5em;
}
.guides-index.guides-index-small {
display: none;
}
}
@media screen and (max-width: 480px) {
.nav {
float: none;
width: 100%;
text-align: center;
}
.nav .nav-item {
display: block;
margin: 0;
width: 100%;
background-color: #980905;
border: solid 1px #620c04;
border-top: 0;
padding: 15px 0;
text-align: center;
}
.nav .nav-item, .nav-item.guides-index-item {
text-transform: uppercase;
}
.nav .nav-item:first-child, .nav-item.guides-index-small {
border-top: solid 1px #620c04;
}
.guides-index.guides-index-small {
display: block;
margin-top: 1.5em;
}
.guides-index.guides-index-large {
display: none;
}
.guides-index-small .guides-index-item {
font: inherit;
padding-right: .75em;
font-size: .95em;
background-position: 96% 16px;
-webkit-appearance: none;
}
.guides-index-small .guides-index-item:hover{
background-position: 96% -65px;
}
}
#guides {
width: 37em;
display: block;
background: #980905;
border-radius: 1em;
color: #f1938c;
padding: 1.5em 2em;
position: absolute;
z-index: 10;
top: -0.25em;
left: 0;
padding-top: 2em;
}
#guides.visible {
display: block !important;
}
.guides-section dt, .guides-section dd {
font-weight: normal;
font-size: 0.722em;
margin: 0;
padding: 0;
}
.guides-section dt {
margin: 0.5em 0 0;
padding:0;
}
#guides a {
background: none !important;
color: #FFF;
text-decoration: none;
}
#guides a:hover {
text-decoration: underline;
}
.guides-section-container {
display: flex;
flex-direction: column;
flex-wrap: wrap;
width: 100%;
max-height: 35em;
}
.guides-section {
min-width: 5em;
margin: 0 2em 0.5em 0;
flex: auto;
max-width: 12em;
}
.guides-section dd {
line-height: 1.3;
margin-bottom: 0.5em;
}
#guides hr {
display: block;
border: none;
height: 1px;
color: #f1938c;
background: #f1938c;
}
/* Headings
--------------------------------------- */
h1 {
font-size: 2.5em;
line-height: 1;
margin: 0.6em 0 .2em;
font-weight: bold;
}
h2 {
font-size: 2.1428em;
line-height: 1;
margin: 0.7em 0 .2333em;
font-weight: bold;
}
@media screen and (max-width: 480px) {
h2 {
font-size: 1.45em;
}
}
h3 {
font-size: 1.7142em;
line-height: 1.286;
margin: 0.875em 0 0.2916em;
font-weight: bold;
}
@media screen and (max-width: 480px) {
h3 {
font-size: 1.45em;
}
}
h4 {
font-size: 1.2857em;
line-height: 1.2;
margin: 1.6667em 0 .3887em;
font-weight: bold;
}
h5 {
font-size: 1em;
line-height: 1.5;
margin: 1em 0 .5em;
font-weight: bold;
}
h6 {
font-size: 1em;
line-height: 1.5;
margin: 1em 0 .5em;
font-weight: normal;
}
.section {
padding-bottom: 0.25em;
border-bottom: 1px solid #999;
}
/* Content
--------------------------------------- */
.pic {
margin: 0 2em 2em 0;
}
#topNav strong {color: #999; margin-left: 0.5em;}
#topNav strong a {color: #FFF;}
#header h1 {
float: right;
background: url(../images/rails_guides_logo_1x.png) no-repeat;
width: 297px;
text-indent: -9999em;
margin: 0;
padding: 0;
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and ( min--moz-device-pixel-ratio: 2),
only screen and ( -o-min-device-pixel-ratio: 2/1),
only screen and ( min-device-pixel-ratio: 2),
only screen and ( min-resolution: 192dpi),
only screen and ( min-resolution: 2dppx) {
#header h1 {
background: url(../images/rails_guides_logo_2x.png) no-repeat;
background-size: 160%;
}
}
@media screen and (max-width: 480px) {
#header h1 {
float: none;
}
}
#header h1 a {
text-decoration: none;
display: block;
height: 77px;
}
#feature p {
font-size: 1.2857em;
margin-bottom: 0.75em;
}
@media screen and (max-width: 480px) {
#feature p {
font-size: 1em;
}
}
#feature ul {margin-right: 0;}
#feature ul li {
list-style: none;
background: url(../images/check_bullet.gif) no-repeat right 0.5em;
padding: 0.5em 1.75em 0.5em 1.75em;
font-size: 1.1428em;
font-weight: bold;
}
#mainCol dd, #subCol dd {
padding: 0.25em 0 1em;
border-bottom: 1px solid #CCC;
margin-bottom: 1em;
margin-right: 0;
/*padding-right: 28px;*/
padding-right: 0;
}
#mainCol dt, #subCol dt {
font-size: 1.2857em;
padding: 0.125em 0 0.25em 0;
margin-bottom: 0;
}
@media screen and (max-width: 480px) {
#mainCol dt, #subCol dt {
font-size: 1em;
}
}
#mainCol dd.work-in-progress, #subCol dd.work-in-progress {
background: #fff9d8 url(../images/tab_yellow.gif) no-repeat left top;
border: none;
padding: 1.25em 1em 1.25em 48px;
margin-right: 0;
margin-top: 0.25em;
}
#mainCol dd.kindle, #subCol dd.kindle {
background: #d5e9f6 url(../images/tab_info.gif) no-repeat left top;
border: none;
padding: 1.25em 1em 1.25em 48px;
margin-right: 0;
margin-top: 0.25em;
}
#mainCol div.warning, #subCol dd.warning {
background: #f9d9d8 url(../images/tab_red.gif) no-repeat left top;
border: none;
padding: 1.25em 1.25em 0.25em 48px;
margin-right: 0;
margin-top: 0.25em;
}
#subCol .chapters {color: #980905;}
#subCol .chapters a {font-weight: bold;}
#subCol .chapters ul a {font-weight: normal;}
#subCol .chapters li {margin-bottom: 0.75em;}
#subCol h3.chapter {margin-top: 0.25em;}
#subCol h3.chapter img {vertical-align: text-bottom;}
#subCol .chapters ul {margin-right: 0; margin-top: 0.5em;}
#subCol .chapters ul li {
list-style: none;
padding: 0 1em 0 0;
background: url(../images/bullet.gif) no-repeat right 0.45em;
margin-right: 0;
font-size: 1em;
font-weight: normal;
}
#subCol li ul, li ol { margin:0 1.5em; }
div.code_container {
background: #EEE url(../images/tab_grey.gif) no-repeat right top;
padding: 0.25em 48px 0.5em 1em;
position: relative;
}
.note {
background: #fff9d8 url(../images/tab_note.gif) no-repeat right top;
border: none;
padding: 1em 48px 0.25em 1em;
margin: 0.25em 0 1.5em 0;
}
.info {
background: #d5e9f6 url(../images/tab_info.gif) no-repeat right top;
border: none;
padding: 1em 48px 0.25em 1em;
margin: 0.25em 0 1.5em 0;
}
#mainCol div.todo {
background: #fff9d8 url(../images/tab_yellow.gif) no-repeat right top;
border: none;
padding: 1em 48px 0.25em 1em;
margin: 0.25em 0 1.5em 0;
}
.note code, .info code, .todo code {
background: #fff;
}
#mainCol ul li {
list-style:none;
background: url(../images/grey_bullet.gif) no-repeat right 0.5em;
padding-right: 1em;
margin-right: 0;
}
#subCol .content {
font-size: 0.7857em;
line-height: 1.5;
}
#subCol .content li {
font-weight: normal;
background: none;
padding: 0 0 1em;
font-size: 1.1667em;
}
/* Clearing
--------------------------------------- */
.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
* html .clearfix {height: 1%;}
.clearfix {display: block;}
/* Same bottom margin for special boxes than for regular paragraphs, this way
intermediate whitespace looks uniform. */
div.code_container, div.important, div.caution, div.warning, div.note, div.info {
margin-bottom: 1.5em;
}
/* Remove bottom margin of paragraphs in special boxes, otherwise they get a
spurious blank area below with the box background. */
div.important p, div.caution p, div.warning p, div.note p, div.info p {
margin-bottom: 1em;
}
/* When triple-clicking console code, select only the command, not the prompt */
code.highlight.console span.w, code.highlight.irb span.w {
display: table-cell;
}
/* Version Badge
--------------------------------------- */
#version-badge {
position: fixed;
right: 0;
top: 0;
z-index: 100;
color: white;
font-size: 30px;
transform: rotate(45deg) translate(27.5%, -40%);
min-width: 200px;
font-weight: bold;
font-style: italic;
box-shadow: 0px 2px 2px 1px #1209096e;
text-shadow: 2px 2px 4px #5400007d;
background: radial-gradient(circle, rgb(255, 10, 0) 0%, rgb(200, 0, 0) 90%);
}

View file

@ -15,14 +15,14 @@ module RailsGuides
class Generator
GUIDES_RE = /\.(?:erb|md)\z/
def initialize(edge:, version:, all:, only:, kindle:, language:, direction: "ltr")
def initialize(edge:, version:, all:, only:, kindle:, language:, direction: nil)
@edge = edge
@version = version
@all = all
@only = only
@kindle = kindle
@language = language
@direction = direction
@direction = direction || "ltr"
if @kindle
check_for_kindlegen
@ -114,14 +114,6 @@ module RailsGuides
def copy_assets
FileUtils.cp_r(Dir.glob("#{@guides_dir}/assets/*"), @output_dir)
if @direction == "rtl"
overwrite_css_with_right_to_left_direction
end
end
def overwrite_css_with_right_to_left_direction
FileUtils.mv("#{@output_dir}/stylesheets/main.rtl.css", "#{@output_dir}/stylesheets/main.css")
end
def output_file_for(guide)
@ -152,7 +144,8 @@ module RailsGuides
edge: @edge,
version: @version,
mobi: "kindle/#{mobi}",
language: @language
language: @language,
direction: @direction,
)
view.extend(Helpers)

View file

@ -19,7 +19,7 @@
<meta property="og:image" content="https://avatars.githubusercontent.com/u/4223" />
<meta property="og:type" content="website" />
</head>
<body class="guide">
<body dir="<%= @direction %>" class="guide">
<% if badge_version = @edge ? "edge" : @version %>
<div>
<div id="version-badge"><%= badge_version %></div>