Skip to content

feat: update skeleton #2371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions components/skeleton/index.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { inject } from 'vue';
import classNames from 'classnames';
import PropTypes from '../_util/vue-types';
import { initDefaultProps, hasProp } from '../_util/props-util';
import { ConfigConsumerProps } from '../config-provider';
import Avatar, { SkeletonAvatarProps } from './Avatar';
import Title, { SkeletonTitleProps } from './Title';
import Paragraph, { SkeletonParagraphProps } from './Paragraph';
import Base from '../base';

export const SkeletonProps = {
active: PropTypes.bool,
Expand Down Expand Up @@ -69,8 +69,10 @@ const Skeleton = {
title: true,
paragraph: true,
}),
inject: {
configProvider: { default: () => ConfigConsumerProps },
setup() {
return {
configProvider: inject('configProvider', ConfigConsumerProps),
};
},
render() {
const {
Expand Down Expand Up @@ -157,13 +159,12 @@ const Skeleton = {
</div>
);
}
const children = this.$slots.default;
const children = this.$slots.default && this.$slots.default();
return children && children.length === 1 ? children[0] : <span>{children}</span>;
},
};
/* istanbul ignore next */
Skeleton.install = function(Vue) {
Vue.use(Base);
Vue.component(Skeleton.name, Skeleton);
Skeleton.install = function(app) {
app.component(Skeleton.name, Skeleton);
};
export default Skeleton;
2 changes: 2 additions & 0 deletions examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Anchor from 'ant-design-vue/anchor';
import ConfigProvider from 'ant-design-vue/config-provider';
import Result from 'ant-design-vue/result';
import Spin from 'ant-design-vue/spin';
import Skeleton from 'ant-design-vue/skeleton';
import Empty from 'ant-design-vue/empty';
import Timeline from 'ant-design-vue/timeline';
import 'ant-design-vue/style.js';
Expand All @@ -27,6 +28,7 @@ createApp(App)
.use(Divider)
.use(Result)
.use(Anchor)
.use(Skeleton)
.use(Spin)
.use(Empty)
.use(Timeline)
Expand Down