materials.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
  3. * SPDX-License-Identifier: MIT
  4. */
  5. // @ts-expect-error
  6. import { PackageManagerTabs, SourceCode } from '@theme';
  7. export function MaterialDisplay(props: any) {
  8. return (
  9. <div>
  10. <br />
  11. <PackageManagerTabs
  12. command={{
  13. 'By Import': `import { ${props.exportName} } from '@flowgram.ai/form-materials'`,
  14. // components/type-selector/index.tsx -> components/type-selector
  15. 'By CLI': `npx @flowgram.ai/form-materials@latest ${props.filePath
  16. .split('/')
  17. .slice(0, -1)
  18. .join('/')}`,
  19. }}
  20. />
  21. <br />
  22. <div style={{ display: 'flex', justifyContent: 'space-between' }}>
  23. <div style={{ width: '42%' }}>
  24. {props.imgs.map((img: string | any, index: number) => (
  25. <div key={index}>
  26. <img
  27. loading="lazy"
  28. src={typeof img === 'string' ? img : img.src}
  29. style={{ width: '100%' }}
  30. />
  31. {img.caption && (
  32. <div style={{ textAlign: 'center', fontSize: 12, color: '#666' }}>
  33. {img.caption}
  34. </div>
  35. )}
  36. </div>
  37. ))}
  38. </div>
  39. <div style={{ width: '55%' }}>
  40. {props.children}
  41. <SourceCode
  42. href={`https://github.com/bytedance/flowgram.ai/tree/main/packages/materials/form-materials/src/${props.filePath}`}
  43. />
  44. </div>
  45. </div>
  46. </div>
  47. );
  48. }