@apify/ui-library 0.51.6-featurepublishuilibrary-0a4729.38266

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (349) hide show
  1. package/.eslintrc +39 -0
  2. package/.stylelintrc +12 -0
  3. package/CHANGELOG.md +2804 -0
  4. package/README.md +15 -0
  5. package/dist/src/components/action_link.d.ts +5 -0
  6. package/dist/src/components/action_link.d.ts.map +1 -0
  7. package/dist/src/components/action_link.jsx +35 -0
  8. package/dist/src/components/action_link.jsx.map +1 -0
  9. package/dist/src/components/actor_template_card.d.ts +10 -0
  10. package/dist/src/components/actor_template_card.d.ts.map +1 -0
  11. package/dist/src/components/actor_template_card.jsx +73 -0
  12. package/dist/src/components/actor_template_card.jsx.map +1 -0
  13. package/dist/src/components/badge.d.ts +26 -0
  14. package/dist/src/components/badge.d.ts.map +1 -0
  15. package/dist/src/components/badge.jsx +96 -0
  16. package/dist/src/components/badge.jsx.map +1 -0
  17. package/dist/src/components/banner.d.ts +11 -0
  18. package/dist/src/components/banner.d.ts.map +1 -0
  19. package/dist/src/components/banner.jsx +73 -0
  20. package/dist/src/components/banner.jsx.map +1 -0
  21. package/dist/src/components/blog_article.d.ts +9 -0
  22. package/dist/src/components/blog_article.d.ts.map +1 -0
  23. package/dist/src/components/blog_article.jsx +73 -0
  24. package/dist/src/components/blog_article.jsx.map +1 -0
  25. package/dist/src/components/box.d.ts +41 -0
  26. package/dist/src/components/box.d.ts.map +1 -0
  27. package/dist/src/components/box.jsx +48 -0
  28. package/dist/src/components/box.jsx.map +1 -0
  29. package/dist/src/components/button.d.ts +35 -0
  30. package/dist/src/components/button.d.ts.map +1 -0
  31. package/dist/src/components/button.jsx +193 -0
  32. package/dist/src/components/button.jsx.map +1 -0
  33. package/dist/src/components/chip.d.ts +52 -0
  34. package/dist/src/components/chip.d.ts.map +1 -0
  35. package/dist/src/components/chip.jsx +89 -0
  36. package/dist/src/components/chip.jsx.map +1 -0
  37. package/dist/src/components/code/action_button.d.ts +11 -0
  38. package/dist/src/components/code/action_button.d.ts.map +1 -0
  39. package/dist/src/components/code/action_button.jsx +67 -0
  40. package/dist/src/components/code/action_button.jsx.map +1 -0
  41. package/dist/src/components/code/code_block/code_block.d.ts +38 -0
  42. package/dist/src/components/code/code_block/code_block.d.ts.map +1 -0
  43. package/dist/src/components/code/code_block/code_block.jsx +99 -0
  44. package/dist/src/components/code/code_block/code_block.jsx.map +1 -0
  45. package/dist/src/components/code/code_block/code_block.styled.d.ts +13 -0
  46. package/dist/src/components/code/code_block/code_block.styled.d.ts.map +1 -0
  47. package/dist/src/components/code/code_block/code_block.styled.jsx +215 -0
  48. package/dist/src/components/code/code_block/code_block.styled.jsx.map +1 -0
  49. package/dist/src/components/code/code_block/utils.d.ts +2 -0
  50. package/dist/src/components/code/code_block/utils.d.ts.map +1 -0
  51. package/dist/src/components/code/code_block/utils.js +20 -0
  52. package/dist/src/components/code/code_block/utils.js.map +1 -0
  53. package/dist/src/components/code/index.d.ts +4 -0
  54. package/dist/src/components/code/index.d.ts.map +1 -0
  55. package/dist/src/components/code/index.js +4 -0
  56. package/dist/src/components/code/index.js.map +1 -0
  57. package/dist/src/components/code/inline_code/inline_code.d.ts +11 -0
  58. package/dist/src/components/code/inline_code/inline_code.d.ts.map +1 -0
  59. package/dist/src/components/code/inline_code/inline_code.jsx +24 -0
  60. package/dist/src/components/code/inline_code/inline_code.jsx.map +1 -0
  61. package/dist/src/components/code/one_line_code/one_line_code.d.ts +27 -0
  62. package/dist/src/components/code/one_line_code/one_line_code.d.ts.map +1 -0
  63. package/dist/src/components/code/one_line_code/one_line_code.jsx +157 -0
  64. package/dist/src/components/code/one_line_code/one_line_code.jsx.map +1 -0
  65. package/dist/src/components/code/syntax_highlighter.d.ts +16 -0
  66. package/dist/src/components/code/syntax_highlighter.d.ts.map +1 -0
  67. package/dist/src/components/code/syntax_highlighter.jsx +94 -0
  68. package/dist/src/components/code/syntax_highlighter.jsx.map +1 -0
  69. package/dist/src/components/color_wheel_gradient.d.ts +9 -0
  70. package/dist/src/components/color_wheel_gradient.d.ts.map +1 -0
  71. package/dist/src/components/color_wheel_gradient.jsx +23 -0
  72. package/dist/src/components/color_wheel_gradient.jsx.map +1 -0
  73. package/dist/src/components/floating/index.d.ts +4 -0
  74. package/dist/src/components/floating/index.d.ts.map +1 -0
  75. package/dist/src/components/floating/index.js +4 -0
  76. package/dist/src/components/floating/index.js.map +1 -0
  77. package/dist/src/components/floating/menu.d.ts +33 -0
  78. package/dist/src/components/floating/menu.d.ts.map +1 -0
  79. package/dist/src/components/floating/menu.jsx +95 -0
  80. package/dist/src/components/floating/menu.jsx.map +1 -0
  81. package/dist/src/components/floating/menu_common.d.ts +42 -0
  82. package/dist/src/components/floating/menu_common.d.ts.map +1 -0
  83. package/dist/src/components/floating/menu_common.jsx +20 -0
  84. package/dist/src/components/floating/menu_common.jsx.map +1 -0
  85. package/dist/src/components/floating/menu_components.d.ts +29 -0
  86. package/dist/src/components/floating/menu_components.d.ts.map +1 -0
  87. package/dist/src/components/floating/menu_components.jsx +73 -0
  88. package/dist/src/components/floating/menu_components.jsx.map +1 -0
  89. package/dist/src/components/image.d.ts +12 -0
  90. package/dist/src/components/image.d.ts.map +1 -0
  91. package/dist/src/components/image.jsx +8 -0
  92. package/dist/src/components/image.jsx.map +1 -0
  93. package/dist/src/components/index.d.ts +21 -0
  94. package/dist/src/components/index.d.ts.map +1 -0
  95. package/dist/src/components/index.js +21 -0
  96. package/dist/src/components/index.js.map +1 -0
  97. package/dist/src/components/link.d.ts +24 -0
  98. package/dist/src/components/link.d.ts.map +1 -0
  99. package/dist/src/components/link.jsx +67 -0
  100. package/dist/src/components/link.jsx.map +1 -0
  101. package/dist/src/components/message.d.ts +31 -0
  102. package/dist/src/components/message.d.ts.map +1 -0
  103. package/dist/src/components/message.jsx +105 -0
  104. package/dist/src/components/message.jsx.map +1 -0
  105. package/dist/src/components/readme_renderer/index.d.ts +4 -0
  106. package/dist/src/components/readme_renderer/index.d.ts.map +1 -0
  107. package/dist/src/components/readme_renderer/index.js +4 -0
  108. package/dist/src/components/readme_renderer/index.js.map +1 -0
  109. package/dist/src/components/readme_renderer/pythonize_value.d.ts +3 -0
  110. package/dist/src/components/readme_renderer/pythonize_value.d.ts.map +1 -0
  111. package/dist/src/components/readme_renderer/pythonize_value.js +81 -0
  112. package/dist/src/components/readme_renderer/pythonize_value.js.map +1 -0
  113. package/dist/src/components/readme_renderer/table_of_contents.d.ts +10 -0
  114. package/dist/src/components/readme_renderer/table_of_contents.d.ts.map +1 -0
  115. package/dist/src/components/readme_renderer/table_of_contents.jsx +197 -0
  116. package/dist/src/components/readme_renderer/table_of_contents.jsx.map +1 -0
  117. package/dist/src/components/readme_renderer/utils.d.ts +6 -0
  118. package/dist/src/components/readme_renderer/utils.d.ts.map +1 -0
  119. package/dist/src/components/readme_renderer/utils.jsx +42 -0
  120. package/dist/src/components/readme_renderer/utils.jsx.map +1 -0
  121. package/dist/src/components/simple_markdown/index.d.ts +3 -0
  122. package/dist/src/components/simple_markdown/index.d.ts.map +1 -0
  123. package/dist/src/components/simple_markdown/index.jsx +3 -0
  124. package/dist/src/components/simple_markdown/index.jsx.map +1 -0
  125. package/dist/src/components/simple_markdown/simple_markdown.d.ts +16 -0
  126. package/dist/src/components/simple_markdown/simple_markdown.d.ts.map +1 -0
  127. package/dist/src/components/simple_markdown/simple_markdown.jsx +137 -0
  128. package/dist/src/components/simple_markdown/simple_markdown.jsx.map +1 -0
  129. package/dist/src/components/simple_markdown/simple_markdown_components.d.ts +26 -0
  130. package/dist/src/components/simple_markdown/simple_markdown_components.d.ts.map +1 -0
  131. package/dist/src/components/simple_markdown/simple_markdown_components.jsx +193 -0
  132. package/dist/src/components/simple_markdown/simple_markdown_components.jsx.map +1 -0
  133. package/dist/src/components/tag.d.ts +38 -0
  134. package/dist/src/components/tag.d.ts.map +1 -0
  135. package/dist/src/components/tag.jsx +126 -0
  136. package/dist/src/components/tag.jsx.map +1 -0
  137. package/dist/src/components/text/heading_content.d.ts +10 -0
  138. package/dist/src/components/text/heading_content.d.ts.map +1 -0
  139. package/dist/src/components/text/heading_content.jsx +31 -0
  140. package/dist/src/components/text/heading_content.jsx.map +1 -0
  141. package/dist/src/components/text/heading_marketing.d.ts +10 -0
  142. package/dist/src/components/text/heading_marketing.d.ts.map +1 -0
  143. package/dist/src/components/text/heading_marketing.jsx +31 -0
  144. package/dist/src/components/text/heading_marketing.jsx.map +1 -0
  145. package/dist/src/components/text/heading_shared.d.ts +10 -0
  146. package/dist/src/components/text/heading_shared.d.ts.map +1 -0
  147. package/dist/src/components/text/heading_shared.jsx +32 -0
  148. package/dist/src/components/text/heading_shared.jsx.map +1 -0
  149. package/dist/src/components/text/index.d.ts +12 -0
  150. package/dist/src/components/text/index.d.ts.map +1 -0
  151. package/dist/src/components/text/index.js +11 -0
  152. package/dist/src/components/text/index.js.map +1 -0
  153. package/dist/src/components/text/text_base.d.ts +13 -0
  154. package/dist/src/components/text/text_base.d.ts.map +1 -0
  155. package/dist/src/components/text/text_base.jsx +23 -0
  156. package/dist/src/components/text/text_base.jsx.map +1 -0
  157. package/dist/src/components/text/text_content.d.ts +11 -0
  158. package/dist/src/components/text/text_content.d.ts.map +1 -0
  159. package/dist/src/components/text/text_content.jsx +68 -0
  160. package/dist/src/components/text/text_content.jsx.map +1 -0
  161. package/dist/src/components/text/text_marketing.d.ts +11 -0
  162. package/dist/src/components/text/text_marketing.d.ts.map +1 -0
  163. package/dist/src/components/text/text_marketing.jsx +116 -0
  164. package/dist/src/components/text/text_marketing.jsx.map +1 -0
  165. package/dist/src/components/text/text_shared.d.ts +14 -0
  166. package/dist/src/components/text/text_shared.d.ts.map +1 -0
  167. package/dist/src/components/text/text_shared.jsx +55 -0
  168. package/dist/src/components/text/text_shared.jsx.map +1 -0
  169. package/dist/src/components/tile/horizontal_tile.d.ts +9 -0
  170. package/dist/src/components/tile/horizontal_tile.d.ts.map +1 -0
  171. package/dist/src/components/tile/horizontal_tile.jsx +43 -0
  172. package/dist/src/components/tile/horizontal_tile.jsx.map +1 -0
  173. package/dist/src/components/tile/index.d.ts +3 -0
  174. package/dist/src/components/tile/index.d.ts.map +1 -0
  175. package/dist/src/components/tile/index.js +3 -0
  176. package/dist/src/components/tile/index.js.map +1 -0
  177. package/dist/src/components/tile/shared.d.ts +17 -0
  178. package/dist/src/components/tile/shared.d.ts.map +1 -0
  179. package/dist/src/components/tile/shared.js +12 -0
  180. package/dist/src/components/tile/shared.js.map +1 -0
  181. package/dist/src/components/tile/vertical_tile.d.ts +10 -0
  182. package/dist/src/components/tile/vertical_tile.d.ts.map +1 -0
  183. package/dist/src/components/tile/vertical_tile.jsx +32 -0
  184. package/dist/src/components/tile/vertical_tile.jsx.map +1 -0
  185. package/dist/src/components/to_consolidate/card.d.ts +27 -0
  186. package/dist/src/components/to_consolidate/card.d.ts.map +1 -0
  187. package/dist/src/components/to_consolidate/card.jsx +93 -0
  188. package/dist/src/components/to_consolidate/card.jsx.map +1 -0
  189. package/dist/src/components/to_consolidate/index.d.ts +5 -0
  190. package/dist/src/components/to_consolidate/index.d.ts.map +1 -0
  191. package/dist/src/components/to_consolidate/index.js +5 -0
  192. package/dist/src/components/to_consolidate/index.js.map +1 -0
  193. package/dist/src/components/to_consolidate/markdown.d.ts +40 -0
  194. package/dist/src/components/to_consolidate/markdown.d.ts.map +1 -0
  195. package/dist/src/components/to_consolidate/markdown.jsx +454 -0
  196. package/dist/src/components/to_consolidate/markdown.jsx.map +1 -0
  197. package/dist/src/components/to_consolidate/pagination.d.ts +8 -0
  198. package/dist/src/components/to_consolidate/pagination.d.ts.map +1 -0
  199. package/dist/src/components/to_consolidate/pagination.jsx +88 -0
  200. package/dist/src/components/to_consolidate/pagination.jsx.map +1 -0
  201. package/dist/src/components/to_consolidate/tab_number_chip.d.ts +7 -0
  202. package/dist/src/components/to_consolidate/tab_number_chip.d.ts.map +1 -0
  203. package/dist/src/components/to_consolidate/tab_number_chip.jsx +22 -0
  204. package/dist/src/components/to_consolidate/tab_number_chip.jsx.map +1 -0
  205. package/dist/src/design_system/colors_theme.d.ts +213 -0
  206. package/dist/src/design_system/colors_theme.d.ts.map +1 -0
  207. package/dist/src/design_system/colors_theme.js +213 -0
  208. package/dist/src/design_system/colors_theme.js.map +1 -0
  209. package/dist/src/design_system/properties_theme.d.ts +175 -0
  210. package/dist/src/design_system/properties_theme.d.ts.map +1 -0
  211. package/dist/src/design_system/properties_theme.js +315 -0
  212. package/dist/src/design_system/properties_theme.js.map +1 -0
  213. package/dist/src/design_system/theme.d.ts +630 -0
  214. package/dist/src/design_system/theme.d.ts.map +1 -0
  215. package/dist/src/design_system/theme.js +17 -0
  216. package/dist/src/design_system/theme.js.map +1 -0
  217. package/dist/src/design_system/tokens/index.d.ts +6 -0
  218. package/dist/src/design_system/tokens/index.d.ts.map +1 -0
  219. package/dist/src/design_system/tokens/index.js +6 -0
  220. package/dist/src/design_system/tokens/index.js.map +1 -0
  221. package/dist/src/design_system/tokens/layouts.d.ts +29 -0
  222. package/dist/src/design_system/tokens/layouts.d.ts.map +1 -0
  223. package/dist/src/design_system/tokens/layouts.js +29 -0
  224. package/dist/src/design_system/tokens/layouts.js.map +1 -0
  225. package/dist/src/design_system/tokens/radiuses.d.ts +23 -0
  226. package/dist/src/design_system/tokens/radiuses.d.ts.map +1 -0
  227. package/dist/src/design_system/tokens/radiuses.js +23 -0
  228. package/dist/src/design_system/tokens/radiuses.js.map +1 -0
  229. package/dist/src/design_system/tokens/shadows.d.ts +23 -0
  230. package/dist/src/design_system/tokens/shadows.d.ts.map +1 -0
  231. package/dist/src/design_system/tokens/shadows.js +23 -0
  232. package/dist/src/design_system/tokens/shadows.js.map +1 -0
  233. package/dist/src/design_system/tokens/spaces.d.ts +15 -0
  234. package/dist/src/design_system/tokens/spaces.d.ts.map +1 -0
  235. package/dist/src/design_system/tokens/spaces.js +14 -0
  236. package/dist/src/design_system/tokens/spaces.js.map +1 -0
  237. package/dist/src/design_system/tokens/transitions.d.ts +20 -0
  238. package/dist/src/design_system/tokens/transitions.d.ts.map +1 -0
  239. package/dist/src/design_system/tokens/transitions.js +20 -0
  240. package/dist/src/design_system/tokens/transitions.js.map +1 -0
  241. package/dist/src/design_system/typography_theme.d.ts +189 -0
  242. package/dist/src/design_system/typography_theme.d.ts.map +1 -0
  243. package/dist/src/design_system/typography_theme.js +190 -0
  244. package/dist/src/design_system/typography_theme.js.map +1 -0
  245. package/dist/src/index.d.ts +7 -0
  246. package/dist/src/index.d.ts.map +1 -0
  247. package/dist/src/index.js +7 -0
  248. package/dist/src/index.js.map +1 -0
  249. package/dist/src/type_utils.d.ts +6 -0
  250. package/dist/src/type_utils.d.ts.map +1 -0
  251. package/dist/src/type_utils.js +2 -0
  252. package/dist/src/type_utils.js.map +1 -0
  253. package/dist/src/ui_dependency_provider.d.ts +29 -0
  254. package/dist/src/ui_dependency_provider.d.ts.map +1 -0
  255. package/dist/src/ui_dependency_provider.jsx +14 -0
  256. package/dist/src/ui_dependency_provider.jsx.map +1 -0
  257. package/dist/src/utils/copy_to_clipboard.d.ts +7 -0
  258. package/dist/src/utils/copy_to_clipboard.d.ts.map +1 -0
  259. package/dist/src/utils/copy_to_clipboard.js +16 -0
  260. package/dist/src/utils/copy_to_clipboard.js.map +1 -0
  261. package/dist/src/utils/image_color.d.ts +7 -0
  262. package/dist/src/utils/image_color.d.ts.map +1 -0
  263. package/dist/src/utils/image_color.js +35 -0
  264. package/dist/src/utils/image_color.js.map +1 -0
  265. package/dist/src/utils/index.d.ts +4 -0
  266. package/dist/src/utils/index.d.ts.map +1 -0
  267. package/dist/src/utils/index.js +4 -0
  268. package/dist/src/utils/index.js.map +1 -0
  269. package/dist/src/utils/sanitization.d.ts +11 -0
  270. package/dist/src/utils/sanitization.d.ts.map +1 -0
  271. package/dist/src/utils/sanitization.js +16 -0
  272. package/dist/src/utils/sanitization.js.map +1 -0
  273. package/dist/tsconfig.build.tsbuildinfo +1 -0
  274. package/package.json +71 -0
  275. package/src/codemods/generate_color_property_tokens.mjs +97 -0
  276. package/src/codemods/generate_color_theme_files.mjs +46 -0
  277. package/src/codemods/generate_typograpy_tokens_files.mjs +136 -0
  278. package/src/components/action_link.tsx +59 -0
  279. package/src/components/actor_template_card.tsx +99 -0
  280. package/src/components/badge.tsx +144 -0
  281. package/src/components/banner.tsx +95 -0
  282. package/src/components/blog_article.tsx +85 -0
  283. package/src/components/box.tsx +127 -0
  284. package/src/components/button.tsx +303 -0
  285. package/src/components/chip.tsx +121 -0
  286. package/src/components/code/action_button.tsx +96 -0
  287. package/src/components/code/code_block/code_block.styled.tsx +228 -0
  288. package/src/components/code/code_block/code_block.tsx +235 -0
  289. package/src/components/code/code_block/utils.ts +19 -0
  290. package/src/components/code/index.ts +3 -0
  291. package/src/components/code/inline_code/inline_code.tsx +44 -0
  292. package/src/components/code/one_line_code/one_line_code.tsx +232 -0
  293. package/src/components/code/syntax_highlighter.tsx +125 -0
  294. package/src/components/color_wheel_gradient.tsx +31 -0
  295. package/src/components/floating/index.ts +3 -0
  296. package/src/components/floating/menu.tsx +191 -0
  297. package/src/components/floating/menu_common.tsx +31 -0
  298. package/src/components/floating/menu_components.tsx +94 -0
  299. package/src/components/image.tsx +23 -0
  300. package/src/components/index.ts +20 -0
  301. package/src/components/link.tsx +114 -0
  302. package/src/components/message.tsx +157 -0
  303. package/src/components/readme_renderer/index.ts +3 -0
  304. package/src/components/readme_renderer/pythonize_value.ts +78 -0
  305. package/src/components/readme_renderer/table_of_contents.tsx +257 -0
  306. package/src/components/readme_renderer/utils.tsx +46 -0
  307. package/src/components/simple_markdown/index.tsx +2 -0
  308. package/src/components/simple_markdown/simple_markdown.tsx +181 -0
  309. package/src/components/simple_markdown/simple_markdown_components.tsx +295 -0
  310. package/src/components/tag.tsx +185 -0
  311. package/src/components/text/heading_content.tsx +56 -0
  312. package/src/components/text/heading_marketing.tsx +55 -0
  313. package/src/components/text/heading_shared.tsx +57 -0
  314. package/src/components/text/index.ts +18 -0
  315. package/src/components/text/text_base.tsx +52 -0
  316. package/src/components/text/text_content.tsx +104 -0
  317. package/src/components/text/text_marketing.tsx +152 -0
  318. package/src/components/text/text_shared.tsx +96 -0
  319. package/src/components/tile/horizontal_tile.tsx +76 -0
  320. package/src/components/tile/index.ts +2 -0
  321. package/src/components/tile/shared.ts +27 -0
  322. package/src/components/tile/vertical_tile.tsx +58 -0
  323. package/src/components/to_consolidate/card.tsx +141 -0
  324. package/src/components/to_consolidate/index.ts +4 -0
  325. package/src/components/to_consolidate/markdown.tsx +593 -0
  326. package/src/components/to_consolidate/pagination.tsx +139 -0
  327. package/src/components/to_consolidate/tab_number_chip.tsx +31 -0
  328. package/src/design_system/colors_theme.ts +213 -0
  329. package/src/design_system/generate_color_definitions.js +43 -0
  330. package/src/design_system/properties_theme.ts +453 -0
  331. package/src/design_system/supernova_color_tokens.json +1766 -0
  332. package/src/design_system/supernova_typography_tokens.json +657 -0
  333. package/src/design_system/theme.ts +26 -0
  334. package/src/design_system/tokens/index.ts +5 -0
  335. package/src/design_system/tokens/layouts.ts +29 -0
  336. package/src/design_system/tokens/radiuses.ts +22 -0
  337. package/src/design_system/tokens/shadows.ts +22 -0
  338. package/src/design_system/tokens/spaces.ts +15 -0
  339. package/src/design_system/tokens/transitions.ts +19 -0
  340. package/src/design_system/typography_theme.ts +197 -0
  341. package/src/index.ts +7 -0
  342. package/src/type_utils.ts +7 -0
  343. package/src/ui_dependency_provider.tsx +50 -0
  344. package/src/utils/copy_to_clipboard.ts +24 -0
  345. package/src/utils/image_color.ts +44 -0
  346. package/src/utils/index.ts +3 -0
  347. package/src/utils/sanitization.ts +14 -0
  348. package/tsconfig.build.json +18 -0
  349. package/tsconfig.json +10 -0
@@ -0,0 +1,121 @@
1
+ import clsx from 'clsx';
2
+ import type { FC } from 'react';
3
+ import React, { forwardRef } from 'react';
4
+ import styled, { css } from 'styled-components';
5
+
6
+ import type { ValueOf } from '@apify-packages/types';
7
+
8
+ import { theme } from '../design_system/theme';
9
+ import type { RegularBoxProps } from './box';
10
+
11
+ const CHIP_SIZES = {
12
+ SMALL: 'S',
13
+ MEDIUM: 'M',
14
+ LARGE: 'L',
15
+ } as const;
16
+ type CHIP_SIZES = ValueOf<typeof CHIP_SIZES>;
17
+
18
+ const CHIP_TYPES = {
19
+ DEFAULT: 'DEFAULT',
20
+ PRIMARY: 'PRIMARY',
21
+ SUCCESS: 'SUCCESS',
22
+ WARNING: 'WARNING',
23
+ DANGER: 'DANGER',
24
+ } as const;
25
+ type CHIP_TYPES = ValueOf<typeof CHIP_TYPES>;
26
+
27
+ export const classNames = {
28
+ BODY: 'Chip-body',
29
+ };
30
+
31
+ const chipSizeStyle = {
32
+ [CHIP_SIZES.SMALL]: css`
33
+ font-size: 12px;
34
+ line-height: 16px;
35
+ padding: 2px 4px;
36
+ border-radius: 6px;
37
+ `,
38
+ [CHIP_SIZES.MEDIUM]: css`
39
+ font-size: 14px;
40
+ line-height: 20px;
41
+ padding: 2px 8px;
42
+ border-radius: 100px;
43
+ `,
44
+ [CHIP_SIZES.LARGE]: css`
45
+ font-size: 16px;
46
+ line-height: 20px;
47
+ padding: 2px 8px;
48
+ border-radius: 100px;
49
+ `,
50
+ } satisfies Record<CHIP_SIZES, unknown>;
51
+
52
+ const chipTypeStyle = {
53
+ [CHIP_TYPES.DEFAULT]: css`
54
+ color: ${theme.color.neutral.text};
55
+ background: ${theme.color.neutral.chipBackground};
56
+ `,
57
+ [CHIP_TYPES.PRIMARY]: css`
58
+ color: ${theme.color.primary.chipText};
59
+ background: ${theme.color.primary.chipBackground};
60
+ `,
61
+ [CHIP_TYPES.SUCCESS]: css`
62
+ color: ${theme.color.success.chipText};
63
+ background: ${theme.color.success.chipBackground};
64
+ `,
65
+ [CHIP_TYPES.WARNING]: css`
66
+ color: ${theme.color.warning.chipText};
67
+ background: ${theme.color.warning.chipBackground};
68
+ `,
69
+ [CHIP_TYPES.DANGER]: css`
70
+ color: ${theme.color.danger.chipText};
71
+ background: ${theme.color.danger.chipBackground};
72
+ `,
73
+ } satisfies Record<CHIP_TYPES, unknown>;
74
+
75
+ const StyledChip = styled.span<{size: CHIP_SIZES, type: CHIP_TYPES, clickable: boolean}>`
76
+ ${({ size }) => chipSizeStyle[size]};
77
+ ${({ type }) => chipTypeStyle[type]};
78
+ /* Static styles */
79
+ width: fit-content;
80
+ display: flex;
81
+ flex-direction: row;
82
+ justify-content: center;
83
+ align-items: center;
84
+ font-weight: normal;
85
+ white-space: nowrap;
86
+ cursor: ${({ clickable }) => (clickable ? 'pointer' : 'default')};
87
+ gap: ${theme.space.space4};
88
+ `;
89
+
90
+ export type ChipProps = RegularBoxProps & {
91
+ type?: CHIP_TYPES
92
+ size?: CHIP_SIZES
93
+ icon?: React.ReactNode
94
+ clickable?: boolean
95
+ }
96
+
97
+ /**
98
+ * Component for displaying status and for labelling other components.
99
+ */
100
+ export const Chip = forwardRef(({
101
+ type = CHIP_TYPES.DEFAULT,
102
+ size = CHIP_SIZES.MEDIUM,
103
+ icon,
104
+ children,
105
+ className,
106
+ ...passThroughProps
107
+ }: ChipProps, ref) => {
108
+ const otherProps = { ...passThroughProps, type, size, className: clsx(className, classNames.BODY) };
109
+
110
+ return <StyledChip ref={ref} {...otherProps}>{children}{icon}</StyledChip>;
111
+ });
112
+
113
+ Chip.displayName = 'Chip';
114
+
115
+ type SpecificChipProps = Omit<ChipProps, 'type'>
116
+
117
+ export const PrimaryChip: FC<SpecificChipProps> = (props) => <Chip type={CHIP_TYPES.PRIMARY} {...props} />;
118
+ export const NeutralChip: FC<SpecificChipProps> = (props) => <Chip type={CHIP_TYPES.DEFAULT} {...props} />;
119
+ export const SuccessChip: FC<SpecificChipProps> = (props) => <Chip type={CHIP_TYPES.SUCCESS} {...props} />;
120
+ export const DangerChip: FC<SpecificChipProps> = (props) => <Chip type={CHIP_TYPES.DANGER} {...props} />;
121
+ export const WarningChip: FC<SpecificChipProps> = (props) => <Chip type={CHIP_TYPES.WARNING} {...props} />;
@@ -0,0 +1,96 @@
1
+ import React from 'react';
2
+ import styled, { css } from 'styled-components';
3
+
4
+ import { Copy16, Check16 } from '@apify/icons';
5
+
6
+ import { theme } from '../../design_system/theme';
7
+ import { useCopyToClipboard } from '../../utils';
8
+ import { Text } from '../text';
9
+
10
+ interface StyledButtonProps {
11
+ $successStyle?: boolean;
12
+ $hasText?: boolean;
13
+ };
14
+
15
+ const StyledButton = styled.button<StyledButtonProps>`
16
+ display: flex;
17
+ justify-content: center;
18
+ align-items: center;
19
+
20
+ border: 1px solid ${theme.color.neutral.border};
21
+ border-radius: ${theme.radius.radius6};
22
+
23
+ cursor: pointer;
24
+
25
+ background: ${theme.color.neutral.backgroundMuted};
26
+ color: ${theme.color.neutral.icon};
27
+ &:hover {
28
+ background-color: ${theme.color.neutral.hover};
29
+ }
30
+
31
+ padding: ${theme.space.space4};
32
+ height: 2.8rem;
33
+ width: 2.8rem;
34
+
35
+ svg {
36
+ width: 2rem;
37
+ height: 2rem;
38
+ }
39
+
40
+ ${({ $hasText }) => $hasText
41
+ && css`
42
+ width: auto;
43
+ padding: ${theme.space.space4} ${theme.space.space8};
44
+ p {
45
+ white-space: nowrap;
46
+ }
47
+ `}
48
+
49
+ ${({ $successStyle }) => $successStyle
50
+ && css`
51
+ background-color: ${theme.color.success.action};
52
+ color: ${theme.color.neutral.textOnPrimary};
53
+ border: none;
54
+ :active {
55
+ background-color: ${theme.color.success.actionActive};
56
+ }
57
+ :hover {
58
+ background-color: ${theme.color.success.action};
59
+ }
60
+ `}
61
+ `;
62
+
63
+ interface ActionButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
64
+ successStyle?: boolean;
65
+ }
66
+
67
+ export const ActionButton = ({
68
+ successStyle,
69
+ children,
70
+ ...props
71
+ }: ActionButtonProps) => {
72
+ const hasText = typeof children === 'string';
73
+
74
+ return (
75
+ <StyledButton
76
+ $successStyle={successStyle}
77
+ $hasText={hasText}
78
+ {...props}
79
+ >
80
+ {hasText ? <Text weight="bold">{children}</Text> : children}
81
+ </StyledButton>
82
+ );
83
+ };
84
+
85
+ interface CopyButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
86
+ code: string;
87
+ }
88
+
89
+ export const CopyButton = ({ code, ...props }: CopyButtonProps) => {
90
+ const [isCopied, handleClick] = useCopyToClipboard({ text: code });
91
+ return (
92
+ <ActionButton onClick={handleClick} data-test='copy_to_clipboard' {...props}>
93
+ {isCopied ? <Check16 viewBox="0 0 16 16" /> : <Copy16 viewBox="0 0 16 16" />}
94
+ </ActionButton>
95
+ );
96
+ };
@@ -0,0 +1,228 @@
1
+ import styled, { css } from 'styled-components';
2
+
3
+ import { theme } from '../../../design_system/theme';
4
+ import type { SharedTextSize } from '../../text/text_shared';
5
+ import { SyntaxHighlighterBaseStylesWrapper } from '../syntax_highlighter';
6
+
7
+ const HIGHLIGHT_BACKGROUND_COLOR = 'rgba(22, 114, 235, 0.05)';
8
+
9
+ export const CodeBlockWrapper = styled(SyntaxHighlighterBaseStylesWrapper) <{
10
+ $hasHeader: boolean;
11
+ $gradientRotation?: number;
12
+ $highlightLines?: number[];
13
+ $hasActionButton?: boolean;
14
+ $hasTabs?: boolean;
15
+ $fullWidth?: boolean;
16
+ $showLineNumbers?: boolean;
17
+ $fullHeight?: boolean;
18
+ size?: SharedTextSize,
19
+ }>`
20
+ position: relative;
21
+ display: flex;
22
+ flex-direction: column;
23
+ min-width: 266px;
24
+
25
+ .CodeBlock-Header {
26
+ padding-top: 7px; /* only 7 due to transform translateY(1px) */
27
+ gap: ${theme.space.space4};
28
+ background-color: ${theme.color.neutral.backgroundSubtle};
29
+ border-bottom: 1px solid ${theme.color.neutral.border};
30
+ z-index: 3;
31
+ position: relative;
32
+ display: flex;
33
+ height: 4rem;
34
+
35
+ .CodeBlock-HeaderTitle {
36
+ margin-left: ${theme.space.space16};
37
+ margin-bottom: ${theme.space.space8};
38
+ margin-top: 0.5rem;
39
+ }
40
+
41
+ .CodeBlock-HeaderTabsWrapper {
42
+ display: flex;
43
+ transform: translateY(1px);
44
+ padding-right: ${theme.space.space32};
45
+ padding-left: ${theme.space.space8};
46
+ overflow-x: auto;
47
+ overflow-y: hidden;
48
+ gap: ${theme.space.space4};
49
+
50
+ margin-right: ${({ $hasActionButton }) => ($hasActionButton ? '128' : '20')}px;
51
+
52
+ .CodeBlock-Tab {
53
+ border-radius: ${theme.radius.radius8};
54
+ background-color: transparent;
55
+ border: 1px solid transparent;
56
+ border-bottom-left-radius: 0;
57
+ border-bottom-right-radius: 0;
58
+ border-bottom: none;
59
+ cursor: pointer;
60
+ height: 3.2rem;
61
+ max-width: 26rem;
62
+
63
+ color: ${theme.color.neutral.textMuted};
64
+
65
+ text-align: center;
66
+ white-space: nowrap;
67
+
68
+ padding: 0.2rem ${theme.space.space8} 0.6rem ${theme.space.space8};
69
+ p {
70
+ padding-top: 0.2rem;
71
+ text-overflow: ellipsis;
72
+ overflow: hidden;
73
+ }
74
+
75
+
76
+ &.selected {
77
+ color: ${theme.color.neutral.text};
78
+ border: 1px solid ${theme.color.neutral.border};
79
+ background-color: ${theme.color.neutral.backgroundMuted};
80
+ border-bottom: none;
81
+ padding: 0.6rem ${theme.space.space8};
82
+ p {
83
+ padding-top: 0;
84
+ }
85
+ }
86
+
87
+ &:hover {
88
+ border: 1px solid ${theme.color.neutral.border};
89
+ border-bottom: none;
90
+ text-decoration: none;
91
+ }
92
+
93
+ &::after {
94
+ /* ensures same width of text when switching tabs and making it bold */
95
+ ${theme.typography.shared.tablet.bodyMStrong}
96
+ display: block;
97
+ content: attr(title);
98
+ font-weight: bold;
99
+ height: 0px;
100
+ color: transparent;
101
+ overflow: hidden;
102
+ visibility: hidden;
103
+ }
104
+ }
105
+ }
106
+ }
107
+
108
+ .CodePre {
109
+ z-index: 2;
110
+ padding: ${theme.space.space16} 0 !important;
111
+
112
+ code {
113
+ & > span {
114
+ display: block;
115
+ padding-left: ${({ $showLineNumbers }) => ($showLineNumbers ? theme.space.space8 : theme.space.space16)};
116
+ padding-right: ${theme.space.space16};
117
+ &:hover {
118
+ background-color: ${HIGHLIGHT_BACKGROUND_COLOR} !important;
119
+ border-left: 6px solid ${theme.color.neutral.border} !important;
120
+ padding-left: ${({ $showLineNumbers }) => ($showLineNumbers ? '0.2' : '1')}rem;
121
+ }
122
+ }
123
+
124
+ // Common styles
125
+ [data*='bash']{
126
+ &::before {
127
+ color: ${theme.color.lavender.base};
128
+ padding-right: ${theme.space.space16};
129
+ min-width: ${theme.space.space24};
130
+ user-select: none;
131
+ -webkit-user-select: none;
132
+ font-size: 1em;
133
+ }
134
+ }
135
+
136
+ [data*='bashStartCommand'] {
137
+ &::before {
138
+ content: '$';
139
+ }
140
+ }
141
+
142
+ [data*='bashCommand'] {
143
+ &::before {
144
+ content: '>';
145
+ }
146
+ }
147
+
148
+ [data*='bashEmptyLine'] {
149
+ &::before {
150
+ content: ' ';
151
+ }
152
+ }
153
+
154
+ [data*='highlighted'] {
155
+ background-color: ${HIGHLIGHT_BACKGROUND_COLOR} !important;
156
+ border-left: 6px solid ${theme.color.neutral.border} !important;
157
+ padding-left: ${({ $showLineNumbers }) => ($showLineNumbers ? '0.2' : '1')}rem;
158
+ }
159
+
160
+
161
+ .linenumber {
162
+ color: ${theme.color.neutral.textSubtle} !important;
163
+ padding-right: ${theme.space.space16} !important;
164
+ min-width: ${theme.space.space24} !important;
165
+ box-sizing: unset !important;
166
+ user-select: none;
167
+ -webkit-user-select: none;
168
+
169
+ ${({ $showLineNumbers }) => (!$showLineNumbers && css`display: none !important;`)}
170
+
171
+ }
172
+ }
173
+ }
174
+
175
+ .CodeBlock-TopRightActionsWrapper {
176
+ position: absolute;
177
+ top: 0;
178
+ right: 0;
179
+ ${({ $hasHeader }) => ($hasHeader
180
+ ? css`
181
+ padding-top: 6px;
182
+ padding-right: ${theme.space.space8};`
183
+ : css`
184
+ padding-top: ${theme.space.space16};
185
+ padding-right: ${theme.space.space16};`)}
186
+
187
+ display: flex;
188
+ gap: ${theme.space.space8};
189
+ z-index: 3;
190
+ height: 3.9rem;
191
+
192
+ ${({ $hasHeader }) => $hasHeader && css`
193
+ padding-left: ${theme.space.space32};
194
+ background: linear-gradient(
195
+ to right,
196
+ transparent,
197
+ ${theme.color.neutral.backgroundSubtle} 20px
198
+ );
199
+ `}
200
+ }
201
+
202
+ .CodeBlock-Gradient {
203
+ right: 0px;
204
+ bottom: 0px;
205
+
206
+ aspect-ratio: 1/1;
207
+ height: 250%;
208
+
209
+ transform: translate(50%, 70%) rotate(${({ $gradientRotation }) => $gradientRotation ?? 0}deg) scaleX(-1);
210
+ }
211
+
212
+ .CodeBlock-HederDotsWrapper {
213
+ display: flex;
214
+ padding: ${theme.space.space8};
215
+ align-items: flex-start;
216
+ gap: ${theme.space.space8};
217
+ margin-bottom: 0.5rem;
218
+ margin-left: ${theme.space.space8};
219
+ background: transparent;
220
+
221
+ .CodeBlock-HeaderDot {
222
+ width: 1.2rem;
223
+ height: 1.2rem;
224
+ border-radius: 50%;
225
+ background-color: ${theme.color.neutral.iconSubtle};
226
+ }
227
+ }
228
+ `;
@@ -0,0 +1,235 @@
1
+ import clsx from 'clsx';
2
+ import React, { useCallback, useMemo, useRef, useState } from 'react';
3
+
4
+ import type { RegularBoxProps } from '../../box';
5
+ import { ColorWheelGradient } from '../../color_wheel_gradient';
6
+ import { Link } from '../../link';
7
+ import { Text } from '../../text';
8
+ import type { SharedTextSize } from '../../text/text_shared';
9
+ import { ActionButton, CopyButton } from '../action_button';
10
+ import SyntaxHighlighter from '../syntax_highlighter';
11
+ import { CodeBlockWrapper } from './code_block.styled';
12
+ import { mapPrefixToBashLine } from './utils';
13
+
14
+ function HeaderDots() {
15
+ return (
16
+ <div className="CodeBlock-HederDotsWrapper">
17
+ <div className="CodeBlock-HeaderDot" />
18
+ <div className="CodeBlock-HeaderDot" />
19
+ <div className="CodeBlock-HeaderDot" />
20
+ </div>
21
+ );
22
+ }
23
+
24
+ interface HeaderProps {
25
+ tabs: CodeTab[] | null;
26
+ currentTab: CodeTab | null;
27
+ onTabChange: (tab: CodeTab, e: React.MouseEvent) => void;
28
+ title?: string;
29
+ showBashHeader?: boolean;
30
+ }
31
+
32
+ function Header({
33
+ tabs,
34
+ currentTab,
35
+ showBashHeader,
36
+ onTabChange,
37
+ title,
38
+ }: HeaderProps) {
39
+ return (
40
+ <div className="CodeBlock-Header">
41
+ {showBashHeader && <HeaderDots />}
42
+ {title && (
43
+ <Text weight="bold" className="CodeBlock-HeaderTitle">
44
+ {title}
45
+ </Text>
46
+ )}
47
+ <div className="CodeBlock-HeaderTabsWrapper">
48
+ {tabs?.map((tab) => {
49
+ const selected = tab.key === currentTab?.key;
50
+ const props = {
51
+ className: clsx('CodeBlock-Tab', { selected }),
52
+ onClick: (e: React.MouseEvent) => onTabChange(tab, e),
53
+ title: tab.label,
54
+ id: tab.id ?? tab.key,
55
+ };
56
+
57
+ const label = <Text weight={tab.key === currentTab?.key ? 'bold' : 'normal'}>
58
+ {tab.label}
59
+ </Text>;
60
+
61
+ if (tab.to) {
62
+ return (
63
+ <Link key={tab.key} to={tab.to} {...props}>
64
+ {label}
65
+ </Link>
66
+ );
67
+ }
68
+ return (
69
+ <div key={tab.key} {...props}>
70
+ {label}
71
+ </div>
72
+ );
73
+ })}
74
+ </div>
75
+ </div>
76
+ );
77
+ }
78
+
79
+ const LANGUAGES_WITHOUT_LINE_NUMBERS = ['json', 'jsonp', 'jsonp', 'rss', 'yaml', 'xml', 'html', 'bash', 'text', 'dockerfile', 'http'];
80
+
81
+ interface CodeTab {
82
+ key: string;
83
+ label: string;
84
+ code: string;
85
+ id?: string;
86
+ highlightLines?: number[];
87
+ language?: string;
88
+ bashCommandsStart?: number[];
89
+ to?: string;
90
+ }
91
+
92
+ type CodeBlockProps = RegularBoxProps & {
93
+ content: string | CodeTab[]; // TODO: Try to make it work with children props
94
+ size?: SharedTextSize;
95
+ language?: string | undefined;
96
+ className?: string;
97
+ hideBashHeader?: boolean;
98
+ onTabChange?: (key: string, e: React.MouseEvent) => Promise<void> | void;
99
+ showGradient?: boolean;
100
+ gradientRotation?: number;
101
+ highlightLines?: number[];
102
+ showActionButton?: boolean;
103
+ actionButtonLabel?: string;
104
+ onActionButtonClick?: () => Promise<void> | void;
105
+ defaultTabKey?: string;
106
+ fullWidth?: boolean;
107
+ fullHeight?: boolean;
108
+ title?: string;
109
+ hideCopyButton?: boolean;
110
+ bashCommandsStart?: number[];
111
+ hideBashPromptPrefixes?: boolean;
112
+ hideLineNumbers?: boolean | undefined;
113
+ }
114
+
115
+ export function CodeBlock({
116
+ content,
117
+ size,
118
+ language,
119
+ highlightLines,
120
+ onTabChange,
121
+ defaultTabKey,
122
+ showGradient,
123
+ hideBashHeader,
124
+ showActionButton,
125
+ fullWidth,
126
+ actionButtonLabel,
127
+ gradientRotation = 340,
128
+ hideLineNumbers,
129
+ fullHeight,
130
+ title,
131
+ hideCopyButton,
132
+ bashCommandsStart,
133
+ hideBashPromptPrefixes,
134
+ onActionButtonClick,
135
+ ...rest
136
+ }: CodeBlockProps) {
137
+ const isMultiTab = content instanceof Array;
138
+ const defaultTab = isMultiTab
139
+ ? content.find((tab) => tab.key === defaultTabKey) ?? content[0]
140
+ : null;
141
+ const [currentTab, setCurrentTab] = useState<CodeTab | null>(defaultTab);
142
+ const currentCode = (isMultiTab ? currentTab?.code : content)?.trim() ?? '';
143
+ const currentLanguage = language ?? currentTab?.language;
144
+
145
+ const currentHighlightLines = useMemo(
146
+ () => (isMultiTab ? currentTab?.highlightLines ?? [] : highlightLines),
147
+ [isMultiTab, currentTab, highlightLines],
148
+ );
149
+
150
+ const isBash = currentLanguage === 'bash';
151
+
152
+ const showLineNumbers = !hideLineNumbers
153
+ && !LANGUAGES_WITHOUT_LINE_NUMBERS.includes(currentLanguage ?? '');
154
+ const showBashPrompt = isBash && !hideBashPromptPrefixes;
155
+ const showBashHeader = isBash && !hideBashHeader && !isMultiTab;
156
+
157
+ const showHeader = isMultiTab || !!title || showBashHeader;
158
+
159
+ const syntaxHighlighterRef = useRef<HTMLPreElement>(null);
160
+
161
+ const handleTabClick = async (tab: CodeTab, e: React.MouseEvent) => {
162
+ await onTabChange?.(tab.key, e);
163
+ setCurrentTab(tab);
164
+ syntaxHighlighterRef.current?.scrollTo(0, 0);
165
+ };
166
+
167
+ const currentBashLinesPrefixes = useMemo(() => {
168
+ if (!showBashPrompt) return [];
169
+ return mapPrefixToBashLine(
170
+ currentCode,
171
+ currentTab?.bashCommandsStart ?? bashCommandsStart,
172
+ );
173
+ }, [currentCode, bashCommandsStart, showBashPrompt, currentTab]);
174
+
175
+ const getLineProps = useCallback(
176
+ (lineNumber: number) => {
177
+ const data = [];
178
+ if (currentHighlightLines?.includes(lineNumber)) {
179
+ data.push('highlighted');
180
+ }
181
+ if (showBashPrompt) {
182
+ data.push(currentBashLinesPrefixes[lineNumber - 1]);
183
+ }
184
+
185
+ return { data: data.join(' ') };
186
+ },
187
+ [currentHighlightLines, showBashPrompt, currentBashLinesPrefixes],
188
+ );
189
+
190
+ return (
191
+ <CodeBlockWrapper
192
+ $hasHeader={showHeader}
193
+ $gradientRotation={gradientRotation}
194
+ $hasActionButton={showActionButton}
195
+ $hasTabs={isMultiTab}
196
+ $fullWidth={fullWidth}
197
+ $fullHeight={fullHeight}
198
+ $showLineNumbers={showLineNumbers}
199
+ {...rest}
200
+ >
201
+ {showHeader && (
202
+ <Header
203
+ tabs={isMultiTab ? content : null}
204
+ currentTab={currentTab}
205
+ onTabChange={handleTabClick}
206
+ showBashHeader={showBashHeader}
207
+ title={title}
208
+ />
209
+ )}
210
+
211
+ <SyntaxHighlighter
212
+ showLineNumbers
213
+ wrapLines
214
+ language={currentLanguage}
215
+ size={size}
216
+ lineProps={getLineProps}
217
+ ref={syntaxHighlighterRef}
218
+ >
219
+ {currentCode}
220
+ </SyntaxHighlighter>
221
+
222
+ <div className="CodeBlock-TopRightActionsWrapper">
223
+ {showActionButton && <ActionButton successStyle onClick={onActionButtonClick}>{actionButtonLabel ?? 'Run on Apify'}</ActionButton>}
224
+ {!hideCopyButton && <CopyButton code={currentCode} />}
225
+ </div>
226
+
227
+ {showGradient && (
228
+ <ColorWheelGradient
229
+ className="CodeBlock-Gradient"
230
+ blurSize={69}
231
+ />
232
+ )}
233
+ </CodeBlockWrapper >
234
+ );
235
+ }
@@ -0,0 +1,19 @@
1
+ // input: [2, 4, 5, 6, 8, 10, 11, 12]
2
+ // returns string indicating what type of line it is (bashStartCommand, bashCommand, bashEmptyLine)
3
+ // commands start -> bashStartCommand
4
+ // every next line after command start until next command start or empty line -> bashCommand
5
+ // empty line or comment -> bashEmptyLine
6
+ export const mapPrefixToBashLine = (code: string, bashCommandsStart: number[] = []) => {
7
+ const lines = code.split('\n').map((line) => line.trim());
8
+
9
+ // by default each line that is not empty or comment is a command start
10
+ if (bashCommandsStart.length === 0) {
11
+ return lines.map((line) => ((line.startsWith('#') || !line) ? 'bashEmptyLine' : 'bashStartCommand'));
12
+ }
13
+
14
+ return lines.map((line, i) => {
15
+ if (bashCommandsStart.includes(i + 1)) return 'bashStartCommand';
16
+ if (line.startsWith('#') || !line) return 'bashEmptyLine';
17
+ return 'bashCommand';
18
+ });
19
+ };
@@ -0,0 +1,3 @@
1
+ export * from './code_block/code_block';
2
+ export * from './one_line_code/one_line_code';
3
+ export * from './inline_code/inline_code';