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

props-to-styled

v2.0.0

Published

Transform custom props of your styled components to styles

Downloads

22

Readme

props-to-styled

Build Status Coverage Status npm version Greenkeeper badge

Transform custom props of your styled components to styles.

Installation

NPM

npm install --save props-to-styled

Usage

Using this:

<CustomComponent fixed="top">
    Fixed to top of the page
</CustomComponent>

<CustomComponent fixed="bottom">
    Fixed to bottom of the page
</CustomComponent>
import styled from 'styled-components';
import { fixed } from 'props-to-styled';

const CustomComponent = styled.div`
    ${fixed};
`

the result is similar to:

<div style="position: fixed; top: 0; bottom: inherit; left: 0; right: 0;">
    Fixed to top of the page
</div>

<div style="position: fixed; top: inherit; bottom: 0; left: 0; right: 0;">
    Fixed to bottom of the page
</div>

you can use also propTypes:

import PropTypes from 'prop-types';
import styled from 'styled-components';
import { fixed, fixedPropTypes } from 'props-to-styled';

const CustomComponent = styled.div`
    ${fixed};
`

CustomComponent.propTypes = {
    ...fixedPropTypes
}

Available props

ellipsis

Truncate string with "..." for one or many rows

Type: boolean || number

Values: true (1 row) || (number of rows) || false

Default: false


filter

Filter CSS attribute (https://www.w3schools.com/cssref/css3_pr_filter.asp)

Type: string

Values: (value of CSS filter)

Default: ''


fixed

Fix to top/bottom of the page when user scrolls

Type: string

Values: 'top' || 'bottom' || 'none'

Default: 'none'


float

Float an element to left or right

Type: string

Values: 'left' || 'right' || 'none'

Default: 'none'


linearGradient

Add linear gradient as background of a component (only two values, top-to-down)

Type: array (first value of the array is top color, second value is bottom color)

Values: (rgba or hex)

Default: []

Example:

<CustomComponent linearGradient={['#FFFFFF', '#000000']} />

shape

Change shape of the component

Type: string

Values: 'circle' || 'square' || 'none'

Default: 'none'


swipe

Make a component swipeable

Type: boolean

Values: true || false

Default: false


uppercase

Apply uppercase to a string

Type: boolean

Values: true || false

Default: false

Documentation

To read documentation, go to:

http://docomodigital.github.io/props-to-styled/latest

or run the following command inside the props-to-styled folder:

npm run doc:open