Skip to content

Commit

Permalink
feat: 中间的文字提示可以通过props更改
Browse files Browse the repository at this point in the history
  • Loading branch information
yi-boide committed Sep 18, 2023
1 parent 843bac6 commit 45be547
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ test('AvatarCropper: Select the image to open the crop window', async () => {
expect(wrapper.vm.angle).toBe(90);
setAngle.trigger('click');
expect(wrapper.vm.angle).toBe(180);
setAngle.trigger('click');
setAngle.trigger('click');
expect(wrapper.vm.angle).toBe(0);

const confirm = btns[3];
confirm.trigger('click');
Expand Down
2 changes: 1 addition & 1 deletion src/packages/__VUE/avatarcropper/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</nut-cell>
<h2>裁剪区域bottom插槽</h2>
<nut-cell>
<nut-avatar-cropper ref="avatarCropperRef" btns-position="top" cancel-text="关闭" @confirm="cutImage">
<nut-avatar-cropper ref="avatarCropperRef" btns-position="top" edit-text="修改" @confirm="cutImage">
<nut-avatar size="large">
<img :src="imageUrl" />
</nut-avatar>
Expand Down
3 changes: 2 additions & 1 deletion src/packages/__VUE/avatarcropper/doc.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Customize the clipping area toolbar, and BNs-position controls the toolbar posit

```vue
<template>
<nut-avatar-cropper ref="avatarCropperRef" btns-position="top" @confirm="cutImage">
<nut-avatar-cropper ref="avatarCropperRef" btns-position="top" edit-text="修改" @confirm="cutImage">
<nut-avatar size="large">
<img :src="imageUrl" />
</nut-avatar>
Expand Down Expand Up @@ -94,6 +94,7 @@ const cutImage = (url: string) => {
| maxZoom | Maximum zoom | number | 3 |
| space | The gap reserved on both sides of the clipping area | number | 20 |
| btnsPosition | Location of the toolbar in the clipping area. The optional value is:`top` `bottom` | string | bottom |
| editText | The text content in the middle | string | 编辑 |
| cancelText | Cancel button text | string | 取消 |
| cancelConfirm | Confirm button text | string | 确认 |

Expand Down
3 changes: 2 additions & 1 deletion src/packages/__VUE/avatarcropper/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const cutImage = (url: string) => {

```vue
<template>
<nut-avatar-cropper ref="avatarCropperRef" btns-position="top" @confirm="cutImage">
<nut-avatar-cropper ref="avatarCropperRef" btns-position="top" edit-text="修改" @confirm="cutImage">
<nut-avatar size="large">
<img :src="imageUrl" />
</nut-avatar>
Expand Down Expand Up @@ -94,6 +94,7 @@ const cutImage = (url: string) => {
| maxZoom | 最大缩放倍数 | number | 3 |
| space | 裁剪区域两边预留的间隙 | number | 10 |
| btnsPosition | 裁剪区域工具栏位置,可选值为:`top` `bottom` | string | bottom |
| editText | 中间的文字内容 | string | 编辑 |
| cancelText | 取消按钮的文字 | string | 取消 |
| cancelConfirm | 确认按钮的文字 | string | 确认 |

Expand Down
3 changes: 2 additions & 1 deletion src/packages/__VUE/avatarcropper/index.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.nut-avatar-cropper {
position: relative;
&::after {
content: '编辑';
content: attr(data-edit-text);
position: absolute;
top: 0;
left: 0;
Expand Down Expand Up @@ -53,6 +53,7 @@
bottom: inherit;
}
.flex-sb {
width: 100%;
display: flex;
justify-content: space-between;
}
Expand Down
6 changes: 5 additions & 1 deletion src/packages/__VUE/avatarcropper/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<view class="nut-avatar-cropper">
<view class="nut-avatar-cropper" :data-edit-text="editText">
<slot></slot>
<input
ref="inputImageRef"
Expand Down Expand Up @@ -68,6 +68,10 @@ export default create({
type: String as PropType<BtnsPosition>,
default: 'bottom'
},
editText: {
type: String,
default: '编辑'
},
cancelText: {
type: String,
default: '取消'
Expand Down

0 comments on commit 45be547

Please sign in to comment.