Skip to content

Commit

Permalink
moves selectable button in components
Browse files Browse the repository at this point in the history
  • Loading branch information
cephaschapa committed Mar 3, 2025
1 parent 9edb829 commit d884117
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 48 deletions.
52 changes: 52 additions & 0 deletions app/src/components/custom-selectable-buttons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { TFunction } from "i18next";
import { FC } from "react";
import { Button } from "./ui/button";
import { Icon } from "@chakra-ui/react";
import { InventoryButtonCheckIcon } from "./icons";

export default function CustomSelectableButton({
field,
value,
inputValue,
inputValueFunction,
t,
}: {
value: string;
field: any;
inputValue: string;
inputValueFunction: Function;
t: TFunction;
}) {
return (
<Button
key={value}
w="181px"
borderColor={
inputValue === value ? "interactive.secondary" : "border.neutral"
}
bg={inputValue === value ? "background.neutral" : "base.light"}
h="56px"
color={inputValue === value ? "content.link" : "content.secondary"}
borderRadius="4xl"
display="flex"
justifyContent="center"
alignItems="center"
fontFamily="heading"
fontStyle="500"
textTransform="uppercase"
lineHeight="20px"
gap="8px"
letterSpacing="wide"
className="transition-all duration-150"
borderWidth="1px"
variant={inputValue === value ? "solid" : "outline"}
onClick={() => {
field.onChange(value);
inputValueFunction(value);
}}
>
{inputValue == value && <Icon as={InventoryButtonCheckIcon} />}
{t(value)}
</Button>
);
}
49 changes: 1 addition & 48 deletions app/src/components/steps/add-inventory-details-step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
import { Field } from "@/components/ui/field";
import { Button } from "../ui/button";
import { InventoryButtonCheckIcon } from "../icons";
import CustomSelectableButton from "../custom-selectable-buttons";

export default function SetInventoryDetailsStep({
t,
Expand Down Expand Up @@ -360,51 +361,3 @@ export default function SetInventoryDetailsStep({
</Box>
);
}

interface CustomSelectableButtonProps {
value: string;
field: any;
inputValue: string;
inputValueFunction: Function;
t: TFunction;
}
const CustomSelectableButton: FC<CustomSelectableButtonProps> = ({
field,
value,
inputValue,
inputValueFunction,
t,
}) => {
return (
<Button
key={value}
w="181px"
borderColor={
inputValue === value ? "interactive.secondary" : "border.neutral"
}
bg={inputValue === value ? "background.neutral" : "base.light"}
h="56px"
color={inputValue === value ? "content.link" : "content.secondary"}
borderRadius="4xl"
display="flex"
justifyContent="center"
alignItems="center"
fontFamily="heading"
fontStyle="500"
textTransform="uppercase"
lineHeight="20px"
gap="8px"
letterSpacing="wide"
className="transition-all duration-150"
borderWidth="1px"
variant={inputValue === value ? "solid" : "outline"}
onClick={() => {
field.onChange(value);
inputValueFunction(value);
}}
>
{inputValue == value && <Icon as={InventoryButtonCheckIcon} />}
{t(value)}
</Button>
);
};

0 comments on commit d884117

Please sign in to comment.