pdf.scss 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. :root {
  2. --pdf-bg: var(--bg-dark-secondary);
  3. --pdf-toolbar-btn-hover-color: rgb(125 125 125 / 20%);
  4. --synctex-control-size: 24px;
  5. }
  6. @include theme('light') {
  7. --pdf-toolbar-btn-hover-color: var(--neutral-10);
  8. --pdf-bg: var(--neutral-10);
  9. }
  10. .pdf-code-check-failed-banner-container {
  11. position: absolute;
  12. top: calc(var(--toolbar-small-height) + var(--spacing-04));
  13. left: 0;
  14. right: 0;
  15. z-index: 1;
  16. display: flex;
  17. justify-content: center;
  18. padding: 0 var(--spacing-06);
  19. }
  20. .pdf-code-check-failed-banner {
  21. display: flex;
  22. align-items: center;
  23. gap: var(--spacing-02);
  24. background-color: var(--bg-light-primary);
  25. color: var(--content-primary);
  26. border: 1px solid var(--border-divider);
  27. padding: var(--spacing-02) var(--spacing-03) var(--spacing-02)
  28. var(--spacing-02);
  29. border-radius: var(--border-radius-full);
  30. box-shadow: 0 2px 4px 0 #1e253029;
  31. }
  32. .pdf .toolbar.toolbar-pdf {
  33. @include toolbar-sm-height;
  34. @include toolbar-alt-bg;
  35. padding-right: var(--spacing-03);
  36. margin-left: 0;
  37. .btn.disabled,
  38. .btn[disabled] {
  39. pointer-events: auto;
  40. cursor: not-allowed;
  41. opacity: 1;
  42. }
  43. }
  44. .toolbar-pdf-left {
  45. gap: var(--spacing-02);
  46. .compile-button-group {
  47. height: 24px;
  48. background-color: var(--bg-accent-01);
  49. border-radius: 12px;
  50. margin-left: var(--spacing-02);
  51. .btn-primary:hover {
  52. z-index: auto; // prevents border from being hidden
  53. }
  54. }
  55. .dropdown > .btn {
  56. border-top-left-radius: 0;
  57. border-bottom-left-radius: 0;
  58. &[disabled],
  59. &[disabled]:active {
  60. background-color: var(--bs-btn-bg);
  61. color: var(--bs-btn-color);
  62. opacity: 1;
  63. pointer-events: auto;
  64. cursor: not-allowed;
  65. }
  66. }
  67. .dropdown > .compile-button {
  68. border-top-left-radius: 12px;
  69. border-bottom-left-radius: 12px;
  70. font-size: var(--font-size-02);
  71. }
  72. .dropdown > .compile-dropdown-toggle {
  73. width: 26px;
  74. padding: var(--spacing-01);
  75. }
  76. }
  77. .toolbar-pdf-left,
  78. .toolbar-pdf-right,
  79. .toolbar-pdf-controls {
  80. display: flex;
  81. align-items: center;
  82. align-self: stretch;
  83. }
  84. .toolbar-pdf-controls {
  85. margin-right: var(--spacing-02);
  86. justify-content: flex-end;
  87. flex: 1 1 100%;
  88. }
  89. .toolbar-pdf-right {
  90. flex: 1;
  91. justify-content: flex-end;
  92. }
  93. .toolbar-pdf-orphan {
  94. color: var(--toolbar-btn-color);
  95. }
  96. .toolbar-pdf-orphan-btn,
  97. .toolbar-pdf-orphan {
  98. margin-left: var(--spacing-02);
  99. }
  100. .btn.pdf-toolbar-btn {
  101. display: inline-block;
  102. color: var(--toolbar-btn-color);
  103. background-color: transparent;
  104. padding: 0 var(--spacing-01);
  105. line-height: 1;
  106. height: 24px;
  107. border-radius: var(--border-radius-base);
  108. text-decoration: none;
  109. &:hover,
  110. &:active,
  111. &:focus {
  112. color: var(--toolbar-btn-color);
  113. }
  114. &:hover {
  115. &:not(:disabled) {
  116. background-color: var(--pdf-toolbar-btn-hover-color);
  117. }
  118. }
  119. &:active {
  120. background-color: transparent;
  121. }
  122. .button-content {
  123. align-self: center;
  124. }
  125. .badge {
  126. font-size: 60%;
  127. }
  128. &.log-btn {
  129. border: none;
  130. &.active {
  131. color: var(--white);
  132. background-color: var(--link-color);
  133. box-shadow: none;
  134. opacity: 0.65;
  135. &:hover {
  136. &:not(:disabled) {
  137. background-color: transparent;
  138. color: var(--toolbar-btn-color);
  139. }
  140. }
  141. }
  142. &:focus {
  143. outline: none;
  144. }
  145. }
  146. &.theme-toggle-btn {
  147. border: none;
  148. border-radius: var(--border-radius-full);
  149. &.active {
  150. color: var(--white);
  151. background-color: var(--green-70);
  152. &:hover {
  153. background-color: var(--green-60);
  154. }
  155. }
  156. &:focus {
  157. outline: none;
  158. }
  159. }
  160. }
  161. .pdf {
  162. background-color: var(--pdf-bg);
  163. &.pdf-dark-mode {
  164. --pdf-bg: var(--bg-dark-secondary);
  165. .pdfjs-viewer {
  166. --canvas-box-shadow: none;
  167. .page {
  168. filter: invert(95%) hue-rotate(180deg) brightness(90%) contrast(90%);
  169. }
  170. }
  171. }
  172. }
  173. .pdf-viewer,
  174. .pdf-errors,
  175. .pdf-uncompiled {
  176. @extend .full-size;
  177. top: var(--toolbar-small-height);
  178. }
  179. .pdf-viewer {
  180. isolation: isolate;
  181. iframe {
  182. width: 100%;
  183. height: 100%;
  184. border: none;
  185. }
  186. .pdfjs-viewer {
  187. @extend .full-size;
  188. --canvas-box-shadow: 0 0 10px rgb(0 0 0 / 50%);
  189. background-color: transparent;
  190. overflow: scroll;
  191. /* stylelint-disable-next-line selector-class-pattern */
  192. .canvasWrapper > canvas,
  193. div.pdf-canvas {
  194. background: white;
  195. box-shadow: var(--canvas-box-shadow);
  196. }
  197. div.pdf-canvas.pdfng-empty {
  198. background-color: var(--white);
  199. }
  200. div.pdf-canvas.pdfng-loading {
  201. background-color: var(--white);
  202. }
  203. .page-container {
  204. margin: var(--spacing-05) auto;
  205. padding: 0 var(--spacing-05);
  206. box-sizing: content-box;
  207. user-select: none;
  208. }
  209. .page {
  210. display: block; // prevent Overleaf's .loading class (display:inline-flex) from affecting PDF.js page state
  211. box-sizing: content-box;
  212. margin: var(--spacing-05) auto;
  213. box-shadow:
  214. 0 5px 5px 0 #23282f0d,
  215. 0 3px 14px 0 #23282f08,
  216. 0 8px 10px 0 #23282f14;
  217. border: none;
  218. // Overleaf has its own loading state UI; suppress the PDF.js page-level loading
  219. // spinner so the loadingIcon/loading classes have no layout or visual effect.
  220. /* stylelint-disable-next-line selector-class-pattern */
  221. &.loadingIcon::after {
  222. display: none;
  223. }
  224. }
  225. .pdfjs-viewer-inner {
  226. position: absolute;
  227. overflow-y: scroll;
  228. width: 100%;
  229. height: 100%;
  230. -webkit-font-smoothing: initial;
  231. -moz-osx-font-smoothing: initial;
  232. view-transition-name: pdf-viewer;
  233. /* fix review-panel overflow issue, see: https://github.com/overleaf/internal/issues/6781#issuecomment-1112708638 */
  234. /* stylelint-disable-next-line selector-class-pattern */
  235. .pdfViewer {
  236. min-height: 100%;
  237. }
  238. }
  239. &:focus-within {
  240. outline: none;
  241. }
  242. /* Avoid slowdown in Safari when text layers are reset on selection change */
  243. /* stylelint-disable-next-line selector-class-pattern */
  244. .textLayer {
  245. will-change: transform;
  246. }
  247. /* Avoid multiple small layers within annotation layer */
  248. /* stylelint-disable-next-line selector-class-pattern */
  249. .annotationLayer {
  250. will-change: transform;
  251. }
  252. /* Avoids https://github.com/mozilla/pdf.js/issues/13840 in Chrome */
  253. /* stylelint-disable-next-line selector-class-pattern */
  254. .textLayer br::selection {
  255. background: transparent;
  256. }
  257. }
  258. .progress-thin {
  259. position: absolute;
  260. top: -2px;
  261. height: 3px;
  262. left: 0;
  263. right: 0;
  264. .progress-bar {
  265. height: 100%;
  266. background-color: var(--link-color);
  267. }
  268. }
  269. }
  270. ::view-transition-old(pdf-viewer),
  271. ::view-transition-new(pdf-viewer) {
  272. animation-duration: 0.25s;
  273. }
  274. .pdfjs-viewer-controls {
  275. display: flex;
  276. align-items: center;
  277. justify-content: flex-end;
  278. width: 100%;
  279. }
  280. .pdfjs-zoom-controls {
  281. display: inline-flex;
  282. border-left: 1px solid rgb(125 125 125 / 30%);
  283. }
  284. .pdfjs-toolbar-buttons {
  285. display: flex;
  286. gap: var(--spacing-04);
  287. margin-left: var(--spacing-04);
  288. margin-right: var(--spacing-04);
  289. .btn {
  290. border-radius: var(--border-radius-base) !important;
  291. }
  292. }
  293. .pdfjs-toolbar-button {
  294. padding: var(--spacing-01) !important;
  295. display: flex;
  296. align-items: center;
  297. }
  298. .pdfjs-zoom-dropdown-button {
  299. width: 60px;
  300. text-align: right;
  301. font-weight: normal;
  302. }
  303. .pdfjs-custom-zoom-menu-item {
  304. display: block;
  305. pointer-events: initial !important;
  306. &:hover {
  307. background-color: initial !important;
  308. color: initial !important;
  309. cursor: initial !important;
  310. }
  311. }
  312. .toolbar-pdf-compile-time {
  313. color: var(--toolbar-btn-color);
  314. font-size: var(--font-size-02);
  315. padding: 0 var(--spacing-04);
  316. display: inline-flex;
  317. align-items: center;
  318. gap: var(--spacing-02);
  319. white-space: nowrap;
  320. }
  321. .pdfjs-page-number-input {
  322. color: var(--toolbar-btn-color);
  323. font-size: var(--font-size-02);
  324. padding-right: var(--spacing-04);
  325. display: flex;
  326. align-items: center;
  327. gap: var(--spacing-02);
  328. input {
  329. background-color: var(--bg-primary-themed);
  330. color: var(--content-primary-themed);
  331. border: 1px solid var(--border-primary-themed);
  332. width: 32px;
  333. height: 24px;
  334. border-radius: var(--border-radius-base);
  335. text-align: center;
  336. }
  337. }
  338. .pdfjs-viewer-controls-small {
  339. display: flex;
  340. align-items: center;
  341. gap: var(--spacing-04);
  342. }
  343. .pdfjs-toolbar-popover-button {
  344. padding: var(--spacing-01) !important;
  345. }
  346. .pdfjs-toolbar-popover {
  347. background-color: var(--editor-toolbar-bg);
  348. border-radius: var(--border-radius-base);
  349. .popover-arrow {
  350. display: none;
  351. }
  352. button {
  353. background-color: transparent;
  354. color: var(--toolbar-btn-color);
  355. }
  356. .popover-body {
  357. display: flex;
  358. align-items: center;
  359. padding: var(--spacing-04) 0;
  360. }
  361. }
  362. // The new viewer UI has overflow on the inner element,
  363. // so disable the overflow on the outer element
  364. .pdf-viewer .pdfjs-viewer.pdfjs-viewer-outer {
  365. overflow: hidden;
  366. }
  367. :fullscreen {
  368. /* stylelint-disable selector-class-pattern */
  369. .pdfViewer {
  370. min-height: auto !important;
  371. }
  372. .pdfjs-viewer-inner {
  373. overflow-y: hidden !important;
  374. display: flex;
  375. align-items: center;
  376. justify-content: center;
  377. }
  378. }
  379. .synctex-controls {
  380. margin-right: calc(var(--spacing-04) * -1);
  381. position: absolute;
  382. z-index: 6;
  383. padding: 0;
  384. top: 68px;
  385. }
  386. .synctex-control:not(.detach-synctex-control) {
  387. align-items: center;
  388. background-color: rgba($bg-dark-tertiary, 0.8);
  389. border-color: transparent;
  390. border-radius: var(--border-radius-full);
  391. color: var(--content-primary-dark);
  392. display: flex !important;
  393. height: var(--synctex-control-size);
  394. justify-content: center;
  395. margin-bottom: var(--spacing-05);
  396. padding: 0;
  397. transition: background 0.15s ease;
  398. width: var(--synctex-control-size);
  399. &:focus:not(:focus-visible) {
  400. outline: none;
  401. }
  402. &:active {
  403. background-color: rgba($bg-dark-tertiary, 0.8);
  404. color: var(--content-primary-dark);
  405. }
  406. }
  407. .synctex-control {
  408. .synctex-control-icon {
  409. font-size: var(--font-size-06);
  410. font-weight: normal;
  411. }
  412. }
  413. .keyboard-tooltip {
  414. .tooltip-inner {
  415. max-width: none;
  416. }
  417. }
  418. #dropdown-files-logs-pane-list {
  419. overflow-y: auto;
  420. .dropdown-header {
  421. white-space: nowrap;
  422. }
  423. // This keeps the dropdown menu inside the Logs div.
  424. // "spacing-11" is there to compensate the button height and the margin around the logs.
  425. max-height: calc(
  426. 100vh - #{$toolbar-small-height + $toolbar-height + $spacing-11}
  427. );
  428. }
  429. .pdf-preview-messages {
  430. position: absolute;
  431. right: var(--spacing-06);
  432. left: var(--spacing-06);
  433. top: var(--spacing-10);
  434. z-index: 1;
  435. }
  436. .synctex-error-toast-content {
  437. display: flex;
  438. gap: 20px;
  439. }