mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
functional: CellGroup, Icon, Info, Loading, GoodsAction (#2674)
This commit is contained in:
parent
f0056297c6
commit
3c6c32e305
@ -2,19 +2,25 @@ import { use } from '../utils';
|
|||||||
|
|
||||||
const [sfc, bem] = use('cell-group');
|
const [sfc, bem] = use('cell-group');
|
||||||
|
|
||||||
export default sfc({
|
export default sfc(
|
||||||
props: {
|
{
|
||||||
border: {
|
props: {
|
||||||
type: Boolean,
|
border: {
|
||||||
default: true
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
render(h, context) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
class={[bem(), { 'van-hairline--top-bottom': context.props.border }]}
|
||||||
|
{...context.data}
|
||||||
|
>
|
||||||
|
{context.children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
true
|
||||||
render(h) {
|
);
|
||||||
return (
|
|
||||||
<div class={[bem(), { 'van-hairline--top-bottom': this.border }]}>
|
|
||||||
{this.$slots.default}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
@ -2,8 +2,15 @@ import { use } from '../utils';
|
|||||||
|
|
||||||
const [sfc, bem] = use('goods-action');
|
const [sfc, bem] = use('goods-action');
|
||||||
|
|
||||||
export default sfc({
|
export default sfc(
|
||||||
render(h) {
|
{
|
||||||
return <div class={bem()}>{this.$slots.default}</div>;
|
render(h, context) {
|
||||||
}
|
return (
|
||||||
});
|
<div class={bem()} {...context.data}>
|
||||||
|
{context.children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
|
@ -4,41 +4,41 @@ import isSrc from '../utils/validate/src';
|
|||||||
|
|
||||||
const [sfc] = use('icon');
|
const [sfc] = use('icon');
|
||||||
|
|
||||||
export default sfc({
|
export default sfc(
|
||||||
props: {
|
{
|
||||||
name: String,
|
props: {
|
||||||
size: String,
|
name: String,
|
||||||
color: String,
|
size: String,
|
||||||
info: [String, Number],
|
color: String,
|
||||||
classPrefix: {
|
info: [String, Number],
|
||||||
type: String,
|
classPrefix: {
|
||||||
default: 'van-icon'
|
type: String,
|
||||||
|
default: 'van-icon'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
render(h, context) {
|
||||||
|
const { props } = context;
|
||||||
|
const urlIcon = isSrc(props.name);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<i
|
||||||
|
class={[
|
||||||
|
props.classPrefix,
|
||||||
|
urlIcon ? 'van-icon--image' : `${props.classPrefix}-${props.name}`
|
||||||
|
]}
|
||||||
|
style={{
|
||||||
|
color: props.color,
|
||||||
|
fontSize: props.size
|
||||||
|
}}
|
||||||
|
{...context.data}
|
||||||
|
>
|
||||||
|
{context.children}
|
||||||
|
{urlIcon && <img src={props.name} />}
|
||||||
|
<Info info={props.info} />
|
||||||
|
</i>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
true
|
||||||
computed: {
|
);
|
||||||
isSrc() {
|
|
||||||
return isSrc(this.name);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
render(h) {
|
|
||||||
return (
|
|
||||||
<i
|
|
||||||
class={[
|
|
||||||
this.classPrefix,
|
|
||||||
this.isSrc ? 'van-icon--image' : `${this.classPrefix}-${this.name}`
|
|
||||||
]}
|
|
||||||
style={{
|
|
||||||
color: this.color,
|
|
||||||
fontSize: this.size
|
|
||||||
}}
|
|
||||||
{...{ on: this.$listeners }}
|
|
||||||
>
|
|
||||||
{this.$slots.default}
|
|
||||||
{this.isSrc && <img src={this.name} />}
|
|
||||||
<Info info={this.info} />
|
|
||||||
</i>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
@ -2,12 +2,21 @@ import { use, isDef } from '../utils';
|
|||||||
|
|
||||||
const [sfc, bem] = use('info');
|
const [sfc, bem] = use('info');
|
||||||
|
|
||||||
export default sfc({
|
export default sfc(
|
||||||
props: {
|
{
|
||||||
info: [String, Number]
|
props: {
|
||||||
},
|
info: [String, Number]
|
||||||
|
},
|
||||||
|
|
||||||
render(h) {
|
render(h, { props, data }) {
|
||||||
return isDef(this.info) && <div class={bem()}>{this.info}</div>;
|
return (
|
||||||
}
|
isDef(props.info) && (
|
||||||
});
|
<div class={bem()} {...data}>
|
||||||
|
{props.info}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
|
@ -3,50 +3,53 @@ import { use } from '../utils';
|
|||||||
const [sfc, bem] = use('loading');
|
const [sfc, bem] = use('loading');
|
||||||
const DEFAULT_COLOR = '#c9c9c9';
|
const DEFAULT_COLOR = '#c9c9c9';
|
||||||
|
|
||||||
export default sfc({
|
export default sfc(
|
||||||
props: {
|
{
|
||||||
size: String,
|
props: {
|
||||||
type: {
|
size: String,
|
||||||
type: String,
|
type: {
|
||||||
default: 'circular'
|
type: String,
|
||||||
|
default: 'circular'
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
type: String,
|
||||||
|
default: DEFAULT_COLOR
|
||||||
|
}
|
||||||
},
|
},
|
||||||
color: {
|
|
||||||
type: String,
|
render(h, context) {
|
||||||
default: DEFAULT_COLOR
|
const { color, size, type } = context.props;
|
||||||
|
|
||||||
|
const colorType = color === 'white' || color === 'black' ? color : '';
|
||||||
|
|
||||||
|
const style = {
|
||||||
|
color: color === 'black' ? DEFAULT_COLOR : color,
|
||||||
|
width: size,
|
||||||
|
height: size
|
||||||
|
};
|
||||||
|
|
||||||
|
const Spin = [];
|
||||||
|
if (type === 'spinner') {
|
||||||
|
for (let i = 0; i < 12; i++) {
|
||||||
|
Spin.push(<i />);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const Circular = type === 'circular' && (
|
||||||
|
<svg class={bem('circular')} viewBox="25 25 50 50">
|
||||||
|
<circle cx="50" cy="50" r="20" fill="none" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div class={bem([type, colorType])} style={style} {...context.data}>
|
||||||
|
<span class={bem('spinner', type)}>
|
||||||
|
{Spin}
|
||||||
|
{Circular}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
true
|
||||||
render(h) {
|
);
|
||||||
const { color, size, type } = this;
|
|
||||||
|
|
||||||
const colorType = color === 'white' || color === 'black' ? color : '';
|
|
||||||
|
|
||||||
const style = {
|
|
||||||
color: color === 'black' ? DEFAULT_COLOR : color,
|
|
||||||
width: size,
|
|
||||||
height: size
|
|
||||||
};
|
|
||||||
|
|
||||||
const Spin = [];
|
|
||||||
if (type === 'spinner') {
|
|
||||||
for (let i = 0; i < 12; i++) {
|
|
||||||
Spin.push(<i />);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const Circular = type === 'circular' && (
|
|
||||||
<svg class={bem('circular')} viewBox="25 25 50 50">
|
|
||||||
<circle cx="50" cy="50" r="20" fill="none" />
|
|
||||||
</svg>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div class={bem([type, colorType])} style={style}>
|
|
||||||
<span class={bem('spinner', type)}>
|
|
||||||
{Spin}
|
|
||||||
{Circular}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
@ -30,10 +30,17 @@ function install(Vue) {
|
|||||||
Vue.component((camelize(`-${name}`)), this);
|
Vue.component((camelize(`-${name}`)), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default name => sfc => {
|
export default name => (sfc, functional) => {
|
||||||
sfc.name = name;
|
sfc.name = name;
|
||||||
sfc.install = install;
|
sfc.install = install;
|
||||||
sfc.props && defaultProps(sfc.props);
|
|
||||||
|
if (sfc.props) {
|
||||||
|
defaultProps(sfc.props);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (functional) {
|
||||||
|
sfc.functional = true;
|
||||||
|
}
|
||||||
|
|
||||||
return sfc;
|
return sfc;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user