我已经在 Danilowoz 上创建了内容加载器,我想将其转换为 SVG 。我进行了研究,并访问了无数网站以实现此任务,但我没有做到。
如何将React Content Loader源代码转换为SVG?
谢谢!
创建您的加载程序:
import React from "react"
import ContentLoader from "react-content-loader"
const MyLoader = () => (
<ContentLoader
height={160}
width={400}
speed={2}
primaryColor="#f3f3f3"
secondaryColor="#ecebeb"
>
<rect x="70" y="15" rx="4" ry="4" width="117" height="6" />
<rect x="70" y="35" rx="3" ry="3" width="85" height="6" />
<rect x="0" y="80" rx="3" ry="3" width="350" height="6" />
<rect x="0" y="100" rx="3" ry="3" width="380" height="6" />
<rect x="0" y="120" rx="3" ry="3" width="201" height="6" />
<circle cx="30" cy="30" r="30" />
</ContentLoader>
)
render(<MyLoader />)
创建SVG文件(如loader.svg
,add svg
element container并保存。
<svg>
<rect x="70" y="15" rx="4" ry="4" width="117" height="6" />
<rect x="70" y="35" rx="3" ry="3" width="85" height="6" />
<rect x="0" y="80" rx="3" ry="3" width="350" height="6" />
<rect x="0" y="100" rx="3" ry="3" width="380" height="6" />
<rect x="0" y="120" rx="3" ry="3" width="201" height="6" />
<circle cx="30" cy="30" r="30" />
</svg>
现在,您已经拥有了SVG文件,甚至可以将其拖放到您喜欢的原型应用程序中,例如Figma / Zeplin等: