composite-nodes-preview.tsx 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /**
  2. * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
  3. * SPDX-License-Identifier: MIT
  4. */
  5. /* eslint-disable import/no-unresolved */
  6. import tryCatch from '@flowgram.ai/demo-fixed-layout-simple/src/data/tryCatch.ts?raw';
  7. import slot from '@flowgram.ai/demo-fixed-layout-simple/src/data/slot.ts?raw';
  8. import multiOutputs from '@flowgram.ai/demo-fixed-layout-simple/src/data/multiOutputs.ts?raw';
  9. import multiInputs from '@flowgram.ai/demo-fixed-layout-simple/src/data/multiInputs.ts?raw';
  10. import loop from '@flowgram.ai/demo-fixed-layout-simple/src/data/loop.ts?raw';
  11. import dynamicSplit from '@flowgram.ai/demo-fixed-layout-simple/src/data/dynamicSplit.ts?raw';
  12. import { PreviewEditor } from '../preview-editor.tsx';
  13. import { FixedLayoutSimple } from './fixed-layout-simple.tsx';
  14. export function CompositeNodesPreview(props: { cellHeight?: number }) {
  15. const previewWidth = '50%';
  16. const editorWidth = '50%';
  17. const cellHeight = props.cellHeight || 300;
  18. return (
  19. <table
  20. className=""
  21. style={{
  22. width: '100%',
  23. border: '1px solid var(--rp-c-divider-light)',
  24. zIndex: 1,
  25. position: 'relative',
  26. }}
  27. >
  28. <tr>
  29. <td style={{ textAlign: 'center' }}>dynamicSplit</td>
  30. <td>
  31. <PreviewEditor
  32. codeInRight
  33. files={{
  34. 'index.tsx': {
  35. code: dynamicSplit,
  36. active: true,
  37. },
  38. }}
  39. previewStyle={{
  40. width: previewWidth,
  41. height: cellHeight,
  42. position: 'relative',
  43. }}
  44. editorStyle={{
  45. width: editorWidth,
  46. height: cellHeight,
  47. }}
  48. >
  49. <FixedLayoutSimple hideTools demo="dynamicSplit" />
  50. </PreviewEditor>
  51. </td>
  52. </tr>
  53. <tr>
  54. <td style={{ textAlign: 'center' }}>loop</td>
  55. <td>
  56. <PreviewEditor
  57. codeInRight
  58. files={{
  59. 'index.tsx': {
  60. code: loop,
  61. active: true,
  62. },
  63. }}
  64. previewStyle={{
  65. width: previewWidth,
  66. height: cellHeight,
  67. position: 'relative',
  68. }}
  69. editorStyle={{
  70. height: cellHeight,
  71. width: editorWidth,
  72. }}
  73. >
  74. <FixedLayoutSimple hideTools demo="loop" />
  75. </PreviewEditor>
  76. </td>
  77. </tr>
  78. <tr>
  79. <td style={{ textAlign: 'center' }}>tryCatch</td>
  80. <td>
  81. <PreviewEditor
  82. codeInRight
  83. files={{
  84. 'index.tsx': {
  85. code: tryCatch,
  86. active: true,
  87. },
  88. }}
  89. previewStyle={{
  90. width: previewWidth,
  91. height: cellHeight,
  92. position: 'relative',
  93. }}
  94. editorStyle={{
  95. height: cellHeight,
  96. width: editorWidth,
  97. }}
  98. >
  99. <FixedLayoutSimple hideTools demo="tryCatch" />
  100. </PreviewEditor>
  101. </td>
  102. </tr>
  103. <tr>
  104. <td style={{ textAlign: 'center' }}>multiInputs</td>
  105. <td>
  106. <PreviewEditor
  107. codeInRight
  108. files={{
  109. 'index.tsx': {
  110. code: multiInputs,
  111. active: true,
  112. },
  113. }}
  114. previewStyle={{
  115. width: previewWidth,
  116. height: cellHeight,
  117. position: 'relative',
  118. }}
  119. editorStyle={{
  120. height: cellHeight,
  121. width: editorWidth,
  122. }}
  123. >
  124. <FixedLayoutSimple hideTools demo="multiInputs" />
  125. </PreviewEditor>
  126. </td>
  127. </tr>
  128. <tr>
  129. <td style={{ textAlign: 'center' }}>multiOutputs</td>
  130. <td>
  131. <PreviewEditor
  132. codeInRight
  133. files={{
  134. 'index.tsx': {
  135. code: multiOutputs,
  136. active: true,
  137. },
  138. }}
  139. previewStyle={{
  140. width: previewWidth,
  141. height: cellHeight,
  142. position: 'relative',
  143. }}
  144. editorStyle={{
  145. height: cellHeight,
  146. width: editorWidth,
  147. }}
  148. >
  149. <FixedLayoutSimple hideTools demo="multiOutputs" />
  150. </PreviewEditor>
  151. </td>
  152. </tr>
  153. <tr>
  154. <td style={{ textAlign: 'center' }}>slot</td>
  155. <td>
  156. <PreviewEditor
  157. codeInRight
  158. files={{
  159. 'index.tsx': {
  160. code: slot,
  161. active: true,
  162. },
  163. }}
  164. previewStyle={{
  165. width: previewWidth,
  166. height: cellHeight,
  167. position: 'relative',
  168. }}
  169. editorStyle={{
  170. height: cellHeight,
  171. width: editorWidth,
  172. }}
  173. >
  174. <FixedLayoutSimple hideTools demo="slot" />
  175. </PreviewEditor>
  176. </td>
  177. </tr>
  178. </table>
  179. );
  180. }