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-borders

v1.0.1

Published

A React component for attaching shapes to the edges any html element

Downloads

12

Readme

React Borders

Basic Usage

You can attach a border to an element using the border component exported from react-borders.

The below code will generate a box with triangles on all sides.

NOTE: The border component will set the position property of the parent to relative.

import React, { useRef } from 'react';
import { Border } from 'react-borders';

const BorderBox: React.VFC = () => {
	const boxRef = useRef<HTMLDivElement>(null);

	return (
		<div style={{ position: 'relative' }} ref={boxRef}>
			Triangles
			<Border parentRef={boxRef} type='triangles' sides={[1, 1, 1, 1]} />
		</div>
	);
};

Example

The exmaple site is deployed to vercel here. It is not yet complete.

Border

This is a function component used attach and customize borders.

Usage

For usage of this component, reference the basic usage section of the README.

Props

The prop types for the Border component are exported from the package, if you want to use them.

import { BorderSettings } from 'react-borders';

parentRef

Type: React.MutableRefObject<any> Required: true

The ref passed to the Border component should contain a reference to the element you wish to attach a border to.

type

Type: 'triangles' | 'ellipses' Required: true

The type of border you would like the component to display.

sides

Type: [0 | 1 | undefined, 0 | 1 | undefined, 0 | 1 | undefined, 0 | 1 | undefined] Required: false

Each position in the array correlates to a side of the element being populated with a border. [top, right, bottom, left]

Example: [1, 0, 1, 0] would place a border on only the top and bottom

widthContrains & heightConstrains

Type: { max: number, min: number } Required: false

Sets the max height and width for each element in the border.

backgroundColor

Type: string Required: false

Sets the color of the border elements. Anything CSS supports, this does as well.

You can even set the background to a linear gradient. All you have to do is pass the colors and when they stop, as you can see in the example below.

const Component = () => (
	<Border
		parentRef={ref}
		type='triangles'
		sides={[1, 1, 1, 1]}
		backgroundColor='red 60%, green 20%, blue 20%'
	/>
);

offset

Type: string | number required: false

This prop is used to decide how far the border should be from the element, 100% means it is on the element border, lower makes it closer, while higher does the opposite.

spacing

Type: number required: false

How far apart each element in the border should be from each other.

BorderSettings

A interface that defines all of the props listed above, for your convenience.