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

v1.0.2

Published

### 介绍

Downloads

4

Readme

Popup 弹出层

介绍

弹出层容器,用于展示弹窗、信息提示等内容,支持多个弹出层叠加展示。

引入

import Vue from 'vue';
import Popup from '@ophiuchus/popup';

Vue.use(Popup);

代码演示

基础用法

通过 v-model 控制弹出层是否展示。

<sf-cell is-link @click="showPopup">展示弹出层</sf-cell>
<sf-popup v-model="show">内容</sf-popup>
export default {
  data() {
    return {
      show: false,
    };
  },

  methods: {
    showPopup() {
      this.show = true;
    },
  },
};

弹出位置

通过 position 属性设置弹出位置,默认居中弹出,可以设置为 topbottomleftright

<sf-popup v-model="show" position="top" :style="{ height: '30%' }" />

关闭图标

设置 closeable 属性后,会在弹出层的右上角显示关闭图标,并且可以通过 close-icon 属性自定义图标,使用 close-icon-position 属性可以自定义图标位置。

<sf-popup
  v-model="show"
  closeable
  position="bottom"
  :style="{ height: '30%' }"
/>
<!-- 自定义图标 -->
<sf-popup
  v-model="show"
  closeable
  close-icon="close"
  position="bottom"
  :style="{ height: '30%' }"
/>
<!-- 图标位置 -->
<sf-popup
  v-model="show"
  closeable
  close-icon-position="top-left"
  position="bottom"
  :style="{ height: '30%' }"
/>

圆角弹窗

设置 round 属性后,弹窗会根据弹出位置添加不同的圆角样式。

<sf-popup v-model="show" round position="bottom" :style="{ height: '30%' }" />

指定挂载位置

弹出层默认挂载到组件所在位置,可以通过 get-container 属性指定挂载位置。

<!-- 挂载到 body 节点下 -->
<sf-popup v-model="show" get-container="body" />

<!-- 挂载到 #app 节点下 -->
<sf-popup v-model="show" get-container="#app" />

<!-- 通过函数指定挂载位置 -->
<sf-popup v-model="show" :get-container="getContainer" />
export default {
  methods: {
    // 返回一个特定的 DOM 节点,作为挂载的父节点
    getContainer() {
      return document.querySelector('.my-container');
    },
  },
};

注意:使用 get-container 属性的组件不能为根节点

API

Props

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | v-model (value) | 是否显示弹出层 | boolean | false | | overlay | 是否显示遮罩层 | boolean | true | | position | 弹出位置,可选值为 top bottom right left | string | center | | overlay-class | 自定义遮罩层类名 | string | - | | overlay-style | 自定义遮罩层样式 | object | - | | duration | 动画时长,单位秒 | number | string | 0.3 | | round | 是否显示圆角 | boolean | false | | lock-scroll | 是否锁定背景滚动 | boolean | true | | lazy-render | 是否在显示弹层时才渲染节点 | boolean | true | | close-on-popstate | 是否在页面回退时自动关闭 | boolean | false | | close-on-click-overlay | 是否在点击遮罩层后关闭 | boolean | true | | closeable | 是否显示关闭图标 | boolean | false | | close-icon | 关闭图标名称或图片链接 | string | cross | | close-icon-position | 关闭图标位置,可选值为top-leftbottom-left bottom-right | string | top-right | | transition | 动画类名,等价于 transtionname属性 | string | - | | transition-appear | 是否在初始渲染时启用过渡动画 | boolean | false | | get-container | 指定挂载的节点 | string | () => Element | - |

Events

| 事件名 | 说明 | 回调参数 | | -------------------------- | -------------------------- | -------------- | | click | 点击弹出层时触发 | event: Event | | click-overlay | 点击遮罩层时触发 | - | | click-close-icon | 点击关闭图标时触发 | event: Event | | open | 打开弹出层时触发 | - | | close | 关闭弹出层时触发 | - | | opened | 打开弹出层且动画结束后触发 | - | | closed | 关闭弹出层且动画结束后触发 | - |

样式变量

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

| 名称 | 默认值 | 描述 | | ------------------------------ | ------------------------------------ | ---- | | @popup-background-color | @white | - | | @popup-transition | transform @animation-duration-base | - | | @popup-round-border-radius | 16px | - | | @popup-close-icon-size | 22px | - | | @popup-close-icon-color | @gray-5 | - | | @popup-close-icon-active-color | @gray-6 | - | | @popup-close-icon-margin | 16px | - | | @popup-close-icon-z-index | 1 | - |