[improvement] Functional: ContactList, NavBar, Panel, SubmitBar, SwitchCell, Tag (#2675)

This commit is contained in:
neverland
2019-02-02 16:04:54 +08:00
committed by GitHub
parent 3c6c32e305
commit 5926d02d38
11 changed files with 302 additions and 265 deletions

View File

@@ -1,4 +1,4 @@
import { use } from '../utils';
import { use, noop } from '../utils';
import Icon from '../icon';
import Cell from '../cell';
import Button from '../button';
@@ -7,55 +7,57 @@ import RadioGroup from '../radio-group';
const [sfc, bem, t] = use('contact-list');
export default sfc({
props: {
value: null,
list: Array,
addText: String
},
export default sfc(
{
props: {
value: null,
list: Array,
addText: String
},
render(h) {
return (
<div class={bem()}>
<RadioGroup
value={this.value}
class={bem('group')}
onInput={event => {
this.$emit('input', event);
render(h, context) {
const { props, listeners } = context;
const List = props.list.map((item, index) => (
<Cell
key={item.id}
isLink
onClick={() => {
listeners.input && listeners.input(item.id);
listeners.select && listeners.select(item, index);
}}
>
{this.list.map((item, index) => (
<Cell key={item.id} isLink>
<Radio
name={item.id}
onClick={() => {
this.$emit('select', item, index);
}}
>
<div class={bem('name')}>{`${item.name}${item.tel}`}</div>
</Radio>
<Icon
slot="right-icon"
name="edit"
class={bem('edit')}
onClick={() => {
this.$emit('edit', item, index);
}}
/>
</Cell>
))}
</RadioGroup>
<Button
square
size="large"
type="danger"
class={bem('add')}
text={this.addText || t('addText')}
onClick={() => {
this.$emit('add');
}}
/>
</div>
);
}
});
<Radio name={item.id}>
<div class={bem('name')}>{`${item.name}${item.tel}`}</div>
</Radio>
<Icon
slot="right-icon"
name="edit"
class={bem('edit')}
onClick={event => {
event.stopPropagation();
listeners.edit && listeners.edit(item, index);
}}
/>
</Cell>
));
return (
<div class={bem()} {...context.data}>
<RadioGroup value={props.value} class={bem('group')}>
{List}
</RadioGroup>
<Button
square
size="large"
type="danger"
class={bem('add')}
text={props.addText || t('addText')}
onClick={listeners.add || noop}
/>
</div>
);
}
},
true
);