npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tournant/breadcrumb

v1.0.1

Published

A trail of links to let users find their place within a website.

Downloads

5

Readme

@tournant/breadcrumb

A trail of links to let users find their place within a website.

Installation

No rocket science here. Although rockets are cool, to be honest. 🚀 You can install the component using NPM or Yarn.

npm install @tournant/breadcrumb --save

If you use Yarn:

yarn add @tournant/breadcrumb

Once the component is installed you need to import it wherever you want to use it.

import TournantBreadcrumb from '@tournant/breadcrumb'

Don’t forget to add it to the registered components (been there, done that):

components: {
  TournantBreadcrumb,
  // ... all the other amazing components
}

Usage

The breadcrumb renders an ordered list of links. The last item in the list is marked with aria-current.

Props

  • links: Array. Required. The links in the path you want to render. Consisting of items which are structured as follow:
    • item: Object. Needs to have the properties to and text. If used with Nuxt or @vue/router exact can also be set.
  • labelText: String. Default: «Breadcrumb». A breadcrumb navigation has to have an aria-label, you can change it with this prop.
  • labelledBy: You can provide the ID of an element on the page to label the navigation. If you use labelledBy, aria-label will not be added.

Basic Example

<!-- Input -->
<tournant-breadcrumb
	:links="[
    { to: '/', text: 'Homepage' },
    { to: '/archive', text: 'Archive' },
    { to: '/archive/post', text: 'Post' }
  ]"
/>

<!-- Output -->
<nav aria-label="Breadcrumb" class="t-ui-breadcrumb">
	<ol class="t-ui-breadcrumb__list">
		<li class="t-ui-breadcrumb__item"><a href="/">Homepage</a></li>
		<li class="t-ui-breadcrumb__item"><a href="/archive">Archive</a></li>
		<li class="t-ui-breadcrumb__item">
			<a href="/archive/post" aria-current="Page">Post</a>
		</li>
	</ol>
</nav>

aria-current

You can omit to for the last item. In which case aria-current will not be set.

Labelling

A label can be either provided by passing a labelText or linking an element via ID using labelledBy. The linked element can be included in the component by using the label slot.

<tournant-breadcrumb :links="links" :labelledBy="test-id">
	<template v-slot:label>
		<h2 id="test-id">Breadcrumb</h2>
	</template>
</tournant-breadcrumb>

Framework Detection

By default, all links are rendered as simple a tags. However, if you use Nuxt or @vue/router this is automatically detected and the links are rendered as nuxt-link or router-link respectively.

Under the hood it makes use of @tournant/dynamic-anchor.

CSS

| Classname | Element | | ----------------------- | ----------------------------------------- | | t-ui-breadcrumb | Root | | t-ui-breadcrumb__list | The ol containing list items with links | | t-ui-breadcrumb__item | li containing a link | | t-ui-breadcrumb__link | a to the actual item |

Microdata

Schema.org compatible BreadcrumbList microdata is embedded into the markup. Hence this breadcrumb is discoverable by third parties and they are able to use this data, e.g. in displaying it in a search results page.

Events

If a user clicks on a link in the breadcrumb it emits a custom event named itemClick. The payload is the index of the clicked item.

Bugs & Enhancements

If you found a bug, please create a bug ticket.

For enhancements please refer to the contributing guidelines.