-
Notifications
You must be signed in to change notification settings - Fork 208
feat(withComponent): add withComponent api #168
Conversation
Codecov Report
@@ Coverage Diff @@
## master #168 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 10 10
Lines 138 139 +1
Branches 35 35
=====================================
+ Hits 138 139 +1
Continue to review full report at Codecov.
|
src/create-glamorous.js
Outdated
function withComponent(newComp, options) { | ||
return glamorous(newComp, { | ||
forwardProps: GlamorousComponent.forwardProps, | ||
...options, |
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.
For some reason I always thought this would throw an exception when undefined
, but I see by your unit tests, that's not the case!
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.
Oh yeah, I would expect that to throw too 🤔
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.
Oh you know.. if you were to pass it as a rest parameter, i think that's when it might:
var obj = undefined
method(...obj)
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.
Makes sense to me. I defaulted it anyway just to illustrate intent (that it can be optionally provided) 👍
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.
That was interesting -- summarized: https://twitter.com/atticoos/status/872881844563447812
expect(View.displayName).toBe('View') | ||
}) | ||
|
||
test('4esulting component can have its styles extended further', () => { |
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.
Tiny typo :)
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.
DUDE! What are you doing here!? Good to have you around 🎉
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.
lol totally random. Thinking about converting a project to glamorous and was just poking around. 😆
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.
Nice. Well you're always welcome here :) Let us know how we can help you!
expect(View.displayName).toBe('View') | ||
}) | ||
|
||
test('4esulting component can have its styles extended further', () => { |
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.
Typo, unless we're moving tests to 1337 speak
@@ -606,6 +606,37 @@ const MyStyledComponent = glamorous(MyComponent, { | |||
// be forwarded to `MyComponent` because it is a valid prop for a `div`. | |||
``` | |||
|
|||
#### withComponent |
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.
Should we be seeing a diff for doctoc
in this file?
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.
No, we only go three levels deep for doctoc
.
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.
Ah, forgot we have a max depth!
1b69a29
to
d9ae37e
Compare
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.
Nice! Things look great.
Copied from #159 from @ansumanshah
What: Adds withComponent function as discussed in #135
Why: for changing the underlying component that's rendered :)
How:
Checklist:
Closes #135