From ea9923e0c85024e475a2b62fb499d26de34d1ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1ssio=20Zen?= Date: Tue, 12 Jul 2016 17:03:39 -0300 Subject: [PATCH] content Cards refactor --- example/config.yml | 2 +- src/components/Cards.js | 4 ++-- src/components/Cards/ImageCard.js | 22 ++++++++++++++++++++++ src/components/Cards/MediaCard.js | 16 ---------------- src/components/EntryListing.js | 4 ++-- src/containers/CollectionPage.js | 7 ------- 6 files changed, 27 insertions(+), 28 deletions(-) create mode 100644 src/components/Cards/ImageCard.js delete mode 100644 src/components/Cards/MediaCard.js diff --git a/example/config.yml b/example/config.yml index 9f45f06d..a930e59b 100644 --- a/example/config.yml +++ b/example/config.yml @@ -17,7 +17,7 @@ collections: # A list of collections the CMS should be able to edit meta: - {label: "Publish Date", name: "date", widget: "datetime", format: "YYYY-MM-DD hh:mma"} - {label: "SEO Description", name: "description", widget: "text"} - card: {type: "media", media: "image", text: "title"} + card: {type: "image", image: "image", text: "title"} - name: "faq" # Used in routes, ie.: /admin/collections/:slug/edit label: "FAQ" # Used in the UI, ie.: "New Post" diff --git a/src/components/Cards.js b/src/components/Cards.js index ba455280..ab903e2b 100644 --- a/src/components/Cards.js +++ b/src/components/Cards.js @@ -1,10 +1,10 @@ import UnknownCard from './Cards/UnknownCard'; -import MediaCard from './Cards/MediaCard'; +import ImageCard from './Cards/ImageCard'; import AlltypeCard from './Cards/AlltypeCard'; const Cards = { _unknown: UnknownCard, - media: MediaCard, + image: ImageCard, alltype: AlltypeCard }; diff --git a/src/components/Cards/ImageCard.js b/src/components/Cards/ImageCard.js new file mode 100644 index 00000000..001bf391 --- /dev/null +++ b/src/components/Cards/ImageCard.js @@ -0,0 +1,22 @@ +import React, { PropTypes } from 'react'; +import { Card } from '../UI'; + +export default function ImageCard({ onClick, image, text }) { + return ( + + +

{text}

+
+ ); +} + +ImageCard.propTypes = { + image: PropTypes.string.isRequired, + + onClick: PropTypes.func, + text: PropTypes.string.isRequired +}; + +ImageCard.defaultProps = { + onClick: function() {}, +}; diff --git a/src/components/Cards/MediaCard.js b/src/components/Cards/MediaCard.js deleted file mode 100644 index fbb10e49..00000000 --- a/src/components/Cards/MediaCard.js +++ /dev/null @@ -1,16 +0,0 @@ -import React, { PropTypes } from 'react'; -import { Card } from '../UI'; - -export default function MediaCard({ onClick, media, text }) { - return ( - - -

{text}

-
- ); -} - -MediaCard.propTypes = { - media: PropTypes.string.isRequired, - text: PropTypes.string.isRequired -}; diff --git a/src/components/EntryListing.js b/src/components/EntryListing.js index d45378ea..beed5b30 100644 --- a/src/components/EntryListing.js +++ b/src/components/EntryListing.js @@ -58,7 +58,7 @@ export default class EntryListing extends React.Component { collection: collection, onClick: browserHistory.push.bind(this, link), text: entry.getIn(['data', collection.getIn(['card', 'text'])]), - media: entry.getIn(['data', collection.getIn(['card', 'media'])]), + image: entry.getIn(['data', collection.getIn(['card', 'image'])]), }); } @@ -67,7 +67,7 @@ export default class EntryListing extends React.Component { const name = collection.get('name'); return
-

Listing entries!

+

Listing {name}

this._entries = c}> {entries.map((entry) => { const path = `/collections/${name}/entries/${entry.get('slug')}`; diff --git a/src/containers/CollectionPage.js b/src/containers/CollectionPage.js index 8d8b12b4..d7e43ea9 100644 --- a/src/containers/CollectionPage.js +++ b/src/containers/CollectionPage.js @@ -30,13 +30,6 @@ class DashboardPage extends React.Component { return

Dashboard

-
- {collections.map((collection) => ( -
- {collection.get('name')} -
- )).toArray()} -
{entries ? : 'Loading entries...'}