From f480e34f679522ef165d0aafc5ce5588a71cd593 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 18 Aug 2018 14:38:36 +0200 Subject: [PATCH] Created TagCard and DeleteTagConfirmModal components --- src/servers/DeleteServerModal.js | 2 +- src/tags/TagCard.js | 59 +++++++++++++++++++++++ src/tags/{TagsList.scss => TagCard.scss} | 12 ++--- src/tags/TagsList.js | 36 +++----------- src/tags/helpers/DeleteTagConfirmModal.js | 28 +++++++++++ 5 files changed, 100 insertions(+), 37 deletions(-) create mode 100644 src/tags/TagCard.js rename src/tags/{TagsList.scss => TagCard.scss} (66%) create mode 100644 src/tags/helpers/DeleteTagConfirmModal.js diff --git a/src/servers/DeleteServerModal.js b/src/servers/DeleteServerModal.js index ed1c4c65..419e6a33 100644 --- a/src/servers/DeleteServerModal.js +++ b/src/servers/DeleteServerModal.js @@ -15,7 +15,7 @@ export const DeleteServerModal = ({ server, toggle, isOpen, deleteServer, histor }; return ( - + Delete server

Are you sure you want to delete server {server ? server.name : ''}?

diff --git a/src/tags/TagCard.js b/src/tags/TagCard.js new file mode 100644 index 00000000..5f5a79a0 --- /dev/null +++ b/src/tags/TagCard.js @@ -0,0 +1,59 @@ +import { Card, CardBody } from 'reactstrap'; +import FontAwesomeIcon from '@fortawesome/react-fontawesome'; +import deleteIcon from '@fortawesome/fontawesome-free-solid/faTrash'; +import editIcon from '@fortawesome/fontawesome-free-solid/faPencilAlt'; +import DeleteTagConfirmModal from './helpers/DeleteTagConfirmModal'; +import PropTypes from 'prop-types'; +import React from 'react'; +import ColorGenerator, { colorGeneratorType } from '../utils/ColorGenerator'; +import './TagCard.scss'; + +const propTypes = { + tag: PropTypes.string, + colorGenerator: colorGeneratorType, +}; +const defaultProps = { + colorGenerator: ColorGenerator, +}; + +export default class TagCard extends React.Component { + state = { isDeleteModalOpen: false, isEditModalOpen: false }; + + render() { + const { tag, colorGenerator } = this.props; + const toggleDelete = () => + this.setState({ isDeleteModalOpen: !this.state.isDeleteModalOpen }); + + return ( + + + + +
+
+ {tag} +
+
+ + +
+ ); + } +} + +TagCard.propTypes = propTypes; +TagCard.defaultProps = defaultProps; diff --git a/src/tags/TagsList.scss b/src/tags/TagCard.scss similarity index 66% rename from src/tags/TagsList.scss rename to src/tags/TagCard.scss index f06e5a61..a2861ff6 100644 --- a/src/tags/TagsList.scss +++ b/src/tags/TagCard.scss @@ -1,12 +1,12 @@ -.tags-list__tag-card.tags-list__tag-card { +.tag-card.tag-card { background-color: #eeeeee; margin-bottom: .5rem; } -.tags-list__tag-card-body.tags-list__tag-card-body { +.tag-card__body.tag-card__body { padding: .75rem; } -.tags-list__tag-title { +.tag-card__tag-title { margin: 0; line-height: 31px; text-overflow: ellipsis; @@ -15,7 +15,7 @@ padding-right: 5px; } -.tags-list__tag-bullet { +.tag-card__tag-bullet { $width: 20px; border-radius: 50%; width: $width; @@ -25,9 +25,9 @@ margin-right: 7px; } -.tags-list__btn { +.tag-card__btn { float: right; } -.tags-list__btn:not(:last-child) { +.tag-card__btn:not(:last-child) { margin-left: 2px; } diff --git a/src/tags/TagsList.js b/src/tags/TagsList.js index df5accf7..b6b5e3b3 100644 --- a/src/tags/TagsList.js +++ b/src/tags/TagsList.js @@ -2,24 +2,21 @@ import React from 'react'; import { connect } from 'react-redux'; import { pick, splitEvery } from 'ramda'; import { listTags } from './reducers/tagsList'; -import { Card, CardBody } from 'reactstrap'; -import ColorGenerator from '../utils/ColorGenerator'; import MuttedMessage from '../utils/MuttedMessage'; -import editIcon from '@fortawesome/fontawesome-free-solid/faPencilAlt'; -import deleteIcon from '@fortawesome/fontawesome-free-solid/faTrash'; -import FontAwesomeIcon from '@fortawesome/react-fontawesome'; -import './TagsList.scss'; +import TagCard from './TagCard'; const { round } = Math; export class TagsList extends React.Component { + state = { isDeleteModalOpen: false }; + componentDidMount() { const { listTags } = this.props; listTags(); } renderContent() { - const { tagsList, colorGenerator } = this.props; + const { tagsList } = this.props; if (tagsList.loading) { return Loading... } @@ -34,29 +31,12 @@ export class TagsList extends React.Component { } const tagsGroups = splitEvery(round(tagsCount / 4), tagsList.tags); + return ( {tagsGroups.map((group, index) => (
- {group.map(tag => ( - - - - -
-
- {tag} -
-
-
- ))} + {group.map(tag => )}
))}
@@ -74,8 +54,4 @@ export class TagsList extends React.Component { } } -TagsList.defaultProps = { - colorGenerator: ColorGenerator -}; - export default connect(pick(['tagsList']), { listTags })(TagsList); diff --git a/src/tags/helpers/DeleteTagConfirmModal.js b/src/tags/helpers/DeleteTagConfirmModal.js new file mode 100644 index 00000000..b4df93ad --- /dev/null +++ b/src/tags/helpers/DeleteTagConfirmModal.js @@ -0,0 +1,28 @@ +import React from 'react'; +import { Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap'; +import PropTypes from 'prop-types'; + +const propTypes = { + tag: PropTypes.string.isRequired, + toggle: PropTypes.func.isRequired, + isOpen: PropTypes.bool.isRequired, +}; + +export default function DeleteTagConfirmModal({ tag, toggle, isOpen }) { + return ( + + + Delete tag + + + Are you sure you want to delete tag {tag}? + + + + + + + ); +} + +DeleteTagConfirmModal.propTypes = propTypes;