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

Display spoilers in text messages #274

Closed
kevinaboos opened this issue Nov 23, 2024 · 7 comments · Fixed by #319
Closed

Display spoilers in text messages #274

kevinaboos opened this issue Nov 23, 2024 · 7 comments · Fixed by #319
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Looking for help from anyone!

Comments

@kevinaboos
Copy link
Member

kevinaboos commented Nov 23, 2024

Currently Robrix does not display anything at all for text message content that is wrapped within a <data-mx-spoiler> tag. This is bad and makes it seem like the message is empty.

The easiest way to implement this is to make the message unreadable by setting the text background color to be the same as the foreground color.
(Ideally, we would use a fancy blur animation, but that's quite difficult to implement.)

Then, when the user clicks the spoiler text, we should "reveal" the text and make it readable, e.g., by setting the background color of the text back to normal.

The key to this implementation is to show the Cursor hand upon hovering over the spoiler text, otherwise the user may now be aware that there's anything clickable there.

With this implementation we can optionally choose to hide or show the spoiler reason (if one is given). That's not super important in the first step.

@kevinaboos kevinaboos added enhancement New feature or request good first issue Good for newcomers help wanted Looking for help from anyone! labels Nov 23, 2024
@github-project-automation github-project-automation bot moved this to Ready in Robrix Nov 23, 2024
@kevinaboos kevinaboos changed the title Display <spoiler> tags in messages Display spoilers in text messages Nov 23, 2024
@rabelmervin
Copy link

Hi sir @kevinaboos Can i contribute to this issue ? This will be a good learning opportunity for me.

@kevinaboos
Copy link
Member Author

Hi sir @kevinaboos Can i contribute to this issue ? This will be a good learning opportunity for me.

definitely, go for it! We love to have contributions from anyone, they're much appreciated.

@rabelmervin
Copy link

rabelmervin commented Nov 26, 2024

Thanks @kevinaboos Excited to work on this :)

@rabelmervin
Copy link

Hi @kevinaboos it would be great if you tell me the file location where changes needed.

@kevinaboos
Copy link
Member Author

Well you'll need to modify a few different things to implement this. First up would be to create a Spoiler widget, probably in its own separate file, which includes the blurred or colored-over view of the hidden text and the spoiler reason text, both as Rust states.
Then, you'll need to add this new Spoiler widget into the RobrixHtml widget (in html_or_text.rs) such that it is used when the span tag includes a data-mx-spoiler attribute. That's not super easy to do at the moment, but you can also take a look at Makepad's own Html widget to see how other custom widgets can be integrated into it.

You'll also need to implement click handlers for the Spoiler widget such that it can transform info plaintext upon click.

@kevinaboos kevinaboos moved this from Ready to In progress in Robrix Jan 8, 2025
@kevinaboos
Copy link
Member Author

So this was a bit more complex than I initially thought, but I have just implemented both background colors and spoilers myself (they use similar techniques). @rabelmervin Just wanted to let you know in case you were still tinkering with it.

@rabelmervin
Copy link

rabelmervin commented Jan 9, 2025

Yeah @kevinaboos , Initially i struggled with this issue a lot Since, I was new to rust and failed to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Looking for help from anyone!
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants