_components.textbook__page.scss 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. }
  27. // Right margin
  28. div.jb_cell {
  29. &.tag_popout {
  30. .cell {
  31. border-left: 3px solid #c3c3c3;
  32. padding-left: 5%
  33. }
  34. // On laptops, pop out to the right instead of in-line
  35. @include mq($from: laptop) {
  36. width: calc(100% - #{$textbook-page-with-sidebar-width});
  37. font-size: .8em;
  38. position: relative;
  39. float: right;
  40. padding-left: $spacing-unit-large * .8;
  41. clear: both;
  42. h1, h2, h3, h4, h5, h6 {
  43. margin: .5em 0px 0px 0px;
  44. }
  45. // This prevents *sequential* popouts from creating a bunch of white-space when stacked
  46. & + div.tag_popout {
  47. height: 0px;
  48. }
  49. // Remove the border when we pop-out to the right
  50. .cell {
  51. border-left: none;
  52. padding-left: 0;
  53. }
  54. }
  55. }
  56. &.tag_full_width {
  57. width: 100%;
  58. img {
  59. max-width: 100%;
  60. }
  61. }
  62. }
  63. /**
  64. * Jupyter notebook styling
  65. */
  66. div.highlighter-rouge {
  67. // Ensures that items within this div can be positioned absolutely
  68. position: relative;
  69. }
  70. div.inner_cell div.highlight > pre,
  71. div.highlighter-rouge > div.highlight > pre,
  72. div.output_wrapper pre {
  73. background-color: $color-light-gray;
  74. font-size: 0.9em;
  75. margin-bottom: $spacing-unit-small;
  76. padding: $spacing-unit-small;
  77. overflow-x: auto;
  78. border: 1px solid $color-dark-gray;
  79. }
  80. // If we've got intentionally non-highlighted markup, make sure that the lines wrap
  81. pre code.language-no-highlight {
  82. white-space: pre-wrap;
  83. }
  84. div.output_wrapper {
  85. margin-bottom: $spacing-unit-small;
  86. }
  87. div.output_wrapper pre {
  88. border: 1px solid $color-light-gray !important;
  89. background-color: #fcfcfc !important;
  90. }
  91. .output_html {
  92. /* [4] */
  93. overflow-x: auto;
  94. }
  95. /* [5] */
  96. code {
  97. padding: 4px;
  98. overflow-x: auto;
  99. @include inuit-font-size(14px);
  100. }
  101. pre.highlight code {
  102. display: block;
  103. }
  104. blockquote {
  105. margin: $spacing-unit-small;
  106. padding: $spacing-unit-med;
  107. border-left: 4px solid $color-dark-gray;
  108. p:last-child {
  109. margin-bottom: 0;
  110. }
  111. }
  112. /* Outputs */
  113. .output_stream,
  114. .output_data_text,
  115. .output_traceback_line {
  116. margin-left: 2% !important;
  117. border: none !important;
  118. border-radius: 4px !important;
  119. background-color: #fafafa !important;
  120. box-shadow: none !important;
  121. }
  122. .output_stream:before,
  123. .output_data_text:before,
  124. .output_traceback_line:before {
  125. content: none !important;
  126. }
  127. .output_text pre {
  128. background-color: #f8f8fb !important;
  129. }
  130. .output_html,
  131. .output_png::before {
  132. padding: 1em 1.5em !important;
  133. }
  134. .output_png img,
  135. p img {
  136. max-width: 500px;
  137. display: block;
  138. margin-left: auto;
  139. margin-right: auto;
  140. }
  141. .output_png img {
  142. width: 100% !important;
  143. }
  144. .hl-ipython3 pre::before,
  145. .output_subarea pre::before,
  146. .output_html::before,
  147. .output_png::before {
  148. color: #ccc !important;
  149. float: left !important;
  150. margin-bottom: 0.25em !important;
  151. width: 100% !important;
  152. }
  153. /**
  154. * nbinteract styling
  155. */
  156. .cell.nbinteract-left {
  157. width: 50%;
  158. float: left;
  159. }
  160. .cell.nbinteract-right {
  161. width: 50%;
  162. float: right;
  163. }
  164. .cell.nbinteract-hide_in > .input {
  165. display: none;
  166. }
  167. .cell.nbinteract-hide_out > .output_wrapper {
  168. display: none;
  169. }
  170. .cell:after {
  171. content: '';
  172. display: table;
  173. clear: both;
  174. }
  175. div.output_subarea {
  176. max-width: initial;
  177. }
  178. .jp-OutputPrompt {
  179. display: none;
  180. }