Skip to content

Commit

Permalink
docs(icons): Add more documentation and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lzcabrera committed Sep 26, 2017
1 parent 6003580 commit f8d4c8c
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 69 deletions.
1 change: 1 addition & 0 deletions config/styleguide.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ module.exports = {
},
{
name: 'Icons',
content: path.resolve('src/components/Icons/icons.md'),
components() {
return compact([
toggleByEnv('Icon', path.resolve('src/components/Icons/DecorativeIcon/DecorativeIcon.jsx')),
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icons/DecorativeIcon/DecorativeIcon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
import Icon from '../Icon/Icon'

/**
* An icon that is used just for visual aesthetics.
* An icon used for visual aesthetics only.
*
* <span class="docs--badge__wip">wip</span>
*/
Expand Down
44 changes: 1 addition & 43 deletions src/components/Icons/DecorativeIcon/DecorativeIcon.md
Original file line number Diff line number Diff line change
@@ -1,43 +1 @@
### Available Icons

```
<div className="docs--horizontal-spacing">
<DecorativeIcon symbol="caretDown" />
<DecorativeIcon symbol="caretUp" />
<DecorativeIcon symbol="checkmark" />
<DecorativeIcon symbol="leftChevron" />
<DecorativeIcon symbol="chevron" />
<DecorativeIcon symbol="exclamationPointCircle" />
<DecorativeIcon symbol="expander" />
<DecorativeIcon symbol="hamburger" />
<DecorativeIcon symbol="location" />
<DecorativeIcon symbol="minus" />
<DecorativeIcon symbol="plus" />
<DecorativeIcon symbol="questionMarkCircle" />
<DecorativeIcon symbol="spyglass" />
<DecorativeIcon symbol="times" />
</div>
```

### Modifying color

Use the `variant` prop to alter the icon's color. Each variant has semantic meaning.

```
<div className="docs--horizontal-spacing">
<DecorativeIcon symbol="checkmark" variant="primary" />
<DecorativeIcon symbol="incomplete" variant="secondary" />
<DecorativeIcon symbol="exclamationPointCircle" variant="error" />
</div>
```

### Adjusting size

Use the `size` prop to adjust the icon's size.

```
<div className="docs--horizontal-spacing">
<DecorativeIcon symbol="chevron" variant="primary" size={16} />
<DecorativeIcon symbol="exclamationPointCircle" variant="error" size={24} />
</div>
```
Decorative icons do not perform a role beyond visual aesthetics and are hidden from screen readers using the aria-hidden attribute. Usually, the information being communicated with the icon is also conveyed in another manner.
8 changes: 0 additions & 8 deletions src/components/Icons/Icon/Icon.modules.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,6 @@
}
}

.iconIncomplete {
composes: icon;

&::before {
content: "\f104";
}
}

.iconLocation {
composes: icon;

Expand Down
27 changes: 10 additions & 17 deletions src/components/Icons/StandaloneIcon/StandaloneIcon.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
### Available Icons
### Making interactive icons

Standalone icons can also be interactive elements. This example shows the preferred way of creating an interactive icon:

```
<div className="docs--horizontal-spacing">
<StandaloneIcon symbol="caretDown" a11yText="text" />
<StandaloneIcon symbol="caretUp" a11yText="text" />
<StandaloneIcon symbol="checkmark" a11yText="text" />
<StandaloneIcon symbol="leftChevron" a11yText="text" />
<StandaloneIcon symbol="chevron" a11yText="text" />
<StandaloneIcon symbol="exclamationPointCircle" a11yText="text" />
<StandaloneIcon symbol="expander" a11yText="text" />
<StandaloneIcon symbol="hamburger" a11yText="text" />
<StandaloneIcon symbol="location" a11yText="text" />
<StandaloneIcon symbol="minus" a11yText="text" />
<StandaloneIcon symbol="plus" a11yText="text" />
<StandaloneIcon symbol="questionMarkCircle" a11yText="text" />
<StandaloneIcon symbol="spyglass" a11yText="text" />
<StandaloneIcon symbol="times" a11yText="text" />
</div>
<button
style={{appearance: 'none', background: 'none', border: 0, cursor: 'pointer'}}
type="submit">
<StandaloneIcon symbol="spyglass" size={48} a11yText="Search this site." />
</button>
```

This will be added as a built in feature in the future, until then follow the above example.
43 changes: 43 additions & 0 deletions src/components/Icons/icons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
### Available Icons

```
<div className="docs--horizontal-spacing">
<DecorativeIcon symbol="caretDown" />
<DecorativeIcon symbol="caretUp" />
<DecorativeIcon symbol="checkmark" />
<DecorativeIcon symbol="leftChevron" />
<DecorativeIcon symbol="chevron" />
<DecorativeIcon symbol="exclamationPointCircle" />
<DecorativeIcon symbol="expander" />
<DecorativeIcon symbol="hamburger" />
<DecorativeIcon symbol="location" />
<DecorativeIcon symbol="minus" />
<DecorativeIcon symbol="plus" />
<DecorativeIcon symbol="questionMarkCircle" />
<DecorativeIcon symbol="spyglass" />
<DecorativeIcon symbol="times" />
</div>
```

### Modifying colour

Use the `variant` prop to alter the icon's colour. Each variant has semantic meaning.

```
<div className="docs--horizontal-spacing">
<DecorativeIcon symbol="checkmark" variant="primary" />
<DecorativeIcon symbol="times" variant="secondary" />
<DecorativeIcon symbol="exclamationPointCircle" variant="error" />
</div>
```

### Adjusting size

Use the `size` prop to adjust the icon's size.

```
<div className="docs--horizontal-spacing">
<DecorativeIcon symbol="exclamationPointCircle" size={16} />
<DecorativeIcon symbol="exclamationPointCircle" size={24} />
</div>
```

0 comments on commit f8d4c8c

Please sign in to comment.