Add CircularIconButton Component
This commit is contained in:
parent
1c00abe12e
commit
7ffda11a34
2 changed files with 45 additions and 13 deletions
37
frontend/src/components/basics/CircularIconButton.tsx
Normal file
37
frontend/src/components/basics/CircularIconButton.tsx
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
import {defaultIconSize} from "./SvgIcon";
|
||||||
|
import type {LucideIcon} from "lucide-react";
|
||||||
|
import {ButtonType} from "./BasicButtonDefinitions.ts";
|
||||||
|
|
||||||
|
type CircularIconButtonProps = {
|
||||||
|
icon: LucideIcon;
|
||||||
|
onClick: () => void;
|
||||||
|
disabled?: boolean;
|
||||||
|
className?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Circular button component
|
||||||
|
*/
|
||||||
|
export default function CircularIconButton({
|
||||||
|
onClick,
|
||||||
|
icon: Icon,
|
||||||
|
className = "",
|
||||||
|
disabled = false,
|
||||||
|
...props
|
||||||
|
}: CircularIconButtonProps) {
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
className={`flex-shrink-0 w-7 h-7 rounded-full text-white flex items-center justify-center shadow-sm
|
||||||
|
${ButtonType.PrimaryButton.backgroundColor} ${className}`}
|
||||||
|
onClick={onClick}
|
||||||
|
disabled={disabled}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{Icon && (
|
||||||
|
<Icon
|
||||||
|
size={defaultIconSize}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import {Minus, Plus} from "lucide-react";
|
import {Minus, Plus} from "lucide-react";
|
||||||
import {defaultIconSize} from "./SvgIcon.tsx";
|
import CircularIconButton from "./CircularIconButton.tsx";
|
||||||
|
|
||||||
type NumberStepControlProps = {
|
type NumberStepControlProps = {
|
||||||
/** Current numeric value */
|
/** Current numeric value */
|
||||||
|
|
@ -45,13 +45,10 @@ export function NumberStepControl({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`flex items-center gap-2 ${className}`}>
|
<div className={`flex items-center gap-2 ${className}`}>
|
||||||
<button
|
<CircularIconButton
|
||||||
type="button"
|
|
||||||
onClick={handleDecrease}
|
onClick={handleDecrease}
|
||||||
className="circular-container primary-button-bg"
|
icon={Minus}
|
||||||
>
|
/>
|
||||||
<Minus size={defaultIconSize}/>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
|
|
@ -62,13 +59,11 @@ export function NumberStepControl({
|
||||||
className="w-16 text-center"
|
className="w-16 text-center"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<button
|
<CircularIconButton
|
||||||
type="button"
|
|
||||||
onClick={handleIncrease}
|
onClick={handleIncrease}
|
||||||
className="circular-container primary-button-bg"
|
icon={Plus}
|
||||||
>
|
/>
|
||||||
<Plus size={defaultIconSize}/>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue