materials.tsx 1.4 KB

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