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-svg-border

v0.0.15

Published

React svg border

Downloads

37

Readme

Status GitHub Issues GitHub Pull Requests License


Demo

Simple Progress animation Multiple paths Morph demo

🧐 About

This project addresses the challenge of creating responsive borders or backgrounds with a dynamic ratio. Traditional SVG images lack this responsive behavior, making this component a valuable tool for enhancing web design.

🏁 Getting Started

Installing

npm i react-svg-border

Example

App.tsx

import React from 'react';
import SvgBorder from 'react-svg-border/dist';
import styles from './app.module.scss';

const borderConf = [
  {
    path: [
      "left, top",
      "right, top",
      "right, calc(100% - 30px)",
      "calc(100% - 30px), bottom",
      "left, bottom",
    ],
  },
];

function App() {
  return (
    <div className={styles.item}>
      <SvgBorder borderConf={borderConf}>
        <div className={styles.itemInner}>
          <div className={styles.itemTitle}>Lorem ipsum dolor</div>
          <div className={styles.itemDescription}>
            Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
            eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
            ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
            aliquip ex ea commodo consequat.
          </div>
        </div>
      </SvgBorder>
    </div>
  );
}

export default App;

App.module.scss

.item {
  max-width: 600px;
  margin: 20px auto 0;
}

.itemInner {
  padding: 30px 20px;
}

.itemTitle {
  font-size: 32px;
  font-weight: 700;
}

.itemDescription {
  margin: 20px 0 0;
  font-size: 18px;
}

Result

Demo

API

| name | description | type | default | | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ------- | | figures* | Here you can define multiple figures with individual properties, see Figure Api below for more details | FigureType[] | | | figuresDefaultParams | Used for define default figure params, sames as Figure Api except path property | FiguresDefaultParams | {} | | children* | The content of the component | JSX.Element, string | string | | classes | Override the styles applied to the component. See CSS API below for more details | object | {} | | drawProgress | Set drawing progress. See Progress animation demo | number[] | [] | | morphProgress | Set morph progress. See Morph animation demo | number[] | [] |

Figure API

| key | description | type | default | | ----------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------ | --------- | | path* | Cordinates of SVG. See Path API below for more details | (string | { from: string; to: string })[] | | | type | Defining type of svg, if you want to prevent connect last point to first, use polyline | 'polyline' | 'polygon' | 'polygon' | | fill | Fill svg property | string | 'none' | | stroke | Stroke svg property | string | '#000' | | strokeWidth | Stroke width svg property, be aware this property used in calculating padding space for children wrap | number | 1 |

Path type

| type | decription | | -------------------------- | ---------------------------------------------------------------------------------------------------- | | string | Define static position. See String coordinate type below for more details | | {from: string; to: string} | Define init(from) value and morph(to) value. |

String coordinate type

Each cordinates should containt position by axis X and Y separated by comma. | type | description | example | | ------------- | ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Px units | Position defined without units or as px will be static and don't react to change the size of the element | 30 pixels from left and 30px from top will be "30px, 30px" or "30, 30" | | Percent units | Position defined with percent unit will react to element size, x-axis react to width, y-axis react to height | If element have size 200px width and 300px height, "50%, 50%" will be equal "100px, 150px", but in this case px values will be calculated by element resize | | Calc position | If we need to combine pixels and percents, we can use calc, it's similar to css property value calc | If we need position in the top right corner, but we want 30px offset by the x-axis, we can use "calc(100% - 30), 0" | | Side position | This type of position helps define position by specific side with considering stroke width | If we have stroke width 5 and we want to place position in the top left corner, we should consider stroke width, so as result we will have "2.5, 2.5" and top right corner "calc(100% - 2.5), 2.5". Instead of this you can use side position and the top left corner will be "left, top", and the top right will be "right, top" |