Skip to content

Commit

Permalink
Merge branch 'rp--input-component' of github.com:interledger/web-mone…
Browse files Browse the repository at this point in the history
…tization-extension into rp--input-component
  • Loading branch information
ionutanin committed Jan 10, 2024
2 parents d4060ca + 22ff46c commit a90bb5a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/components/__tests__/input.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Input', () => {
expect(queryByLabelText('test input')).toHaveClass('border-base')
})

it('should have the `border-error` class when the `error` variant is passed', () => {
it('should have the `border-error` class when an error message is passed', () => {
const { queryByLabelText } = render(<Input aria-label="test input" error />)

expect(queryByLabelText('test input')).toBeInTheDocument()
Expand Down
11 changes: 2 additions & 9 deletions src/components/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,9 @@ const inputVariants = cva(
variant: {
default: 'border-base',
},
error: {
true: 'border-error',
},
loading: {
true: 'text-transparent',
},
hasIcon: {
true: 'pl-12',
},
disabled: {
true: 'bg-disabled border-transparent',
},
Expand All @@ -38,10 +32,9 @@ export interface InputProps
extends VariantProps<typeof inputVariants>,
React.InputHTMLAttributes<HTMLInputElement> {
loading?: boolean
error?: boolean
error?: string
disabled?: boolean
icon?: React.ReactNode
type?: 'text' | 'password' | 'email' | 'number'
}

export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
Expand All @@ -54,7 +47,7 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
<input
ref={ref}
type={type}
className={cn(inputVariants({ loading, hasIcon: !!icon, disabled, error }), className)}
className={cn(inputVariants({ loading, disabled }), icon && 'pl-12', error && 'border-error', className)}
disabled={disabled ?? loading ?? false}
aria-disabled={disabled ?? loading ?? false}
{...props}
Expand Down
13 changes: 1 addition & 12 deletions src/components/label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,8 @@ import React, { forwardRef } from 'react'

import { cn } from '@/utils/cn'

const labelVariants = cva(
['text-medium font-medium leading-6 px-2 flex items-center gap-2'],
const labelVariants = cva('text-medium font-medium leading-6',

{
variants: {
variant: {
default: 'border-base',
},
},
defaultVariants: {
variant: 'default',
},
},
)

export interface LabelProps
Expand Down

0 comments on commit a90bb5a

Please sign in to comment.