-
Notifications
You must be signed in to change notification settings - Fork 53
feat(input): new Input component with 'input' slot #326
Conversation
12fee4f
to
aace092
Compare
8a2fc91
to
723fda5
Compare
a7241d4
to
4dad087
Compare
5686846
to
d519ba8
Compare
eeac1f1
to
ad25278
Compare
@levithomason @kuzhelov @miroslavstastny @mnajdova review needed |
Codecov Report
@@ Coverage Diff @@
## master #326 +/- ##
=========================================
+ Coverage 89.33% 89.94% +0.6%
=========================================
Files 64 64
Lines 1257 1253 -4
Branches 186 162 -24
=========================================
+ Hits 1123 1127 +4
+ Misses 131 123 -8
Partials 3 3
Continue to review full report at Codecov.
|
ad25278
to
e9a4381
Compare
it('sets correct "as" prop in defaultProps', () => { | ||
const as = 'span' | ||
const options = { testOption: 'test option value' } | ||
const createShorthandSpy = spyOn(lib, 'createShorthand') |
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.
here we are checking the implementation details - we should rather check method's result instead
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.
agreed with @kuzhelov to add the tests in the dedicated PR for Slot factory that's about to come
const createShorthandSpy = spyOn(lib, 'createShorthand') | ||
createSlotFactory(as, () => ({}))('testValue', { defaultProps: { as: asOverride } }) // clone of the options | ||
|
||
const optionsArg = createShorthandSpy.calls.mostRecent().args[3] |
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 test is very brittle - if the next day we will check the arguments that createShorthand
accepts, this will fail this test - while this failure won't surely guarantee that the logic of createSlotFactory
has become to be incorrect
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.
agreed with @kuzhelov to add the tests in the dedicated PR for Slot factory that's about to come
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.
addressed @kuzhelov 's comments
Note: Please provide all the initial feedback on the first review so I can address it from beginning. It'd be better not to start new conversations in the phase of addressing review comment (after initial code review from specific dev) unless there are code changes in that area, of course
docs/src/examples/components/Input/Variations/InputExampleTargeting.shorthand.tsx
Show resolved
Hide resolved
docs/src/examples/components/Input/Variations/InputExampleWrapperSlot.shorthand.tsx
Outdated
Show resolved
Hide resolved
docs/src/examples/components/Input/Variations/InputExampleWrapperSlot.shorthand.tsx
Outdated
Show resolved
Hide resolved
@@ -21,6 +21,7 @@ class ComposeMessage extends React.Component { | |||
<Input | |||
fluid | |||
placeholder="Type a message" | |||
input={{ styles: { height: '44px' } }} |
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, done, thx
55bd7b1
to
62bb49a
Compare
62bb49a
to
8ed8347
Compare
0d442e6
to
78503f9
Compare
78503f9
to
93156c3
Compare
[RFC] Input
New input component according following the strategy in #314 (closes #314)
This PR contains:
input
andwrapper
slots);Slot
factoryv1
;Slot
factory,input
andwrapper
slots forInput
component,controlled
/uncontrolled
mode forInput
, etcTODO
Proposed solution
Input
component consisting of an<input />
element wrapped with a<div />
;partitionHTMLProps
to decide whatprops
(<Input {...props} />
) go to the<input />
element or wrapping<div />
;input
slot to target the<input />
element andwrapper
slot to target wrapping<div />
whenpartitionHTMLProps
does not work as expected:e.g.:
Input
component has the following structure:Props:
API
e.g.:
Component structure
DOM structure
This will solve all the scenarios mentioned above in the following fashion:
1. Styling the
<input />
2. Setting HTML attributes for the
<input />
3. Setting HTML attributes for the wrapping
<div />
Rendered component: