🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@ophiuchus/cell

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ophiuchus/cell

### 介绍

latest
npmnpm
Version
1.0.2
Version published
Weekly downloads
4
-63.64%
Maintainers
1
Weekly downloads
 
Created
Source

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是否显示外边框booleantrue

Cell Props

参数说明类型默认值
title左侧标题number | string-
value右侧内容number | string-
label标题下方的描述信息string-
size单元格大小,可选值为 largestring-
icon左侧图标名称或图片链接string-
icon-prefix图标类名前缀,同 Icon 组件的 class-prefix 属性stringsf-icon
url点击后跳转的链接地址string-
to点击后跳转的目标路由对象,同 vue-router 的 to 属性string | object-
border是否显示内边框booleantrue
replace是否在跳转时替换当前页面历史booleanfalse
clickable是否开启点击反馈booleannull
is-link是否展示右侧箭头并开启点击反馈booleanfalse
required是否显示表单必填星号booleanfalse
center是否使内容垂直居中booleanfalse
arrow-direction箭头方向,可选值为 left up downstringright
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-height24px-
@cell-vertical-padding10px-
@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-size16px-
@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-height16px-

Keywords

ui

FAQs

Package last updated on 26 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts