[improvement] Loading: tsx (#2765)

This commit is contained in:
neverland 2019-02-16 22:00:42 +08:00 committed by GitHub
parent af0fb98c9e
commit 2e308ffc62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,18 @@
import { use } from '../utils'; import { use } from '../utils';
import { inherit } from '../utils/functional'; import { inherit } from '../utils/functional';
// Types
import { FunctionalComponent } from '../utils/use/sfc';
const [sfc, bem] = use('loading'); const [sfc, bem] = use('loading');
const DEFAULT_COLOR = '#c9c9c9'; const DEFAULT_COLOR = '#c9c9c9';
function Loading(h, props, slots, ctx) { const Loading: FunctionalComponent<LoadingProps> = function(
h,
props,
slots,
ctx
) {
const { color, size, type } = props; const { color, size, type } = props;
const colorType = color === 'white' || color === 'black' ? color : ''; const colorType = color === 'white' || color === 'black' ? color : '';
@ -36,7 +44,7 @@ function Loading(h, props, slots, ctx) {
</span> </span>
</div> </div>
); );
} };
Loading.props = { Loading.props = {
size: String, size: String,
@ -50,4 +58,10 @@ Loading.props = {
} }
}; };
export default sfc(Loading); export type LoadingProps = {
size?: string;
type?: string;
color?: string;
};
export default sfc<LoadingProps>(Loading);