✨ (DropdownButtonComponent/index.tsx): add support for displaying a plus button and hiding dropdown options based on props
♻️ (inputComponent/index.tsx): refactor the logic for setting the paddingRight CSS property based on password and selectedOption values ✨ (MainPage/index.tsx): add support for displaying a plus button and hiding dropdown options in the DropdownButton component ♻️ (types/components/index.ts): add optional plusButton and dropdownOptions properties to the dropdownButtonPropsType type
This commit is contained in:
parent
d318386483
commit
51a405d0cc
4 changed files with 29 additions and 17 deletions
|
|
@ -13,6 +13,8 @@ export default function DropdownButton({
|
||||||
firstButtonName,
|
firstButtonName,
|
||||||
onFirstBtnClick,
|
onFirstBtnClick,
|
||||||
options,
|
options,
|
||||||
|
plusButton = false,
|
||||||
|
dropdownOptions = true,
|
||||||
}: dropdownButtonPropsType): JSX.Element {
|
}: dropdownButtonPropsType): JSX.Element {
|
||||||
const [showOptions, setShowOptions] = useState<boolean>(false);
|
const [showOptions, setShowOptions] = useState<boolean>(false);
|
||||||
|
|
||||||
|
|
@ -23,14 +25,18 @@ export default function DropdownButton({
|
||||||
<Button
|
<Button
|
||||||
id="new-project-btn"
|
id="new-project-btn"
|
||||||
variant="primary"
|
variant="primary"
|
||||||
className="relative pr-10"
|
className={"relative" + dropdownOptions ? "" : " pr-10"}
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
onFirstBtnClick();
|
onFirstBtnClick();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{plusButton && (
|
||||||
|
<IconComponent name="Plus" className="main-page-nav-button" />
|
||||||
|
)}
|
||||||
{firstButtonName}
|
{firstButtonName}
|
||||||
|
{dropdownOptions && (
|
||||||
<div
|
<div
|
||||||
className="absolute right-2 items-center text-muted-foreground"
|
className="absolute right-2 items-center text-muted-foreground"
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
|
|
@ -45,6 +51,7 @@ export default function DropdownButton({
|
||||||
<IconComponent name="ChevronUp" />
|
<IconComponent name="ChevronUp" />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent
|
<DropdownMenuContent
|
||||||
|
|
|
||||||
|
|
@ -119,8 +119,9 @@ export default function InputComponent({
|
||||||
? " text-clip password "
|
? " text-clip password "
|
||||||
: "",
|
: "",
|
||||||
editNode ? " input-edit-node " : "",
|
editNode ? " input-edit-node " : "",
|
||||||
password && selectedOption === "" && editNode ? "pr-8" : "",
|
password && selectedOption === "" && editNode ? "pr-16" : "",
|
||||||
password && selectedOption === "" && !editNode ? "pr-10" : "",
|
password && selectedOption === "" && !editNode ? "pr-16" : "",
|
||||||
|
!password && selectedOption === "" ? "pr-8" : "",
|
||||||
className!
|
className!
|
||||||
)}
|
)}
|
||||||
placeholder={password && editNode ? "Key" : placeholder}
|
placeholder={password && editNode ? "Key" : placeholder}
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,8 @@ export default function HomePage(): JSX.Element {
|
||||||
firstButtonName="New Project"
|
firstButtonName="New Project"
|
||||||
onFirstBtnClick={() => setOpenModal(true)}
|
onFirstBtnClick={() => setOpenModal(true)}
|
||||||
options={dropdownOptions}
|
options={dropdownOptions}
|
||||||
|
plusButton={true}
|
||||||
|
dropdownOptions={false}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -688,6 +688,8 @@ export type dropdownButtonPropsType = {
|
||||||
firstButtonName: string;
|
firstButtonName: string;
|
||||||
onFirstBtnClick: () => void;
|
onFirstBtnClick: () => void;
|
||||||
options: Array<{ name: string; onBtnClick: () => void }>;
|
options: Array<{ name: string; onBtnClick: () => void }>;
|
||||||
|
plusButton?: boolean;
|
||||||
|
dropdownOptions?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type IOInputProps = {
|
export type IOInputProps = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue