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

react-skeleton-splash

v1.0.0

Published

A skeleton splash component for React which is fully customisable.

Downloads

5

Readme

React Skeleton Splash 🦄

License: MIT

As a frontend developer I have always thought that my designs were missing something. Loading screens just didn't ever line up with how I pictured them in my mind. I tried everyhting, loading bars, spinners, inspirational messages with themed backgrounds but it still didn't seem right.

But one faithful day while I was reading articles on the intertubular speedway of information (the internet) I came across this article about skeleton screen and boyo did it change how I saw and understood loading screens. Here's my favorite part

Skeleton screens (as splash screens), when used to indicate that a screen is loading, are perceived as being shorter in duration when compared against a blank screen (our control) and a spinner — but not by much

Isn't that something? So I began incorporating them into my design and what do you know, things just started to line up. My designs felt more performant and best of all: no longer was there awkward margin- / padding-issues when a screen was finished loading!

Aaaand what do we say to that, well 🦄🦄🦄

But there was still one problem, I could not find a React-package that was not giving me unforeseen headaches. So I thought, why not make my own? So, with 38 lines of breathtaking code and the all powerful package styled-components, I did

import React from 'react';
import styled, { keyframes } from 'styled-components';

const fade = keyframes`
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
`;

const Wave = styled.div`
    animation: ${fade} 2s ease-in-out infinite;
    background-color: ${props => props.baseColor};
    background-image: linear-gradient(
        90deg, 
        ${props => props.baseColor},
        ${props => props.shineColor},
        ${props => props.baseColor}
    );
    background-size: 200px 100%;
    background-repeat: no-repeat;
`;

export default function Skeleton({
    style = { height: '100%', width: '100%', borderRadius: 5 },
    baseColor = '#f4f4f4',
    shineColor = '#e5e5e5',
}) {
    return (
        <Wave
            style={style}
            baseColor={baseColor}
            shineColor={shineColor}
        />
    );
}

Then to prove its 🦄 I then wrote an implentation with create-react-app to see it working in action

import React from 'react';
import Loader from 'react-skeleton-splash';
import { holderStyle, getRandomItems, imageLoaderStyle, getRandomTextStyle } from './defaults';

export default function () {
    const items = getRandomItems();
    return (
        <div style={holderStyle}>
            <Loader style={imageLoaderStyle} />
            {items.map(id => (
                <Loader
                    key={`loading-item-${id}`}
                    style={getRandomTextStyle()}
                />
            ))}
        </div>
    );
}

I split the code up with the helpers in a different file so you could actually understand the index-component.

const widths = [
    '15%',
    '25%',
    '35%',
    '45%',
    '55%',
    '65%',
    '75%',
    '85%',
    '95%',
    '100%',
];

export const holderStyle = {
    width: '600px',
    margin: '0 auto',
};

const imageHeight = '70px';
export const imageLoaderStyle = {
    marginTop: '15px',
    height: imageHeight,
    width: imageHeight,
    borderRadius: imageHeight,
};

export const textLoaderStyle = {
    marginTop: '15px',
    height: '14px',
    borderRadius: '5px',
};

function getRandomWidth() {
    const index = Math.floor(Math.random() * widths.length);
    return widths[index];
}

export function getRandomTextStyle() {
    return { ...textLoaderStyle, width: getRandomWidth() };
}

export function getRandomItems() {
    const numberOfItems = Math.floor(Math.random() * 15) + 1;
    const items = [...Array(numberOfItems).keys()];

    return items;
}

So what can you do with this? Copy it, use it, show your boss, learn, anything!