materials.tsx 1.6 KB

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