1.0.1 • Published 2 years ago

squircle.js v1.0.1

Weekly downloads
20
License
MIT
Repository
github
Last release
2 years ago

What is a squircle?

A squircle is a shape intermediate between a square and a circle. There are at least two definitions of "squircle" in use, the most common of which is based on the superellipse. The word "squircle" is a portmanteau of the words "square" and "circle". Squircles have been applied in design and optics. — Wikipedia

Why squircle.js?

In CSS, currently there is no such a spec for making squircles yet, and apparently it's not possible with just border-radius. The most common solution to implement squircles in web is to mask elements with a squircle image or an SVG path like this page. Unfortunately these static masks are unchangeable and doesn't work responsively. You have to manually create an image or generate one using some tools every time you need.

squircle.js automatically and dynamically generates squircle SVG paths based on the element's size and its border radius.

Installation

npm i squircle.js

API

import { squirclify } from 'squircle.js'

const toBeSquircles = document.querySelectorAll('.squircle')

squirclify(Array.from(toBeSquircles))

TypeScript

It has built-in types since it is totally written in TypeScript.

Limitations

To Do

  • Demo website
  • React
  • Vue
  • Svelte
  • Garbage collect unused masks
  • Unobserve removed DOMs

License

MIT

1.0.1

2 years ago

1.0.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago