1
0
mirror of synced 2025-12-21 10:57:10 -05:00
Files
docs/components/ui/TruncateLines/TruncateLines.tsx
Kevin Heis 29ebc555cb Add btn-primary-matte, ScrollButton, TruncateLines to storybook (#21611)
* Update create-processor.js

* Use built in semibold

* Preparing articlelist

* Add blue button to storybook

* Scope fade styles

* Add truncate component

* Add scroll button to storybook

* Update storybook.tsx

* Update DefaultLayout.tsx
2021-09-20 23:21:29 +00:00

27 lines
649 B
TypeScript

import React, { ReactNode } from 'react'
import cx from 'classnames'
export type TruncateLinesPropsT = {
as?: keyof JSX.IntrinsicElements
maxLines: number
children: ReactNode
className?: string
}
export const TruncateLines = (props: TruncateLinesPropsT) => {
const { maxLines, className, children, as: Component = 'div' } = props
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>
)
}