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

v1.0.2

Published

### 介绍

Downloads

1

Readme

Cell 单元格

介绍

单元格为列表中的单个展示项。

引入

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

Vue.use(Cell);

// 方式2
import Vue from 'vue';
import { Cell, CellGroup } from '@ophiuchus/cell';

Vue.component(Cell.name, Cell);
Vue.component(CellGroup.name, CellGroup);

代码演示

基础用法

Cell 可以单独使用,也可以与 CellGroup 搭配使用,CellGroup 可以为 Cell 提供上下外边框。

<sf-cell-group>
  <sf-cell title="单元格" value="内容" />
  <sf-cell title="单元格" value="内容" label="描述信息" />
</sf-cell-group>

卡片风格

通过 CellGroupinset 属性,可以将单元格转换为圆角卡片风格。

<sf-cell-group inset>
  <sf-cell title="单元格" value="内容" />
  <sf-cell title="单元格" value="内容" label="描述信息" />
</sf-cell-group>

单元格大小

通过 size 属性可以控制单元格的大小。

<sf-cell title="单元格" value="内容" size="large" />
<sf-cell title="单元格" value="内容" size="large" label="描述信息" />

展示图标

通过 icon 属性在标题左侧展示图标。

<sf-cell title="单元格" icon="location-o" />

只设置 value

只设置 value 时,内容会靠左对齐。

<sf-cell value="内容" />

展示箭头

设置 is-link 属性后会在单元格右侧显示箭头,并且可以通过 arrow-direction 属性控制箭头方向。

<sf-cell title="单元格" is-link />
<sf-cell title="单元格" is-link value="内容" />
<sf-cell title="单元格" is-link arrow-direction="down" value="内容" />

页面导航

可以通过 url 属性进行 URL 跳转,或通过 to 属性进行路由跳转。

<sf-cell title="URL 跳转" is-link url="/demo.html" />
<sf-cell title="路由跳转" is-link to="index" />

分组标题

通过 CellGrouptitle 属性可以指定分组标题。

<sf-cell-group title="分组1">
  <sf-cell title="单元格" value="内容" />
</sf-cell-group>
<sf-cell-group title="分组2">
  <sf-cell title="单元格" value="内容" />
</sf-cell-group>

使用插槽

如以上用法不能满足你的需求,可以使用插槽来自定义内容。

<sf-cell value="内容" is-link>
  <!-- 使用 title 插槽来自定义标题 -->
  <template #title>
    <span class="custom-title">单元格</span>
    <sf-tag type="danger">标签</sf-tag>
  </template>
</sf-cell>

<sf-cell title="单元格" icon="shop-o">
  <!-- 使用 right-icon 插槽来自定义右侧图标 -->
  <template #right-icon>
    <sf-icon name="search" class="search-icon" />
  </template>
</sf-cell>

<style>
  .custom-title {
    margin-right: 4px;
    vertical-align: middle;
  }

  .search-icon {
    font-size: 16px;
    line-height: inherit;
  }
</style>

垂直居中

通过 center 属性可以让 Cell 的左右内容都垂直居中。

<sf-cell center title="单元格" value="内容" label="描述信息" />

API

CellGroup Props

| 参数 | 说明 | 类型 | 默认值 | | ------ | -------------- | --------- | ------ | | title | 分组标题 | string | - | | border | 是否显示外边框 | boolean | true |

Cell Props

| 参数 | 说明 | 类型 | 默认值 | | -------------------- | ----------------------------------------------------------------------------------------- | ------------------ | ---------- | | title | 左侧标题 | number | string | - | | value | 右侧内容 | number | string | - | | label | 标题下方的描述信息 | string | - | | size | 单元格大小,可选值为 large | string | - | | icon | 左侧图标名称或图片链接 | string | - | | icon-prefix | 图标类名前缀,同 Icon 组件的 class-prefix 属性 | string | sf-icon | | url | 点击后跳转的链接地址 | string | - | | to | 点击后跳转的目标路由对象,同 vue-router 的 to 属性 | string | object | - | | border | 是否显示内边框 | boolean | true | | replace | 是否在跳转时替换当前页面历史 | boolean | false | | clickable | 是否开启点击反馈 | boolean | null | | is-link | 是否展示右侧箭头并开启点击反馈 | boolean | false | | required | 是否显示表单必填星号 | boolean | false | | center | 是否使内容垂直居中 | boolean | false | | arrow-direction | 箭头方向,可选值为 left up down | string | right | | title-style | 左侧标题额外样式 | any | - | | title-class | 左侧标题额外类名 | any | - | | value-class | 右侧内容额外类名 | any | - | | label-class | 描述信息额外类名 | any | - |

Cell Events

| 事件名 | 说明 | 回调参数 | | ------ | ---------------- | -------------- | | click | 点击单元格时触发 | event: Event |

CellGroup Slots

| 名称 | 说明 | | ------- | -------------- | | default | 默认插槽 | | title | 自定义分组标题 |

Cell Slots

| 名称 | 说明 | | ---------- | ----------------------------- | | default | 自定义右侧 value 的内容 | | title | 自定义左侧 title 的内容 | | label | 自定义标题下方 label 的内容 | | icon | 自定义左侧图标 | | right-icon | 自定义右侧按钮,默认为arrow | | extra | 自定义单元格最右侧的额外内容 |

样式变量

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

| 名称 | 默认值 | 描述 | | ----------------------------- | ------------------------------------- | ---- | | @cell-font-size | @font-size-md | - | | @cell-line-height | 24px | - | | @cell-vertical-padding | 10px | - | | @cell-horizontal-padding | @padding-md | - | | @cell-text-color | @text-color | - | | @cell-background-color | @white | - | | @cell-border-color | @border-color | - | | @cell-active-color | @active-color | - | | @cell-required-color | @red | - | | @cell-label-color | @gray-6 | - | | @cell-label-font-size | @font-size-sm | - | | @cell-label-line-height | @line-height-sm | - | | @cell-label-margin-top | @padding-base | - | | @cell-value-color | @gray-6 | - | | @cell-icon-size | 16px | - | | @cell-right-icon-color | @gray-6 | - | | @cell-large-vertical-padding | @padding-sm | - | | @cell-large-title-font-size | @font-size-lg | - | | @cell-large-label-font-size | @font-size-md | - | | @cell-group-background-color | @white | - | | @cell-group-title-color | @gray-6 | - | | @cell-group-title-padding | @padding-md @padding-md @padding-xs | - | | @cell-group-title-font-size | @font-size-md | - | | @cell-group-title-line-height | 16px | - |