• Stars
    star
    167
  • Rank 226,635 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 7 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create the skeleton screen through SVG element

SVG-Skeleton

Licence NPM Size

Why

Skeletal screen, we are no stranger to, and the biggest existence of the skeletal screen is due to the page rendering out of content for a long time, and use it to occupy the page, users to reduce the time to perceive white screen.

If the skeletal screen depend on core frameworks such as React / Vue, it will inevitably first need to parse the core library before rendering to the skeletal screen, which is undoubtedly not the best choice.

SVG-Skeleton is exactly what we've been looking for.

By SVG elements to describe the placeholder elements of the skeletal diagram, support JSX write SVG indifference, reuse SVG fragments, component-based mode.

简体中文

Installing

npm i svg-skeleton --save

or

<script src="https://cdn.jsdelivr.net/npm/svg-skeleton/dist/svg-skeleton.min.js"></script>

Usage

JSX Code

import SVGSkeleton from 'svg-skeleton';

const { h, render } = SVGSkeleton;

// inside #shining animation
const Item = (
    <svg width="750" height="191">
        <circle cx="95" cy="102" r="63" fill="#edeff0" mask="url(#shining)" />
        <rect width="160" height="35" x="190" y="45" fill="#edeff0" mask="url(#shining)" />
        <rect width="400" height="35" x="190" y="90" fill="#edeff0" mask="url(#shining)" />
        <line x1="0" y1="190" x2="750" y2="190" stroke="#edeff0"></line>
    </svg>
);

const Page = ( ( ) => {
    let List = [ ];

    for ( let i = 0; i < 6; i++ ) {
        List.push( ( <Item y={ i == 0 ? 0 : i * 191 } /> ) );
    }

    return (
        <svg width="750" height="1334" fill="#fafafa">
            { List }
        </svg>
    );
} )( );

render( Page,  document.body );

Output

Diff

In order to try to position the elements of the bone screen the same as the design draft, you need the Diff function.

Code

const { diff } = SVGSkeleton;

render( diff( Page, require('./list.png') ),  document.body );

Output

Depend on JSX & h

the setting will be similar to

{
    "plugins": [
        [ "transform-react-jsx", { "pragma": "h" } ]
    ]
}

License

MIT

More Repositories

1

TwitterPaggingViewer

A twitter like navigation bar, page viewer.
Objective-C
356
star
2

XCode-Color-Fixer

StoryBoard / XIB 颜色偏差很严重,怎么破?XCode-Color-Fixer帮你忙!
Objective-C
125
star
3

flowhub

Through a simple way to deal with the event flow.
JavaScript
110
star
4

fe-guide

Joyy UED 前端规范指南
92
star
5

MagicDrag

MagicDrag is an application introducing page components build for Interactive Animations.
Swift
45
star
6

CRChecker

CRChecker is a debug tool, helps you find out circular reference problem.
Objective-C
39
star
7

cherry

一款高效、好用的图片处理工具(https://yyued.github.io/cherry/)
HTML
34
star
8

generator-lego

F2E workflow, base on yeoman & gulp
CSS
22
star
9

legolib

面向移动端的轻量级前端 Components,提供易用、可靠的解决方案
CSS
20
star
10

LEGO-Mobile

LEGO移动前端开发框架,提供简单、快速的 Web 开发体验
JavaScript
18
star
11

H5Live

JavaScript
15
star
12

grunt-workflow

这是一个帮助前端开发工程师简化工作的工具
CSS
13
star
13

lottery

一个浏览器端抽奖动画js组件
JavaScript
12
star
14

ENMetadataCleaner

Decrease PSD file size.
JavaScript
11
star
15

LegoUI-pc

LegoUI, 一套基于BEM的轻量级前端UI库
CSS
8
star
16

LegoUI-mobi

CSS
6
star
17

ENAutoBackUpTool

JavaScript
6
star
18

UIKit-Android

Kotlin
6
star
19

nice-commit

规范 Git Commit
JavaScript
6
star
20

share-sheet

share sheet
Vue
5
star
21

fekit.crx

f2e toolkit chrome-extension dev env
JavaScript
4
star
22

YFT

create Image and Label from Character-Bitmap.
Objective-C
3
star
23

value-animator

TypeScript
3
star
24

Lego-Snippets

LegoUI Snippets for Sublime Text 2/3
2
star
25

fe-solution

前端解决方案
JavaScript
2
star
26

PSD-Etiquette

PSD图层管理指南
2
star
27

fekit

f2e dev toolkit
JavaScript
1
star
28

document-template

The project document template
1
star
29

LEGO-Pack

Just pack a folder and generate md5 hash.
JavaScript
1
star
30

CodeX

CodeX helps you build User Interface from PRD to design, and generate code via Sketch.
JavaScript
1
star