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

awesome-watermark

v1.1.0

Published

watermark component for vue,react and miniprogram

Downloads

5

Readme

awesome-watermark

可用于 react,vue 和微信小程序(更多平台正在开发)的水印组件

使用

1.安装依赖
npm install awesome-watermark
2.引入组件

react:

import Watermark from "awesome-watermark/react";

vue:

import Watermark from "awesome-watermark/vue";

微信小程序(需构建 npm):

{
	"usingComponents": {
		"watermark": "awesome-watermark"
	}
}
3.具体使用

由于 Watermark 组件使用position:absolute;定位,确保你需要加上水印的区域 position 值不为 static;且因需计算水印位置,要有固定高度,具体可见下面的实例:

React:

import React, { Component } from "react";
import Watermark from "awesome-watermark/react";
import "./index.css";

class Avatar extends Component {
	render() {
		return (
			<div className="avatar">
				<Watermark
					text="bowen"
					textStyle={{ color: "#fff", fontSize: 20 }}
				/>
			</div>
		);
	}
}

export default Avatar;
.avatar {
	width: 30%;
	height: 300px;
	border-radius: 50%;
	border: 1px solid #000;
	background: url(../../assets/27432981.jpeg);
	background-size: cover;
	position: relative;
}

Vue:

<template>
	<div class="avatar">
		<Watermark v-bind:text="text" />
	</div>
</template>

<script>
import Watermark from "awesome-watermark/vue";
export default {
	name: "Avatar",
	components: {
		Watermark
	},
	data: function() {
		return {
			text: "bowen"
		};
	}
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.avatar {
	width: 300px;
	height: 300px;
	border-radius: 50%;
	border: 1px solid #000;
	background: url(../../assets/27432981.jpeg);
	background-size: cover;
	position: relative;
}
</style>

微信小程序:

<view class="avatar">
	<image src="../../assets/27432981.jpeg" class="img"></image>
	<watermark text="bowen"></watermark>
</view>
.avatar {
	width: 300px;
	height: 300px;
	border-radius: 50%;
	border: 1px solid #000;
	background-size: cover;
	position: relative;
	overflow: hidden;
}

.img {
	width: 300px;
	height: 300px;
}
5.使用效果

效果图

Api

| 属性名 | 类型 | 默认值 | 说明 | | :-------: | :---------------------------------------------: | :----: | :------------------------------------: | | text | String(required) | "" | 水印的文字,该属性更改后会引起重新渲染 | | angle | Number | 30 | 水印文字旋转的角度 | | row | Number | 2 | 水印的行数 | | col | Number | 3 | 水印的列数 | | textStyle | react 和 vue 中为 Object,微信小程序中为 String | {} | 水印文字的 style 属性 |

Todo

  • [ ] 实现 react hooks 版本
  • [ ] 拓展更多小程序平台
  • [ ] api 拓展