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

fix(css): update layer-cascade diagram #29

Merged
merged 5 commits into from
Nov 11, 2024
Merged

Conversation

OnkarRuikar
Copy link
Contributor

@OnkarRuikar OnkarRuikar commented Nov 5, 2024

The PR makes explicit what are the author declarations in the diagram and removes the "normal" word.

@Kaiido
Copy link

Kaiido commented Nov 5, 2024

As the reporter of the linked issue, thank you, this looks a lot better to me, and with #36656 it will perfectly resolve the issue.

Copy link
Member

@bsmth bsmth left a comment

Choose a reason for hiding this comment

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

LGTM, can wait for Vadim to have a look 👀

@estelle
Copy link
Member

estelle commented Nov 7, 2024

How about SVG:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 880">
    <title>Style origins and layers in order of precedence, from highest to lowest</title>
<style>
 text {
   color: black;
   font-family: sans-serif;
   font-size: 1rem;
   text-anchor: middle;
 }
[fill="#fff"],
.css {
   font-style: italic;
}
</style>

<path fill="#fffed9" stroke="#d6b656" d="M180 0h420v820H180z"/>

<text x="80" y="20" >Highest priority</text>
<g stroke="#000" stroke-miterlimit="10" stroke-width="3" id="arrow">
  <path fill="none" d="M80 771V41.1" />
  <path d="m80 34.35 4.5 9L80 41.1l-4.5 2.25Z"/>
</g>

<path fill="#fff2cc" stroke="#d6b656" d="M190 10h400v40H190z"/>
<text x="390" y="35" class="css">Transition declarations</text>

<g id="all_important">
    <path fill="#fff2cc" stroke="#d6b656" d="M190 60h400v40H190z"/>
    <text x="390" y="85">Important user agent declarations</text>
    <path fill="#fff2cc" stroke="#d6b656" d="M190 110h400v40H190z"/>
    <text x="390" y="135">Important user declarations</text>
    <g id="important-author">
        <path fill="none" stroke="#000" d="M190 160h400v240H190z"/>
        <text x="390" y="185">Important author declarations</text>
        <path fill="#dae8fc" stroke="#6c8ebf" d="M200 199h380v30H200z"/>
        <text x="390" y="219">Important @layer 1 { ... }</text>
        <path fill="#d5e8d4" stroke="#82b366" d="M200 238h380v30H200z"/>
        <text x="390" y="258">Important @layer 2 { ... }</text>
        <path fill="#ffe6cc" stroke="#d79b00" d="M200 278h380v30H200z"/>
        <text x="390" y="298">Important @layer ... { ... }</text>
        <path fill="#e1d5e7" stroke="#9673a6" d="M200 318h380v30H200z"/>
        <text x="390" y="338">Important @layer N { ... }</text>
        <path fill="#647687" stroke="#314354" d="M200 358h380v30H200z"/>
        <text x="390" y="378" fill="#fff">Important Unlayered</text>
    </g>
</g>

<path fill="#fff2cc" stroke="#d6b656" d="M190 411h400v30H190z"/>
<text x="390" y="431" class="css">Animation declarations</text>

<g id="all_normal">
    <g id="author_normal">
        <path fill="none" stroke="#000" d="M190 450h400v250H190z"/>
        <text x="391" y="481">Author declarations</text>
        <path fill="#dae8fc" stroke="#6c8ebf" d="M200 655h380v30H200z"/>
        <text x="390" y="675">@layer 1 { ... }</text>
        <path fill="#d5e8d4" stroke="#82b366" d="M200 615h380v30H200z"/>
        <text x="390" y="635">@layer 2 { ... }</text>
        <path fill="#ffe6cc" stroke="#d79b00" d="M200 575h380v30H200z"/>
        <text x="390" y="595">@layer ... { ... }</text>
        <path fill="#e1d5e7" stroke="#9673a6" d="M200 535h380v30H200z"/>
        <text x="390" y="555">@layer N { ... }</text>
        <path fill="#647687" stroke="#314354" d="M200 495h380v30H200z"/>
        <text x="390" y="515" fill="#fff">Unlayered</text>
    </g>
    <path fill="#fff2cc" stroke="#d6b656" d="M190 714h400v40H190z"/>
    <text x="390" y="739">User declarations</text>
    <path fill="#fff2cc" stroke="#d6b656" d="M190 764h400v40H190z"/>
    <text x="390" y="789">User agent declarations</text>
</g>
<text x="80" y="800" >Lowest priority</text>
</svg>

that makes it accessible (and removes a ton of characters from drawio that aren't needed.

@estelle
Copy link
Member

estelle commented Nov 7, 2024

The id's and g's in my SVG aren't needed either, but they make it easier to read in case the SVG needs to be updated.

@OnkarRuikar
Copy link
Contributor Author

@estelle, Your SVG doesn't render well on my PC:

layer-cascade

We draw images using drawio and export as png, SVG, etc. Wouild like to know from Brian why we use drawio and not some svg editor directly.

@estelle
Copy link
Member

estelle commented Nov 8, 2024

Oh, that's a viewbox issue. Change the 400 to 600 on line 1 and it should work.
I hand-coded the SVG ;). It was just boxes, and the boxes were in the drawio SVG output, so it was fairly straightforward. I basically removed unnecessary attributes and all the switches / foreign objects, pulling out just the <text> and <path> elements, and then put all the presentational attributes in a style block.

I did reorder some content, so if someone uses a screen reader, it is rendered in order.

@bsmth
Copy link
Member

bsmth commented Nov 11, 2024

Would like to know from Brian why we use drawio and not some svg editor directly.

There's a draw.io file because it was easier for me to build it there rather than hand-code the SVG from scratch. I've no preference, really. If there's source files from any editor, it's good to commit them for future.

Anyway, I'm going to merge this one to unblock the related PR. Thank you, both!

@bsmth bsmth merged commit 99e06b6 into mdn:main Nov 11, 2024
@OnkarRuikar OnkarRuikar deleted the layer-cascade branch November 12, 2024 03:37
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.

4 participants