CarbonLDP / carbonldp-workbench

Workbench to administer an on premise installation of Carbon LDP's platform
Other
2 stars 3 forks source link

Define CSS conventions (naming, structure, etc.) #129

Open AlexSerrano22 opened 6 years ago

AlexSerrano22 commented 6 years ago

.{ g | c | d } -{component_name | directive_name} (-{ layout | theme | target_name }) (--{description}) (__{ is | has })*

block 1 g: global c: component d: directive

block 2 component or directive name where the css rule is declared.

block 3 layout: this class has rules to modificate the layout of the element. theme: this class has rules to modificate the look and feel of the element. target_name: general css rules for an specific element, like title, header, text-area...

block 4 description: could be a text to describe a modifier that is not a state of the element. like --flex or --bold

block 5 is or has: to indicate thar this is an state of the element. like has-error or is-selected.

()*: this is an optional block.

AlexSerrano22 commented 6 years ago

I'm thinking on use a naming convetion similar to SUIT where do you have:

I would like add/change some rules to be sure that we are covering all cases that we have:

AlexSerrano22 commented 6 years ago

or we can take the all advantage of the encapsulation this option does not finish convincing me but we could use clases only when these are necessary and apply the css directly to the html tags.

e.g.

<document>
  <div class="documents-widget">
    <header>
        Documents
        <div>
            <i class="refresh" (click)="refreshWidget()"></i>
            <i class="remove" (click)="closeWidget()"></i>
        </div>
    </header>
    <section [class.broken]="hasError">
        <div>{{documentsTotalCount}}</div>
    </section>
</div>
</document>

the css could be something like:

:host{
    .documents-widget{
        header{
            ...
            div{
                ...
                i{
                    ...
                }
            }
        }
        section{
            ...
            &.hasError{
                ...
            }
            div{
                ...
            }
        }
    }
}