_components.page.scss 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /**
  2. * Styling for textbook pages. Jupyter notebooks generate their own HTML markup
  3. * which we style under the #ipython-notebook selector.
  4. *
  5. * Most of the textbook content is styled using this component.
  6. *
  7. * [1]: Within-textbook__page layout
  8. * [2]: Since we use JS to focus the page on load, hide the outline to avoid
  9. * visual cruft.
  10. *
  11. * Notebook styling:
  12. *
  13. * [4]: Some tables are too wide for the page on smaller screens so we let the
  14. * user scroll horizontally.
  15. * [5]: Inline code snippets (usually variable names) should have a gray bg.
  16. */
  17. /**
  18. * [1] Within-textbook__page layout
  19. */
  20. div.jb_cell {
  21. width: 100%;
  22. position: relative;
  23. @include mq($from: laptop) {
  24. width: $textbook-page-with-sidebar-width;
  25. }
  26. // Add some empty space before headers for anchor links
  27. h1, h2, h3, h4, h5 {
  28. &:before {
  29. display: block;
  30. content: " ";
  31. margin-top: -80px;
  32. height: 80px;
  33. visibility: hidden;
  34. pointer-events: none;
  35. }
  36. }
  37. }
  38. #page-title {
  39. font-size: 4em;
  40. font-weight: lighter;
  41. line-height: 1em;
  42. }
  43. #page-author {
  44. font-size: 1.75em;
  45. margin-bottom: 20px;
  46. padding-left: 5px;
  47. }
  48. // Right margin
  49. div.jb_cell {
  50. &.tag_popout {
  51. .cell {
  52. border-left: 3px solid #c3c3c3;
  53. padding-left: 5%
  54. }
  55. // On laptops, pop out to the right instead of in-line
  56. @include mq($from: laptop) {
  57. width: calc(100% - #{$textbook-page-with-sidebar-width});
  58. font-size: .8em;
  59. position: relative;
  60. float: right;
  61. padding-left: $spacing-unit-large * .8;
  62. clear: both;
  63. h1, h2, h3, h4, h5, h6 {
  64. margin: .5em 0px 0px 0px;
  65. }
  66. // This prevents *sequential* popouts from creating a bunch of white-space when stacked
  67. & + div.tag_popout {
  68. height: 0px;
  69. }
  70. // Remove the border when we pop-out to the right
  71. .cell {
  72. border-left: none;
  73. padding-left: 0;
  74. }
  75. }
  76. }
  77. &.tag_full_width {
  78. width: 100%;
  79. img {
  80. max-width: 100%;
  81. }
  82. }
  83. }
  84. /**
  85. * Jupyter notebook styling
  86. */
  87. div.highlighter-rouge {
  88. // Ensures that items within this div can be positioned absolutely
  89. position: relative;
  90. }
  91. div.inner_cell div.highlight > pre,
  92. div.highlighter-rouge > div.highlight > pre,
  93. div.output_wrapper pre {
  94. background-color: $color-light-gray;
  95. font-size: 0.9em;
  96. margin-bottom: $spacing-unit-small;
  97. padding: $spacing-unit-small;
  98. overflow-x: auto;
  99. border: 1px solid $color-dark-gray;
  100. }
  101. // If we've got intentionally non-highlighted markup, make sure that the lines wrap
  102. pre code.language-no-highlight {
  103. white-space: pre-wrap;
  104. }
  105. div.output_wrapper {
  106. margin-bottom: $spacing-unit-small;
  107. }
  108. div.output_wrapper pre {
  109. border: 1px solid $color-light-gray !important;
  110. background-color: #fcfcfc !important;
  111. }
  112. .output_html {
  113. /* [4] */
  114. overflow-x: auto;
  115. }
  116. /* [5] */
  117. code {
  118. padding: 4px;
  119. overflow-x: auto;
  120. @include inuit-font-size(14px);
  121. }
  122. pre.highlight code {
  123. display: block;
  124. }
  125. /* Outputs */
  126. .output_stream,
  127. .output_data_text,
  128. .output_traceback_line {
  129. margin-left: 2% !important;
  130. border: none !important;
  131. border-radius: 4px !important;
  132. background-color: #fafafa !important;
  133. box-shadow: none !important;
  134. }
  135. .output_stream:before,
  136. .output_data_text:before,
  137. .output_traceback_line:before {
  138. content: none !important;
  139. }
  140. .output_text pre {
  141. background-color: #f8f8fb !important;
  142. }
  143. .output_html,
  144. .output_png::before {
  145. padding: 1em 1.5em !important;
  146. }
  147. .output_png img,
  148. p img {
  149. max-width: 500px;
  150. display: block;
  151. margin-left: auto;
  152. margin-right: auto;
  153. }
  154. .output_png img {
  155. width: 100% !important;
  156. }
  157. .hl-ipython3 pre::before,
  158. .output_subarea pre::before,
  159. .output_html::before,
  160. .output_png::before {
  161. color: #ccc !important;
  162. float: left !important;
  163. margin-bottom: 0.25em !important;
  164. width: 100% !important;
  165. }
  166. /**
  167. * nbinteract styling
  168. */
  169. .cell.nbinteract-left {
  170. width: 50%;
  171. float: left;
  172. }
  173. .cell.nbinteract-right {
  174. width: 50%;
  175. float: right;
  176. }
  177. .cell.nbinteract-hide_in > .input {
  178. display: none;
  179. }
  180. .cell.nbinteract-hide_out > .output_wrapper {
  181. display: none;
  182. }
  183. .cell:after {
  184. content: '';
  185. display: table;
  186. clear: both;
  187. }
  188. div.output_subarea {
  189. max-width: initial;
  190. }
  191. .jp-OutputPrompt {
  192. display: none;
  193. }
  194. // Quotation cells
  195. // Default
  196. blockquote {
  197. margin: $spacing-unit-small;
  198. border-left: 4px solid $color-dark-gray;
  199. padding: $spacing-unit-tiny $spacing-unit-med;
  200. p {
  201. margin-bottom: $spacing-unit-small;
  202. }
  203. ul, ol {
  204. margin-bottom: $spacing-unit-tiny;
  205. }
  206. // This should only trigger if the last child of a blockquote is an ul/ol
  207. > :last-child li {
  208. text-align: right;
  209. list-style-type: none;
  210. margin: none;
  211. padding-right: 5%;
  212. &:before {
  213. content: "—";
  214. padding-right: 10px;
  215. }
  216. }
  217. }
  218. // Epigraph adds new styling
  219. div.jb_cell.tag_epigraph blockquote {
  220. font-style: italic;
  221. font-size: 1.2em;
  222. width: 90%;
  223. margin-left: auto;
  224. margin-right: auto;
  225. border-left: none;
  226. ul {
  227. font-style: normal;
  228. }
  229. }