Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-skeleton

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-skeleton

a nice tool to make skeleton screen

  • 1.3.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

create-skeleton

轻松提供 CLI 自动生成骨屏, 提供 includeNode, 或者 beforeDraw 等方法定制化骨架屏, headless 为 false 支持打开待生成骨架屏页面,手动生成骨架屏

Install

npm i create-skeleton -D

Usage

  1. 方案一: 提供 create-skeleton.config.js , 执行npx create-skeleton
  • 配置 output.filePath,如果配置的是目录,会写入到该目录里的 create-skeleton.html (没有的话我们会创建)文件里;
  • 自定义写入的方式 writeSkeleton: (outputHtml: string) => void;
  • 如果前面两种方式您都没有提供,那么将会在您当前目录下创建 create-skeleton.html ,并将骨架屏节点写入;
  1. 方案二: npx create-skeleton <create-skeleton-url> 生成骨架屏

Examples

// create-skeleton.config.js
const fs = require("fs");

module.exports = {
  url: "https://baidu.com",
  output: {
    filePath: "",
    injectSelector: "#app"
  },
  background:
    "linear-gradient(90deg,rgba(190,190,190,.2) 25%,rgba(129,129,129,.24) 37%,rgba(190,190,190,.2) 63%);background-size: 400% 100%;",
  animation: "ant-skeleton-loading 1s linear infinite;",
  header: {
    // height: 44,
    // background: "#eee"
  },
  beforeDraw: function() {
    //生成骨架屏之前的操作,比如删除干扰节点
    const conWrap = document.querySelector(".con-wrap");
    if (conWrap) {
      conWrap.style.cssText = "visibility: hidden";
    }
  },
  includeNode: function(node, draw) {
    // 删除干扰节点
    if (node.id === "skipNode") {
      return false;
    }
  }
  // writeSkeleton: function(html) {
  //   //自己处理生成的骨架屏
  //   fs.writeFileSync(__dirname, html);
  // }
};

参数说明

参数说明默认值是否必填
url待生成骨架屏页面地址--
extraHTTPHeaders请求头--
device设备类型iPhone 6
output.filePath生成的骨架屏节点写入的文件--
output.injectSelector骨架屏节点插入的位置#app
header.height主题 header 的高--
header.background主题 header 的背景色--
background骨架屏主题色#ecf0f2
animationcss3 动画属性--
rootNode针对模块生成骨架屏document.body
beforeDraw开始生成之前的操作--
includeNode(node, draw({width:numbenr,height:number,left:number, top:number, zIndex:number,background:'#ccc}))定制某个节点如何生成--
writeSkeleton(html)回调的骨架屏节点--
headless headless mode 如果为 false, 将不关闭浏览器, 需手动点击生成骨架屏页面(按钮)右上角【骨架屏】按钮生成骨架屏true

Keywords

FAQs

Package last updated on 11 Mar 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc