Skip to content

Commit

Permalink
convert React Checkbox component to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
Théo Cherblanc authored and Lucanis committed Jan 17, 2024
1 parent dd83636 commit cd9caad
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React, { forwardRef } from 'react';
import { CheckboxProps } from './Checkbox.types';

const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
(
{ label, name, small = false, className = '', ...props }: CheckboxProps,
ref
) => {
return (
<label className={`Checkbox ${className ? className : ''}`}>
<input type="checkbox" name={name} {...props} ref={ref} />

<span>{label}</span>
</label>
);
}
);

export default Checkbox;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ChangeEvent } from 'react';
import { ChangeHandler } from 'react-hook-form';

export type CheckboxProps = {
label: string | JSX.Element;
name: string;
id?: string;
type?: string;
small?: boolean;
className?: string;
description?: string | JSX.Element;
value?: string | number;
defaultChecked?: boolean;
checked?: boolean;
onChange?: ((e: ChangeEvent<HTMLInputElement>) => void) | ChangeHandler;
};
18 changes: 0 additions & 18 deletions templates/frontOffice/modern/components/React/Checkbox/index.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Checkbox';

0 comments on commit cd9caad

Please sign in to comment.