1
1
mirror of https://github.com/primer/css.git synced 2024-12-18 03:31:43 +03:00
css/modules/primer-labels
Emily 1b5ff950cc Publish
- primer-alerts@1.5.9
 - primer-avatars@1.5.6
 - primer-base@1.7.4
 - primer-blankslate@1.4.9
 - primer-box@2.5.9
 - primer-branch-name@1.0.7
 - primer-breadcrumb@1.5.5
 - primer-buttons@2.6.0
 - primer-core@6.10.3
 - primer-forms@2.1.4
 - primer-labels@1.5.9
 - primer-layout@1.4.9
 - primer-markdown@3.7.9
 - primer-marketing-buttons@1.0.8
 - primer-marketing-type@1.4.9
 - primer-marketing-utilities@1.6.5
 - primer-marketing@6.2.4
 - primer-navigation@1.5.7
 - primer-page-headers@1.4.9
 - primer-page-sections@1.4.9
 - primer-pagination@1.0.3
 - primer-popover@0.1.3
 - primer-product@5.6.6
 - primer-subhead@1.0.7
 - primer-support@4.6.0
 - primer-table-object@1.4.9
 - primer-tables@1.4.9
 - primer-tooltips@1.5.7
 - primer-truncate@1.4.9
 - primer-utilities@4.12.0
 - primer@10.8.0
 - generator-primer-module@1.0.8
 - primer-module-build@1.0.5
 - stylelint-config-primer@2.2.10
 - stylelint-selector-no-utility@1.8.10
2018-07-27 11:31:23 -07:00
..
lib update components to use em spacer variables: 2018-01-05 17:55:47 -05:00
.npmignore rename packages directory to modules 2017-06-29 12:49:16 -07:00
index.scss rename packages directory to modules 2017-06-29 12:49:16 -07:00
LICENSE Happy new year 2018-01-03 15:05:16 -08:00
package-lock.json Adding package-lock.json back 2018-06-13 16:48:56 -07:00
package.json Publish 2018-07-27 11:31:23 -07:00
README.md update label links 2018-05-07 10:36:22 -07:00
stories.js Pulling in markdown components from all the rest of the modules 2018-01-09 15:27:14 -08:00

Primer Labels

npm version Build Status

Labels add metadata or indicate status of items and navigational elements.

This repository is a module of the full primer repository.

Install

This repository is distributed with npm. After installing npm, you can install primer-labels with this command.

$ npm install --save primer-labels

Usage

The source files included are written in Sass (scss) You can simply point your sass include-path at your node_modules directory and import it like this.

@import "primer-labels/index.scss";

You can also import specific portions of the module by importing those partials from the /lib/ folder. Make sure you import any requirements along with the modules.

Build

For a compiled css version of this module, a npm script is included that will output a css version to build/build.css The built css file is also included in the npm package.

$ npm run build

Documentation

Labels add metatdata or indicate status of items and navigational elements. Three different types of labels are available: Labels for adding metadata, States for indicating status, and Counters for showing the count for a number of items.

{:toc}

Labels

The base label component styles the text, adds padding and rounded corners, and an inset box shadow. Labels come in various themes which apply colors and different border styles.

GitHub also programmatically generates and applies a background color for labels on items such as issues and pull requests. Users are able to select any background color and the text color will adjust to work with light and dark background colors.

The base Label style does not apply a background color, here's an example using the bg-blue utility to apply a blue background:

<span title="Label: default label" class="Label bg-blue">default label</span>

Note: Be sure to include a title attribute on labels, it's helpful for people using screen-readers to differentiate a label from other text. I.e. without the title attribute, the following example would read as "New select component design", rather than identifying design as a label.

<!-- Don't do this -->
<a href="#url">New select component</a><span class="Label bg-blue ml-1">design</span>

Label themes

Labels come in a few different themes. Use a theme that helps communicate the content of the label, and ensure it's used consistently.

Use Label--gray to create a label with a light gray background and gray text. This label is neutral in color and can be used in contexts where all you need to communicate is metadata, or whe you want a label to feel less prominent compared with labels with stronger colors.

<span title="Label: gray label" class="Label Label--gray">gray label</span>

Use Label--gray-darker to create a label with a dark-gray background color. This label is also neutral in color, however, since it's background is darker it can stand out more compared to Label--gray.

<span title="Label: dark gray label" class="Label Label--gray-darker">dark gray label</span>

Use Label--orange to communicate "warning". The orange background color is very close to red, so avoid using next to labels with a red background color since most people will find it hard to tell the difference.

<span title="Label: orange label" class="Label Label--orange">orange label</span>

Use Label--outline to create a label with gray text, a gray border, and a transparent background. The outline reduces the contrast of this label in combination with filled labels. Use this in contexts where you need it to stand out less than other labels and communicate a neutral message.

<span title="Label: outline label" class="Label Label--outline">outlined label</span>

Use Label--outline-green in combination with Label--outline to communicate a positive message.

<span title="Label: green outline label" class="Label Label--outline Label--outline-green">green outlined label</span>

States

Use state labels to inform users of an items status. States are large labels with bolded text. The default state has a gray background.

<span class="State">Default</span>

State themes

States come in a few variations that apply different colors. Use the state that best communicates the status or function.

<span title="Status: open" class="State State--green"><%= octicon "git-pull-request" %> Open</span>
<span title="Status: closed" class="State State--red"><%= octicon "git-pull-request" %> Closed</span>
<span title="Status: merged" class="State State--purple"><%= octicon "git-merge" %> Merged</span>

Note: Similar to labels, you should include the title attribute on states to differentiate them from other content.

Small states

Use State--small for a state label with reduced padding a smaller font size. This is useful in denser areas of content.

<span title="Status: open" class="State State--green State--small"><%= octicon "issue-opened" %> Open</span>
<span title="Status: closed" class="State State--red State--small"><%= octicon "issue-closed" %> Closed</span>

Counters

Use the Counter component to add a count to navigational elements and buttons. Counters come in 3 variations: the default Counter with a light gray background, Counter--gray with a dark-gray background and inverse white text, and Counter--gray-light with a light-gray background and dark gray text.

<span class="Counter">16</span>
<span class="Counter Counter--gray">32</span>
<span class="Counter Counter--gray-light">64</span>

Use the Counter in navigation to indicate the number of items without the user having to click through or count the items, such as open issues in a GitHub repo. See more options in navigation.

<div class="tabnav">
  <nav class="tabnav-tabs" aria-label="Foo bar">
    <a href="#url" class="tabnav-tab selected" aria-current="page">Foo tab <span class="Counter">23</a>
    <a href="#url" class="tabnav-tab">Bar tab</a>
  </nav>
</div>

Counters can also be used in Box headers to indicate the number of items in a list. See more on the box component.

<div class="Box">
  <div class="Box-header">
    <h3 class="Box-title">
      Box title
      <span class="Counter Counter--gray">3</span>
    </h3>
  </div>
  <ul>
    <li class="Box-row">
      Box row one
    </li>
    <li class="Box-row">
      Box row two
    </li>
    <li class="Box-row">
      Box row three
    </li>
  </ul>
</div>

License

MIT © GitHub