4.0.1 • Published 1 year ago

@jorsek/content-portal-themes v4.0.1

Weekly downloads
192
License
ISC
Repository
-
Last release
1 year ago

Themes

Structure

+-- base
+-- dark
+-- light
+-- whitelabel
...

The dark and light themes independently inherit from the base theme using the npm deepmerge package.

  • base should never contain color properties and should only contain structural (grid, flex, position, etc...) CSS
  • dark, light, and any other color themes should contain mostly color specifications but should avoid containing structural CSS changes. This should be limited in scope.
  • None of the basic themes should make use of :before or :after pseudo-selectors.
    • Those are powerful tools for drastically changing the layout structure and presentation of a specific tenant. They should be reserved exclusively for tenant theme CSS.
  • Tenant themes will likely contain all of the above and css adjustments (position, top, margins, padding)

Rules

  1. Never use negative margins in the base themes. Customer overrides may require it (such as Vyatta's hero image and background color) but should be avoided if at all possible.
  2. Never use percentages unless It's a base 8 root %. (100%, 50%, 25%, 12.5%, 6.25% 3.125%)
    • 33% sucks for this very reason. Use it sparingly.
    • Instead, try to use flex properties and flex-basis when forced to use awkward percentages.)
  3. Use rems whenever possible. The html base font-size should be set by default to 16px. Scale everything off rems that way.
  4. Use flex for general layout properties. Use grid for specific use-cases with lists and items that need to be fixed to a certain number. grid is an extension of flex and anything can be achieved with flex that you can with grid albeit less rigid.

BEM

BEM stands for "{Block}-{Element}-{Modifier}". We use a slightly modified variation of BEM for CSS naming, but it's good to understand BEM and why it exists. The reason for this is we want and invite people to apply their own styling.

Typical jss/sass stylesheet generation obfuscates the names of CSS classes. ./media/jss.png

What we generate are semantic naming of elements based on the layout and page they are rendered on. ./media/bem~ish.png

Element CSS naming

Every element should have a specifically unique CSS name. No elements should be left without a class.

Do NOT do this:

<!-- not very descriptive of your intent. What are your dogs doing here? Why should I care if they are YOUR dogs?-->
<div className={classes.my_dogs}>
    <!-- THIS SPAN IS BAD AND DIFFICULT TO TARGET WITH CSS AND YOOU SHOULD FEEL BAD -->
    <span>
        <!-- ... just... why? ...WHY!? a ul serves the same function. just style the ul  -->
        <div>
            <!-- Cool, but COMPLETELY unrelated to the parent container. -->
            <!-- kittens/kitten This creates a TON of confusion and it often easy to overlook and hard to remember -->
            <ul className={classes.kittensBlender}>
                <!-- Why it is a blender? Does it need to be a blender? maybe a more apt name would be blendedKitten -->
                <!-- Also, "toys_1" Does NOT describe the INTENT of the list. we should be more SPECIFIC! -->
                {this.props.toys_1.map((item, i)=> <li className={classes.kitten}></li>}
            </ul>
        </div>
    </span>
</div>

Much better:

<!-- if the name of the component pa-->
<div className={classes.dogToys}>
    <!-- Title vs Header is debatable here. just pick one and BE CONSISTENT -->
    <h3 className={classes.dogToysTitle}>{props.title}</h3>
    <!-- If wrap an element within another div, just make sure there are at least TWO elements inside it-->
    <!-- In fact, we should consider wrappiing every TWO elements within a div to provide better style override opportinities -->
    <div className={classes.dogToysContainer}>
        <!-- don't switch up from Title to Header now. If you do, go back and change the other one to header.  -->
        <!-- You might be tempted to go with SubTitle here, but we are within the Container. -->
        <!-- If you want to move this next to to be a sibling of the dogToysTitle element, -->
        <!-- you would name it SubTitle and wrap both dogToysTitle and dogToysSubTitle in a dogToysTitleWrapper div. -->
        <p className={classes.dogToysContainerTitle}></p>
        <!-- dogToysChewToys vs dogToysChewToyList - always go with the List instead of pluralizing a shorter name. -->
        <!-- Remember, we want to be SPECIFIC! The name chosen based on the property we are maping over to generate the list -->
        <!-- that name should also be SPECIFIC to the intent. -->
        <ul className={classes.dogToysChewToyList}>
            <!-- dogToysChewToys vs dogToysChewToyList - always go with the List instead of pluralizing a shorter name. --> 
            <!-- Remember, we want to be specific! Theese are Dog Chew toys. -->
            <!-- The naming should be consistent so it's easy to find issues -->
            {this.props.dogChewToys.map((item, i)=> (
                <!-- dogToysChewToyListItem. This is a highly specific name. this shows intent, itration, specificity, -->
                <!-- and it is VERY easy to see what it is doing JUST by looking at the name -->
                <li key={title+i} className={classes.dogToysChewToyListItem}>{item}</li>
            ))}
        </ul>
    </div>
</div>

Full~ish example:

<!-- Wrapper - outer becomes .dog-toys-wrapper -->
<div className={classes.dogToysWrapper}>
    <!-- when unsure, Think of the intent, then fall back to the name of the element if need be.-->
    <!-- becomes .dog-toys-caption -->
    <caption className={classes.dogToysCaption}></caption>
    <!-- this will become .dog-toys-root. Why is the root inside a wrapper? It doesn't need to be. Just be consistent. -->
    <div className={classes.dogToys}>
        <!-- becomes .dog-toys-title -->
        <h3 className={classes.dogToysTitle}>{props.title}</h3>
        <!-- becomes .dog-toys-container -->
        <div className={classes.dogToysContainer}>
            <!-- becomes .dog-toys-container-title -->
            <p className={classes.dogToysContainerTitle}></p>
            <!-- becomes .dog-toys-chew-toy-list -->
            <ul className={classes.dogToysChewToyList}>
                <!-- becomes .dog-toys-chew-toy-list -->
                {this.props.dogChewToys.map((item, i)=> (
                    <!-- becomes .dog-toys-chew-toy-list-item -->
                    <li key={title+i} className={classes.dogToysChewToyListItem}>{item}</li>
                ))}
            </ul>
        </div>
    </div>
</div>

If you end up nesting containers within containers and wrappers within wrappers, etc...

STOP

Make a new component.

Breakpoints.

We have standardized the breakpoints to hit most popular device widths.

mediaBreakpoints: [375, 480, 640, 768, 1024, 1280, 1366]
  • 375 - 640: targets most Mobile devices. Some guides show 320, but those are older iphone 4s~5 era devices.
  • 640 - 1280 Targets most tablet devices and smaller laptop screens
  • 1366+ - Desktop Only

Local Development within in the content-portal repo

$ cd ~/src
$ git clone git@github.com:Jorsek/content-portal-themes.git
$ cd content-portal-themes 
$ npm link
$ cd ../content-portal 
& npm link @jorsek/content-portal-themes
4.0.1

1 year ago

4.0.0

1 year ago

1.4.37-dev

1 year ago

1.4.34-dev

1 year ago

1.4.38-dev

1 year ago

3.0.0

1 year ago

1.4.51

1 year ago

1.4.50

1 year ago

1.4.53

1 year ago

1.4.52

1 year ago

1.4.37

1 year ago

1.4.35

2 years ago

1.4.36

2 years ago

1.4.33

2 years ago

1.4.34

2 years ago

1.4.31

3 years ago

1.4.32

3 years ago

1.4.30

3 years ago

1.4.28

3 years ago

1.4.29

3 years ago

1.4.27

3 years ago

1.4.26

3 years ago

1.4.25

3 years ago

1.4.24

3 years ago

1.4.20

3 years ago

1.4.22

3 years ago

1.4.21

3 years ago

1.4.23

3 years ago

1.4.6

3 years ago

1.4.5

3 years ago

1.4.4

3 years ago

1.4.9

3 years ago

1.4.11

3 years ago

1.4.8

3 years ago

1.4.10

3 years ago

1.4.7

3 years ago

1.4.13

3 years ago

1.4.12

3 years ago

1.4.15

3 years ago

1.4.14

3 years ago

1.4.17

3 years ago

1.4.16

3 years ago

1.4.19

3 years ago

1.4.18

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.10

3 years ago

1.3.13

3 years ago

1.3.14

3 years ago

1.3.11

3 years ago

1.3.12

3 years ago

1.3.17

3 years ago

1.3.18

3 years ago

1.3.15

3 years ago

1.3.16

3 years ago

1.3.19

3 years ago

1.3.20

3 years ago

1.3.21

3 years ago

1.3.9

3 years ago

1.3.8

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.2.19

3 years ago

1.3.0

3 years ago

1.2.20

3 years ago

1.2.18

3 years ago

1.2.17

3 years ago

1.2.16

3 years ago

1.2.14

3 years ago

1.2.15

3 years ago

1.2.13

3 years ago

1.2.12

3 years ago

1.2.11

3 years ago

1.2.10

3 years ago

1.2.9

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.0

3 years ago

1.2.1

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.2

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago