-
Notifications
You must be signed in to change notification settings - Fork 2
Conversation
34cc212
to
18de489
Compare
Deploy preview for kiwicom-universal-components ready! Built with commit 0bc5c1c https://deploy-preview-177--kiwicom-universal-components.netlify.com |
4ffe572
to
33c3f73
Compare
Finally, the MR is ready, it was tricky find way how to handle it with one code because of differences between web input and native input. I created the hidden element (sizer) and based on it I count the input width. It is kind of hacky but I can't find a better solution. So pls check it properly I spent a lot of the time on it so maby I missed something. Thanks |
33c3f73
to
add74b7
Compare
add74b7
to
1ac1014
Compare
1ac1014
to
5ceae12
Compare
Issue with test fixed |
@@ -1085,6 +1106,13 @@ | |||
5C04BEA7D09C4DC4B05BB661 /* Roboto-MediumItalic.ttf in Resources */, | |||
90151CF9607749A28BB60FDD /* Roboto-Regular.ttf in Resources */, | |||
F9A904A78F284EE6989903AF /* orbit-icons.ttf in Resources */, | |||
D88FDFB084E3435482711AB1 /* orbit-icons.ttf in Resources */, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think this is related to your recent tests fix update? I'm just wondering why all fonts were added to xcode
project for a second time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, could you try to remove this file from the commit and see if you can still run the storybook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am working on it
src/TagsInput/TagsInput.js
Outdated
}; | ||
|
||
class TagInput extends React.Component<Props, State> { | ||
inputRef: any; // @TODO find a way how to type this properly, the issue with mixing react and react-native |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are using react > v16.3, so that could be helpful: https://reactjs.org/docs/refs-and-the-dom.html#creating-refs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the first approach what I tried but, it didn't work.
src/TagsInput/TagsInput.js
Outdated
if (containerWidth && width) { | ||
return containerWidth - width; | ||
} | ||
return undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've always been told that it was better to return null
than undefined
, as null
meant value could not be set instead of being undefined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, just there is another side of the coin, https://youtu.be/rhV6hlL_wMc?t=1326 😄
But I will change it as you suggest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the reference, I think he's got some very valid points. If we feel strongly about this, then we should enforce it.
src/TagsInput/TagsInput.js
Outdated
getWidth = (width: ?number) => { | ||
const { containerWidth } = this.state; | ||
if (containerWidth && width) { | ||
return containerWidth - width; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if you get a negative result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can't happen I suppose, in the current use-case.
It can be zero but not negative.
} | ||
|
||
return ( | ||
<View> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this wrapping necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, I need it for the web, if I don't use it break how overflow works
style={[styles.container, styles.row, { maxWidth }]} | ||
showsHorizontalScrollIndicator={false} | ||
contentContainerStyle={{ | ||
alignItems: 'center', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you extract the style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we might need to address how our StyleSheet.create
works, compared to RN's native one. Or use StyleSheet.create
from RN implementation.
@tbergq What do you think about this issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I played with the flow for while but without success so I decided to use StyleSheet.create from RN implementation.
73ce31e
to
dbe9b6d
Compare
src/TagsInput/TagsInput.js
Outdated
// $FlowFixMe property focus is missing in object type | ||
Platform.OS === 'web' && this.inputRef.current.focus(); | ||
|
||
if (onClearPress) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you can even do onClearPress?.()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, I have been learned something new.
src/TagsInput/TagsInput.js
Outdated
fontSize={fontSize} | ||
disabled={disabled} | ||
minWidth={MIN_WIDTH} | ||
maxWidth={this.getWidth(MIN_WIDTH)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the naming could be improved here: why is maxWidth
linked to MIN_WIDTH
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of in the getWidth method I subtract passing param, in this case, MIN_WIDTH from the width of the whole container.
And because TagsContainer minWidth is also MIN_WIDTH, maxWidth of the InputField must respect this.
I will try to improve it to something more readable.
|}; | ||
|
||
type State = {| | ||
componentWidth: number | string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
componentWidth: number | string, | |
componentWidth: number | 'auto', |
That's the only string that's allowed, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot see it added now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
}, | ||
input: { | ||
web: { | ||
outline: 'none', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be a problem for accessibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've improved website design. An inspiration I took from kiwi.com
dbe9b6d
to
f35dd03
Compare
Summary: Created TagsInput component. Added tests and Storybook's stories for the TagsInput.
f35dd03
to
0bc5c1c
Compare
No description provided.