Skip to content

Better format boundary design #14023

Closed

Description

@ellatrix

Describe the bug

Currently, the format boundary design is an added, or in some cases an updated, background colour. This doesn't really work well with all formats.

  • The link format is an exception, it changes the colour to blue.
  • The code format is an exception, it changes the colour to a different gray.
  • Custom format would need to include their own styles as it may not work for them. E.g. a colour background button cannot have a background as a boundary style.
  • It doesn't work great on different backgrounds, such as the cover image.

Ideally, we would need something that:

  • Works well with all themes, so that themes do not need to update format boundaries.
  • Works well with all formats and potential custom formats.
  • Works well on all backgrounds.

I would suggest using:

  • currentColor as it inherits the text colour, so the contrast will automatically work.
  • Something that is additional foreground, not background. This is more difficult as it should not interfere with anything the format does. So no underline, as that interferes with links. It should also spread over the whole length. Perhaps an overline? This might not look so good.

The design of this is quite challenging. Cc @jasmussen @karmatosed @kjellr and maybe others (?) for ideas.

Activity

  1. added
    [Feature] Rich Text
    Needs Design
    on Feb 21, 2019
  2. ellatrix commented on Feb 21, 2019

    @ellatrix
    MemberAuthor

    screenshot 2019-02-21 at 18 18 57

    Maybe this could work?

    screenshot 2019-02-21 at 18 19 59

    ^ double format

  3. ellatrix commented on Feb 21, 2019

    @ellatrix
    MemberAuthor

    Personally I like the background, it just doesn't work in all cases. :(

  4. jasmussen commented on Feb 22, 2019

    @jasmussen
    Contributor

    Thanks for making this ticket and explaining it so thoroughly. Just to be sure, this is a design consideration, not a technical one, correct?

    I put together a codepen with two ideas: https://codepen.io/joen/pen/ZwdBgN?editors=1100

    None honestly seem better than the background idea — and using mix-blend-mode we could theoretically ensure it should always work in any color sets. I also don't hagte your idea. Just wondering if it's obvious enough what's going on.

  5. ellatrix commented on Feb 22, 2019

    @ellatrix
    MemberAuthor

    The best thing I found so far is having ~20% currentColor and ~80% transparent as a background. The only problem is that there's no way other than using a pseudo element for it, which doesn't work well with inline elements. I tried background: rbga( currentColor, 0.2 ), but that doesn't work. :(

  6. jasmussen commented on Feb 22, 2019

    @jasmussen
    Contributor

    Yep, I had the exact same idea and even tried it. Didn't work.

    You can even use a magic CSS variable to use the color from the operating system selection color. But we tried that and it wasn't solid enough either :(

  7. ellatrix commented on Feb 22, 2019

    @ellatrix
    MemberAuthor

    @jasmussen I tried everything there is in CSS but couldn't get it to work in any way. Luckily we still have JavaScript. :) So now I made something that calculates the current color + opacity and puts the rule in an inline style element. Not perfect, but it works really well. There are some small downsides like hovering style won't change the background, but I think this may be ok. Even that I think I may be able to do.

    Not sure if the amount of opacity is perfect, but we could tune it. When it is white, it seems like it could be more white, but when it is gray, I'm not sure if we can go darker.

    The good thing about this is that no block will ever need to think about boundary styles. What do you think?

    Format Before After
    Link in Cover Image screenshot 2019-02-22 at 11 47 07 screenshot 2019-02-22 at 11 45 19
    Bold in Cover Image screenshot 2019-02-22 at 11 47 14 screenshot 2019-02-22 at 11 45 27
    Bold in Button screenshot 2019-02-22 at 11 48 00 screenshot 2019-02-22 at 11 46 21
    Link screenshot 2019-02-22 at 11 47 46 screenshot 2019-02-22 at 11 45 54
    Colour screenshot 2019-02-22 at 11 47 21 screenshot 2019-02-22 at 11 25 00
    Bold screenshot 2019-02-22 at 11 47 29 screenshot 2019-02-22 at 11 45 41
  8. jasmussen commented on Feb 22, 2019

    @jasmussen
    Contributor

    Wow that is ... holy wow that's kind of incredible work. :slow clap for a long time:

    I don't know why I didn't consider JS here — but this is a JS editor, it won't work at all without JS so it seems totally fine to do this.

    There are some small downsides like hovering style won't change the background, but I think this may be ok.

    I think that's totally okay, and can be revisited if we feel we need it.

  9. kjellr commented on Feb 22, 2019

    @kjellr
    Contributor

    Wow, that latest exploration looks great, @iseulde! 👏

    I think the opacity could be tuned down very slightly, but otherwise that seems excellent. I totally agree with @jasmussen above — I don't see any reason not to use JS here, and I think the hovering issue is fine too. 👍

  10. ellatrix commented on Feb 22, 2019

    @ellatrix
    MemberAuthor

    @kjellr Less opacity? That would mean the background behind bold would be darker, which looks like a bit too much for me. It's hard to find a good balance.

  11. kjellr commented on Feb 22, 2019

    @kjellr
    Contributor

    Sorry for the confusion — I mean that the background could be a little bit lighter, not darker. But yeah, striking a balance is tough. 🙂

  12. ellatrix commented on Feb 22, 2019

    @ellatrix
    MemberAuthor

    @kjellr even in that case, the background for e.g. white text would feel a bit too light to me. Happy to try to figure out to set different opacities for different circumstances though. Not sure what I’d have to base it on. :)

  13. kjellr commented on Feb 22, 2019

    @kjellr
    Contributor

    Now that I'm looking at the screenshots again, I agree that'd be a problem in that case. Using different opacities for different backgrounds would be cool, but even if that doesn't work out I think this is a really solid solution. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs Design[Feature] Rich Text

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions