Compare commits

...

3 Commits

Author SHA1 Message Date
neverland
9c9cce00ea
chore: should publish README to npm (#10470) 2022-04-05 09:52:38 +08:00
neverland
800d9a6af9
feat(ShareSheet): no longer rely on CDN images (#10469) 2022-04-05 09:50:26 +08:00
neverland
c4535ef77c
feat(Icon): add some icons for ShareSheet (#10468) 2022-04-05 09:39:33 +08:00
8 changed files with 100 additions and 26 deletions

View File

@ -977,3 +977,23 @@
.van-icon-cash-o:before {
content: '\e74d';
}
.van-icon-qq:before {
content: '\e74e';
}
.van-icon-wechat-moments:before {
content: '\e74f';
}
.van-icon-weibo:before {
content: '\e750';
}
.van-icon-link-o:before {
content: '\e751';
}
.van-icon-miniprogram-o:before {
content: '\e752';
}

View File

@ -150,6 +150,8 @@ export default {
'shield-o',
'guide-o',
'cash-o',
'link-o',
'miniprogram-o',
],
filled: [
// has corresponding outline icon
@ -224,7 +226,10 @@ export default {
// without corresponding outline icon
'wechat',
'wechat-pay',
'wechat-moments',
'qq',
'alipay',
'weibo',
'photograph',
'youzan-shield',
'umbrella-circle',

File diff suppressed because one or more lines are too long

View File

@ -5,10 +5,10 @@
font-style: normal;
font-display: auto;
font-family: 'vant-icon';
src: url('https://at.alicdn.com/t/font_2553510_5imfhdc20ag.woff2?t=1640074908811')
src: url('https://at.alicdn.com/t/font_2553510_iv4v8nulyz.woff2?t=1649083952952')
format('woff2'),
url('https://at.alicdn.com/t/font_2553510_5imfhdc20ag.woff?t=1640074908811')
url('https://at.alicdn.com/t/font_2553510_iv4v8nulyz.woff?t=1649083952952')
format('woff'),
url('https://at.alicdn.com/t/font_2553510_5imfhdc20ag.ttf?t=1640074908811')
url('https://at.alicdn.com/t/font_2553510_iv4v8nulyz.ttf?t=1649083952952')
format('truetype');
}

View File

@ -35,7 +35,7 @@
"test": "vant-cli test",
"build": "vant-cli build",
"build:site": "vant-cli build-site",
"release": "vant-cli release",
"release": "cp ../../README.md ./ && vant-cli release && rm ./README.md",
"release:site": "pnpm build:site && gh-pages -d site-dist --add",
"test:watch": "vant-cli test --watch",
"test:coverage": "open test/coverage/index.html"

View File

@ -12,6 +12,7 @@ import {
import { popupSharedProps, popupSharedPropKeys } from '../popup/shared';
// Components
import { Icon } from '../icon';
import { Popup } from '../popup';
export type ShareSheetOption = {
@ -23,17 +24,6 @@ export type ShareSheetOption = {
export type ShareSheetOptions = ShareSheetOption[] | ShareSheetOption[][];
const PRESET_ICONS = [
'qq',
'link',
'weibo',
'wechat',
'poster',
'qrcode',
'weapp-qrcode',
'wechat-moments',
];
const popupInheritKeys = [
...popupSharedPropKeys,
'round',
@ -41,12 +31,16 @@ const popupInheritKeys = [
'safeAreaInsetBottom',
] as const;
function getIconURL(icon: string) {
if (PRESET_ICONS.includes(icon)) {
return `https://img.yzcdn.cn/vant/share-sheet-${icon}.png`;
}
return icon;
}
const iconMap: Record<string, string> = {
qq: 'qq',
link: 'link-o',
weibo: 'weibo',
qrcode: 'qr',
poster: 'photo-o',
wechat: 'wechat',
'weapp-qrcode': 'miniprogram-o',
'wechat-moments': 'wechat-moments',
};
const [name, bem, t] = createNamespace('share-sheet');
@ -98,6 +92,17 @@ export default defineComponent({
}
};
const renderIcon = (icon: string) => {
if (iconMap[icon]) {
return (
<div class={bem('icon', [icon])}>
<Icon name={iconMap[icon] || icon} />
</div>
);
}
return <img src={icon} class={bem('image-icon')} />;
};
const renderOption = (option: ShareSheetOption, index: number) => {
const { name, icon, className, description } = option;
return (
@ -107,7 +112,7 @@ export default defineComponent({
class={[bem('option'), className, HAPTICS_FEEDBACK]}
onClick={() => onSelect(option, index)}
>
<img src={getIconURL(icon)} class={bem('icon')} />
{renderIcon(icon)}
{name && <span class={bem('name')}>{name}</span>}
{description && (
<span class={bem('option-description')}>{description}</span>

View File

@ -65,12 +65,56 @@
user-select: none;
}
&__icon {
&__icon,
&__image-icon {
width: var(--van-share-sheet-icon-size);
height: var(--van-share-sheet-icon-size);
margin: 0 var(--van-padding-md);
}
&__icon {
display: flex;
align-items: center;
justify-content: center;
color: var(--van-gray-7);
border-radius: 100%;
background-color: var(--van-gray-2);
&--link,
&--poster,
&--qrcode {
font-size: 26px;
}
&--weapp-qrcode {
font-size: 28px;
}
&--qq,
&--weibo,
&--wechat,
&--wechat-moments {
font-size: 30px;
color: var(--van-white);
}
&--qq {
background-color: #38b9fa;
}
&--wechat {
background-color: #0bc15f;
}
&--weibo {
background-color: #ee575e;
}
&--wechat-moments {
background-color: #7bc845;
}
}
&__name {
margin-top: var(--van-padding-xs);
padding: 0 var(--van-padding-base);