-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#300 load more information on profile page #303
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,42 @@ | ||
import { useState } from 'react'; | ||
import { Typography } from 'antd'; | ||
import { PropTypes } from 'prop-types'; | ||
import classes from './ReadMore.module.css'; | ||
|
||
const { Paragraph } = Typography; | ||
|
||
const ReadMore = ({ children }) => { | ||
const text = children; | ||
const [readMore, setReadMore] = useState(false); | ||
const [ellipsis, setEllipsis] = useState(true); | ||
|
||
const toggleReadMore = () => { | ||
setReadMore(!readMore); | ||
setEllipsis(!ellipsis); | ||
}; | ||
const maxTextLength = 150; | ||
|
||
const displayText = text && (readMore || text.length <= maxTextLength ? text : `${text.slice(0, maxTextLength)}...`); | ||
const ellipsisSymbol = ellipsis ? ( | ||
<span className={classes['read-more-symbol']} onClick={toggleReadMore}> | ||
читати далі | ||
</span> | ||
) : null; | ||
|
||
return ( | ||
text ? ( | ||
<p className={classes['read-more']}> | ||
{displayText} | ||
{text.length > maxTextLength && ( | ||
<span onClick={toggleReadMore} className={classes['read-or-hide']}> | ||
{!readMore ? 'читати далі' : 'приховати'} | ||
</span> | ||
)} | ||
</p>) : null | ||
<> | ||
<Paragraph | ||
className={classes['read-more']} | ||
onClick={toggleReadMore} | ||
ellipsis={ | ||
ellipsis | ||
? { | ||
rows: 6, | ||
expandable: true, | ||
symbol: ellipsisSymbol, | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we move it to constant with a meaningful name? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we do it if it is Ant Design component and its structure? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
: false | ||
} | ||
> | ||
{text} | ||
</Paragraph> | ||
</> | ||
); | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,15 +10,15 @@ import BannerImage from './BannerImage'; | |
import classes from './ProfileDetailPage.module.css'; | ||
|
||
function ProfileDetailPage({ isAuthorized }) { | ||
const authToken = localStorage.getItem('Token'); | ||
const { id } = useParams(); | ||
const urlProfile = `${process.env.REACT_APP_BASE_API_URL}/api/profiles/${id}`; | ||
|
||
async function fetcher(url) { | ||
const headers = { | ||
'Content-Type': 'application/json', | ||
}; | ||
if (isAuthorized) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's passed to child components |
||
const authToken = localStorage.getItem('Token'); | ||
if (authToken) { | ||
headers.Authorization = `Token ${authToken}`; | ||
} | ||
return fetch(url, { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add a fragment if there is only one element
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed