Skip to content

Commit

Permalink
Docs: Add Guidelines (#68)
Browse files Browse the repository at this point in the history
* Nested Guidelines pages

* Fix sort order of generated nav items

* Update Getting Started page

* Update Code conventions page

* Add naming convention image

* Update BEM syntax copy

* Add credit links

* Build documentation

* Add Internationalization docs

* Add Grid guidance

Resolves https://jira.cms.gov/browse/HDSG-70

* Build docs
  • Loading branch information
sawyerh authored Jun 4, 2017
1 parent 87f00ca commit a0774cf
Show file tree
Hide file tree
Showing 69 changed files with 1,071 additions and 627 deletions.
14 changes: 7 additions & 7 deletions docs/base/index.html

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions docs/base/typography/index.html

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions docs/components/alert/index.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/components/badge/index.html

Large diffs are not rendered by default.

60 changes: 31 additions & 29 deletions docs/components/button/index.html

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions docs/components/choice/index.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/components/index.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/components/list/index.html

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions docs/components/select/index.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/components/table/index.html

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions docs/components/tabs/index.html

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions docs/components/text-field/index.html

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions docs/components/vertical-nav/index.html

Large diffs are not rendered by default.

82 changes: 0 additions & 82 deletions docs/core-concepts/index.html

This file was deleted.

73 changes: 73 additions & 0 deletions docs/guidelines/code-conventions/index.html

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions docs/guidelines/grid/index.html

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions docs/guidelines/i18n/index.html

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions docs/guidelines/responsive/index.html

Large diffs are not rendered by default.

89 changes: 66 additions & 23 deletions docs/index.html

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions docs/public/images/naming-convention.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions docs/public/scripts/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/public/styles/docs.css

Large diffs are not rendered by default.

66 changes: 0 additions & 66 deletions docs/responsive/index.html

This file was deleted.

8 changes: 4 additions & 4 deletions docs/utilities/background-color/index.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/utilities/border-radius/index.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/utilities/border/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/utilities/clearfix/index.html

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions docs/utilities/color/index.html

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions docs/utilities/float/index.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/utilities/font-family/index.html

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions docs/utilities/font-size/index.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/utilities/font-style/index.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/utilities/font-weight/index.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/utilities/index.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/utilities/line-height/index.html

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions docs/utilities/margin/index.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/utilities/measure/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/utilities/overflow/index.html

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions docs/utilities/padding/index.html

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions docs/utilities/text-align/index.html

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions docs/utilities/text-decoration/index.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/utilities/text-transform/index.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/utilities/truncate/index.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/utilities/vertical-align/index.html

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions docs/utilities/visibility/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/core/dist/components/Alert/Alert.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/core/dist/components/Button/Button.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/core/dist/components/ChoiceList/Choice.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/core/dist/index.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/core/dist/utilities/color.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/core/dist/utilities/index.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/core/dist/utilities/text-decoration.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions packages/docs/src/images/naming-convention.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 0 additions & 62 deletions packages/docs/src/pages/core-concepts.md

This file was deleted.

46 changes: 46 additions & 0 deletions packages/docs/src/pages/guidelines/code-conventions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: Code conventions
---

<p class="ds-text--lead">
The design system favors clarity over succinctness. This means the design system may be verbose, but it should deliver clarity and resilience in exchange. Keeping CSS legible and scalable means sacrificing a shorter syntax.
</p>

## CSS naming convention

<img src="{{root}}/public/images/naming-convention.svg" class="ds-u-border--1" />

### Namespace

To avoid conflicting with other libraries and existing code, the design system namespaces its CSS class names with `ds-`.

### Prefix

Prefixes are added to class names to make it more apparent what job the class is doing.

| Prefix | Description |
| ------ | ----------- |
| `l-` | Indicates layout-related styles. These classes may be used in any number of unrelated contexts. Example: `.ds-l-container` |
| `c-` | Indicates a component. Example: `.ds-c-button`
| `u-` | Indicates a utility. Example: `.ds-u-color--base` |
| `is-`, `has-` | Indicates state. |

### BEM syntax

Following the namespace and prefix is a name conforming to [BEM syntax](http://getbem.com/introduction/).

Put all together, a CSS class can be broken down to these key parts: `[NAMESPACE]-[PREFIX]-[BLOCK]__[ELEMENT]--[MODIFIER]`

- **Block** is a standalone entity that is meaningful on its own. For example: `.ds-c-card`, `.ds-c-button`
- **Element** is a part of a block that has no standalone meaning and is semantically tied to its block, such as `.ds-c-card__title`
- **Modifier** is a flag on a block or element and is used to change appearance or behavior. For example: `.ds-c-button--primary`, `ds-u-color--primary`, `ds-u-margin--3`

[BEM’s strict naming rules can be found here](http://getbem.com/naming/).

## Credits

The CSS naming convention outlined here was heavily influenced by:

- [CSS Architecture for Design Systems](http://bradfrost.com/blog/post/css-architecture-for-design-systems/), by Brad Frost
- [Thoughtful CSS Architecture](https://seesparkbox.com/foundry/thoughtful_css_architecture), by Nathan Rambeck
- [More Transparent UI Code with Namespaces](https://csswizardry.com/2015/03/more-transparent-ui-code-with-namespaces/), by Harry Roberts
17 changes: 17 additions & 0 deletions packages/docs/src/pages/guidelines/grid.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Grid layout
---

Choosing a suitable grid framework is dependent on several factors. Some of these factors are browser support, if and which CSS preprocessor is being used, degree of customizability, and [layout mode](https://developer.mozilla.org/en-US/docs/Web/CSS/Layout_mode) preference.

As a result, the design system doesn't currently include its own grid framework and instead suggests that you pick from existing solutions, based on what works best for your project and preferences.

Below is a non-exhaustive list of existing grid solutions:

- [Neat](http://neat.bourbon.io/)
- [Flexbox Grid](http://flexboxgrid.com/)
- [Susy](http://susy.oddbird.net/)
- [Unsemantic](https://unsemantic.com/)
- [Bootstrap grid](http://getbootstrap.com/css/#grid)

If you have more suggestions, feel free to [open a ticket](https://github.com/CMSgov/design-system/issues/new).
21 changes: 21 additions & 0 deletions packages/docs/src/pages/guidelines/i18n.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: Internationalization
---

The design system's React components accepts all text as `props`, and it is the app's responsibility to provide the internationalized strings.

For example:

```jsx
import {Alert} from '@cmsgov/design-system-core';
import i18n from 'i18n';

export default function() {
return (
<Alert heading={i18n('success')}>
{i18n('account.created')}
</Alert>
);
}

```
File renamed without changes.
Loading

0 comments on commit a0774cf

Please sign in to comment.