feat: reusable input component

This commit is contained in:
Carlos Valente
2025-06-22 11:24:22 +02:00
committed by Carlos Valente
parent 3f3cef7d6f
commit 97691eba05
5 changed files with 61 additions and 4 deletions
@@ -10,7 +10,7 @@
padding-inline: 1em;
border: 1px solid transparent;
border-radius: 3px;
border-radius: $component-border-radius-md;
cursor: pointer;
@@ -82,4 +82,5 @@
.xlarge {
height: 3rem;
height: 3rem;
font-size: 1.5rem;
}
@@ -9,9 +9,13 @@ interface IconButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
size?: 'medium' | 'large' | 'xlarge';
}
export default function IconButton(props: IconButtonProps) {
const { className, children, variant = 'subtle', size = 'medium', ...buttonProps } = props;
export default function IconButton({
className,
children,
variant = 'subtle',
size = 'medium',
...buttonProps
}: IconButtonProps) {
return (
<button
className={cx([style.baseIconButton, style[variant], style[size], className])}
@@ -0,0 +1,38 @@
.input {
box-sizing: border-box;
background-color: $gray-1200;
font-size: 1rem;
font-weight: 400;
color: $gray-200;
border-radius: $component-border-radius-md;
border: 1px solid transparent;
padding-inline: 0.5em;
&:hover:not(:disabled) {
background-color: $gray-1100;
}
&:focus {
background-color: $gray-1000;
border: 1px solid $blue-500;
}
&:disabled {
opacity: 0.4;
cursor: not-allowed;
}
&::placeholder {
color: $gray-500;
}
}
.medium {
height: 2rem;
}
.large {
height: 2.5rem;
}
@@ -0,0 +1,14 @@
import { InputHTMLAttributes } from 'react';
import { cx } from '../../../utils/styleUtils';
import style from './Input.module.scss';
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
variant?: 'subtle';
height?: 'medium' | 'large';
}
export default function Input({ className, variant = 'subtle', height = 'medium', ...inputProps }: InputProps) {
return <input type='text' className={cx([style.input, style[variant], style[height], className])} {...inputProps} />;
}