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

yd-react-watermark-component

v1.0.5

Published

react-watermark-component is a component that can generate a water mark background image.

Downloads

7

Readme

  • react-watermark-component is a component that can generate a water mark background image.
  • this react component is from an internal project of youzan company.

feature

  • the arrangement is oblique
  • security defense -- prevent somebody from deleting the watermark dom, or modifying the style attribute
  • support securityAlarm callback -- it will be revoked when the watermark is attacked
  • support to configurate the style of watermark text, such as the font, rotate angle, chunkWidth, chunkHeight.
  • support to use this component twice or more times in one page
  • the watermark is drawn by canvas

suggestion

  • we suggest to use this component in the global, namely, the root dom.
  • the performance is better when the component is used in single page application, the position is the root component of react-router.

display

  • water mark image

install

    yarn add react-watermark-component

or

  npm i react-watermark-component --save

import

  • this package is developed using es6 syntax, so we recommend to load the package as follows:
    import ReactWaterMark from 'react-watermark-component';

or you can also load as follows:

  const ReactWaterMark = require('react-watermark-component')

the props of this component

  • waterMarkText:string, the text of watermark

  • openSecurityDefense:bool, decide whether to open security defense. By default, the security defense isn't opened.

  • securityAlarm:function, when the security defense is opened and water mark is attacked, the securityAlarm callback will be called. The securityAlarm props is optional, it will be triggered when someone is deleting the water mark dom or modifying the style attribute of the water mark dom.

  • options:object, the options is optional, the default value of the field of the options object is as follows.

    | option | default value | | --------- | ------------- | | chunkWidth | 200 | | chunkHeight | 60 | | textAlign | 'left' | | textBaseline | 'bottom' | | globalAlpha | 0.17 | | font | '14px Microsoft Yahei' | | rotateAngle | -0.26 | | fillStyle | '#666' |

    • chunkWidth:number, the width of a piece of water mark, it's suggested that the value is more than the real width, such as the real width is 150, correspondingly the chunkWidth is 200
    • chunkHeight:number, the height of a piece of water mark, it's suggested that the value is at least four times than the font-size of the real water mark text

Demo

  render() {
    const text = `${loginedUser.cas_username}, ${loginedUser.cas_id}`;
    const beginAlarm = function() { console.log('start alarm'); };
    const options = {
      chunkWidth: 200,
      chunkHeight: 60,
      textAlign: 'left',
      textBaseline: 'bottom',
      globalAlpha: 0.17,
      font: '14px Microsoft Yahei',
      rotateAngle: -0.26,
      fillStyle: '#666'
    }
    return (
      <ReactWaterMark
        waterMarkText={text}
        openSecurityDefense
        securityAlarm={beginAlarm}
        options={options}
      >
        <AppLayout>
          ...
        </Applayout>
      </ReactWaterMark>
    )
  }

compatibility

Contributing

  • compile
  npm run build

License

  • ISC