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

rulers

v1.0.8

Published

Rulers A complete library for building ruler components in any environment such as React, Angular and Vue.js.

Downloads

26

Readme

Rulers

Rulers A complete library for building ruler components in any environment such as React, Angular and Vue.js.

Getting Started

Installation

  • npm install rulers

PropTypes

| Property | Type | Default | Description | | :------------ | :------- | :----------- | :--------------------- | | handleValue | Function | | get the return value | | canvasWidth | Number | screen width | ruler width | | canvasHeight | Number | 83 | ruler height | | heightDecimal | Number | 35 | scale marks length | | heightDigit | Number | 18 | division marks length | | lineWidth | Number | 2 | marks width | | colorDecimal | String | #E4E4E4 | scale marks color | | colorDigit | String | #E4E4E4 | division marks color | | divide | Number | 10 | division length of px | | precision | Number | 1 | division value | | fontSize | Number | 20 | scale fontSize | | fontColor | String | #666666 | scale fontColor | | fontMarginTop | Number | 35 | font margin to the top | | maxValue | Number | 230 | max value | | minValue | Number | 100 | min value | | currentValue | Number | 100 | current value |

React

import Rulers from 'rulers';

function App() {
    const rulerRef = useRef(null);
    const [state, setState] = useState(50000);

    useEffect(() => {
        renderRuler();
    }, [rulerRef])

    const handleValue = (value) => {
        console.log(value); //return value
        setState(value);
    }

    const renderRuler = () => {
        return new Rulers (
            {
                el: rulerRef.current,
                maxValue: 100000,
                minValue: 0,
                currentValue: state,
                handleValue: handleValue,
                precision: 100
            }
        );
    }

  return (
    <div className="App">

        <div ref={rulerRef} className='container'>
            <h2 className='typeName'>Value</h2>
            <div className='valueContainer'>
                <span className='value'>{state}</span>
            </div>
        </div>
    </div>
  );
}

export default App;

CSS

.App {

}
:root {
  font-size: 100px;
}

.container {
  padding: .1rem 0;
}

.typeName {
  position: relative;
  font-size: .16rem;
  line-height: .4rem;
  text-align: center;

  &:after {
    position: absolute;
    z-index: 1;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    content: '';
    width: .5rem;
    height: .04rem;
    border-radius: .02rem;
    background-color: #00b0ab;
  }
}

.valueContainer {
  padding-bottom: .04rem;
  text-align: center;
  position: relative;
}

.value {
  padding-right: .04rem;
  font-size: .3rem;
}