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

@shortcm/shape

v0.43.0

Published

Shape utilities for Material Components for the web

Downloads

3

Readme

Shape

Shapes direct attention, identify components, communicate state, and express brand.

Currently shape system for web only supports rounded corners.

Design & API Documentation

Installation

npm install @material/shape

Basic Usage

Styles

@import "@material/shape/mixins";
@import "@material/shape/functions";

Style Customization

Sass Variables

Components are categorized as small, medium and large in shape system. Overriding below sass variables applies shape (rounded) to respective categories. For example, overriding $mdc-shape-medium-radius variable would apply shape to all components that belong to medium category.

Variable | Description --- | --- $mdc-shape-small-component-radius | Rounded shape radius size for small components. Default value 4px. $mdc-shape-medium-component-radius | Rounded shape radius size for medium components. Default value 4px. $mdc-shape-large-component-radius | Rounded shape radius size for large components. Default value 0.

Please refer Material Design guidelines: Shape to learn about how components are categorized.

Sass Mixins

Mixin | Description --- | --- mdc-shape-radius($radius, $rtl-reflexive) | Shape API used by all other components to apply radius to appropriate corners. $radius can be single value or list of up to 4 radius corner values. Set $rtl-reflexive to true to flip the radius in RTL case, false by default.

Use mdc-shape-resolve-percentage-radius sass function to resolve percentage unit value to absolute radius value.

Sass Functions

Function | Description --- | --- mdc-shape-flip-radius($radius) | Flips the radius values in RTL context. $radius is list of 2-4 corner values. mdc-shape-resolve-percentage-radius($component-height, $radius) | Calculates the absolute radius value based on its component height. Use this for fixed height components only. mdc-shape-mask-radius($radius, $masked-corners) | Accepts radius number or list of 2-4 radius values and returns 4 value list with masked corners as mentioned in $masked-corners. mdc-shape-prop-value($radius) | Returns $radius value of shape category - large, medium or small. Otherwise, it returns the $radius itself if valid. $radius can be a single value or list of up to 4.

Additional Information

Shapes for fixed height components

Styles for applying shape to a fixed height component such as button looks like this:

@include mdc-shape-radius(mdc-shape-resolve-percentage-radius($mdc-button-height, $radius));

Where, $mdc-button-height is the height of standard button and $radius is the size of shape. mdc-shape-resolve-percentage-radius function is used to resolve percentage unit value to absolute $radius value based on component height.

Shapes for dynamic height components

Styles for applying shapes to dynamic height component such as card looks like this:

@include mdc-shape-radius($radius);

Where, $radius is absolute value only.

Shapes for components on specific corners

Styles for applying shapes for specific corners such as drawer looks like this:

@include mdc-shape-radius(0 $radius $radius 0, $rtl-reflexive: true);

Where, only top-right & bottom-right corners are customizable and it automatically flips radius values based on RTL context when $rtl-reflexive is set to true.

Component theming

The styles for applying custom shape to button component instance looks like this:

@import "@material/button/mixins";

.my-custom-button {
  @include mdc-button-shape-radius(50%);
}

In this example, the above styles applies 50% (pill) shape to button. It can also be absolute value (e.g., 8px);

You would indirectly use the Shape API through respective component's mixin which takes care of applying radius to applicable corners for all its variants.