chore: prettier all tsx codes

This commit is contained in:
陈嘉涵 2020-01-19 17:22:33 +08:00
parent 08c84c9c38
commit f7c5f994dd
9 changed files with 70 additions and 31 deletions

View File

@ -66,7 +66,9 @@ function AddressList(
<div class={bem()} {...inherit(ctx)}> <div class={bem()} {...inherit(ctx)}>
{slots.top?.()} {slots.top?.()}
<RadioGroup value={props.value}>{List}</RadioGroup> <RadioGroup value={props.value}>{List}</RadioGroup>
{props.disabledText && <div class={bem('disabled-text')}>{props.disabledText}</div>} {props.disabledText && (
<div class={bem('disabled-text')}>{props.disabledText}</div>
)}
{DisabledList} {DisabledList}
{slots.default?.()} {slots.default?.()}
<div class={bem('bottom')}> <div class={bem('bottom')}>

View File

@ -24,7 +24,10 @@ function CellGroup(
ctx: RenderContext<CellGroupProps> ctx: RenderContext<CellGroupProps>
) { ) {
const Group = ( const Group = (
<div class={[bem(), { [BORDER_TOP_BOTTOM]: props.border }]} {...inherit(ctx, true)}> <div
class={[bem(), { [BORDER_TOP_BOTTOM]: props.border }]}
{...inherit(ctx, true)}
>
{slots.default?.()} {slots.default?.()}
</div> </div>
); );
@ -32,7 +35,9 @@ function CellGroup(
if (props.title || slots.title) { if (props.title || slots.title) {
return ( return (
<div> <div>
<div class={bem('title')}>{slots.title ? slots.title() : props.title}</div> <div class={bem('title')}>
{slots.title ? slots.title() : props.title}
</div>
{Group} {Group}
</div> </div>
); );

View File

@ -33,7 +33,11 @@ function LoadingIcon(h: CreateElement, props: LoadingProps) {
); );
} }
function LoadingText(h: CreateElement, props: LoadingProps, slots: DefaultSlots) { function LoadingText(
h: CreateElement,
props: LoadingProps,
slots: DefaultSlots
) {
if (slots.default) { if (slots.default) {
const style = props.textSize && { const style = props.textSize && {
fontSize: addUnit(props.textSize), fontSize: addUnit(props.textSize),
@ -63,7 +67,10 @@ function Loading(
} }
return ( return (
<div class={bem([type, { vertical: props.vertical }])} {...inherit(ctx, true)}> <div
class={bem([type, { vertical: props.vertical }])}
{...inherit(ctx, true)}
>
<span class={bem('spinner', type)} style={style}> <span class={bem('spinner', type)} style={style}>
{LoadingIcon(h, props)} {LoadingIcon(h, props)}
</span> </span>

View File

@ -36,36 +36,41 @@ function NavBar(
slots: NavBarSlots, slots: NavBarSlots,
ctx: RenderContext<NavBarProps> ctx: RenderContext<NavBarProps>
) { ) {
function LeftPart() {
if (slots.left) {
return slots.left();
}
return [
props.leftArrow && <Icon class={bem('arrow')} name="arrow-left" />,
props.leftText && <span class={bem('text')}>{props.leftText}</span>,
];
}
function RightPart() {
if (slots.right) {
return slots.right();
}
if (props.rightText) {
return <span class={bem('text')}>{props.rightText}</span>;
}
}
return ( return (
<div <div
class={[
bem({ fixed: props.fixed }),
{ [BORDER_BOTTOM]: props.border },
]}
style={{ zIndex: props.zIndex }} style={{ zIndex: props.zIndex }}
class={[bem({ fixed: props.fixed }), { [BORDER_BOTTOM]: props.border }]}
{...inherit(ctx)} {...inherit(ctx)}
> >
<div class={bem('left')} onClick={ctx.listeners['click-left'] || noop}> <div class={bem('left')} onClick={ctx.listeners['click-left'] || noop}>
{slots.left {LeftPart()}
? slots.left()
: [
props.leftArrow && (
<Icon class={bem('arrow')} name="arrow-left" />
),
props.leftText && (
<span class={bem('text')}>{props.leftText}</span>
),
]}
</div> </div>
<div class={[bem('title'), 'van-ellipsis']}> <div class={[bem('title'), 'van-ellipsis']}>
{slots.title ? slots.title() : props.title} {slots.title ? slots.title() : props.title}
</div> </div>
<div class={bem('right')} onClick={ctx.listeners['click-right'] || noop}> <div class={bem('right')} onClick={ctx.listeners['click-right'] || noop}>
{slots.right {RightPart()}
? slots.right()
: props.rightText && (
<span class={bem('text')}>{props.rightText}</span>
)}
</div> </div>
</div> </div>
); );

View File

@ -39,7 +39,11 @@ function PasswordInput(
Points.push( Points.push(
<li class={{ [BORDER_LEFT]: showBorder }} style={style}> <li class={{ [BORDER_LEFT]: showBorder }} style={style}>
{props.mask ? <i style={{ visibility: char ? 'visible' : 'hidden' }} /> : char} {props.mask ? (
<i style={{ visibility: char ? 'visible' : 'hidden' }} />
) : (
char
)}
{showCursor && <div class={bem('cursor')} />} {showCursor && <div class={bem('cursor')} />}
</li> </li>
); );
@ -57,7 +61,9 @@ function PasswordInput(
> >
{Points} {Points}
</ul> </ul>
{info && <div class={bem(props.errorInfo ? 'error-info' : 'info')}>{info}</div>} {info && (
<div class={bem(props.errorInfo ? 'error-info' : 'info')}>{info}</div>
)}
</div> </div>
); );
} }

View File

@ -43,7 +43,11 @@ function Search(
) { ) {
function Label() { function Label() {
if (slots.label || props.label) { if (slots.label || props.label) {
return <div class={bem('label')}>{slots.label ? slots.label() : props.label}</div>; return (
<div class={bem('label')}>
{slots.label ? slots.label() : props.label}
</div>
);
} }
} }

View File

@ -33,7 +33,9 @@ function Skeleton(
function Title() { function Title() {
if (props.title) { if (props.title) {
return <h3 class={bem('title')} style={{ width: addUnit(props.titleWidth) }} />; return (
<h3 class={bem('title')} style={{ width: addUnit(props.titleWidth) }} />
);
} }
} }
@ -54,7 +56,9 @@ function Skeleton(
} }
for (let i = 0; i < props.row; i++) { for (let i = 0; i < props.row; i++) {
Rows.push(<div class={bem('row')} style={{ width: addUnit(getRowWidth(i)) }} />); Rows.push(
<div class={bem('row')} style={{ width: addUnit(getRowWidth(i)) }} />
);
} }
return Rows; return Rows;

View File

@ -16,7 +16,10 @@ export type SkuHeaderProps = {
const [createComponent, bem] = createNamespace('sku-header'); const [createComponent, bem] = createNamespace('sku-header');
function getSkuImg(sku: SkuData, selectedSku: SelectedSkuData): string | undefined { function getSkuImg(
sku: SkuData,
selectedSku: SelectedSkuData
): string | undefined {
let img; let img;
sku.tree.some(item => { sku.tree.some(item => {

View File

@ -24,7 +24,10 @@ function SkuRow(
); );
return ( return (
<div class={[bem(), BORDER_BOTTOM]} {...inherit(ctx)}> <div class={[bem(), BORDER_BOTTOM]} {...inherit(ctx)}>
<div class={bem('title')}>{props.skuRow.k}{multipleNode}</div> <div class={bem('title')}>
{props.skuRow.k}
{multipleNode}
</div>
{slots.default && slots.default()} {slots.default && slots.default()}
</div> </div>
); );