PolicyGenius - Style Guide

Architecture


What is this doc?

This doc describes architecture that is used in this Pattern library.

For conventions and implementation details, see conventions.md.

For approach and philosophy introduction, see index.md.

At the beginning, this doc will contain information/notes about the migration path from current state of things. This part will be removed once the migration is over.

Doc adopted: 2/24/2017

Migration expected completion date: 5/26/2017


Changing/adding to this doc

If you have a suggestion or addition to this doc, here is a good place to start:

  1. Summarize your proposed change and what problem it is solving.
  2. Make a PR on Github. Include examples and a proposed migration path, if appropriate.
  3. Once PR is merged, create Pivotal Tracker stories implementing your change. Include detailed Acceptance Criteria.

Biggest goals of this migration:

1. Make it easier for full stack developers to use the Pattern Library.

This means:

2. Make it easier for designers to use the Pattern Library.

This means:


Combining the two items above will increase the productivity of designer-engineer collaboration.


Item types

The styleguide has these categories of items:

BASE STYLES

WHY?

For engineers:
Base Styles help to keep code organized and easily changeable. If variable/mixin/placeholder is used, it is very easy to change things. Change in one place -> effect applied to the entire library.

For ticket owners:
Base Styles reduce time necessary to prepare the Acceptance Criteria. No need to specify the colors and details of a shadow, just pick one and write its name.

For designers:
Base Styles certainly introduce limitations. However, in the long run they will make design development faster. It takes less time to reuse existing designs, than to create every time from scratch.

EXAMPLES

Typography, Colors, Gradients and Shadows

ADDING TO THIS CATEGORY

Adding a new Base Style is a design direction: they are design standards.
A good rule of thumb: if designers don't care about something being a Base Style in our app, it probably should not be.

Once something is a Base Style, engineers are responsible for enforcing it in the code.

An example of what that means:
Say, Shadows are Base Styles. Engineer starts a ticket which has a new module with a shadow. The Acceptance Criteria will specify the name of the shadow from Base Styles and engineer should reuse the mixin/placeholder/variable, rather than create new rules, even if they result in the same output.

BASE STYLE OVERRIDE

Sometimes a designer will create a module with a unique shadow (or color, or any other Base Style). When this happens, it will be specified in the ticket. It is important that a specific shadow is used, but it's a one off and should not count as a standard. In this case custom rules for shadow will be used in this module.

MIGRATION TASKS, AKA HOW DO WE GET THERE?

ELEMENT

WHY?

For engineers:
Elements add a layer of abstraction allowing to extract styles from Components, Modules and Templates. This results in more modularity and an added framework of reusing parts of code and saves times in development.

For designers:
Same as for Base Styles, this adds already designed styles to the designer's arsenal. It is faster to choose between existing designs than to design new every time. The cons are also the same, this introduces limitations for variaty, but in the long term, will save time and effort.

EXAMPLES

Links, Buttons, Lists and Tables

ADDING TO THIS CATEGORY

An item qualifies to be an Element when:

It is usually the intention that Element is to be used with the html element it is associated with. Having said that, there is no requirement and it will work with any html element.

ELEMENT OVERRIDE

Many html elements in the library will fall back to default Element styles. Overriding this behavior in Modules and Components is normal and necessary.

When Element is used with a class, for example, .button, it may not be overriden by Module, Component, or Template.

MIGRATION TASKS, AKA HOW DO WE GET THERE?

COMPONENT

WHY?

Being able to plug-and-play Components and Modules is a crucial advantage for a full stack engineer, resulting in speed improvement when developing. For a front-end engineer, Components provide building blocks to be reused in bigger items such as Modules and Templates. As a designer, benefits are much the same as Base Styles: existing building blocks are faster to use than design from scratch. It also gives the website a consistent style/look.

EXAMPLES

Checkbox, Searchbox, Tooltip, Caption Bubble, but also Spacers and Icons

ADDING TO THIS CATEGORY

There is somewhat hazy distinction between Module and Component.

One of the hardest things about adding items to the library is naming. Components are abundant and there are many more which can or should be extracted.

When adding new Component:

COMPONENT OVERRIDE

Component rules may not be overriden, except for the situations in the above example.

MIGRATION TASKS, AKA HOW DO WE GET THERE?

We currently have Components pattern, but sometimes they are coupled with Modules/Layouts.

MODULE

WHY?

Modules are like Components, but bigger and they have slightly different rules for what's inside of them. Benefits are the same as Components.

EXAMPLES

Panels, Cards, Fields, Footer, Nav and Breadcrumbs

ADDING TO THIS CATEGORY

Similar to Components. Consider these things:

MODULE OVERRIDE

Modules may not be overriden by any of its parents. They are completely the same as anywhere they are used. If an altered version is needed, a variation can be created (with guidance and approval of designer)

MIGRATION TASKS, AKA HOW DO WE GET THERE?

We currently have Modules pattern, but sometimes they are coupled with Layouts.

LAYOUT

WHY?

Layouts are different than Modules or Components, or even Templates. Layouts are purely utility in function, and are reused in other parts of the library. Layouts will reduce the code repetition and increase modularity, allowing to reuse more of mundane repetitive CSS under the hood. It will also reduce ambiguity of Layout-vs-Page objects, making a clear line between the two.

EXAMPLES

layout-equal-columns, arrange-children-in-a-row, but also existing "Layouts" such as layout-banner and layout-hero.

ADDING TO THIS CATEGORY

Addition to this category will be more of a engineer decision than any other category. This is about reusable mixins and placeholders behind the hood, so design won't care about it.

An item here should be added if:

The naming of Layouts mixins or placeholders should start with layout-.

Every addition should also include detailed documentation and/or pattern library example.

LAYOUT OVERRIDE

Layout mixins and placeholder may be overriden in code, if necessary. Some of that usage variation may also be addressed by arguments (mixins).

MIGRATION TASKS, AKA HOW DO WE GET THERE?

Our current Layout needs are met with a combination of Layout classes and mixins/placeholders, but more heavy on classes.

TEMPLATE

WHY?

Templates are the final umbrella-type objects that don't have any heavy rules by themselves but their purpose is to combine and position blocks of content. Templates build upon the pattern that has worked well for us on pages such as Navigator and Comparison. Templates will work well with the other items in the Pattern Library, and complete the modular approach set by them.

EXAMPLES

Navigator, Comparison, Landing/Homepage, Affiliate and About.

ADDING TO THIS CATEGORY

Templates classnames will start with tem-, to keep incline with modules and components, and make them easily identifiable in the markup.

TEMPLATE OVERRIDE

There are no bigger items to override Templates. Templates should also not have custom-usage overrides. Use variants or different markup for this purpose.

MIGRATION TASKS, AKA HOW DO WE GET THERE?

We already have some of these Templates known as Layouts. For example, Navigator and Comparison.

EXAMPLE (CATEGORY)

WHY?

Big reason for examples is to enable to monitor/catch regressions (Percy). But also, Examples will simplify some of the engineering work as well, providing a full final picture of how the item looks with real content. Examples do not have to be Templates necessarily and can include Modules/Components if they are complex enough to warrant a feature test (a good example of that is the new nav).

For designers, it will provide the complete look of a new page, before it is implemented in the markup.

EXAMPLES

All of the Templates (above) New Nav

ADDING TO THIS CATEGORY

An Example should be added for each new Template. Also, for other items, if they are complex enough or have many states. For other items, will be on engineer's discretion if they think it is likely to break when it has real content inside of them.

MIGRATION TASKS, AKA HOW DO WE GET THERE?

We already have some examples.