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

inverted-corners

v1.0.2

Published

A Houdini Paint worklet for inverted corners using the CSS Paint API.

Downloads

46

Readme

Inverted Corners

npm NPM

🎨 A Houdini Paint worklet for inverted corners.

Table of Contents

📦 Setup

🧪 Please remember this is experimental and may not work in all browsers. Is Houdini ready yet?

Standalone

Add the following to your HTML to include Inverted Corners using unpkg.

<script src="https://unpkg.com/inverted-corners/lib/inverted-corners.min.js"></script>

Omit the version number to use the latest version, or use a specific one:

<script src="https://unpkg.com/[email protected]/lib/inverted-corners.min.js"></script>

That's it! Read the Usage section to learn how to access the paint worklet.

Worklet

If you want to include the worklet yourself, you can add the paint module like this:

CSS.paintWorklet.addModule('https://unpkg.com/inverted-corners/lib/inverted-corners-worklet.min.js');

For example, in a React app you could execute this on the component mount:

import React, { useEffect } from 'react';

const MyComponent = () => {
    useEffect(() => {
        if ('paintWorklet' in CSS) {
            CSS.paintWorklet.addModule('https://unpkg.com/inverted-corners/lib/inverted-corners-worklet.min.js');
        }
    }, []);

    return (
        {/* some content here */}
    );
};

export default MyComponent;

Check support

To check if a browser supports the Paint API via JavaScript:

if ('paintWorklet' in CSS) {
    // Browser supports paint worklets, add the module here
} else {
    console.warn('Houdini\'s Paint Worklet is not supported on your browser.');
}

To check if a browser supports the Paint API via CSS:

@supports (background: paint(something)) {
    /* Browser supports paint worklets, do something here */
}

⌨️ Usage

Once you're done with the Setup, you can immediately access the paint worklet with either background: paint(inverted-corners); or -webkit-mask-image: paint(inverted-corners);

Properties

There are three input properties for the paint worklet:

| Property | Description | | --------------------- | ------------------------------------------------- | | --corner-radius | The radii of the four corners | | --background | A color or a gradient to use as the background | | list-style-image | An image to use as the background |

Corners

You can set the radius of each corner using the --corner-radius property.

It uses a shorthand syntaxt similar to the native border-radius property.

--corner-radius: <top-left> <top-right> <bottom-right> <bottom-left>;

For example,

--corner-radius: 20 20 -20 -20;

Positive values produce normal corners (similar to the border-radius property), while negative values produce inverted corners.

Backgrounds

You can set the background using the --background property.

For example,

--background: #fff;

To add a shadow, use filter: drop-shadow() instead of box-shadow.

You can also use gradients! Just set multiple colors separated with a comma.

Basic gradient

--background: cyan, purple;

Tri-color gradient

--background: #879af2, #d3206b, #fda000;

Color stops

To set a custom color stop, use the following format:

<color> <color-stop>

where <color-stop> is a number between 0.0 and 1.0.

For example,

--background: #879af2, #d3206b 0.2, #fda000;

Angles

To set a custom angle, add the rotation (in degrees) as the first parameter:

--background: 90deg, cyan, purple;

Masks

You can also use the mask-image (and the prefixed -webkit-mask-image) property to apply a mask and reshape an element.

-webkit-mask-image: paint(inverted-corners);
mask-image: paint(inverted-corners);

When using masks, you can apply a background with the regular background, background-color, and background-image CSS properties.

Keep in mind, that while this method is really useful in some cases, you'll lose the ability to add shadows to the element.

Images

To set an image as the background of the element, you can use the list-image-type property. This is necessary to workaround an issue where images wouldn't load with custom image properties on Chrome/Opera/Edge.

list-style-image: url(YOUR_IMAGE);

📙 Examples

Take a look at the following examples:

🐞 Bugs & Features

If you have spotted any bugs, or would like to request additional features from the library, please file an issue.

📖 License

The MIT License, check the LICENSE file.