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

Add RichText component #875

Merged
merged 13 commits into from
Jun 5, 2020
Merged

Add RichText component #875

merged 13 commits into from
Jun 5, 2020

Conversation

ericluap
Copy link
Contributor

@ericluap ericluap commented Jun 1, 2020

Adds a basic RichText component. Closes #654

It also adds a simple example.

Having different font sizes causes problems with alignment. alignItems(`Baseline) would solve this but I don't think that currently exists here.

@ericluap
Copy link
Contributor Author

ericluap commented Jun 2, 2020

The way I'm doing this seems a bit foolish as every tree concatenation eventually becomes a list concatenation in the toList function. How can I avoid doing this? I'll keep working on it.

Copy link
Member

@glennsl glennsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome @SirFurness! The code looks mostly great, but I do have a few general suggestions:

  • It would be nice to have a separate RichTextmodel that is not bound to the component, so that rich text can be manipulated without bringing in the whole UI layer, and even so that alternative renderers may be implemented. We might want to have one that can embed rich text using immediate mode in a <Canvas> for example.

  • It would also be nice to have a DSL for creating rich text. Something like RichText.(text(~family="Arial", "Hello ") ++ text(~size=24, "world") |> color(Colors.red)). That is, to be able to optionally set properties at creation, and also be able to set them across a span of text nodes.

  • You might want/have to adapt this to feat(components): move font styling out of Style and use families #879

src/UI_Components/RichText.re Outdated Show resolved Hide resolved
Copy link
Member

@glennsl glennsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Aside from a few stylistic suggestion below, I have a couple more general suggestions:

  • As a user, RichTextModel is what you're mostly going to use to work with the model. The component is just used to render the end result. Therefore it seems more convenient to rename RichTextModel to RIchText and the component to RichTextView so that the one that's most frequently used is also the shortest and most convenient to use.

  • The model isn't really UI-specific (or specific to this UI). Could it be moved to Core instead?

  • It would be great to have an interface file for RichTextModel.

src/UI/RichTextModel.re Outdated Show resolved Hide resolved
src/UI/RichTextModel.re Outdated Show resolved Hide resolved
src/UI_Components/RichText.re Outdated Show resolved Hide resolved
@ericluap
Copy link
Contributor Author

ericluap commented Jun 4, 2020

I tried moving RichText to Core but it creates a dependency cycle.

RichText depends on Font which depends on Core.

src/UI/RichText.rei Outdated Show resolved Hide resolved
src/UI/RichText.rei Show resolved Hide resolved
src/UI/RichText.rei Outdated Show resolved Hide resolved
src/UI/RichText.rei Outdated Show resolved Hide resolved
src/UI/RichText.rei Outdated Show resolved Hide resolved
src/UI/RichText.rei Outdated Show resolved Hide resolved
examples/RichTextExample.re Outdated Show resolved Hide resolved
@glennsl
Copy link
Member

glennsl commented Jun 4, 2020

I tried moving RichText to Core but it creates a dependency cycle.

RichText depends on Font which depends on Core.

Ah, I see, that's unfortunate. Thanks for trying though!

src/UI/RichText.re Show resolved Hide resolved
examples/RichTextExample.re Outdated Show resolved Hide resolved
Copy link
Member

@glennsl glennsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, looks good to me now at least!

@glennsl glennsl merged commit 6255331 into revery-ui:master Jun 5, 2020
@glennsl
Copy link
Member

glennsl commented Jun 5, 2020

Thanks for doing an awesome job with this @SirFurness! 🎉

@lessp
Copy link
Member

lessp commented Jun 7, 2020

ping @thangngoc89 😄

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.

RichText model
6 participants