Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ 新增Curtain 幕帘属性,支持使用其他图标 #648

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/component/curtain.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ function handleClose() {
| close-position | 关闭按钮位置 | string | inset / top / bottom / top-left / top-right / bottom-left / bottom-right | inset | - |
| close-on-click-modal | 点击遮罩是否关闭 | boolean | - | false | - |
| hide-when-close | 是否当关闭时将弹出层隐藏(display: none) | boolean | - | true | - |
| close-icon-name | 关闭按钮图标 | string | close-outline / close | close-outline | - |
| close-icon-size | 图标的字体大小 | string | - | inherit | - |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

新属性 close-icon-size 是个很好的补充

这个属性很好地补充了 close-icon-name,为用户提供了更多的自定义选项。描述简洁明了。

但是,这一行存在格式问题。请修复硬标签(hard tabs)的使用,改用空格来保持一致性。例如:

| close-icon-size | 图标的字体大小 | string | - | inherit | - |
🧰 Tools
🪛 Markdownlint

112-112: Column: 39
Hard tabs

(MD010, no-hard-tabs)


112-112: Column: 43
Hard tabs

(MD010, no-hard-tabs)

| close-icon-color | 图标的字体颜色 | string | - | inherit | - |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

新属性 close-icon-color 进一步增强了自定义选项

这个属性很好地补充了之前的两个新属性,为用户提供了全面的关闭图标自定义选项。描述简洁明了。

但是,这一行也存在格式问题。请修复硬标签(hard tabs)的使用,改用空格来保持一致性。例如:

| close-icon-color | 图标的字体颜色 | string | - | inherit | - |

为了更好地展示这些新属性的使用,我建议在文档中添加一个示例。您需要我为您生成一个使用这些新属性的示例代码吗?

🧰 Tools
🪛 Markdownlint

113-113: Column: 40
Hard tabs

(MD010, no-hard-tabs)


113-113: Column: 44
Hard tabs

(MD010, no-hard-tabs)


## Events

Expand Down
20 changes: 20 additions & 0 deletions src/pages/curtain/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<demo-block title="点击遮罩关闭">
<wd-button @click="handleClick8">点击遮罩关闭</wd-button>
</demo-block>
<demo-block title="自定义图标">
<wd-button @click="handleClick9">关闭图标自定义</wd-button>
</demo-block>

<wd-curtain :value="value1" :src="img" :to="link" @close="handleClose1" :width="280"></wd-curtain>
<wd-curtain :value="value2" :src="img" :to="link" close-position="top-left" :width="200" @close="handleClose2"></wd-curtain>
Expand All @@ -35,6 +38,16 @@
@close="handleClose8"
:close-on-click-modal="true"
></wd-curtain>
<wd-curtain
:value="value9"
:src="img"
:to="link"
closeIconName="close"
closeIconSize="20"
closeIconColor="red"
@close="handleClose9"
:width="280"
></wd-curtain>
</page-wraper>
</template>
<script lang="ts" setup>
Expand All @@ -48,6 +61,7 @@ const value5 = ref<boolean>(false)
const value6 = ref<boolean>(false)
const value7 = ref<boolean>(false)
const value8 = ref<boolean>(false)
const value9 = ref<boolean>(false)
const img = ref<string>('https://img20.360buyimg.com/da/jfs/t1/141592/25/8861/261559/5f68d8c1E33ed78ab/698ad655bfcfbaed.png')
const link = ref<string>('/pages/index/index')

Expand Down Expand Up @@ -99,6 +113,12 @@ function handleClick8() {
function handleClose8() {
value8.value = false
}
function handleClick9() {
value9.value = true
}
function handleClose9() {
value9.value = false
}
function clickImg() {
uni.navigateTo({
url: '/pages/index/index'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
@include m(active) {
&:active::before {
opacity: 0.15;
border-radius: 6px;
}
}

Expand Down
15 changes: 14 additions & 1 deletion src/uni_modules/wot-design-uni/components/wd-curtain/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { ExtractPropTypes } from 'vue'
import { baseProps, makeBooleanProp, makeStringProp } from '../common/props'

export type ClosePosition = 'inset' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
export type CloseIconName = 'close-outline' | 'close'

export const curtainProps = {
...baseProps,
Expand Down Expand Up @@ -32,7 +33,19 @@ export const curtainProps = {
/**
* 是否当关闭时将弹出层隐藏(display: none)
*/
hideWhenClose: makeBooleanProp(true)
hideWhenClose: makeBooleanProp(true),
/**
* 关闭按钮图标,可选值:close-outline / close
*/
closeIconName: makeStringProp<CloseIconName>('close-outline'),
/**
* 图标的字体大小
*/
closeIconSize: String,
/**
* 图标的字体颜色
*/
closeIconColor: String
}

export type CurtainProps = ExtractPropTypes<typeof curtainProps>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
>
<view class="wd-curtain__content">
<image :src="src" class="wd-curtain__content-img" :style="imgStyle" @click="clickImage" @error="imgErr" @load="imgLoad"></image>
<wd-icon name="close-outline" :custom-class="`wd-curtain__content-close ${closePosition}`" @click="close" />
<wd-icon
:name="closeIconName"
:size="closeIconSize"
:color="closeIconColor"
:custom-class="`wd-curtain__content-close ${closePosition}`"
@click="close"
/>
</view>
</wd-popup>
</view>
Expand Down