smartcoop / design

An open source design system for Smart applications
https://design.smart.coop
Other
4 stars 1 forks source link

Make the source for the same title styling on different page more uniform #118

Open thusc opened 3 years ago

thusc commented 3 years ago

I'm looking at the main title on these pages:

They look all the same and placed at the right position (which is of course very nice).

Now if I look at the source, they are quite different :

    <main class="o-container">
        <div class="o-container o-container--medium">
            <div class="o-container-vertical">
                <div class="c-display">
                    <h1>Browser support</h1>
    <main class="o-container">
        <div class="o-container o-container--medium">
            <div class="o-container-vertical">
                <h1 class="c-d-h1">Blog</h1>
    <main class="o-container">
        <div class="o-container o-container--medium">
            <div class="o-container-vertical">
                <article class="c-blog-article">
                    <div class="c-blog-article__header">
                        <h1 class="c-d-h1">Smart announces an open design system</h1>

Would it be possible to have less differences ?

Wolfr commented 3 years ago

I think you have to understand the usage of the c-content class vs for example a specific .c-h1 class.

In our stylesheet, we first reset all HTML element styles with a global reset.

Then, within certain areas where we want rich text, we mark them with .c-content (or .c-display, which is equivalent but produces larger type sizes and more distinction between headings).

This gives us rich text for every element within that div.

The specific class c-d-h1 is meant to “invoke” the styling for a specific element.

In the following markup:

  <h1 class="c-d-h1">Smart announces an open design system</h1>
  <p>October 8, 2021</p>
</div>

The h1 gets rich styling, equivalent to .c-display h1, by having a c-d-h1 class, but the paragraph doesn't receive normal paragraph styling (which contains margins). This allows us to simply style .c-blog-article__header p with a muted color, which is the only styling that needs to be applied here.

This way we don't need to reset anything. If you need to reset something in CSS (except for a global reset) you're likely doing something wrong.

This all to say that the system is all very deliberate.


About article, I would only use article for a blog post, I don't think it makes that much sense for a content page. Google news bot for example uses article as a deterministic factor (along with other things like the existence of a date) to find out if something is an article.

If you use article for things that are not news, then where does it stop?

thusc commented 3 years ago

So I rember that

Is that right ?

I really like the explanation you gave above. Do you think we could have additional explanations like this one in the documentation, or maybe it would deserve a blog post ?