UI: fix input base, use mathematical asterisk in required label
This commit is contained in:
@@ -3,9 +3,9 @@ import { JSX, Ref, Show, splitProps } from "solid-js";
|
|||||||
import Icon, { IconVariant } from "../icon";
|
import Icon, { IconVariant } from "../icon";
|
||||||
import { Typography, TypographyProps } from "../Typography";
|
import { Typography, TypographyProps } from "../Typography";
|
||||||
|
|
||||||
type Variants = "outlined" | "ghost";
|
export type InputVariant = "outlined" | "ghost";
|
||||||
interface InputBaseProps {
|
interface InputBaseProps {
|
||||||
variant?: Variants;
|
variant?: InputVariant;
|
||||||
value?: string;
|
value?: string;
|
||||||
inputProps?: JSX.InputHTMLAttributes<HTMLInputElement>;
|
inputProps?: JSX.InputHTMLAttributes<HTMLInputElement>;
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
@@ -22,7 +22,7 @@ interface InputBaseProps {
|
|||||||
divRef?: Ref<HTMLDivElement>;
|
divRef?: Ref<HTMLDivElement>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const variantBorder: Record<Variants, string> = {
|
const variantBorder: Record<InputVariant, string> = {
|
||||||
outlined: "border border-inv-3",
|
outlined: "border border-inv-3",
|
||||||
ghost: "",
|
ghost: "",
|
||||||
};
|
};
|
||||||
@@ -115,40 +115,55 @@ export const InputLabel = (props: InputLabelProps) => {
|
|||||||
class={cx("flex items-center gap-1", labelProps.class)}
|
class={cx("flex items-center gap-1", labelProps.class)}
|
||||||
{...forwardProps}
|
{...forwardProps}
|
||||||
>
|
>
|
||||||
<Typography
|
<span class="flex flex-col justify-center">
|
||||||
hierarchy="label"
|
<span>
|
||||||
size="default"
|
<Typography
|
||||||
weight="bold"
|
hierarchy="label"
|
||||||
class="inline-flex gap-1 align-middle !fg-def-1"
|
size="default"
|
||||||
classList={{
|
weight="bold"
|
||||||
[cx("!fg-semantic-1")]: !!props.error,
|
class="inline-flex gap-1 align-middle !fg-def-1"
|
||||||
}}
|
classList={{
|
||||||
aria-invalid={props.error}
|
[cx("!fg-semantic-1")]: !!props.error,
|
||||||
>
|
|
||||||
{props.children}
|
|
||||||
{props.required && (
|
|
||||||
<span class="inline-flex px-1 align-bottom leading-[0.5] fg-def-3">
|
|
||||||
{"*"}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
{props.help && (
|
|
||||||
<span
|
|
||||||
class="tooltip tooltip-bottom inline px-2"
|
|
||||||
data-tip={props.help}
|
|
||||||
style={{
|
|
||||||
"--tooltip-color": "#EFFFFF",
|
|
||||||
"--tooltip-text-color": "#0D1416",
|
|
||||||
"--tooltip-tail": "0.8125rem",
|
|
||||||
}}
|
}}
|
||||||
|
aria-invalid={props.error}
|
||||||
>
|
>
|
||||||
<Icon class="inline fg-def-3" icon={"Info"} width={"0.8125rem"} />
|
{props.children}
|
||||||
</span>
|
</Typography>
|
||||||
)}
|
{props.required && (
|
||||||
</Typography>
|
<Typography
|
||||||
|
class="inline-flex px-1 align-text-top leading-[0.5] fg-def-4"
|
||||||
|
useExternColor={true}
|
||||||
|
hierarchy="label"
|
||||||
|
weight="bold"
|
||||||
|
size="xs"
|
||||||
|
>
|
||||||
|
{"∗"}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
{props.help && (
|
||||||
|
<span
|
||||||
|
class="tooltip tooltip-bottom inline px-2"
|
||||||
|
data-tip={props.help}
|
||||||
|
style={{
|
||||||
|
"--tooltip-color": "#EFFFFF",
|
||||||
|
"--tooltip-text-color": "#0D1416",
|
||||||
|
"--tooltip-tail": "0.8125rem",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Icon class="inline fg-def-3" icon={"Info"} width={"0.8125rem"} />
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
<Typography
|
||||||
|
hierarchy="body"
|
||||||
|
size="xs"
|
||||||
|
weight="normal"
|
||||||
|
color="secondary"
|
||||||
|
>
|
||||||
|
{props.description}
|
||||||
|
</Typography>
|
||||||
|
</span>
|
||||||
{props.labelAction}
|
{props.labelAction}
|
||||||
<Typography hierarchy="body" size="xs" weight="normal" color="secondary">
|
|
||||||
{props.description}
|
|
||||||
</Typography>
|
|
||||||
</label>
|
</label>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user