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

style-handler

v1.0.0

Published

simple library for styling inside component file

Downloads

2

Readme

Library for defining styles the same page of component. Capable of media queries too

set your media query points

(I recommend you call this in your page component or App component)

mediaQueryComponent([screenSizeSmall, screenSizeMedium, screenSizeLarge, screenSizeCustom])

set styles that do not change

constantStyling({
    styleName : {
        'backgroundColor' : 'green'
    },
    styleName2 : {
        'backgroundColor' : 'orange'
    }
})

call your constant styles like this

<h1 style={{ ...styles('constant').styleName }} >my h1 styled</h1>

set styles depending on screen size

smallWindowStyling()
mediumWindowStyling()
LargeWindowStyling()
customWindowStyling()

call your stylings the same way without the constant keyword

 <p style= {{ ...styles().styleName2}} >paragraph styled</p>

Example

import React from "react";
import { styles, constantStyling, smallWindowStyling, mediaQueryComponent } from './styleHandler'

export default function SampleComponent(){
    return (
        <div>
            <h1 style={{ ...styles('constant').styleh1 }} >my h1 styled</h1>
            <p style= {{...styles('constant').pStyle, ...styles().pStyle}} >paragraph styled</p>
        </div>
    )
}

<!-- setting query points -->
mediaQueryComponent([450,700,1920,1000])


constantStyling({
    pStyle : {
        backgroundColor : '#250E34',
        color : 'white'
    },
    styleh1 : {
        color : 'red',
        backgroundColor : 'yellow'
    } 
})

smallWindowStyling({
    pStyle : {
        backgroundColor : 'green'
    }
})

flush

call this method to remove all your cached objects.
For example, for every instance of constantStyling called, the object it takes is stored in variable.
Call flush() to set these variables to its default state again
example:
flush()

getHTMLInstance

this method takes in a react ref. This method is responsible for referencing your dom when doing animation and other stuffs.
getHTMLInstance('domReferenceName', domRef)
example:
const divEl = useRef()
getHTMLInstance('divElRef', divEl)   

note: best to use in useRef or componentDidMount

setAnimationFrame

this function sets a name to an animation keyframes set
this function takes in object or array. It works the same as css keyframes, only in js way
this function takes in object containing animation options

example keyframes:
const keyframe1 = {
    from: {
        js css styling here
    },
    to: {
        js css styling here
    }
}
const keyframe2 = {
    '0%': {
        js css styling here
    },
    '5%': {
        js css styling here
    },
    '100%': {
        js css styling here
    }
}

const keyframe3 = [
    {
        js css styling here
    },
    {
        js css styling here
    }
]

example options:
const options1 = {
    duration: 2000,   //2 seconds
    iterations: 'Infinity'
}

const options2 = {
    duration: 2000,   //2 seconds
    iterations: '3'
}

const option3 ={
    duration: 1000,   
    iterations: '10',
    easing: 'ease-in-out'
}

example:
setAnimationFrame('myFirstAnimationFrame', keyframe1, options)

note: best to use in useRef or componentDidMount

animateThis

attaches animation keyframes to internal dom reference

example:
animateThis('domReferenceName', 'myFirstAnimationFrame')

note: string inputs here are same as string arguments in getHTMLInstance and setAnimationFrame

note: best to use in useRef or componentDidMount

hoverStyling and activeStyling

stylings for hover and active events respectively

example: 
hoverStyling({
    styleName : {
        'backgroundColor' : 'green'
    },
    styleName2 : {
        'backgroundColor' : 'orange'
    }
})

activeStyling({
    styleName : {
        'backgroundColor' : 'green'
    },
    styleName2 : {
        'backgroundColor' : 'orange'
    }
})

hoverThis and activeThis

attaches hover styling or active styling to your named instance

example:
hoverThis('HtmlElementName', 'styleName')
activeThis('HtmlElementName', 'styleName2')