fix: more small fixes

This commit is contained in:
marcelines 2023-06-27 11:52:43 +01:00
parent c2a7c9b67b
commit 6d705fadb7
No known key found for this signature in database
GPG Key ID: 56B1E53E2A3F43C7
8 changed files with 11 additions and 18 deletions

View File

@ -1,4 +1,4 @@
import { useRef, useState } from 'react' import { useState } from 'react'
import { Avatar, Button, Input, Tag, Text } from '@status-im/components' import { Avatar, Button, Input, Tag, Text } from '@status-im/components'
import { ProfileIcon, SearchIcon } from '@status-im/icons' import { ProfileIcon, SearchIcon } from '@status-im/icons'
@ -10,7 +10,6 @@ import { DropdownFilter, DropdownSort, Tabs } from './filters'
import type { DropdownFilterProps } from './filters/dropdown-filter' import type { DropdownFilterProps } from './filters/dropdown-filter'
import type { DropdownSortProps } from './filters/dropdown-sort' import type { DropdownSortProps } from './filters/dropdown-sort'
import type { TextInput } from 'react-native'
const issues = [ const issues = [
{ {
@ -216,7 +215,6 @@ const sortOptions: DropdownSortProps['data'] = [
const TableIssues = () => { const TableIssues = () => {
const [issuesSearchText, setIssuesSearchText] = useState('') const [issuesSearchText, setIssuesSearchText] = useState('')
const inputRef = useRef<TextInput>(null)
const currentBreakpoint = useCurrentBreakpoint() const currentBreakpoint = useCurrentBreakpoint()
@ -238,7 +236,6 @@ const TableIssues = () => {
onChangeText={setIssuesSearchText} onChangeText={setIssuesSearchText}
variant="retractable" variant="retractable"
direction={currentBreakpoint === '2xl' ? 'rtl' : 'ltr'} direction={currentBreakpoint === '2xl' ? 'rtl' : 'ltr'}
ref={inputRef}
/> />
</div> </div>

View File

@ -12,7 +12,7 @@ import {
import { CheckIcon } from '@status-im/icons' import { CheckIcon } from '@status-im/icons'
import { Stack, styled } from '@tamagui/core' import { Stack, styled } from '@tamagui/core'
import { Checkbox } from '../selectors' import { Checkbox } from '../checkbox'
import { Text } from '../text' import { Text } from '../text'
interface Props { interface Props {

View File

@ -1,6 +1,7 @@
export * from './anchor-actions' export * from './anchor-actions'
export * from './avatar' export * from './avatar'
export * from './button' export * from './button'
export * from './checkbox'
export * from './community' export * from './community'
export * from './composer' export * from './composer'
export * from './context-tag' export * from './context-tag'

View File

@ -1,11 +1,10 @@
import { useEffect, useRef, useState } from 'react' import { useEffect, useState } from 'react'
import { SearchIcon } from '@status-im/icons' import { SearchIcon } from '@status-im/icons'
import { Input } from './input' import { Input } from './input'
import type { Meta, StoryObj } from '@storybook/react' import type { Meta, StoryObj } from '@storybook/react'
import type { TextInput } from 'react-native'
// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction // More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction
const meta: Meta<typeof Input> = { const meta: Meta<typeof Input> = {
@ -19,7 +18,6 @@ type Story = StoryObj<typeof Input>
export const Primary: Story = { export const Primary: Story = {
args: { args: {
placeholder: 'Type something...', placeholder: 'Type something...',
// children: 'Click me',
}, },
} }
@ -56,13 +54,9 @@ const InputSearch = () => {
const InputSearchMinimzed = () => { const InputSearchMinimzed = () => {
const [value, setValue] = useState('') const [value, setValue] = useState('')
const [isMinimized, setIsMinimized] = useState(true)
const inputRef = useRef<TextInput>(null)
return ( return (
<> <>
<Input <Input
onHandleMinimized={() => setIsMinimized(!isMinimized)}
placeholder="Please type something..." placeholder="Please type something..."
value={value} value={value}
onChangeText={setValue} onChangeText={setValue}
@ -70,8 +64,7 @@ const InputSearchMinimzed = () => {
onClear={() => setValue('')} onClear={() => setValue('')}
size={32} size={32}
direction="rtl" direction="rtl"
minimized={isMinimized} variant="retractable"
ref={inputRef}
/> />
</> </>
) )
@ -89,7 +82,6 @@ export const WithError: Story = {
args: { args: {
placeholder: 'Type something...', placeholder: 'Type something...',
error: true, error: true,
// children: 'Click me',
}, },
} }

View File

@ -1,5 +1,6 @@
import { cloneElement, forwardRef, useState } from 'react' import { cloneElement, forwardRef, useRef, useState } from 'react'
import { composeRefs } from '@radix-ui/react-compose-refs'
import { ClearIcon } from '@status-im/icons' import { ClearIcon } from '@status-im/icons'
import { setupReactNative, Stack, styled } from '@tamagui/core' import { setupReactNative, Stack, styled } from '@tamagui/core'
import { focusableInputHOC } from '@tamagui/focusable' import { focusableInputHOC } from '@tamagui/focusable'
@ -51,6 +52,8 @@ const _Input = (props: Props, ref: Ref<TextInput>) => {
const isRetractable = variant === 'retractable' const isRetractable = variant === 'retractable'
const inputRef = useRef<TextInput>(null)
return ( return (
<Stack flexDirection={direction === 'ltr' ? 'row' : 'row-reverse'}> <Stack flexDirection={direction === 'ltr' ? 'row' : 'row-reverse'}>
{Boolean(label || endLabel) && ( {Boolean(label || endLabel) && (
@ -80,7 +83,7 @@ const _Input = (props: Props, ref: Ref<TextInput>) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore ref is not inferred correctly here // @ts-ignore ref is not inferred correctly here
ref?.current?.focus() inputRef?.current?.focus()
} }
}} }}
> >
@ -91,7 +94,7 @@ const _Input = (props: Props, ref: Ref<TextInput>) => {
value={value} value={value}
placeholder={isMinimized && !value ? '' : placeholder} placeholder={isMinimized && !value ? '' : placeholder}
flex={1} flex={1}
ref={ref} ref={composeRefs(ref, inputRef)}
onBlur={() => { onBlur={() => {
if (!value && isRetractable && !isMinimized) { if (!value && isRetractable && !isMinimized) {
setIsMinimized(true) setIsMinimized(true)