Skip to content

Commit

Permalink
Fix/toast single theme (#181)
Browse files Browse the repository at this point in the history
* fix: 配置面板属性调整
  • Loading branch information
YufJi committed Oct 19, 2023
1 parent f3db053 commit f7710d3
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 30 deletions.
3 changes: 2 additions & 1 deletion scripts/genThemeConfig/property.json
Original file line number Diff line number Diff line change
Expand Up @@ -477,5 +477,6 @@
"--van-toast-max-width": "70%",
"--van-toast-font-size": "14px",
"--van-toast-text-color": "#fff",
"--van-toast-background-color": "rgba(0, 0, 0, 0.7)"
"--van-toast-background-color": "rgba(0, 0, 0, 0.7)",
"--van-toast-custom-icon-color": "white"
}
7 changes: 6 additions & 1 deletion scripts/genThemeConfig/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -2099,7 +2099,8 @@
"toPosition": "toast",
"type": [],
"preview": {
"template": "<van-toast message=\"弹出消息\" :duration=\"2000\" type=\"text\" position=\"middle\"></van-toast>"
"template": "<van-button @click=\"onOpen\">弹出消息</van-button>",
"script": "export default {\n data() {\n return {\n };\n },\n methods: {\n onOpen() {\n this.$toast.show(\"弹出消息\");\n },\n },\n};"
},
"cssProperty": {
"--van-toast-max-width": {
Expand All @@ -2117,6 +2118,10 @@
"--van-toast-background-color": {
"type": "color",
"desc": "弹出消息的背景色"
},
"--van-toast-custom-icon-color": {
"type": "color",
"desc": "弹出消息的自定义图标颜色"
}
}
}
Expand Down
21 changes: 11 additions & 10 deletions scripts/lcap/usage.json
Original file line number Diff line number Diff line change
Expand Up @@ -10815,29 +10815,30 @@
},
{
"name": "message",
"title": "文本",
"title": "提示内容",
"type": "string",
"default": "弹出消息消息",
"description": "文本内容"
"default": "弹出消息",
"description": "默认提示内容"
},
{
"name": "type",
"title": "类型",
"title": "消息类型",
"type": "string",
"description": "提示的类型",
"default": "custom",
"options": [
{
"value": "success",
"title": "成功"
},
{
"value": "fail",
"title": "失败"
},
{
"value": "warning",
"title": "警告"
},
{
"value": "fail",
"title": "失败"
},
{
"value": "loading",
"title": "加载中"
Expand All @@ -10860,10 +10861,10 @@
},
{
"name": "duration",
"title": "展示时长",
"title": "停留时间",
"type": "number",
"default": 2000,
"description": "提示停留的时间。`0`表示常驻。"
"description": "自动关闭的延时,单位毫秒。设为 0 时不自动关闭"
},
{
"name": "position",
Expand Down
1 change: 1 addition & 0 deletions src-vusion/styles/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -829,4 +829,5 @@
--van-toast-font-size: 14px; /* @desc 弹出消息的字体大小 */
--van-toast-text-color: #fff; /* @type color */ /* @desc 弹出消息的字体颜色 */
--van-toast-background-color: rgba(0, 0, 0, 0.7); /* @type color */ /* @desc 弹出消息的背景色 */
--van-toast-custom-icon-color: white; /* @type color */ /* @desc 弹出消息的自定义图标颜色 */
}
16 changes: 9 additions & 7 deletions src/toast/Toast.designer.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default createComponent({

if (type === 'custom') {
if (customIcon) {
return <Iconv class={bem('icon')} icotype="only" name={customIcon}></Iconv>;
return <Iconv class={bem('custom-icon')} icotype="only" name={customIcon}></Iconv>;
}

return null;
Expand All @@ -107,19 +107,21 @@ export default createComponent({
}

let name = type;
if (type === 'warning') {
let color;
if (type === 'success') {
color = '#26bd71';
} else if (type === 'fail') {
color = '#f24957';
} else if (type === 'warning') {
name = 'info';
color = '#ffb21a';
}

const hasIcon = name;

if (hasIcon) {
return (
<Iconv
class={bem('icon')}
icotype="only"
name={name}
/>
<Iconv class={bem('icon')} icotype="only" name={name} color={color} />
);
}
},
Expand Down
20 changes: 17 additions & 3 deletions src/toast/ToastGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export default createComponent({
if (customIcon) {
return (
<Iconv
class={bem('item__icon')}
class={bem('item__custom-icon')}
icotype="only"
name={customIcon}
></Iconv>
Expand All @@ -206,14 +206,28 @@ export default createComponent({
}

let name = type;
if (type === 'warning') {
let color;

if (type === 'success') {
color = '#26bd71';
} else if (type === 'fail') {
color = '#f24957';
} else if (type === 'warning') {
name = 'info';
color = '#ffb21a';
}

const hasIcon = name;

if (hasIcon) {
return <Iconv class={bem('item__icon')} icotype="only" name={name} />;
return (
<Iconv
class={bem('item__icon')}
icotype="only"
name={name}
color={color}
/>
);
}
},

Expand Down
17 changes: 9 additions & 8 deletions src/toast/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@
description: 是否展示弹出消息
advanced: true
- name: message
title: 文本
title: 提示内容
type: string
default: 弹出消息消息
description: 文本内容
default: 弹出消息
description: 默认提示内容
- name: type
title: 类型
title: 消息类型
type: string
description: 提示的类型
default: custom
options:
- value: success
title: 成功
- value: fail
title: 失败
- value: warning
title: 警告
- value: fail
title: 失败
- value: loading
title: 加载中
- value: custom
Expand All @@ -39,10 +40,10 @@
dependency:
- type: custom
- name: duration
title: 展示时长
title: 停留时间
type: number
default: 2000
description: 提示停留的时间。`0`表示常驻。
description: 自动关闭的延时,单位毫秒。设为 0 时不自动关闭
- name: position
title: 位置
type: string
Expand Down
10 changes: 10 additions & 0 deletions src/toast/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@
font-size: @toast-icon-size;
}

&__custom-icon {
font-size: @toast-icon-size;
color: var(--van-toast-custom-icon-color);
}

&__loading {
padding: @padding-base;
color: @toast-loading-icon-color;
Expand Down Expand Up @@ -227,6 +232,11 @@
font-size: @toast-icon-size;
}

&__custom-icon {
font-size: @toast-icon-size;
color: var(--van-toast-custom-icon-color);
}

&__loading {
padding: @padding-base;
color: @toast-loading-icon-color;
Expand Down

0 comments on commit f7710d3

Please sign in to comment.