Skip to content

Commit

Permalink
fix add ref to textinput and styles
Browse files Browse the repository at this point in the history
  • Loading branch information
felipprodrigues committed Oct 11, 2023
1 parent fcef28f commit 69cb368
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "turbo run build",
"changeset": "changeset",
"version-packages": "changeset version",
"release": "turbo run build --filter=packages/docs && changeset publish"
"release": "turbo run build --filter=!docs && changeset publish"
},
"devDependencies": {
"@changesets/cli": "^2.26.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/docs/src/stories/TextInput.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export const Primary: StoryObj<TextInputProps> = {

export const WithPrefix: StoryObj<TextInputProps> = {
args: {
prefix: 'call.com/'
prefix: 'call.com/',
placeholder: 'your-username'
}
};

Expand Down
7 changes: 7 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @far-ui/react

## 1.0.1

### Patch Changes

- add option to pass reference to textInput and styles fixes
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@far-ui/react",
"version": "1.0.0",
"version": "1.0.1",
"description": "",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/Avatar/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import * as Avatar from '@radix-ui/react-avatar'
export const AvatarContainer = styled(Avatar.Root, {
borderRadius: '$full',
display: 'inline-block',
width: '$12',
height: '$12',
width: '$16',
height: '$16',
overflow: 'hidden',
})

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { styled } from "../styles";
import { ComponentProps } from "react";

export const Box = styled("div", {
padding: "$4",
padding: "$6",
borderRadius: "$md",
backgroundColor: "$gray800",
border: "1px solid $gray600",
Expand Down
4 changes: 4 additions & 0 deletions packages/react/src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export const ButtonType = styled("div", {
cursor: 'not-allowed'
},

'&:focus': {
boxShadow: '0 0 0 2px $colors$gray100'
},

variants: {
variant: {
primary: {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Checkbox/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const CheckboxContainer = styled(Checkbox.Root, {
backgroundColor: '$ignite300',
},

'&:focus': {
'&:focus, &[data-state="checked"]': {
border: '2px solid $ignite300',
},
})
Expand Down
20 changes: 11 additions & 9 deletions packages/react/src/components/TextInput/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
/* eslint-disable @typescript-eslint/no-empty-interface */
import { ComponentProps } from 'react'
import { ComponentProps, forwardRef, ElementRef } from 'react'
import { Input, Prefix, TextInputContainer } from './styles'

export interface TextInputProps extends ComponentProps<typeof Input> {
prefix?: string
}

export function TextInput({ prefix, ...props }: TextInputProps) {
return (
<TextInputContainer>
{!!prefix && <Prefix>{prefix}</Prefix>}
<Input {...props} />
</TextInputContainer>
)
}
export const TextInput = forwardRef<ElementRef<typeof Input>, TextInputProps>(
({ prefix, ...props }: TextInputProps, ref) => {
return (
<TextInputContainer>
{!!prefix && <Prefix>{prefix}</Prefix>}
<Input ref={ref} {...props} />
</TextInputContainer>
)
},
)

TextInput.displayName = 'TextInput'
21 changes: 18 additions & 3 deletions packages/react/src/components/TextInput/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@ import { styled } from '../../styles'

export const TextInputContainer = styled('div', {
backgroundColor: '$gray900',
padding: '$3 $4',

borderRadius: '$sm',
boxSizing: 'border-box',
border: '2px solid $gray900',
display: 'flex',
alignItems: 'baseline',
alignItems: 'center',

variants: {
size: {
sm: {
padding: '$2 $3',
},
md: {
padding: '$3 $4',
},
},
},

'&:has(input:focus)': {
borderColor: '$ignite300',
Expand All @@ -17,6 +28,10 @@ export const TextInputContainer = styled('div', {
opacity: 0.5,
cursor: 'not-allowed',
},

defaultVariants: {
size: 'md',
},
})

export const Prefix = styled('span', {
Expand All @@ -43,7 +58,7 @@ export const Input = styled('input', {
cursor: 'not-allowed',
},

'&:placeholder': {
'&::placeholder': {
color: '$gray400',
},
})
2 changes: 1 addition & 1 deletion packages/react/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export * from "./components/TextArea";
export * from "./components/Checkbox";
export * from "./components/MultiStep";


export * from './styles'

0 comments on commit 69cb368

Please sign in to comment.