50 lines
1001 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { use } from '../utils';
import { emit, inherit } from '../utils/functional';
import Cell from '../cell';
const [sfc, bem, t] = use('contact-card');
function ContactCard(h, props, slots, ctx) {
const { type, editable } = props;
return (
<Cell
center
border={false}
isLink={editable}
class={bem([type])}
valueClass={bem('value')}
icon={type === 'edit' ? 'contact' : 'add-square'}
onClick={event => {
if (editable) {
emit(ctx, 'click', event);
}
}}
{...inherit(ctx)}
>
{type === 'add'
? props.addText || t('addText')
: [
<div>{`${t('name')}${props.name}`}</div>,
<div>{`${t('tel')}${props.tel}`}</div>
]}
</Cell>
);
}
ContactCard.props = {
tel: String,
name: String,
addText: String,
editable: {
type: Boolean,
default: true
},
type: {
type: String,
default: 'add'
}
};
export default sfc(ContactCard);