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

v1.0.1

Published

### 介绍

Downloads

1

Readme

Grid 宫格

介绍

宫格可以在水平方向上把页面分隔成等宽度的区块,用于展示内容或进行页面导航。

引入

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

Vue.use(Grid);

// 方式2
import Vue from 'vue';
import { Grid, GridItem } from '@ophiuchus/grid';

Vue.component(Grid.name, Grid);
Vue.component(GridItem.name, GridItem);

代码演示

基础用法

通过 icon 属性设置格子内的图标,text 属性设置文字内容。

<sf-grid>
  <sf-grid-item icon="photograph-o" text="文字" />
  <sf-grid-item icon="photograph-o" text="文字" />
  <sf-grid-item icon="photograph-o" text="文字" />
  <sf-grid-item icon="photograph-o" text="文字" />
</sf-grid>

自定义列数

默认一行展示四个格子,可以通过 column-num 自定义列数。

<sf-grid :column-num="3">
  <sf-grid-item v-for="value in 6" :key="value" icon="photograph-o" text="文字" />
</sf-grid>

自定义内容

通过插槽可以自定义格子展示的内容。

<sf-grid :border="false" :column-num="3">
  <sf-grid-item>
    <sf-image src="https://img4.tuhu.org/JU_d6bTpbt6kxlAcmNKCew_w660_h520.jpeg" />
  </sf-grid-item>
  <sf-grid-item>
    <sf-image src="https://img4.tuhu.org/4sVmt9tW6ZR89aBswsUhfA_w1600_h1295.jpeg" />
  </sf-grid-item>
  <sf-grid-item>
    <sf-image src="https://img4.tuhu.org/D3n023kFjjgjYzz87qdh4g_w1600_h1331.jpeg" />
  </sf-grid-item>
</sf-grid>

正方形格子

设置 square 属性后,格子的高度会和宽度保持一致。

<sf-grid square>
  <sf-grid-item v-for="value in 8" :key="value" icon="photograph-o" text="文字" />
</sf-grid>

格子间距

通过 gutter 属性设置格子之间的距离。

<sf-grid :gutter="10">
  <sf-grid-item v-for="value in 8" :key="value" icon="photograph-o" text="文字" />
</sf-grid>

内容横排

direction 属性设置为 horizontal,可以让宫格的内容呈横向排列。

<sf-grid direction="horizontal" :column-num="2">
  <sf-grid-item icon="photograph-o" text="文字" />
  <sf-grid-item icon="photograph-o" text="文字" />
  <sf-grid-item icon="photograph-o" text="文字" />
</sf-grid>

页面导航

通过 to 属性设置 vue-router 跳转链接,通过 url 属性设置 URL 跳转链接。

<sf-grid clickable :column-num="2">
  <sf-grid-item icon="good-job-o" text="路由跳转" to="/" />
  <sf-grid-item icon="search" text="URL 跳转" url="/demo.html" />
</sf-grid>

徽标提示

设置 dot 属性后,会在图标右上角展示一个小红点。设置 badge 属性后,会在图标右上角展示相应的徽标。

<sf-grid :column-num="2">
  <sf-grid-item icon="good-job-o" text="文字" dot />
  <sf-grid-item icon="search" text="文字" badge="99+" />
</sf-grid>

API

Grid Props

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | column-num | 列数 | number | string | 4 | | icon-size | 图标大小,默认单位为px | number | string | 28px | | gutter | 格子之间的间距,默认单位为px | number | string | 0 | | border | 是否显示边框 | boolean | true | | center | 是否将格子内容居中显示 | boolean | true | | square | 是否将格子固定为正方形 | boolean | false | | clickable | 是否开启格子点击反馈 | boolean | false | | direction | 格子内容排列的方向,可选值为 horizontal | string | vertical |

GridItem Props

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | text | 文字 | string | - | | icon | 图标名称或图片链接 | string | - | | icon-prefix | 图标类名前缀,同 Icon 组件的 class-prefix 属性 | string | sf-icon | | dot | 是否显示图标右上角小红点 | boolean | false | | badge | 图标右上角徽标的内容 | number | string | - | | info | 图标右上角徽标的内容(已废弃,请使用 badge 属性) | number | string | - | | url | 点击后跳转的链接地址 | string | - | | to | 点击后跳转的目标路由对象,同 vue-router 的 to 属性 | string | object | - | | replace | 是否在跳转时替换当前页面历史 | boolean | false |

GridItem Events

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

GridItem Slots

| 名称 | 说明 | | ------- | -------------------- | | default | 自定义宫格的所有内容 | | icon | 自定义图标 | | text | 自定义文字 |

样式变量

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

| 名称 | 默认值 | 描述 | | ----------------------------------- | ------------------------- | ---- | | @grid-item-content-padding | @padding-md @padding-xs | - | | @grid-item-content-background-color | @white | - | | @grid-item-content-active-color | @active-color | - | | @grid-item-icon-size | 28px | - | | @grid-item-text-color | @gray-7 | - | | @grid-item-text-font-size | @font-size-sm | - |