diff --git a/packages/vant/src/coupon-list/test/__snapshots__/index.spec.ts.snap b/packages/vant/src/coupon-list/test/__snapshots__/index.spec.ts.snap index fbdf3c621..09367bc49 100644 --- a/packages/vant/src/coupon-list/test/__snapshots__/index.spec.ts.snap +++ b/packages/vant/src/coupon-list/test/__snapshots__/index.spec.ts.snap @@ -366,39 +366,7 @@ exports[`should have two "van-coupon-list__empty" classes when render coupon lis
- - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + JSX.Element> = { + error: renderError, + search: renderSearch, + network: renderNetwork, + default: renderMaterial, +}; const emptyProps = { image: makeStringProp('default'), @@ -29,24 +39,7 @@ export default defineComponent({ if (slots.image) { return slots.image(); } - - let { image } = props; - - if (image === 'network') { - return renderNetwork(); - } - if (image === 'default') { - return renderMaterial(); - } - if (image === 'error') { - return renderError(); - } - - if (PRESET_IMAGES.includes(image)) { - image = `https://img.yzcdn.cn/vant/empty-image-${image}.png`; - } - - return ; + return PRESET_IMAGES[props.image]?.() || ; }; const renderDescription = () => { diff --git a/packages/vant/src/empty/Images.tsx b/packages/vant/src/empty/Images.tsx index ccd19d890..8b360e060 100644 --- a/packages/vant/src/empty/Images.tsx +++ b/packages/vant/src/empty/Images.tsx @@ -5,43 +5,49 @@ const renderStop = (color: string, offset: number, opacity?: number) => ( ); -const renderBuildingDef = () => ( - - {renderStop('#FFF', 0, 0.5)} - {renderStop('#F2F3F5', 100)} - -); +const renderStops = (fromColor: string, toColor: string) => [ + renderStop(fromColor, 0), + renderStop(toColor, 100), +]; -const renderCloudDef = () => ( - - {renderStop('#F2F3F5', 0, 0.3)} - {renderStop('#F2F3F5', 100)} - -); +const renderShadow = (id: string) => [ + + + {renderStop('#EBEDF0', 0)} + {renderStop('#F2F3F5', 100, 0.3)} + + , + , +]; -const renderShadowRef = () => ( - - - - -); - -const renderBuilding = () => ( +const renderBuilding = () => [ + + + {renderStop('#FFF', 0, 0.5)} + {renderStop('#F2F3F5', 100)} + + , - -); + , +]; -const renderCloud = () => ( +const renderCloud = () => [ + + + {renderStop('#F2F3F5', 0, 0.3)} + {renderStop('#F2F3F5', 100)} + + , ( d="M19 23c2 0 3 1 4 3 2 0 4 2 4 4a4 4 0 0 1-4 3v1h-7v-1l-1 1c-2 0-3-2-3-4 0-1 1-3 3-3 0-2 2-4 4-4Z" fill={useId('b')} /> - -); - -const renderShadow = () => ( - -); + , +]; export const renderNetwork = () => ( - {renderBuildingDef()} {renderStop('#FFF', 0, 0.5)} {renderStop('#F2F3F5', 100)} @@ -71,8 +72,7 @@ export const renderNetwork = () => ( {renderStop('#DCDEE0', 100, 0)} - {renderStop('#EAEDF0', 0)} - {renderStop('#DCDEE0', 100)} + {renderStops('#EAEDF0', '#DCDEE0')} ( export const renderMaterial = () => ( - {renderBuildingDef()} - {renderCloudDef()} - - {renderStop('#F2F3F5', 0)} - {renderStop('#DCDEE0', 100)} + + {renderStops('#F2F3F5', '#DCDEE0')} - {renderStop('#EAEDF1', 0)} - {renderStop('#DCDEE0', 100)} + {renderStops('#EAEDF1', '#DCDEE0')} - - {renderStop('#EAEDF1', 0)} - {renderStop('#DCDEE0', 100)} + + {renderStops('#EAEDF1', '#DCDEE0')} {renderBuilding()} @@ -157,20 +152,52 @@ export const renderMaterial = () => ( export const renderError = () => ( - {renderBuildingDef()} - {renderCloudDef()} - {renderShadowRef()} - - {renderStop('#F2F3F5', 0)} - {renderStop('#DCDEE0', 100)} + + {renderStops('#EAEDF1', '#DCDEE0')} {renderBuilding()} {renderCloud()} - {renderShadow()} + {renderShadow('c')} ); + +export const renderSearch = () => ( + + + + {renderStops('#EEE', '#D8D8D8')} + + + {renderStops('#F2F3F5', '#DCDEE0')} + + + {renderStops('#F2F3F5', '#DCDEE0')} + + + {renderStops('#FFF', '#F7F8FA')} + + + {renderBuilding()} + {renderCloud()} + {renderShadow('d')} + + + + + + + + +); diff --git a/packages/vant/src/empty/test/__snapshots__/demo.spec.ts.snap b/packages/vant/src/empty/test/__snapshots__/demo.spec.ts.snap index b648a395f..c17a0b3eb 100644 --- a/packages/vant/src/empty/test/__snapshots__/demo.spec.ts.snap +++ b/packages/vant/src/empty/test/__snapshots__/demo.spec.ts.snap @@ -6,39 +6,7 @@ exports[`should render demo and match snapshot 1`] = `
- - - - - - - - - - - - - + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - + + + + + + + +