From 723c51bac98bb751af44f13737fba12deb298dd4 Mon Sep 17 00:00:00 2001 From: weisheng <1780903673@qq.com> Date: Thu, 18 Jul 2024 23:22:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Toast=20=E8=BD=BB=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E7=BB=84=E4=BB=B6=E6=94=AF=E6=8C=81=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=BA=93=E5=86=85=E7=BD=AE=E5=92=8C=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: #444 --- docs/component/icon.md | 35 ++++++++++----- docs/component/toast.md | 24 ++++++++-- src/App.vue | 2 + src/iconfont/index.css | 18 ++++++++ src/pages/toast/Index.vue | 29 ++++++++---- .../components/common/abstracts/variable.scss | 8 +++- .../wot-design-uni/components/common/util.ts | 2 +- .../components/wd-config-provider/types.ts | 6 +++ .../components/wd-loading/index.scss | 2 + .../components/wd-loading/types.ts | 6 +-- .../components/wd-loading/wd-loading.vue | 17 +++---- .../components/wd-toast/index.scss | 7 ++- .../components/wd-toast/index.ts | 7 +-- .../components/wd-toast/types.ts | 16 ++++--- .../components/wd-toast/wd-toast.vue | 45 ++++++++++--------- 15 files changed, 153 insertions(+), 71 deletions(-) create mode 100644 src/iconfont/index.css diff --git a/docs/component/icon.md b/docs/component/icon.md index 8d265ae7..2877bab1 100644 --- a/docs/component/icon.md +++ b/docs/component/icon.md @@ -30,25 +30,40 @@ ## 自定义图标 如果需要在现有 Icon 的基础上使用更多图标,可以引入第三方 iconfont 对应的字体文件和 CSS 文件,之后就可以在 Icon 组件中直接使用。 -``` scss -/* 引入第三方或自定义的字体图标样式 */ + +``` css +/* 路径 src/iconfont/index.css */ + @font-face { - font-family: 'my-icon'; - src: url('./my-icon.ttf') format('truetype'); + font-family: "fish"; + src: url('//at.alicdn.com/t/c/font_4626013_vwpx4thmin.woff2?t=1721314121733') format('woff2'), + url('//at.alicdn.com/t/c/font_4626013_vwpx4thmin.woff?t=1721314121733') format('woff'), + url('//at.alicdn.com/t/c/font_4626013_vwpx4thmin.ttf?t=1721314121733') format('truetype'); } -.my-icon { - font-family: 'my-icon'; +.fish { + font-family: "fish" !important; + font-size: 16px; + font-style: normal; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; } -.my-icon-extra::before { - content: '\e626'; +.fish-kehuishouwu:before { + content: "\e627"; } + +``` +```html + + ``` ```html - - + + ``` ## Attributes diff --git a/docs/component/toast.md b/docs/component/toast.md index 60e6f331..e9c5b04e 100644 --- a/docs/component/toast.md +++ b/docs/component/toast.md @@ -31,6 +31,25 @@ toast.warning('提示信息') toast.info('常规提示信息') ``` +## 使用图标 +可以使用`iconClass`指定图标,结合`classPrefix`可以使用自定义图标,参见[icon](/component/icon#自定义图标)。 +```ts +// 使用组件库内部图标 +toast.show({ + iconClass: 'star', + msg: '使用组件库内部图标' +}) +``` + +```ts +// 使用自定义图标 +toast.show({ + iconClass: 'kehuishouwu', + classPrefix: 'fish', + msg: '使用自定义图标' +}) +``` + ## 提示位置 ```typescript @@ -89,9 +108,9 @@ toast.close() | msg | 消息内容 | string | - | - | - | | duration | 持续时间,单位 ms,为 0 时表示不自动关闭 | number | - | 2000 | - | | iconName | 图标类型 | string | success / error / warning | - | - | -| iconSize | 左侧图标尺寸 | string | - | 42px | - | +| iconSize | 左侧图标尺寸 | string | - | - | - | | iconClass | 图标类目,自定义图标,可以使用 Icon 章节的那些图标类名,iconName 优先级更高 | string | - | - | - | -| customIcon | 自定义图标,开启后可以通过 custom-icon-class 类名自定义图标 | Boolean | - | false | - | +| classPrefix | 类名前缀,用于使用自定义图标 | string | - | - | - | | position | 提示信息框的位置 | string | top / middle / bottom | middle | - | | zIndex | toast 层级 | number | - | 100 | - | | loadingType | [加载中图标类型](/component/loading) | string | ring | outline | - | @@ -116,4 +135,3 @@ toast.close() | 类名 | 说明 | 最低版本 | | ----------------- | -------------- | -------- | | custom-class | 根节点样式 | - | -| custom-icon-class | 自定义图标类名 | - | diff --git a/src/App.vue b/src/App.vue index 818396d4..94406c4d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -33,6 +33,8 @@ onHide(() => { })