Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
Release 0.0.43
Browse files Browse the repository at this point in the history
Restructured [EditText] and error fixes
  • Loading branch information
hyochan committed Feb 5, 2021
1 parent 05219bf commit 87e1f0e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CHANGELOGS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Changelogs

## 0.0.43

[EditText]

- Fixed hovering issue in `0.0.42` in `column` type. Also fixed where `hover` style should be applied. Previously it was a `container` but it should be applied to the first child `View`.

## 0.0.42

[EditText]
Expand Down
2 changes: 1 addition & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dooboo-ui",
"version": "0.0.42",
"version": "0.0.43",
"main": "index.js",
"types": "index.d.ts",
"author": "dooboolab",
Expand Down
11 changes: 4 additions & 7 deletions main/EditText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const Component: FC<EditTextProps & {theme: Theme}> = ({
}) => {
const [focused, setFocused] = useState(false);
const ref = useRef<View>(null);
const hovered = useHover(ref);

const borderColor = disableColor;
const labelColor = disableColor;
Expand All @@ -95,6 +96,7 @@ const Component: FC<EditTextProps & {theme: Theme}> = ({
hovered: [
{
borderBottomColor: hoveredColor,
borderBottomWidth: 1,
},
styles?.hovered,
],
Expand Down Expand Up @@ -183,23 +185,18 @@ const Component: FC<EditTextProps & {theme: Theme}> = ({
],
};

const hovered = useHover(ref);

return (
<View
testID="container-id"
ref={Platform.select({
web: ref,
default: undefined,
})}
style={[
editable && hovered && [compositeStyles.hovered, styles?.hovered],
{alignSelf: 'stretch', flexDirection: 'column'},
style,
]}>
style={[{alignSelf: 'stretch', flexDirection: 'column'}, style]}>
<View
style={[
compositeStyles.container,
editable && hovered && [compositeStyles.hovered, styles?.hovered],
{
borderColor: hovered
? hoverColor
Expand Down
13 changes: 8 additions & 5 deletions main/__tests__/EditText.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as React from 'react';

import {
RenderAPI,
act,
Expand All @@ -11,7 +9,9 @@ import {
import {EditText} from '../../main';
import type {EditTextProps} from '../../main/EditText';
import RNWebHooks from 'react-native-web-hooks';
import React from 'react';
import {ReactTestInstance} from 'react-test-renderer';
import {View} from 'react-native';

jest.mock('react-native-web-hooks', () => ({
useHover: () => false,
Expand Down Expand Up @@ -53,9 +53,12 @@ describe('[EditText]', () => {

container = await waitFor(() => testingLib.getByTestId('container-id'));

const containerCustomStyle = container.props.style[0][1];
const containerChildViewCustomStyle = container.findByType(View)
.instance.props.style[1][1];

expect(containerCustomStyle).toEqual({backgroundColor: 'green'});
expect(containerChildViewCustomStyle).toEqual({
backgroundColor: 'green',
});
});

describe('labeText', () => {
Expand Down Expand Up @@ -293,7 +296,7 @@ describe('[EditText]', () => {
});
});

// // Below tests is emitting console error but this is expeted
//? Below tests is emitting console error but this is expeted
describe('web', () => {
beforeAll(() => {
jest.mock('react-native/Libraries/Utilities/Platform', () => ({
Expand Down
8 changes: 4 additions & 4 deletions main/__tests__/__snapshots__/EditText.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ exports[`[EditText] interactions Type: [column] renders custom styles without cr
<View
style={
Array [
false,
Object {
"alignSelf": "stretch",
"flexDirection": "column",
Expand All @@ -27,6 +26,7 @@ exports[`[EditText] interactions Type: [column] renders custom styles without cr
},
Object {},
],
false,
Object {
"borderBottomColor": "#00000050",
"borderColor": "#00000050",
Expand Down Expand Up @@ -68,7 +68,6 @@ exports[`[EditText] interactions Type: [column] renders without crashing 1`] = `
<View
style={
Array [
false,
Object {
"alignSelf": "stretch",
"flexDirection": "column",
Expand All @@ -91,6 +90,7 @@ exports[`[EditText] interactions Type: [column] renders without crashing 1`] = `
},
undefined,
],
false,
Object {
"borderBottomColor": "#00000050",
"borderColor": "#00000050",
Expand Down Expand Up @@ -132,7 +132,6 @@ exports[`[EditText] interactions Type: [row] - default should render without cra
<View
style={
Array [
false,
Object {
"alignSelf": "stretch",
"flexDirection": "column",
Expand All @@ -156,6 +155,7 @@ exports[`[EditText] interactions Type: [row] - default should render without cra
},
undefined,
],
false,
Object {
"borderBottomColor": "#00000050",
"borderColor": "#00000050",
Expand Down Expand Up @@ -199,7 +199,6 @@ exports[`[EditText] interactions web renders without crashing 1`] = `
<View
style={
Array [
false,
Object {
"alignSelf": "stretch",
"flexDirection": "column",
Expand All @@ -222,6 +221,7 @@ exports[`[EditText] interactions web renders without crashing 1`] = `
},
undefined,
],
false,
Object {
"borderBottomColor": "#00000050",
"borderColor": "#00000050",
Expand Down
2 changes: 2 additions & 0 deletions stories/dooboo-ui/EditText.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const ColumnEditText = (): React.ReactElement => {
Sign in with Email
</Text>
<EditText
type="column"
labelText="email"
placeholder="[email protected]"
placeholderTextColor="#ADB5BD"
Expand All @@ -77,6 +78,7 @@ const ColumnEditText = (): React.ReactElement => {
onSubmitEditing={onSignIn}
/>
<EditText
type="column"
secureTextEntry={true}
labelText="Password"
placeholder="Write your password"
Expand Down

0 comments on commit 87e1f0e

Please sign in to comment.