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

Show trix / rhino always_show variation #3263

Open
pjmuller opened this issue Sep 24, 2024 · 3 comments
Open

Show trix / rhino always_show variation #3263

pjmuller opened this issue Sep 24, 2024 · 3 comments
Labels
Good first issue Good for newcomers Help wanted We could use some help with this

Comments

@pjmuller
Copy link

pjmuller commented Sep 24, 2024

Feature

Show a part of the content with a click to see more
See loom: https://www.loom.com/share/d95cfc272bb84e1797870265c9a710fb

to be discussed how we introduce this without creating regressions for users that really want to hide everything.
introduce an extra boolean? partial_show ?

Current workarounds

Define a custom partial for the show action -> copying the app/components/avo/fields/trix_field/show_component.html.erb and using our own styles?

or overwriting the hidden CSS class within this wrapper?

@pjmuller
Copy link
Author

pjmuller commented Sep 26, 2024

FYI: we 80/20 fixed this withi this css, #sharing-is-caring ;)
This works for both trix as rhino.
Would still be cool to have this feature more natively embedded

.trix-content.hidden {
  display: block !important;
}

.trix-content.hidden {
  clip-path: inset(0 0 calc(100% - 50px) 0);
  -webkit-mask-image: linear-gradient(to bottom, black 30px, transparent 50px);
  mask-image: linear-gradient(to bottom, black 30px, transparent 50px);
  max-height: 50px;
  min-height: 0px;
}

.trix-content:not(.hidden) {
  clip-path: none;
  -webkit-mask-image: none;
  mask-image: none;
}

a[data-action="click->hidden-input#showContent"].hidden {
  display: none !important;
}

Copy link
Contributor

This issue has been marked as stale because there was no activity for the past 15 days.

@github-actions github-actions bot added the Stale label Oct 12, 2024
@adrianthedev
Copy link
Collaborator

Yup!
Awesome recommendation!

We should have a few junior folks that want to contribute to OSS soon so maybe we can get some help on it.

Approach

  • tweak the field component Avo::Fields::TrixField::ShowComponent to show a bit of the body
  • this body would be in a div
  • the div would have overflow: hidden and a fixed height
  • create a new stimulus controller to remove the overflow and height classes

Nice to have:

  • the bottom part of the div would have a gradient that passes from transparent (top) to white (bottom) so the user peeks that there is more content below (see how we did it on this PR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good first issue Good for newcomers Help wanted We could use some help with this
Projects
Status: No status
Development

No branches or pull requests

2 participants