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/collapse

v1.0.1

Published

### 介绍

Downloads

2

Readme

Collapse 折叠面板

介绍

将一组内容放置在多个折叠面板中,点击面板的标题可以展开或收缩其内容。

引入

// 方式1(推荐)
import Vue from 'vue';
import Collapse from '@ophiuchus/collapse';

Vue.use(Collapse);

// 方式2
import Vue from 'vue';
import { Collapse, CollapseItem } from '@ophiuchus/collapse';

Vue.component(Collapse.name, Collapse);
Vue.component(CollapseItem.name, CollapseItem);

代码演示

基础用法

通过 v-model 控制展开的面板列表,activeNames 为数组格式。

<sf-collapse v-model="activeNames">
  <sf-collapse-item title="标题1" name="1">内容</sf-collapse-item>
  <sf-collapse-item title="标题2" name="2">内容</sf-collapse-item>
  <sf-collapse-item title="标题3" name="3">内容</sf-collapse-item>
</sf-collapse>
export default {
  data() {
    return {
      activeNames: ['1'],
    };
  },
};

手风琴

通过 accordion 可以设置为手风琴模式,最多展开一个面板,此时 activeName 为字符串格式。

<sf-collapse v-model="activeName" accordion>
  <sf-collapse-item title="标题1" name="1">内容</sf-collapse-item>
  <sf-collapse-item title="标题2" name="2">内容</sf-collapse-item>
  <sf-collapse-item title="标题3" name="3">内容</sf-collapse-item>
</sf-collapse>
export default {
  data() {
    return {
      activeName: '1',
    };
  },
};

禁用状态

通过 disabled 属性来禁用单个面板。

<sf-collapse v-model="activeNames">
  <sf-collapse-item title="标题1" name="1">内容</sf-collapse-item>
  <sf-collapse-item title="标题2" name="2" disabled>内容</sf-collapse-item>
  <sf-collapse-item title="标题3" name="3" disabled>内容</sf-collapse-item>
</sf-collapse>

自定义标题内容

通过 title 插槽可以自定义标题栏的内容。

<sf-collapse v-model="activeNames">
  <sf-collapse-item name="1">
    <template #title>
      <div>标题1 <sf-icon name="question-o" /></div>
    </template>
    内容
  </sf-collapse-item>
  <sf-collapse-item title="标题2" name="2" icon="location-o">
    内容
  </sf-collapse-item>
</sf-collapse>
export default {
  data() {
    return {
      activeNames: ['1'],
    };
  },
};

API

Collapse Props

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | v-model | 当前展开面板的 name | 手风琴模式:number | string非手风琴模式:(number | string)[] | - | | accordion | 是否开启手风琴模式 | boolean | false | | border | 是否显示外边框 | boolean | true |

Collapse Events

| 事件名 | 说明 | 回调参数 | | ------ | -------------- | ---------------------------------------- | | change | 切换面板时触发 | activeNames: 类型与 v-model 绑定的值一致 |

CollapseItem Props

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | name | 唯一标识符,默认为索引值 | number | string | index | | icon | 标题栏左侧图标名称或图片链接 | string | - | | size | 标题栏大小,可选值为 large | string | - | | title | 标题栏左侧内容 | number | string | - | | value | 标题栏右侧内容 | number | string | - | | label | 标题栏描述信息 | number | string | - | | border | 是否显示内边框 | boolean | true | | is-link | 是否展示标题栏右侧箭头并开启点击反馈 | boolean | true | | disabled | 是否禁用面板 | boolean | false | | title-class | 左侧标题额外类名 | string | - | | value-class | 右侧内容额外类名 | string | - | | label-class | 描述信息额外类名 | string | - |

CollapseItem Slots

| 名称 | 说明 | | ---------- | ------------------------------ | | default | 面板内容 | | value | 自定义显示内容 | | icon | 自定义 icon | | title | 自定义 title | | right-icon | 自定义右侧按钮,默认是 arrow |

CollapseItem 方法

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

| 方法名 | 说明 | 参数 | 返回值 | | --- | --- | --- | --- | | toggle | 切换面试展开状态,传 true 为展开,false 为收起,不传参为切换 | expand?: boolean | - |

样式变量

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

| 名称 | 默认值 | 描述 | | --------------------------------------- | -------------------------- | ---- | | @collapse-item-transition-duration | @animation-duration-base | - | | @collapse-item-content-padding | @padding-sm @padding-md | - | | @collapse-item-content-font-size | @font-size-md | - | | @collapse-item-content-line-height | 1.5 | - | | @collapse-item-content-text-color | @gray-6 | - | | @collapse-item-content-background-color | @white | - | | @collapse-item-title-disabled-color | @gray-5 | - |