Compare commits

..

No commits in common. "9d55f2d6b8d2e9863295d063d4e053ecedefde7a" and "59d5d76dbea91b930bc9dd91d5be483c88e68207" have entirely different histories.

10 changed files with 11 additions and 115 deletions

View File

@ -43,15 +43,6 @@ export default defineComponent({
extend({ color: props.color }, getSizeStyle(props.size))
);
const renderIcon = () => {
const DefaultIcon = props.type === 'spinner' ? SpinIcon : CircularIcon;
return (
<span class={bem('spinner', props.type)} style={spinnerStyle.value}>
{slots.icon ? slots.icon() : DefaultIcon}
</span>
);
};
const renderText = () => {
if (slots.default) {
return (
@ -76,7 +67,9 @@ export default defineComponent({
aria-live="polite"
aria-busy={true}
>
{renderIcon()}
<span class={bem('spinner', type)} style={spinnerStyle.value}>
{type === 'spinner' ? SpinIcon : CircularIcon}
</span>
{renderText()}
</div>
);

View File

@ -66,19 +66,6 @@ use `color` or `text-color` to change text color.
<van-loading text-color="#0094ff" />
```
### Custom Icon
Use `icon` slot to custom icon.
```html
<van-loading vertical>
<template #icon>
<van-icon name="star-o" size="30" />
</template>
Loading...
</van-loading>
```
## API
### Props
@ -94,10 +81,9 @@ Use `icon` slot to custom icon.
### Slots
| Name | Description |
| ------- | ------------------- |
| default | Loading text |
| icon | Custom loading icon |
| Name | Description |
| ------- | ------------ |
| default | Loading text |
### Types

View File

@ -76,19 +76,6 @@ app.use(Loading);
<van-loading text-color="#0094ff" />
```
### 自定义图标
通过 `icon` 插槽可以自定义加载图标。
```html
<van-loading vertical>
<template #icon>
<van-icon name="star-o" size="30" />
</template>
加载中...
</van-loading>
```
## API
### Props
@ -104,10 +91,9 @@ app.use(Loading);
### Slots
| 名称 | 说明 |
| ------- | -------------- |
| default | 加载文案 |
| icon | 自定义加载图标 |
| 名称 | 说明 |
| ------- | -------- |
| default | 加载文案 |
### 类型定义

View File

@ -1,5 +1,4 @@
<script setup lang="ts">
import VanIcon from '../../icon';
import VanLoading from '..';
import { useTranslate } from '../../../docs/site';
@ -11,7 +10,6 @@ const t = useTranslate({
color: '自定义颜色',
vertical: '垂直排列',
textColor: '自定义文本颜色',
customIcon: '自定义图标',
},
'en-US': {
type: 'Type',
@ -20,7 +18,6 @@ const t = useTranslate({
color: 'Color',
vertical: 'Vertical',
textColor: 'Text Color',
customIcon: 'Custom Icon',
},
});
</script>
@ -61,15 +58,6 @@ const t = useTranslate({
{{ t('loading') }}
</van-loading>
</demo-block>
<demo-block :title="t('customIcon')">
<van-loading vertical>
<template #icon>
<van-icon name="star-o" size="30" />
</template>
{{ t('loading') }}
</van-loading>
</demo-block>
</template>
<style lang="less">

View File

@ -257,20 +257,4 @@ exports[`should render demo and match snapshot 1`] = `
</span>
</div>
</div>
<div>
<div class="van-loading van-loading--circular van-loading--vertical"
aria-live="polite"
aria-busy="true"
>
<span class="van-loading__spinner van-loading__spinner--circular">
<i class="van-badge__wrapper van-icon van-icon-star-o"
style="font-size: 30px;"
>
</i>
</span>
<span class="van-loading__text">
Loading...
</span>
</div>
</div>
`;

View File

@ -33,7 +33,6 @@ export const navBarProps = {
leftArrow: Boolean,
placeholder: Boolean,
safeAreaInsetTop: Boolean,
clickable: truthProp,
};
export type NavBarProps = ExtractPropTypes<typeof navBarProps>;
@ -93,7 +92,7 @@ export default defineComponent({
<div class={bem('content')}>
{hasLeft && (
<div
class={[bem('left'), props.clickable ? HAPTICS_FEEDBACK : '']}
class={[bem('left'), HAPTICS_FEEDBACK]}
onClick={onClickLeft}
>
{renderLeft()}
@ -104,7 +103,7 @@ export default defineComponent({
</div>
{hasRight && (
<div
class={[bem('right'), props.clickable ? HAPTICS_FEEDBACK : '']}
class={[bem('right'), HAPTICS_FEEDBACK]}
onClick={onClickRight}
>
{renderRight()}

View File

@ -99,7 +99,6 @@ export default {
| placeholder | Whether to generate a placeholder element when fixed | _boolean_ | `false` |
| z-index | Z-index | _number \| string_ | `1` |
| safe-area-inset-top | Whether to enable top safe area adaptation | _boolean_ | `false` |
| clickable | Whether to show click feedback when the left or right content is clicked | _boolean_ | `true` |
### Slots

View File

@ -107,7 +107,6 @@ export default {
| placeholder | 固定在顶部时,是否在标签位置生成一个等高的占位元素 | _boolean_ | `false` |
| z-index | 导航栏 z-index | _number \| string_ | `1` |
| safe-area-inset-top | 是否开启[顶部安全区适配](#/zh-CN/advanced-usage#di-bu-an-quan-qu-gua-pei) | _boolean_ | `false` |
| clickable | 是否开启两侧按钮的点击反馈 | _boolean_ | `true` |
### Slots

View File

@ -25,18 +25,6 @@ exports[`should render placeholder element when using placeholder prop 1`] = `
</div>
`;
exports[`should render slots correctly when set clickable to false 1`] = `
<div class="van-nav-bar__left">
Custom Left
</div>
`;
exports[`should render slots correctly when set clickable to false 2`] = `
<div class="van-nav-bar__right">
Custom Right
</div>
`;
exports[`should render title slot correctly 1`] = `
<div class="van-nav-bar__title van-ellipsis">
Custom Title

View File

@ -1,5 +1,4 @@
import { NavBar } from '..';
import { HAPTICS_FEEDBACK } from '../../utils';
import { mount, mockGetBoundingClientRect, later } from '../../../test';
test('should render left slot correctly', () => {
@ -10,9 +9,6 @@ test('should render left slot correctly', () => {
});
expect(wrapper.find('.van-nav-bar__left').html()).toMatchSnapshot();
expect(
wrapper.find('.van-nav-bar__left').classes(HAPTICS_FEEDBACK)
).toBeTruthy();
});
test('should render left slot correctly', () => {
@ -23,9 +19,6 @@ test('should render left slot correctly', () => {
});
expect(wrapper.find('.van-nav-bar__right').html()).toMatchSnapshot();
expect(
wrapper.find('.van-nav-bar__right').classes(HAPTICS_FEEDBACK)
).toBeTruthy();
});
test('should render title slot correctly', () => {
@ -92,22 +85,3 @@ test('should change z-index when using z-index prop', () => {
});
expect(wrapper.style.zIndex).toEqual('100');
});
test('should render slots correctly when set clickable to false', () => {
const wrapper = mount(NavBar, {
slots: {
left: () => 'Custom Left',
right: () => 'Custom Right',
},
props: {
clickable: false,
},
});
const leftDom = wrapper.find('.van-nav-bar__left');
const rightDom = wrapper.find('.van-nav-bar__right');
expect(leftDom.html()).toMatchSnapshot();
expect(rightDom.html()).toMatchSnapshot();
expect(leftDom.classes(HAPTICS_FEEDBACK)).toBeFalsy();
expect(rightDom.classes(HAPTICS_FEEDBACK)).toBeFalsy();
});