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

react-7segments

v0.0.1

Published

React component for displaying seven segments

Downloads

12

Readme

react-7segments

Build Status Coverage Status Npm Version Npm License

React component for seven segments

Usage

npm

npm install react-7segments --save

bower

bower install react-7segments --save

browser

<!DOCTYPE html>
<html>
    <head>
        ...
    </head>
    
    <body>
        ...
        
        <div id="demo"></div>
        
        <script src="//fb.me/react-with-addons-0.14.3.min.js"></script>
        <script src="//fb.me/react-dom-0.14.3.min.js"></script>
        <script src="//cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
        
        <script src="bower_components/react-7segments/react-7segments.js"></script>
        
        <script type="text/babel">
            var SegGroup = React7Seg.Group; // can access by global variable 'React7Seg'
            
            ReactDOM.render(
                <SegGroup value="1234" />, // [1][2][3][4]
                document.getElementById('demo')
            );
            
        </script>
    </body>
</html>

nodejs

import React7Seg from 'react-7segments';
import React from 'react';

const SegGroup = React7Seg.Group;
//or import SegGroup from 'react-7segments/src/components/SegGroup.jsx';

export default React.createClass({
    render: function(){
        return(
            <SegGroup value="1234" />            
        );
    };
});

Example

Live example

Basic

var BasicEg = React.createClass({
    render: function() {
        return (
            <SegGroup value="0123456789" />
            // [0][1][2][3][4][5][6][7][8][9]
            // [ ] means one distinct 7segments-digit
        );
    }
});

Dot

  • Dot has some exceptions because try to reflect real seven digits.

  • Basically, dot doesn't reside in one distinct digit.

    • eg) 12.34 --> [1][2.][3][4]
  • However, under the below conditions, it holds one digit.

    • Dot is the first character.
      • eg) .1234 --> [.][1][2][3][4]
    • Dot's left character is a dot.
      • eg) 1... --> [1.][.][.]
    • Dot's left character is a space.
      • eg) 12 .45 --> [1][2][.][4][5]

Supported characters

  • number
  • alphabet: 'SEG' ( It has a relation with module name :) )
  • special character: hyphen(-), lodash(_), dot(.), space( )

Options

var OptionsEg = React.createClass({
    render: function() {
        var options = {
            size: 10,
            align: 'left'
        };
        return (
            <SegGroup {...options} value="12345" />
            // [1][2][3][4][5][ ][ ][ ][ ][ ]
        );
    }
});

Custom style

.custom-on-class {
    fill: black;
}

.custom-digit-class {
    fill: #ddd;
    background-color: white;
}
var StyleEg = React.createClass({
    render: function() {
        var digitOptions = {
            onClass: 'custom-on-class',
            digitClass: 'custom-digit-class'
        };
        
        return (
            <SegGroup digitOptions={digitOptions} value="12345" />
            // [1][2][3][4][5]
            // background color is white and light-on part color is black -->
        );
    }
});

Custom pattern

Allow to add custom segment pattern by passing it into options

const SegMap = React7Seg.Map;
const SegUtil = React7Seg.Util;

var PatternEg = React.createClass({
    render: function() {
        var customPatterns = {
        'r' : SegUtil.arrToSegNum([0, 0, 0, 0, 1, 0, 1]);
        'o' : SegUtil.arrToSegNum([0, 0, 1, 1, 1, 0, 1]);
        'b' : SegUtil.arrToSegNum([0, 0, 1 ,1 ,1, 1, 1]);
        
        var customMap = _.assign({}, SegMap, customPatterns); // use lodash.assign
        
        return (
            <SegGroup map={customMap} value="bro" />
            // [b][r][o]
            // These are not provided basically
        );
    }
});

Custom shape

const SegPoints = React7Seg.Points;

var ShapeEg = React.createClass({
    render: function() {
        var customPoints = SegPoints.slice(); //will clone SegPoints
        
        customPoints[1] = "38 11, 43 6, 48 11, 48 39, 43 39, 38 34";
        customPoints[2] = "38 46, 43 41, 48 41, 48 69, 43 74, 38 69";
            
        customPoints[4] = "0 41, 5 41, 10 46, 10 69, 5 74, 0 69";
        customPoints[5] = "0 11, 5 6, 10 11, 10 34, 5 39, 0 39";
        
        var digitOptions = {
            points: customPoints
        };
        
        return (
            <SegGroup digitOptions={digitOptions} value="1234" />
            //It has right angle at middle part
        );
    }
});

LICENSE

MIT