Skip to content
This repository has been archived by the owner on Jun 7, 2022. It is now read-only.

Add ActivityCard component #86

Merged
merged 6 commits into from
May 25, 2018
Merged

Add ActivityCard component #86

merged 6 commits into from
May 25, 2018

Conversation

ryelle
Copy link
Member

@ryelle ryelle commented May 24, 2018

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:

screen shot 2018-05-24 at 11 52 04 am

To test

  • Check out the sidebar on any page
  • Should load the card as described in the issue/lofi designs

Copy link
Collaborator

@justinshreve justinshreve left a 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' );
Copy link
Collaborator

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.

Copy link
Member Author

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 {
Copy link
Collaborator

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.
Copy link
Collaborator

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?

Copy link
Member Author

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.

menu={ exampleEllipsisMenu }
actions={ [ <a href="/">View referral analytics</a> ] }
image={
<img src="https://vagrant.local/content/uploads/2017/05/beanie-150x150.jpg" alt="" />
Copy link
Collaborator

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).

Copy link
Member Author

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,
Copy link
Collaborator

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).

Copy link
Contributor

@timmyc timmyc left a 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" /> }
Copy link
Contributor

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"
Copy link
Contributor

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.

Copy link
Member Author

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.

@timmyc
Copy link
Contributor

timmyc commented May 24, 2018

/cc @jameskoster @josemarques for some design 👀

@timmyc timmyc added this to Needs Review in Isotope May 24, 2018
@jameskoster
Copy link
Member

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?

@ryelle
Copy link
Member Author

ryelle commented May 25, 2018

We're using Gridicons in our mocks but a different set is being used here

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 <Dashicon /> and <IconButton />) without jumping through hoops to use our own icons.

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
@ryelle
Copy link
Member Author

ryelle commented May 25, 2018

@timmyc @justinshreve I've made updates based on your feedback - thanks for the review 🙂

@ryelle ryelle force-pushed the add/component-activity-card branch from a05e2ac to fdec1d4 Compare May 25, 2018 14:54
Copy link
Contributor

@timmyc timmyc left a 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 👍

@ryelle ryelle merged commit 67c874f into master May 25, 2018
Isotope automation moved this from Needs Review to Done 2018-05-21 to 2018-05-27 May 25, 2018
@ryelle ryelle deleted the add/component-activity-card branch May 25, 2018 19:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants