index.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import React from 'react';
  2. import cls from 'classnames';
  3. import { cssClasses } from '@douyinfe/semi-foundation/aiCard/constants';
  4. import '@douyinfe/semi-foundation/aiCard/aiCard.scss';
  5. const ICON_MAP = {
  6. default: 'https://cdn-tos-cn.bytedance.net/obj/ies-semi/images/mcvchagt-4rqbkb6.svg',
  7. stroked: 'https://cdn-tos-cn.bytedance.net/obj/ies-semi/images/mcvchagt-cfq9xbz.svg',
  8. filled: 'https://cdn-tos-cn.bytedance.net/obj/ies-semi/images/mcvchagt-w7je9be.svg',
  9. 'filled-top': 'https://cdn-tos-cn.bytedance.net/obj/ies-semi/images/mcvchagt-vut0xqr.svg',
  10. };
  11. /**
  12. * type: 'default' | 'stroked' | 'filled' | 'filled-top'
  13. * status: 'normal' | 'hover' | 'active' | 'disabled'
  14. */
  15. function AICardSection({ type = 'default', status = 'normal', title = 'AI Summary', icon, ...props }) {
  16. const prefixcls = cssClasses.PREFIX;
  17. const blockCls = `${prefixcls}-block`;
  18. const typeCls = `${prefixcls}-${type}`;
  19. // Icon per type
  20. const iconUrl = icon || ICON_MAP[type];
  21. return (
  22. <section
  23. className={cls(
  24. prefixcls,
  25. typeCls,
  26. `${prefixcls}-status-${status}`
  27. )}
  28. {...props}
  29. >
  30. <div className={blockCls}>
  31. <div className={`${blockCls}-header`}>
  32. <img className={`${blockCls}-icon`} src={iconUrl} alt="AI Icon" />
  33. <span className={`${blockCls}-title`}>{title}</span>
  34. </div>
  35. {/* Block content, such as summary, goes here (children) */}
  36. <div className={cls(`${blockCls}-footer`)}>
  37. {/* Footer content or separator if needed */}
  38. </div>
  39. </div>
  40. {/* Special decorations for certain types */}
  41. {type === 'filled-top' && (
  42. <div className={`${prefixcls}-filled-top-bg`} />
  43. )}
  44. {type === 'filled' && (
  45. <div className={`${prefixcls}-separator`} />
  46. )}
  47. {(type === 'default' || type === 'stroked') && (
  48. <div className={`${prefixcls}-rectangle`} />
  49. )}
  50. </section>
  51. );
  52. }
  53. export default AICardSection;