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-simple-svg-placeholder

v1.2.2

Published

Simple React component for simple SVG placeholder images

Downloads

8

Readme

react-simple-svg-placeholder

Simple React component for simple SVG placeholder images based on the awesome Cloudfour Simple SVG Placeholder

NPM JavaScript Style Guide

Install

npm install --save react-simple-svg-placeholder
yarn add react-simple-svg-placeholder

Usage

Default

import React from "react";

import PlaceholderImage from "react-simple-svg-placeholder";

const Example = () => <PlaceholderImage width={300} height={150} />;

With an Object

import React from "react";

import PlaceholderImage from "react-simple-svg-placeholder";

const Example = () => {
  const placeholderSettings = {
    width: 300,
    height: 150,
    bgColor: "#aaa",
    textColor: "#333",
  };

  return <PlaceholderImage {...placeholderSettings} />;
};

Prop Reference

width {Number}

Defaults to 300, the default width of SVG elements in most browsers.

height {Number}

Defaults to 150, the default height of SVG elements in most browsers.

returnAsString {Boolean}

Defaults to false, toggles if the component only returns the source-string or an actual <img>
Please also watch the "getImgSrc Function"-section below

text {String}

The text to display. Defaults to the image dimensions.

fontFamily {String}

The font to use for the text. For data URIs, this needs to be a system-installed font. Defaults to 'sans-serif'.

fontWeight {String}

Defaults to 'bold'.

fontSize {Number}

Defaults to 20% of the shortest image dimension, rounded down.

bgColor {String}

The background color of the image. Defaults to #ddd.

textColor {String}

The color of the text. For transparency, use an rgba or hsla color value. Defaults to rgba(0,0,0,0.5).

charset {String}

Defaults to UTF-8, but if your source HTML document's character set is different, you may want to update this to match.

getImgSrc Function

If you only want to generate an image-src you don't need to use a react-component.
You can use the getImgSrc-function of this project.
The defaults and props-usage is the same as in the react-component.

import { getImgSrc } from "react-simple-svg-placeholder";

const imgSrcWithDefaults = getImgSrc();
const imgSrcWithWidth = getImgSrc({ width: 800 });

License

MIT © r3sMetz