forked from jwplayer/ott-web-app
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(project): restrict text length to avoid scrolling issue (jwplayer…
- Loading branch information
1 parent
54d6faf
commit 91d7a49
Showing
10 changed files
with
82 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
packages/ui-react/src/components/TruncatedText/TruncatedText.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.truncatedText { | ||
display: -webkit-box; | ||
-webkit-box-orient: vertical; | ||
overflow: hidden; | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/ui-react/src/components/TruncatedText/TruncatedText.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import TruncatedText from './TruncatedText'; | ||
|
||
describe('<TruncatedText>', () => { | ||
test('renders and matches snapshot', () => { | ||
const { container } = render(<TruncatedText text="Test..." maximumLines={8} />); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
packages/ui-react/src/components/TruncatedText/TruncatedText.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
import styles from './TruncatedText.module.scss'; | ||
|
||
type TruncatedTextProps = { | ||
text: string; | ||
maximumLines: number; | ||
className?: string; | ||
}; | ||
|
||
const TruncatedText: React.FC<TruncatedTextProps> = ({ text, maximumLines, className }) => { | ||
return ( | ||
<div | ||
className={classNames(styles.truncatedText, className)} | ||
style={{ | ||
maxHeight: `calc(1.5em * ${maximumLines})`, | ||
WebkitLineClamp: maximumLines, | ||
}} | ||
> | ||
{text} | ||
</div> | ||
); | ||
}; | ||
|
||
export default TruncatedText; |
12 changes: 12 additions & 0 deletions
12
packages/ui-react/src/components/TruncatedText/__snapshots__/TruncatedText.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`<TruncatedText> > renders and matches snapshot 1`] = ` | ||
<div> | ||
<div | ||
class="_truncatedText_b1c064" | ||
style="max-height: calc(1.5em * 8); -webkit-line-clamp: 8;" | ||
> | ||
Test... | ||
</div> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters