6.5.8 • Published 6 months ago

@financial-times/o-labels v6.5.8

Weekly downloads
791
License
MIT
Repository
-
Last release
6 months ago

o-labels

Labels for content classification, to emphasise a value, or highlight a status.

Usage

Check out how to include Origami components in your project to get started with o-labels.

Label Types

There are three types of label:

Standard Label

The standard label is used for content classification or to emphasise a value. For example to highlight commercial or premium content for the core brand, or to highlight a service tier in internal products. Custom labels may be created.

Standard Label Sizes

This table outlines the possible standard label sizes.

SizeDescriptionBrand support
bigLabel with increased font size and padding.core, internal, whitelabel
smallLabel with decreased font size and padding.core, internal, whitelabel

Standard Label States

This table outlines the possible standard label states. Custom states may also be created.

StateDescriptionBrand support
content-commercialUsed to identify paid posts or promoted content.core
content-premiumUsed to identify premium content.core
lifecycle-betaUsed to identify a feature that's in beta.core
support-activeUsed to indicate that a component is actively maintained.internal
support-maintainedUsed to indicate that a component is maintained.internal
support-experimentalUsed to indicate that a component is an experimental feature.internal
support-deprecatedUsed to indicate that a component is deprecated.internal
support-deadUsed to indicate that a component is no longer worked on.internal
tier-platinumUsed to indicate a service with a platinum service tier.internal
tier-goldUsed to indicate a service with a gold service tier.internal
tier-silverUsed to indicate a service with a silver service tier.internal
tier-bronzeUsed to indicate a service with a bronze service tier.internal
oxfordA colour based label with no specific meaning specified.internal
tealA colour based label with no specific meaning specified.internal
lemonA colour based label with no specific meaning specified.internal
slateA colour based label with no specific meaning specified.internal
jadeA colour based label with no specific meaning specified.internal
crimsonA colour based label with no specific meaning specified.internal
mandarinA colour based label with no specific meaning specified.internal

Indicator Label

The indicator label is used to show story status with new, updated, and live variants. The indicator label only supports the core brand but internal brand support is under consideration.

Indicator Label Status

This table outlines the possible indicator label statuses:

IndicatorDescriptionBrand support
liveIndicate a story is live.core
closedIndicate a live story is no longer live.core
newIndicate a story is new.core
updatedIndicate a story has been updated.core

E.g. for a live label:

<span class="o-labels-indicator o-labels-indicator--live">
  <span class="o-labels-indicator__status">live</span>
</span>

The live and closed labels also support a more prominent badge variant:

<span
  class="o-labels-indicator o-labels-indicator--live o-labels-indicator--inverse o-labels-indicator--badge"
>
  <span class="o-labels-indicator__status">live</span>
</span>

Timestamp Label

The timestamp label is used to show article status in place of an indicator label when the article is not new, updated, or live. The timestamp label only supports the core brand.

Markup

Standard Label Markup

The most minimal markup for a standard label is as follows:

<span class="o-labels">Label</span>

Standard labels are displayed inline so including the above markup in a paragraph, for example, will make it sit alongside the text.

There are several size modifier classes which can be used to change the general appearance of a standard label:

<span class="o-labels o-labels--big">Big Label</span>
<span class="o-labels o-labels--small">Small Label</span>

Labels can also have one of several states. The available states depend on which brand you are using (there are no states for whitelabel branded components):

The following core brand states are used to categorise content, mostly on FT.com:

<span class="o-labels o-labels--content-commercial">Paid Post</span> (used for paid post and promoted content)
<span class="o-labels o-labels--content-premium">Premium</span> (used for premium-only content)

The following state is used to indicate that a feature is in a beta state:

<span class="o-labels o-labels--lifecycle-beta">Beta</span>

The following internal brand states are used to represent the different support levels of Origami components:

<span class="o-labels o-labels--support-active">Active</span>
<span class="o-labels o-labels--support-maintained">Maintained</span>
<span class="o-labels o-labels--support-experimental">Experimental</span>
<span class="o-labels o-labels--support-deprecated">Deprecated</span>
<span class="o-labels o-labels--support-dead">Dead</span>

The following internal brand states are used to represent the FT's service tiers:

<span class="o-labels o-labels--support-platinum">Platinum</span>
<span class="o-labels o-labels--support-gold">Gold</span>
<span class="o-labels o-labels--support-silver">Silver</span>
<span class="o-labels o-labels--support-bronze">Bronze</span>

The internal brand may also use colour palette based states, these do not specify a particular usecase for flexibility:

<span class="o-labels o-labels--oxford">oxford</span>
<span class="o-labels o-labels--teal">teal</span>
<span class="o-labels o-labels--lemon">lemon</span>
<span class="o-labels o-labels--slate">slate</span>
<span class="o-labels o-labels--jade">jade</span>
<span class="o-labels o-labels--crimson">crimson</span>
<span class="o-labels o-labels--mandarin">mandarin</span>

Indicator Label Markup

Indicator labels have one of three statuses:

  • live
  • closed
  • updated
  • new

Use the following markup for a live label:

<span class="o-labels-indicator o-labels-indicator--live">
    <span class="o-labels-indicator__status">
		live
    </span>
</span>

Use the modifier class o-labels-indicator--closed for a closed label:

<span class="o-labels-indicator o-labels-indicator--closed">
    <span class="o-labels-indicator__status">
		closed
    </span>
</span>

For an updated or new label use the associated modifier class, e.g. o-labels-indicator--updated, and add a child element o-labels-indicator__timestamp to show the new/updated time. We recommend using o-date to format the timestamp element.

<span class="o-labels-indicator o-labels-indicator--new">
    <span class="o-labels-indicator__status">
        new
    </span>
    <span class="o-labels-indicator__timestamp">
        <!-- demo `time` element only (the datetime is not 1 hour ago) -->
        <time datetime="2020-07-09T12:52:33+0000" title="July 9 2020 1:52 pm">1 hour ago</time>
    </span>
</span>

Indicator labels also support an inverse theme for use on dark backgrounds. To use an inverse theme add the o-labels-indicator--inverse class to your markup.

-<span class="o-labels-indicator o-labels-indicator--live">
+<span class="o-labels-indicator o-labels-indicator--live o-labels-indicator--inverse">
    <span class="o-labels-indicator__status">
		live
    </span>
</span>

Timestamp Markup

To include a timestamp label use the following markup. Note the timestamp label also supports an optional inverse variant for dark background with the o-labels-timestamp--inverse class:

<span class="o-labels-timestamp o-labels-timestamp--inverse">
    <!-- demo `time` element only -->
    <time datetime="2016-02-29T12:35:48Z" title="February 29 2016 12:35 pm">February 29 2016</time>
</span>

As with the indicator label, we recommend using o-date to format the timestamp element.

Sass

Output all label styles with the oLabels mixin:

@include oLabels();

Or pass an options map $opts argument to output just the label styles you need. Options include:

  • sizes: a list of standard label sizes to output (see available sizes)
  • states: a list of standard label states to output (see available states))
  • indicators - status: a list of indicator label statuses to output (see available statuses) - inverse
  • timestamp - inverse
@include oLabels($opts: (
	// standard label sizes to output
	// e.g. .o-labels--big
	'sizes': ('big'),
	// standard label states to output
	// e.g. .o-labels--content-commercial
	'states': (
		'content-commercial',
		'content-premium'
	),
	// indicator label labels to output
	// .o-labels-indicator
	'indicators': (
		// indicator label statuses to output
		// .o-labels-indicator--live
		'status': ('live'),
		// whether to output the indicator label inverse style
		// .o-labels-indicator--inverse
		'inverse': true,
	),
	// output the timestamp label label
	// .o-labels-timestamp
	'timestamp': (
		// whether to output the timestamp label inverse style
		// .o-labels-timestamp--inverse
		'inverse': true
	)
));

Custom Standard Label State

Use oLabelsAddState mixin to add a custom label state for the standard label. See the oLabelsAddState SassDoc for more details.

// outputs a class .o-labels--citrus-fruit
@include oLabelsAddState('citrus-fruit', (
	background-color: oColorsByName('lemon')
));

Custom Markup

When it's not possible to use an o-labels CSS class, for example within another Origami component, use:

  • oLabelsContent to output a standard label with a custom class.
  • oLabelsIndicatorContent to output an indicator label with a custom class.
  • oLabelsTimestampContent to output a timestamp label with a custom class.

If it is possible to use o-labels classes we recommend oLabels and oLabelsAddStates instead. Using these will help reduce the size of your CSS bundle where multiple labels are used.

oLabelsContent

oLabelsContent accepts an $opts argument which is a map of options. To output styles required by all labels set "base" to "true". Then set the labels "sizes" and its "state". Any of these options may be output independently.

To output an existing label:

.o-example-my-label {
	@include oLabelsContent($opts: (
		'base': true,
		'size': 'big',
		'state': 'tier-gold'
	));
}

To output a custom label:

.o-example-my-custom-label {
	@include oLabelsContent($opts: (
		'base': true,
		'size': 'big',
		'state': (
			'background-color': oColorsByName('lemon')
		)
	));
}

oLabelsIndicatorContent

As styles for the indicator label apply to multiple html elements, the oLabelsIndicatorContent accepts an $opts argument to output styles for each element separately.

// equivalent to .o-labels-indicator
.my-indicator-label {
	@include oLabelsIndicatorContent($opts: ('block': true));
}
// equivalent to .o-labels-indicator--live
.my-indicator-label--live {
	@include oLabelsIndicatorContent($opts: ('block': true, 'modifier': 'live'));
}
// equivalent to .o-labels-indicator__status
.my-indicator-label__status {
	@include oLabelsIndicatorContent($opts: ('element': 'status'));
}
// equivalent to .o-labels-indicator__timestamp
.my-indicator-label__timestamp {
	@include oLabelsIndicatorContent($opts: ('element': 'timestamp'));
}

Migration guide

StateMajor VersionLast Minor ReleaseMigration guide
✨ active6N/Amigrate to v6
✨ active55.2migrate to v5
⚠ maintained4N/Amigrate to v4
╳ deprecated33.1.1migrate to v3
╳ deprecated22.1.0N/A
╳ deprecated11.0.6N/A

Contact

If you have any questions or comments about this component, or need help using it, please either raise an issue, visit #origami-support or email Origami Support.

Licence

This software is published by the Financial Times under the MIT licence.

6.5.6

10 months ago

6.5.5

10 months ago

6.5.8

6 months ago

6.5.7

9 months ago

6.5.4

1 year ago

6.5.0

2 years ago

6.4.1

2 years ago

6.5.2

1 year ago

6.5.1

2 years ago

6.5.3

1 year ago

6.3.0

2 years ago

6.4.0

2 years ago

6.3.1

2 years ago

5.3.0

2 years ago

6.2.1

2 years ago

6.2.2

2 years ago

6.1.0

2 years ago

6.2.0

2 years ago

6.1.1

2 years ago

6.0.2

2 years ago

6.0.1

3 years ago

6.0.0

3 years ago

6.0.0-beta.0

3 years ago

6.0.0-0

3 years ago

5.2.0

3 years ago

5.1.5

3 years ago

5.1.5-beta.1

3 years ago

5.1.4

4 years ago

5.1.3

4 years ago

5.1.2

4 years ago

5.1.1

4 years ago

5.1.0

4 years ago

5.1.0-beta.1.1.0

4 years ago

5.1.0-beta.1.0.0

4 years ago

5.0.9

4 years ago

5.0.8

4 years ago

5.0.3

4 years ago

5.0.2

4 years ago

5.0.1

4 years ago

5.0.0

4 years ago

5.0.0-beta.1

4 years ago

4.2.4

5 years ago

4.2.3

5 years ago

4.2.2

5 years ago

4.2.1

5 years ago

4.2.0

5 years ago

4.1.0

5 years ago