Skip to content

Sibling layout interactions in content, like p+ul #162

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

Open
gnprice opened this issue Jun 8, 2023 · 4 comments
Open

Sibling layout interactions in content, like p+ul #162

gnprice opened this issue Jun 8, 2023 · 4 comments
Labels
a-content Parsing and rendering Zulip HTML content, notably message contents a-design Visual and UX design

Comments

@gnprice
Copy link
Member

gnprice commented Jun 8, 2023

Zulip web has a couple of CSS rules that adjust spacing between sibling block elements. From web/styles/rendered_markdown.css:

    /* The spacing between two paragraphs is significantly larger.  We
       arrange things so that this spacing matches the spacing between
       paragraphs in two consecutive 1-line messages. */
    & p + p {
        margin-top: 10px;
    }
// …

    /* Reduce top-margin when a paragraph is followed by an ordered or bulleted list */
    & p + ul,
    p + ol {
        margin-top: 0;
    }

(The details have changed occasionally over the years, as in zulip/zulip@d7aa186 and
zulip/zulip@62f2396.)

We should either match that behavior, or determine there's a good reason for mobile to differ from web here.

@gnprice gnprice added the a-content Parsing and rendering Zulip HTML content, notably message contents label Jun 8, 2023
@gnprice gnprice added this to the Launch milestone Jun 8, 2023
@gnprice
Copy link
Member Author

gnprice commented Jan 24, 2024

@karlstolley writes last week that he'll be working soon on cleaning up that CSS, simplifying things. (For example, that rule about p + ul has no effect, because the p has a bottom margin of 3px anyway and the top margin of a ul without that rule would be only 2px.)

So this task should become simpler after that work is complete.

@gnprice
Copy link
Member Author

gnprice commented Jan 24, 2024

Some details here:

In particular one planned simplification is:

Shift inter-element Markdown element spacing to a single dimension (margin-top)

(whereas the status quo involves margin-bottom too — which in turn means that its behavior involves CSS margin-collapsing). So that will provide a significantly more straightforward basis for us to translate from.

@gnprice
Copy link
Member Author

gnprice commented Jan 31, 2024

Another rule with a similar character, about an absence-of-sibling rather than siblings, is the one with :first-child here:

    /* Headings */
    & h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        // …
        margin-top: 15px;
        // …
    }

    /* Headings: Ensure that messages that start with a heading don't have
       a weirdly blank area at the very start of the message. */
    & h1:first-child,
    h2:first-child,
    h3:first-child,
    h4:first-child,
    h5:first-child,
    h6:first-child {
        margin-top: 0;
    }

As @sirpengi points out at #492, we don't yet implement that rule either. Probably we should consider it as part of this issue.

@karlstolley
Copy link

My hope with headings is that presenting them with a generous line-height will obviate the need for additional margin-top, but I'll keep this case in mind as that work proceeds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-content Parsing and rendering Zulip HTML content, notably message contents a-design Visual and UX design
Projects
Status: No status
Development

No branches or pull requests

2 participants