-
Notifications
You must be signed in to change notification settings - Fork 147
Conversation
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.
A few minor comments/questions. This is looking really great though (both code + and the demo).
class ActivityCard extends Component { | ||
render() { | ||
const { actions, date, icon, image, label, menu, children } = this.props; | ||
const className = classnames( 'woo-dash__activity-card' ); |
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 we want to accept an optional className prop? Otherwise you could just pass in the name directly below and not need to import classnames
.
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 added a className prop but we still might not need classnames… I think i'm going to leave it as-is in case we need it for the hifi design (if we need to add classes depending on what props are used, for example).
} | ||
} | ||
|
||
@mixin hover-state { |
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.
👍
* `label`: A title for this card (required). | ||
* `children`: Content used in the body of the action card (required). | ||
* `actions`: A list of links or buttons shown in the footer of the card. | ||
* `date`: The timestamp associated with this activity. |
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 format do you think we'll expect for date
here? I see the @TODO Use @wordpress/date to format the date
comment below, so will this be the actual date from the API and the component will return the relative 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.
It can depend on what the API returns, I guess -- I was thinking it would be just a timestamp, and we would convert to a relative time in the component. moment can accept a lot of different date formats, but most of the other dates in API responses are like 2018-04-24T14:44:15
.
client/layout/sidebar/activity.js
Outdated
menu={ exampleEllipsisMenu } | ||
actions={ [ <a href="/">View referral analytics</a> ] } | ||
image={ | ||
<img src="https://vagrant.local/content/uploads/2017/05/beanie-150x150.jpg" alt="" /> |
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.
Minor since this is just an example, but can we link to a .com image or something? Otherwise the console will throw a 404 (and no demo 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.
Yep, I meant to swap that out before making the PR.... then forgot. Thanks for catching.
|
||
ActivityCard.propTypes = { | ||
actions: PropTypes.oneOfType( [ PropTypes.array, PropTypes.element ] ), | ||
children: PropTypes.node, |
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 should have an .isRequired
since I don't think we'll want empty cards (and it's documented as required in the README).
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 is looking good and testing out nicely for me - nice work!
return ( | ||
<ActivityCard | ||
label="Insight" | ||
icon={ <Dashicon icon="search" /> } |
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 like the flexibility of allowing an img or dashicon component here and in the image below - nice!
<ActivityCard | ||
label="Insight" | ||
icon={ <Dashicon icon="search" /> } | ||
date="30 minutes ago" |
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.
Building off @justinshreve's question above about date format - i could see the date coming in as a timestamp and using moment.js to do "time ago in words" here.
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.
Yep, that's the idea 🙂 using moment from @wordpress/date
so that we can get the correct timezone settings.
/cc @jameskoster @josemarques for some design 👀 |
Looks good to me. We're using Gridicons in our mocks but a different set is being used here. I assume this set is already available so it makes sense to use it, I'm just concerned we'll run in to an issue where a corresponding icon isn't available. Is it a big pain to load Gridicons? |
I was wondering if that was going to come up soon :) I was planning on asking about it next meeting. We're using dashicons because that's what core is using, and so we can use their components (like Here's a dashicons resource page, though AFAIK it's not totally up to date with everything added for Gutenberg. Checking out the list of SVGs is a better reference. |
- Add className prop - children propType is required - Link to a real image
@timmyc @justinshreve I've made updates based on your feedback - thanks for the review 🙂 |
a05e2ac
to
fdec1d4
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.
Changes look good to me 👍
Fixes #48 – this PR adds a new component ActivityCard. You can check out the README for more details. I've also temporarily added an
ActivityList
component into the sidebar, this might stay or not depending on how we fetch the activities, I think. So you can see 3 demo activities in the sidebar:To test