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

@ophiuchus/index-bar

v1.0.1

Published

### 引入

Downloads

4

Readme

IndexBar 索引栏

引入

// 方式1(推荐)
import Vue from 'vue';
import IndexBar from '@ophiuchus/index-bar';

Vue.use(IndexBar);

// 方式2
import Vue from 'vue';
import { IndexBar, IndexAnchor } from '@ophiuchus/index-bar';

Vue.component(IndexBar.name, IndexBar);
Vue.component(IndexAnchor.name, IndexAnchor);

代码演示

基础用法

点击索引栏时,会自动跳转到对应的 IndexAnchor 锚点位置。

<sf-index-bar>
  <sf-index-anchor index="A" />
  <sf-cell title="文本" />
  <sf-cell title="文本" />
  <sf-cell title="文本" />

  <sf-index-anchor index="B" />
  <sf-cell title="文本" />
  <sf-cell title="文本" />
  <sf-cell title="文本" />

  ...
</sf-index-bar>

自定义索引列表

可以通过 index-list 属性自定义展示的索引字符列表。

<sf-index-bar :index-list="indexList">
  <sf-index-anchor index="1">标题1</sf-index-anchor>
  <sf-cell title="文本" />
  <sf-cell title="文本" />
  <sf-cell title="文本" />

  <sf-index-anchor index="2">标题2</sf-index-anchor>
  <sf-cell title="文本" />
  <sf-cell title="文本" />
  <sf-cell title="文本" />

  ...
</sf-index-bar>
export default {
  data() {
    return {
      indexList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    };
  },
};

API

IndexBar Props

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | index-list | 索引字符列表 | string[] | number[] | A-Z | | z-index | z-index 层级 | number | string | 1 | | sticky | 是否开启锚点自动吸顶 | boolean | true | | sticky-offset-top | 锚点自动吸顶时与顶部的距离 | number | 0 | | highlight-color | 索引字符高亮颜色 | string | #ee0a24 |

IndexAnchor Props

| 参数 | 说明 | 类型 | 默认值 | | ----- | -------- | ------------------ | ------ | | index | 索引字符 | number | string | - |

IndexBar Events

| 事件名 | 说明 | 回调参数 | | ----------------- | ---------------------------- | ------------------------- | | select | 点击索引栏的字符时触发 | index: number | string | | change | 当前高亮的索引字符变化时触发 | index: number | string |

IndexAnchor Slots

| 名称 | 说明 | | ------- | -------------------------------- | | default | 锚点位置显示内容,默认为索引字符 |

IndexBar 方法

通过 ref 可以获取到 IndexBar 实例并调用实例方法,详见组件实例方法

| 方法名 | 说明 | 参数 | 返回值 | | ------------------ | -------------- | ------------------------- | ------ | | scrollTo | 滚动到指定锚点 | index: number | string | - |

样式变量

组件提供了下列 Less 变量,可用于自定义样式,使用方法请参考主题定制

| 名称 | 默认值 | 描述 | | ------------------------------------- | ------------------- | ---- | | @index-bar-sidebar-z-index | 2 | - | | @index-bar-index-font-size | @font-size-xs | - | | @index-bar-index-line-height | @line-height-xs | - | | @index-bar-index-active-color | @red | - | | @index-anchor-z-index | 1 | - | | @index-anchor-padding | 0 @padding-md | - | | @index-anchor-text-color | @text-color | - | | @index-anchor-font-weight | @font-weight-bold | - | | @index-anchor-font-size | @font-size-md | - | | @index-anchor-line-height | 32px | - | | @index-anchor-background-color | transparent | - | | @index-anchor-sticky-text-color | @red | - | | @index-anchor-sticky-background-color | @white | - |