✨ add option nav
This commit is contained in:
parent
95b1e28380
commit
b39662f395
@ -10,6 +10,18 @@
|
|||||||
|
|
||||||
background: var(--dropdown-option-background-default, #fff);
|
background: var(--dropdown-option-background-default, #fff);
|
||||||
|
|
||||||
|
svg {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
flex: 1 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: var(--dropdown-option-background-hovered);
|
background-color: var(--dropdown-option-background-hovered);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
|
import IconButton from "@Front/Components/DesignSystem/IconButton";
|
||||||
import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography";
|
import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography";
|
||||||
import { CheckIcon } from "@heroicons/react/24/outline";
|
import { CheckIcon } from "@heroicons/react/24/outline";
|
||||||
import { useCallback } from "react";
|
import { useCallback } from "react";
|
||||||
|
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
import IconButton from "@Front/Components/DesignSystem/IconButton";
|
|
||||||
|
|
||||||
export type IOption = {
|
export type IOption = {
|
||||||
id: string;
|
id: string;
|
||||||
label: string;
|
label: string | { text: string; subtext: string };
|
||||||
};
|
};
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
@ -23,12 +23,34 @@ export default function DropdownOption(props: IProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes["root"]} onClick={handleOnClick}>
|
<div className={classes["root"]} onClick={handleOnClick}>
|
||||||
|
{getContent(option.label)}
|
||||||
|
{isActive && <CheckIcon />}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
function getContent(label: string | { text: string; subtext: string }) {
|
||||||
|
if (typeof label === "string") {
|
||||||
|
return (
|
||||||
<Typography
|
<Typography
|
||||||
typo={isActive ? ETypo.TEXT_MD_SEMIBOLD : ETypo.TEXT_MD_REGULAR}
|
typo={isActive ? ETypo.TEXT_MD_SEMIBOLD : ETypo.TEXT_MD_REGULAR}
|
||||||
color={isActive ? ETypoColor.DROPDOWN_CONTRAST_ACTIVE : ETypoColor.DROPDOWN_CONTRAST_DEFAULT}>
|
color={isActive ? ETypoColor.DROPDOWN_CONTRAST_ACTIVE : ETypoColor.DROPDOWN_CONTRAST_DEFAULT}>
|
||||||
{option.label}
|
{label}
|
||||||
|
</Typography>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div className={classes["content"]}>
|
||||||
|
<Typography
|
||||||
|
typo={ETypo.TEXT_MD_LIGHT}
|
||||||
|
color={isActive ? ETypoColor.NAVIGATION_BUTTON_CONTRAST_ACTIVE : ETypoColor.NAVIGATION_BUTTON_CONTRAST_DEFAULT}>
|
||||||
|
{label.text}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
typo={ETypo.TEXT_MD_BOLD}
|
||||||
|
color={isActive ? ETypoColor.NAVIGATION_BUTTON_CONTRAST_ACTIVE : ETypoColor.NAVIGATION_BUTTON_CONTRAST_DEFAULT}>
|
||||||
|
{label.subtext}
|
||||||
</Typography>
|
</Typography>
|
||||||
{isActive && <IconButton icon={<CheckIcon />} />}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,11 +34,19 @@ export default function Dropdown(props: IProps) {
|
|||||||
<Typography
|
<Typography
|
||||||
typo={ETypo.TEXT_MD_REGULAR}
|
typo={ETypo.TEXT_MD_REGULAR}
|
||||||
color={!!selectedOption ? ETypoColor.DROPDOWN_CONTRAST_ACTIVE : ETypoColor.DROPDOWN_CONTRAST_DEFAULT}>
|
color={!!selectedOption ? ETypoColor.DROPDOWN_CONTRAST_ACTIVE : ETypoColor.DROPDOWN_CONTRAST_DEFAULT}>
|
||||||
{selectedOption?.label ?? placeholder}
|
{getLabel(selectedOption) ?? placeholder}
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
<IconButton icon={<ChevronDownIcon />} />
|
<IconButton icon={<ChevronDownIcon />} />
|
||||||
</div>
|
</div>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function getLabel(option: IOption | null): string | null {
|
||||||
|
if (!option) return null;
|
||||||
|
if (typeof option.label === "string") {
|
||||||
|
return option.label;
|
||||||
|
}
|
||||||
|
return `${option.label.text} ${option.label.subtext}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,10 @@ export default function DesignSystem() {
|
|||||||
id: "3",
|
id: "3",
|
||||||
label: "Option 3",
|
label: "Option 3",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "4",
|
||||||
|
label: { text: "Option 4", subtext: "Subtext" },
|
||||||
|
},
|
||||||
]}
|
]}
|
||||||
placeholder="Placeholder"
|
placeholder="Placeholder"
|
||||||
/>
|
/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user