Skip to content

Commit f9814b3

Browse files
Wesley-0808Copilotanlyyao
authored
feat(watermark): add watermark (#3799)
* feat: docs * feat: watermark component * chore: demo & pixelRatio * chore: rename * chore: optimize * chore: css * chore: fix obs * chore: dark color * chore: demo * chore:watermark.ts Co-authored-by: Copilot <[email protected]> * chore: update demo * feat(Watermark): support style and customStyle props * chore: remove wx.onThemeChange --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: anlyyao <[email protected]>
1 parent d9d51d6 commit f9814b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+759
-1
lines changed

example/app.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@
9090
"pages/col/col",
9191
"pages/col/skyline/col",
9292
"pages/color-picker/color-picker",
93-
"pages/guide/guide"
93+
"pages/guide/guide",
94+
"pages/watermark/watermark"
9495
],
9596
"subpackages": [
9697
{

example/pages/home/data/display.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ const display = {
7979
name: 'Tag',
8080
label: '标签',
8181
},
82+
{
83+
name: 'Watermark',
84+
label: '水印',
85+
},
8286
],
8387
};
8488

example/project.config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,12 @@
406406
"query": "",
407407
"scene": null
408408
},
409+
{
410+
"name": "watermark",
411+
"pathName": "pages/watermark/watermark",
412+
"query": "",
413+
"scene": null
414+
},
409415
{
410416
"id": -1,
411417
"name": "search",
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
:: BASE_DOC ::
2+
3+
## API
4+
5+
### Watermark Props
6+
7+
name | type | default | description | required
8+
-- | -- | -- | -- | --
9+
style | Object | - | CSS(Cascading Style Sheets) | N
10+
custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on virtual component | N
11+
alpha | Number | 1 | \- | N
12+
content | String / Slot | - | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
13+
height | Number | - | \- | N
14+
is-repeat | Boolean | true | \- | N
15+
line-space | Number | 16 | \- | N
16+
movable | Boolean | false | \- | N
17+
move-interval | Number | 3000 | \- | N
18+
offset | Array | - | Typescript:`Array<number>` | N
19+
removable | Boolean | true | \- | N
20+
rotate | Number | -22 | \- | N
21+
watermark-content | Object / Array | - | Typescript:`WatermarkText\|WatermarkImage\|Array<WatermarkText\|WatermarkImage>` | N
22+
width | Number | - | \- | N
23+
x | Number | - | \- | N
24+
y | Number | - | \- | N
25+
z-index | Number | - | \- | N
26+
27+
### WatermarkText
28+
29+
name | type | default | description | required
30+
-- | -- | -- | -- | --
31+
font-color | String | rgba(0,0,0,0.1) | \- | N
32+
font-family | String | - | font-family configuration for watermark text | N
33+
font-size | Number | 16 | \- | N
34+
font-weight | String | normal | options: normal/lighter/bold/bolder | N
35+
text | String | - | \- | N
36+
37+
### WatermarkImage
38+
39+
name | type | default | description | required
40+
-- | -- | -- | -- | --
41+
is-grayscale | Boolean | false | \- | N
42+
url | String | - | \- | N
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
:: BASE_DOC ::
2+
3+
## API
4+
5+
### Watermark Props
6+
7+
名称 | 类型 | 默认值 | 描述 | 必传
8+
-- | -- | -- | -- | --
9+
style | Object | - | 样式 | N
10+
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
11+
alpha | Number | 1 | 水印整体透明度,取值范围 [0-1] | N
12+
content | String / Slot | - | 水印所覆盖的内容节点。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
13+
height | Number | - | 水印高度 | N
14+
is-repeat | Boolean | true | 水印是否重复出现 | N
15+
line-space | Number | 16 | 行间距,只作用在多行(`content` 配置为数组)情况下 | N
16+
movable | Boolean | false | 水印是否可移动 | N
17+
move-interval | Number | 3000 | 水印发生运动位移的间隙,单位:毫秒 | N
18+
offset | Array | - | 水印在画布上绘制的水平和垂直偏移量,正常情况下水印绘制在中间位置,即 `offset = [gapX / 2, gapY / 2]`。TS 类型:`Array<number>` | N
19+
removable | Boolean | true | 水印是否可被删除 | N
20+
rotate | Number | -22 | 水印旋转的角度,单位 ° | N
21+
watermark-content | Object / Array | - | 水印内容,需要显示多行情况下可配置为数组。TS 类型:`WatermarkText\|WatermarkImage\|Array<WatermarkText\|WatermarkImage>` | N
22+
width | Number | - | 水印宽度 | N
23+
x | Number | - | 水印之间的水平间距 | N
24+
y | Number | - | 水印之间的垂直间距 | N
25+
z-index | Number | - | 水印元素的 `z-index`,默认值写在 CSS 中 | N
26+
27+
### WatermarkText
28+
29+
名称 | 类型 | 默认值 | 描述 | 必传
30+
-- | -- | -- | -- | --
31+
font-color | String | rgba(0,0,0,0.1) | 水印文本文字颜色 | N
32+
font-family | String | - | 水印文本文字字体 | N
33+
font-size | Number | 16 | 水印文本文字大小 | N
34+
font-weight | String | normal | 水印文本文字粗细。可选项:normal/lighter/bold/bolder | N
35+
text | String | - | 水印文本内容 | N
36+
37+
### WatermarkImage
38+
39+
名称 | 类型 | 默认值 | 描述 | 必传
40+
-- | -- | -- | -- | --
41+
is-grayscale | Boolean | false | 水印图片是否需要灰阶显示 | N
42+
url | String | - | 水印图片源地址,为了显示清楚,建议导出 2 倍或 3 倍图 | N
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Component({
2+
data: {
3+
watermark: { text: '文字水印' },
4+
},
5+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"component": true,
3+
"usingComponents": {
4+
"t-watermark": "tdesign-miniprogram/watermark/watermark"
5+
}
6+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<t-watermark watermark-content="{{watermark}}" y="{{56}}" x="{{56}}" width="{{68}}" height="{{52}}">
2+
<view style="width: 100%; height: 340px" />
3+
</t-watermark>

packages/components/watermark/_example/base/index.wxss

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Component({
2+
data: {
3+
watermark: {
4+
url: 'https://tdesign.gtimg.com/starter/brand-logo-light.png',
5+
isGrayscale: true,
6+
},
7+
},
8+
});

0 commit comments

Comments
 (0)