Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rex Dri
Rex Dri
Commits
29739569
Commit
29739569
authored
May 03, 2020
by
Estelle Veisemburger
Browse files
fix(Read More Button):only show when necessary
parent
82577697
Changes
1
Hide whitespace changes
Inline
Side-by-side
frontend/src/components/common/markdown/TruncatedMarkdown.jsx
View file @
29739569
...
...
@@ -10,11 +10,12 @@ function TruncatedMarkdown(props) {
const
[
truncated
,
setTruncated
]
=
useState
(
false
);
const
{
source
,
truncateFromLength
,
classes
}
=
props
;
const
sourceAsString
=
source
===
null
?
""
:
source
;
const
truncatable
=
sourceAsString
.
length
>
truncateFromLength
;
const
truncatable
=
sourceAsString
.
length
>
3
*
truncateFromLength
;
if
(
!
truncatable
)
{
return
<
Markdown
source
=
{
sourceAsString
}
/>;
}
return
(
<>
<
Collapse
in
=
{
truncated
}
collapsedHeight
=
"4rem"
>
...
...
@@ -22,9 +23,10 @@ function TruncatedMarkdown(props) {
</
Collapse
>
{
!
truncated
&&
<
div
className
=
{
classes
.
gradientBorder
}
/>
}
<
Button
variant
=
"
conta
ined"
variant
=
"
outl
ined"
className
=
{
classes
.
moreButton
}
onClick
=
{
()
=>
setTruncated
(
!
truncated
)
}
size
=
"small"
>
{
!
truncated
?
"
En lire plus...
"
:
"
En lire moins...
"
}
</
Button
>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment