-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feed: add component #363
Feed: add component #363
Conversation
Current coverage is 94.40% (diff: 100%)@@ master #363 diff @@
==========================================
Files 74 84 +10
Lines 960 1055 +95
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 901 996 +95
Misses 59 59
Partials 0 0
|
Note on docs, I've updated the doc example logic and file naming patterns. Doc files are now organized like so:
You can still put all the examples in the root |
@levithomason Did I correctly named doc files? |
The naming is only dictated for the |
It seems we're ready for initial discussion 😄
<a class="like">
<i class="like icon"></i> 4 Likes
</a>
const events = [
{ content: 'Text' },
...
]
() => <Feed events={events}> Something else? 😄 |
@davezuko and I had an offline discussion regarding similar difficulties with sub components in the Message component PR. I'm out today but will check back tonight or tomorrow and give an update. |
Indeed. I'll take any better ideas on how to improve this. Either way, once we get all the components in, we'll revisit these and see if we can optimize them. We may be able to reuse a single set of component parts. I want to get all the components completed with explicit parts before we start to optimize though. This way we can see all the requirements of all the components before making final decisions on how it should be optimized. If you have any ideas or suggestions, please add them to #345 where this is being worked on.
Makes sense to me. I think the user should be able to pick the icon as well.
It looks like this Side note, I plan on improving the icon/prop renderers a bit. Right now they accept either an icon name or image src, or an Icon or Image element. I think it would be good to allow a string (name/src), a plain props object (
The Regarding shorthand for images, we could accept an array of image
Makes sense to me. Seems a component is component parts should allow a props to configure those parts.
I also thinks this also makes great sense. Just like
Probably! 😄 This is a really great start though, let's keep momentum and just tackle these items for now. |
} | ||
|
||
Feed._meta = { | ||
library: META.library.semanticUI, |
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.
Heads up, I've deprecated library as of today in #380. See that PR for rationale. There is also a failing test for including it now.
Updated.
Nevermind 😄
There is problem with key handling. TAL on |
Sorry, not sure what |
} | ||
|
||
const imagesJSX = images.map((image, index) => { | ||
const key = `${index}` |
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 might be key for image, when image is string? And what when is object?
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.
How about the image src
as it is required and will be unique?
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.
In docs src's are same (/images/wireframe/image.png
), so I have:
How I can deal with this, when I have element at input?
const images = [<img src='http://semantic-ui.com/images/wireframe/image.png' />, ...];
const imagesJSX = images.map(image => {
return _.isString(image) ? <img key={image} src={image} /> : image
})
I think that React.cloneElement(image, {key: image.src})
is smelly solution.
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.
Hm, I see.
/cc @davezuko we we're just talking about weak-key
, here we have an array of objects with possibly no unique key/value pairs. Ideas for generating unique React keys?
EDIT
I prefer not to add the polyfill for WeakMaps...
Seems, docs and components finished. I'll start writting test after review. So, feedback is welcome 😄 |
5628698
to
5276567
Compare
@@ -39,7 +39,7 @@ const Date = () => { | |||
<Feed.Label image={imageSrc} /> | |||
<Feed.Content | |||
date='3 days ago' | |||
summary={<span>You added <a>Jenny Hess</a> to your <a>coworker</a> group.</span>} | |||
summary='You added Jenny Hess to your coworker group.' |
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.
Reduced all shorthand props, except icon/image, to strings only.
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.
Updated, take a look at the last commit and comments. |
Thanks for review, all is nice, I'll fix it soon and add tests. |
Oh, I missed that you've already applied all 😸 Working on tests, seems we can merge it today. |
Awesome, I've got the Modal updates and docs done. It was blocked by the Image, so finishing that up as well. |
|
||
if (Array.isArray(images)) { | ||
const imagesJSX = images.map((image, i) => { | ||
return _.isString(image) ? <img key={i} src={image} /> : image |
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.
@levithomason It seems that you like antipattern with key
more than I 😆
I think:
- allow pass only string, not nodes;
- use pair of
index
andsrc
.
Better ideas?
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.
@levithomason It seems that you like antipattern with key more than I 😆
I must admit, I once took it very lightly :S
- allow pass only string, not nodes;
- use pair of index and src.
There is a chance that the strings might be the same, for instance a placeholder image for multiple images. Also, adding index into the string will affectively do the same thing as having an index only, since the key changes when the child order changes. We would need to accept objects in order to accept a key
: images={[{key: 'foo', src: '...'}]}
.
I think for now, we allow a string only and fix the duplicate image src string edge case if it arises.
I think I blurted out too much about today 😢 |
No worries, I'll review once tests are in then. Thanks. |
Heads up, I've done some heavy utils refactoring in #388. I left many comments there to help get up to speed. That PR greatly improved things and unblocks the Image and Modal work. Really glad with the results and I think you will be too after updating. LMK if you have any questions. I'll leave comments on this PR where it needs updated to meet the new refactors later tonight. |
774d504
to
51da3e3
Compare
I updated this PR to use the new utils. It might be a good idea to familiarize yourself with the changes made in the last commit. I also fixed tests and lint issues. I'm not sure why PhantomJS is crashing in watch mode though. The branch was doing that before the updates. Master branch does not crash. Looking into it. |
Suddenly after the rebase test watching is working again. LMK if you have any issues. |
Offtop: Did you have issues with PhantomJS's crash, too? Feed.jsI've updated const eventsJSX = events.map(eventProps => {
const { childKey, date, meta, summary, ...eventData } = eventProps
const finalKey = childKey || `${date}-${meta}-${summary}`
return <FeedEvent
date={date}
key={finalKey}
meta={meta}
summary={summary}
{...eventData}
/>
}) FeedExtra.js
- PropTypes.arrayOf(PropTypes.node),
+ PropTypes.arrayOf(PropTypes.string),
const imagesJSX = images.map((image, index) => {
const key = [index, image].join('-')
return createImg(image, {key})
}) FeedLabel-test.jsAre tests for Tests are ready. Show must go on 👻 |
Indeed, not sure what fixed it in the rebase but it seems to be fine now?
We'll have to pick a different prop name as |
date={date} | ||
key={finalKey} | ||
meta={meta} | ||
summary={summary} | ||
{...eventData} | ||
/> | ||
/>) |
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.
Indent issue here, needs some new lines inserted.
FeedExtra 👍 FeedLabel-test 👍 though, we'll need to update the |
Yep.
events: customPropTypes.every([
PropTypes.arrayOf(PropTypes.shape({
childKey: PropTypes.string,
})),
]),
??? Not understand you there. |
What you've done for FeedEvent is correct. My comment was in regard to passing a // on an element
const image = <img childKey='...' src='...' />
<FeedLabel image={image} />
// or a props object (this is a new feature of our factories)
<FeedLabel image={{ childKey='...', src='...' }} Our factories are responsible for merging those props by default. Currently, they will simply pass the This work can be done on a separate PR though to keep this one moving. |
Anything else to update here? Looks great. I'd like to merge and make any updates on future PRs. |
No, we can go 🚗 |
💥 Released in |
* feat(Feed) Initial commit * feat(Feed) Docs and components update * feat(Feed) Docs and components update * feat(Feed) More docs and components * feat(Feed) Remove meta.library * feat(Feed) Update prop handling * feat(Feed) Update prop handling * feat(Feed) More shorthands * refactor(Feed): use string shorthand props * feat(Feed) Update prop handling and tests * fix(Feed) More tests * refactor(Feed): update to refactored utils * fix(Feed) Fixes and more tests * fix(Feed) Lint issues * fix(Feed) Update lint issues
WIP
http://semantic-ui.com/views/feed.html
Fixes #188