mirror of
https://github.com/zhigang1992/react.git
synced 2026-03-26 22:42:51 +08:00
27 lines
568 B
TypeScript
27 lines
568 B
TypeScript
import React from 'react'
|
|
|
|
interface Props {
|
|
count: number
|
|
}
|
|
|
|
const TreeIndents: React.FC<Props> = ({ count }) => {
|
|
if (count === 0) return null
|
|
return (
|
|
/* eslint-disable react/jsx-no-useless-fragment */
|
|
<>
|
|
{[...new Array(count)].map((_, index) => (
|
|
<span className="indent" key={`indent-${index}`}>
|
|
<style jsx>{`
|
|
span.indent {
|
|
left: calc(-1.875rem * ${index + 1} + 0.75rem);
|
|
}
|
|
`}</style>
|
|
</span>
|
|
))}
|
|
</>
|
|
/* eslint-enable */
|
|
)
|
|
}
|
|
|
|
export default TreeIndents
|