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

v0.1.1

Published

Add squircles to your React project!

Downloads

9

Readme

react-squirclize npm

Make anything a squircle in your React project!

Installation

npm i react-squirclize

Getting Started

To get started, install react-squirclize in your project.

npm i react-squirclize

Squirclize adds the Squircle component which extends the HTML div.

<Squircle />

Rounding

If you decide you want to adjust the amount that the edged are rounded by, you can use the radius parameter:

<Squircle radius="20px" />

radius supports a number of CSS standard measurement units such as "px", "pt", and "pc". You can also set it to "full" for full corner rounding.

Clip Quality

Squirclize uses a polygon mask for generating it's shape. The default algorithm makes 45 cuts along the edge of the shape it's cutting. You can adjust this number by setting the quality parameter.

<Squircle quality="quarter" />

quality can be set to a number of different values:

full - 360 segments | You'll basically never need this.

half - 180 segments

quarter - 90 segments

lowest - 45 segments

custom - Any number between 45 and 360

If you don't set a quality level, Squirclize will instead check the radius you've set and calculate the best quality setting based on that.

Borders

Squircle provides an in-built border system.

<Squircle borderWidth="1px" borderColor="white" />

By setting the borderWidth and borderColor params you can adjust the border for Squircles!

Both borderWidth and borderColor support the typical CSS types that you would expect them to.

Additionally, Squircle borders also allow you to set transparent backgrounds for your Squircles, a limitation which many other Squircle border implementations don't account for.

Limitations

  • Squircles use clip-path to crop the underlying element. Some CSS styles such as border, box-shadow, and border-radius will not be visible.
  • Squircles always have overflow set as hidden.
  • Squircles always have position set as relative.
  • Squircles will always override any clip-path you have set.
  • Squircles will always ignore border and border-radius styles you have set.

Optimizing

Squirclize uses the useCoordinates hook to generate coordinate values that it then uses for it's polygon mask. useCoordinates is memoized and will only execute if the radius, component width, and component height, have changed. Component re-renders won't cause the hook to re-run.

If you want to further optimize your Squircle, you can consider setting the frozen parameter:

<Squircle frozen={true}>

frozen will disable the Squircle's dynamic transform observer, this effectively breaks the ability for you to use non-absolute unit measurements such as %, min-content, max-content, vh, or vw, with the small performance boost of not having another listener running.

Additionally, you can consider memoizing the Squircle component if you'd like even more control over when it re-renders.