Skip to content
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

Feature/show more show less text #1148

Conversation

AndreyGoranov
Copy link
Contributor

@AndreyGoranov AndreyGoranov commented Nov 21, 2022

Motivation and context

-Problem: To have the ability to truncate longer text and control how visible it should be by rows count anywhere in the app.

-How:

  1. By creating a reusable component that accepts text and rows limit.
  2. The component uses local state to handle visibility of the text. It uses WebkitLineClamp for smooth display of the text by rows and adding ellipsis at the last row.
  3. It compares the current height of the text element with the scroll height (current height + the hidden text element height.
  4. The component also listens for screen size changes in order to support responsive design.
  5. The component can be used solo or could be nested inside other tags like paragraph for example and will still work as expected.

Screenshots:

| Before
image
image
image
image
image
| After |
| ------------------- | ------------------ |
| [before screenshot] | [after screenshot] |

Testing

  1. Testing by clicking the small text and expecting the text to expand or hide
  2. Resizing the screen testing if the button hides if the text content is short and doesn't require truncating
  3. Toggling different states of the text then resizing the screen;
  4. Passing 0 rowsLimit or null as rowsLimit
  5. Passing empty string as text
  6. Changing the language
  7. Refreshing the page
    -Environments: Chrome , Safari , Firefox

New environment variables:

  • env var : env var details

New dependencies:

  • dependency : dependency details

New dev dependencies:

  • dependency : dependency details

@ani-kalpachka
Copy link
Member

Closing this PR as duplicate of #1139
Thanks again for the effort!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement 'Show more / Show less' button to longer texts on About page
2 participants