Files
NotionNext/components/NotionIcon.js
JonasTech0 2cd7f13f02 heo封面居中
动画调整
单独控制标题处NotionIcon使其居中
2024-09-12 09:57:27 +08:00

22 lines
597 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import LazyImage from './LazyImage'
/**
* notion的图标icon
* 可能是emoji 可能是 svg 也可能是 图片
* @returns
*/
const NotionIcon = ({ icon, className = 'w-8 h-8 my-auto inline mr-1' }) => {
if (!icon) {
return <></>
}
if (icon.startsWith('http') || icon.startsWith('data:')) {
// 这里优先使用传入的 className
return <LazyImage src={icon} className={className} />
}
// 对于 emoji 或 svg设置默认 className也可以传递不同的样式
return <span className={`inline-block ${className}`}>{icon}</span>
}
export default NotionIcon