CodeBlock.module.css 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /* Visual baseline: deepsuite `@deepseek/md` code-block.css. Highlight colors
  2. stay on the existing shiki `--shiki-*` sheet (not Prism highlight.css). */
  3. .block {
  4. --dsl-code-block-banner-background-color: var(--dsw-alias-markdown-code-block-banner);
  5. --dsl-code-block-border-radius: 12px;
  6. /* Local 11/18 instead of the shared --dsw-font-xs-13: the banner scales
  7. with the markdown 0.875 ladder without shrinking every other xs-13 use. */
  8. --dsl-code-block-banner-font: 11px/18px var(--dsw-font-family);
  9. --dsl-code-block-content-font: var(--dsw-font-markdown-code-block);
  10. position: relative;
  11. margin: 16px 0;
  12. color: var(--dsw-alias-label-primary);
  13. background: var(--dsw-alias-markdown-code-block);
  14. border-radius: var(--dsl-code-block-border-radius);
  15. }
  16. .block:not(:last-child) {
  17. margin-bottom: 11px;
  18. }
  19. .bannerWrap {
  20. position: sticky;
  21. top: 0;
  22. z-index: 6;
  23. background-color: var(--dsw-alias-bg-base);
  24. border-top-left-radius: var(--dsl-code-block-border-radius);
  25. border-top-right-radius: var(--dsl-code-block-border-radius);
  26. }
  27. .banner {
  28. background: var(--dsl-code-block-banner-background-color);
  29. padding: 9px 14px;
  30. display: flex;
  31. justify-content: space-between;
  32. align-items: center;
  33. gap: 12px;
  34. font: var(--dsl-code-block-banner-font);
  35. border-top-left-radius: var(--dsl-code-block-border-radius);
  36. border-top-right-radius: var(--dsl-code-block-border-radius);
  37. }
  38. .infostring {
  39. color: var(--dsw-alias-label-primary);
  40. font-family: var(--ds-font-family-code);
  41. font-size: 11px;
  42. line-height: 18px;
  43. min-width: 0;
  44. overflow: hidden;
  45. text-overflow: ellipsis;
  46. white-space: nowrap;
  47. }
  48. .action {
  49. display: flex;
  50. align-items: center;
  51. flex-shrink: 0;
  52. gap: 12px;
  53. }
  54. .copyButton {
  55. background-color: rgb(255 255 255 / 0);
  56. border: none;
  57. padding: 0;
  58. margin: 0;
  59. color: inherit;
  60. cursor: pointer;
  61. font: inherit;
  62. }
  63. .block :where(pre) {
  64. font: var(--dsl-code-block-content-font);
  65. padding: 16px;
  66. margin: 0 !important;
  67. overflow-x: auto;
  68. white-space: pre-wrap;
  69. word-break: break-all;
  70. background: var(--dsw-alias-markdown-code-block);
  71. /* Bottom radii live on <pre>: overflow:hidden on .block would kill the
  72. sticky banner, and this opaque fill otherwise squares off the wrapper. */
  73. border-bottom-left-radius: var(--dsl-code-block-border-radius);
  74. border-bottom-right-radius: var(--dsl-code-block-border-radius);
  75. }
  76. /* Shiki inlines its theme background var; route it to the repo token. */
  77. .block :where(pre.shiki) {
  78. background: var(--dsw-alias-markdown-code-block) !important;
  79. }
  80. .block :where(pre) code {
  81. font: inherit;
  82. background: none;
  83. padding: 0;
  84. }
  85. .plain {
  86. color: var(--dsw-alias-label-primary);
  87. }
  88. .numbered :where(pre) code {
  89. display: block;
  90. counter-reset: source-line;
  91. white-space: normal;
  92. }
  93. .numbered :where(pre) code > :global(.line) {
  94. position: relative;
  95. display: block;
  96. min-height: 1lh;
  97. padding-inline-start: calc(var(--dsl-code-block-line-number-width) + 12px);
  98. counter-increment: source-line;
  99. white-space: var(--dsl-code-block-line-white-space, pre-wrap);
  100. }
  101. .numbered :where(pre) code > :global(.line)::before {
  102. position: absolute;
  103. inset-inline-start: 0;
  104. width: var(--dsl-code-block-line-number-width);
  105. color: var(--dsw-alias-label-tertiary);
  106. text-align: end;
  107. content: counter(source-line);
  108. user-select: none;
  109. }
  110. /* Alternate content is a figure; its actions overlay instead of taking a title row. */
  111. .preview.showingPreview {
  112. background: transparent;
  113. }
  114. .preview .bannerWrap {
  115. position: absolute;
  116. top: 8px;
  117. right: 8px;
  118. z-index: 1;
  119. background: transparent;
  120. }
  121. .preview .banner {
  122. padding: 2px;
  123. background: var(--dsw-alias-bg-base);
  124. border: 0;
  125. border-radius: 8px;
  126. box-shadow: var(--dsw-elevation-panel);
  127. }
  128. .preview .action {
  129. gap: 2px;
  130. }
  131. .iconButton {
  132. display: inline-flex;
  133. align-items: center;
  134. justify-content: center;
  135. width: 32px;
  136. height: 32px;
  137. border-radius: 6px;
  138. color: var(--dsw-alias-label-secondary);
  139. }
  140. .iconButton span {
  141. display: flex;
  142. }
  143. .iconButton:hover {
  144. color: var(--dsw-alias-label-primary);
  145. background: var(--dsw-alias-interactive-bg-hover);
  146. }
  147. .preview:not(.showingPreview) :where(pre) {
  148. padding-top: 48px;
  149. }
  150. @media (hover: hover) and (pointer: fine) {
  151. .preview .bannerWrap {
  152. opacity: 0;
  153. pointer-events: none;
  154. }
  155. .preview:hover .bannerWrap,
  156. .preview:focus-within .bannerWrap {
  157. opacity: 1;
  158. pointer-events: auto;
  159. }
  160. }
  161. @media (pointer: coarse) {
  162. .preview {
  163. padding-bottom: 56px;
  164. }
  165. .preview .bannerWrap {
  166. top: auto;
  167. bottom: 8px;
  168. }
  169. .preview .iconButton {
  170. width: 44px;
  171. height: 44px;
  172. }
  173. .preview:not(.showingPreview) :where(pre) {
  174. padding-top: 16px;
  175. }
  176. }