Skip to content

Commit

Permalink
remove need for styled-jsx construct (github#28749)
Browse files Browse the repository at this point in the history
* remove need for styled-jsx construct

* remove line that might not be needed
  • Loading branch information
peterbe authored Jun 28, 2022
1 parent c18d115 commit 67dc3ac
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ COPY content/index.md ./content/index.md

COPY next.config.js ./next.config.js
COPY tsconfig.json ./tsconfig.json
COPY next-env.d.ts ./next-env.d.ts

RUN npm run build

Expand Down
7 changes: 7 additions & 0 deletions components/ui/TruncateLines/TruncateLines.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.truncated {
// Note that `-webkit-line-clamp` gets set by the component JSX
// manually with a `style` attribute.
display: -webkit-box;
-webkit-box-orient: vertical;
overflow: hidden;
}
12 changes: 3 additions & 9 deletions components/ui/TruncateLines/TruncateLines.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { ReactNode } from 'react'
import cx from 'classnames'

import styles from './TruncateLines.module.scss'

export type TruncateLinesPropsT = {
as?: keyof JSX.IntrinsicElements
maxLines: number
Expand All @@ -11,16 +13,8 @@ export type TruncateLinesPropsT = {
export const TruncateLines = (props: TruncateLinesPropsT) => {
const { maxLines, className, children, as: Component = 'div' } = props
return (
<Component className={cx('root', className)}>
<Component className={cx(styles.truncated, className)} style={{ WebkitLineClamp: maxLines }}>
{children}
<style jsx>{`
.root {
display: -webkit-box;
-webkit-line-clamp: ${maxLines};
-webkit-box-orient: vertical;
overflow: hidden;
}
`}</style>
</Component>
)
}
1 change: 0 additions & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
Expand Down

0 comments on commit 67dc3ac

Please sign in to comment.