0.1.9 • Published 8 years ago

r-watermark v0.1.9

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

r-watermark

npm version npm downloads

Introduction

RWatermark is a mini watermark library based on React ⚛ .

Installation

Use yarn

$ yarn add r-watermark

Demo

To run the demo on your local server, please do as follows.

$ yarn
$ yarn start

Then open http://localhost:3000/

Usage

import React, { Component } from "react";
import { render } from "react-dom";
import { wrapWatermark } from "r-watermark";

export interface AppProps {
  style?: CSSProperties;
  watermark?: JSX.Element;
}


const alertIt = () => alert("Here you go.");

class App extends Component<AppProps> {
  render() {
    const { style, watermark } = this.props;

    return (
      <div style={style} className="App">
        {watermark}
        <div className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h2>Welcome to RWatermark</h2>
        </div>
        <div style={{ padding: 160 }}>
          <button
            style={{
              height: 32,
              minWidth: 100,
              color: "white",
              background: "skyblue",
              border: 0,
            }}
            onClick={alertIt}
          >
            Hello App
          </button>
        </div>
      </div>
    );
  }
}

const texts = [
  {
    translateX: 65,
    translateY: 35,
    rotate: -15,
    text: "Yo yo yo",
  },
  {
    translateX: 110,
    translateY: 55,
    rotate: -15,
    text: "Check it now.",
  },
];

const WithWatermark = withWatermark<AppProps>({ texts })(App);

render(
  <WithWatermark />,
  document.querySelector("#react-root")
);

API

  • WatermarkProps
PropTypeDescriptionDefault
widthnumberSVG width180
heightnumberSVG height80
zIndexnumberWatermark div style z-index9999
opacitynumberWatermark div style opacity0.15
textsText[]Watermark texts[]
  • Text
PropTypeDescriptionDefault
translateXnumberSVG TEXT transform translateX
translateYnumberSVG TEXT transform translateY
rotatenumberSVG TEXT transform rotate
fillstringSVG TEXT fill"#000000"
fontFamilystringSVG TEXT font family"monospace"
textstringSVG TEXT inner text

License

MIT

0.1.9

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago