enhance(compo):调整可激活链接中的默认属性处理。
This commit is contained in:
parent
c0815b0a21
commit
fceeb92c06
|
@ -1,6 +1,6 @@
|
||||||
import { A } from "@solidjs/router";
|
import { A } from "@solidjs/router";
|
||||||
import { defaultTo, isNil, pick, pipe, prop } from "ramda";
|
import { defaultTo, isNil, pick, pipe, prop } from "ramda";
|
||||||
import { Show } from "solid-js";
|
import { Show, mergeProps } from "solid-js";
|
||||||
import classes from "./ActivatableLink.module.css";
|
import classes from "./ActivatableLink.module.css";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,17 +24,21 @@ const defaultActivatable = pipe(defaultTo(true), prop("activatable"));
|
||||||
* @returns {import("solid-js").Component<ActivatableLinkProps>}
|
* @returns {import("solid-js").Component<ActivatableLinkProps>}
|
||||||
*/
|
*/
|
||||||
export default function ActivatableLink(props) {
|
export default function ActivatableLink(props) {
|
||||||
|
const mergedProps = mergeProps(
|
||||||
|
{ activatable: true, leftIcon: null, rightIcon: null },
|
||||||
|
props
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<A
|
<A
|
||||||
class={prop("activatable-link", classes)}
|
class={prop("activatable-link", classes)}
|
||||||
{...(defaultActivatable(props) && {
|
{...(prop("activatable", mergedProps) && {
|
||||||
activeClass: "activated",
|
activeClass: "activated",
|
||||||
})}
|
})}
|
||||||
{...pick(["replace", "end", "href"], props)}
|
{...pick(["replace", "end", "href"], mergedProps)}
|
||||||
>
|
>
|
||||||
<Show when={!isNil(props.leftIcon)}>{props.leftIcon}</Show>
|
<Show when={!isNil(mergedProps.leftIcon)}>{mergedProps.leftIcon}</Show>
|
||||||
<Show when={!isNil(props.children)}>{props.children}</Show>
|
<Show when={!isNil(mergedProps.children)}>{mergedProps.children}</Show>
|
||||||
<Show when={!isNil(props.rightIcon)}>{props.rightIcon}</Show>
|
<Show when={!isNil(mergedProps.rightIcon)}>{mergedProps.rightIcon}</Show>
|
||||||
</A>
|
</A>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user