1
0
mirror of synced 2025-12-21 19:06:49 -05:00
Files
docs/components/TruncateLines.tsx
Mike Surowiec e0d9a061a3 React category / sub-landing page (#19635)
Re-work routes to use GlobalPage, implements TocLanding, bundle of minor cleanup / fixes
2021-06-02 16:28:39 +00:00

27 lines
625 B
TypeScript

import React, { ReactNode, ReactHTML } from 'react'
import cx from 'classnames'
type Props = {
as?: keyof ReactHTML
maxLines: number
children: ReactNode
className?: string
}
export const TruncateLines = (props: Props) => {
const { as, maxLines, className, children } = props
const Component = as || 'div'
return (
<Component className={cx('root', className)}>
{children}
<style jsx>{`
.root {
display: -webkit-box;
-webkit-line-clamp: ${maxLines};
-webkit-box-orient: vertical;
overflow: hidden;
}
`}</style>
</Component>
)
}