diff --git a/.storybook/main.ts b/.storybook/main.ts index f3d4e8e..474ae7e 100644 --- a/.storybook/main.ts +++ b/.storybook/main.ts @@ -24,7 +24,7 @@ const config: StorybookConfig = { docs: {}, typescript: { - reactDocgen: 'react-docgen-typescript' - } + reactDocgen: 'react-docgen-typescript', + }, } export default config diff --git a/package.json b/package.json index 8bb7266..9813a9c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ooni-components", - "version": "0.7.0-alpha.3", + "version": "0.7.0-alpha.5", "main": "dist/index.cjs.js", "module": "dist/index.esm.js", "types": "dist/index.d.ts", diff --git a/src/components/Checkbox.tsx b/src/components/Checkbox.tsx index 4122186..6d5d658 100644 --- a/src/components/Checkbox.tsx +++ b/src/components/Checkbox.tsx @@ -1,17 +1,24 @@ import React, { forwardRef } from 'react' import { twMerge } from 'tailwind-merge' -export interface CheckboxProps { +import ErrorMessage from './ErrorMessage' + +type CheckboxProps = Omit< + React.InputHTMLAttributes, + 'type' +> & { error?: string - name: string label: string - disabled?: boolean - className?: string } const Checkbox = forwardRef( ({ name, label, error, disabled = false, className, ...props }, ref) => ( <> -
+
(
- {/* {error} */}
+ {error && {error}} ), ) diff --git a/src/components/ErrorMessage.tsx b/src/components/ErrorMessage.tsx index e954727..032acdd 100644 --- a/src/components/ErrorMessage.tsx +++ b/src/components/ErrorMessage.tsx @@ -1,11 +1,15 @@ -import React, { ReactNode } from 'react' +import React from 'react' +import { twMerge } from 'tailwind-merge' -interface ErrorMessageProps { - children: ReactNode -} - -const ErrorMessage = ({ children }: ErrorMessageProps) => { - return

{children}

+const ErrorMessage = ({ + children, + className, +}: React.HTMLAttributes) => { + return ( +

+ {children} +

+ ) } export default ErrorMessage diff --git a/src/components/IconButton.tsx b/src/components/IconButton.tsx index 2e56d4c..ed41b4d 100644 --- a/src/components/IconButton.tsx +++ b/src/components/IconButton.tsx @@ -1,6 +1,7 @@ import React, { ReactNode } from 'react' -export interface IconButtonProps { +export interface IconButtonProps + extends React.HtmlHTMLAttributes { icon: ReactNode } diff --git a/src/components/Input.tsx b/src/components/Input.tsx index 8237166..2db9ec8 100644 --- a/src/components/Input.tsx +++ b/src/components/Input.tsx @@ -1,18 +1,20 @@ import React, { forwardRef } from 'react' import ErrorMessage from './ErrorMessage' -export interface InputProps { +type InputProps = Omit, 'type'> & { error?: string label?: string - name: string } const Input = forwardRef( - ({ error, name, label, ...props }, ref) => { + ({ error, name, label, className, ...props }, ref) => { return ( -
+
{label && ( -