composite-nodes-preview.tsx 5.0 KB

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