Skip to content

Commit

Permalink
Merge pull request #76 from pennlabs/normal-tags
Browse files Browse the repository at this point in the history
Kill Club Card Tag Filtering
  • Loading branch information
Cameron Cabo committed Jan 14, 2020
2 parents 92b0c0d + 09df0a7 commit 2209b87
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 75 deletions.
8 changes: 1 addition & 7 deletions frontend/components/ClubCard.js
Expand Up @@ -85,8 +85,6 @@ const ClubCard = ({
club,
updateFavorites,
favorite,
selectedTags,
updateTag,
}) => {
const {
name,
Expand Down Expand Up @@ -119,11 +117,7 @@ const ClubCard = ({
{!active && (
<InactiveTag className="tag is-rounded">Inactive</InactiveTag>
)}
<TagGroup
tags={tags}
selectedTags={selectedTags}
updateTag={updateTag}
/>
<TagGroup tags={tags} />
</div>
{img && (
<LazyLoad height={62} offset={800}>
Expand Down
6 changes: 0 additions & 6 deletions frontend/components/ClubDisplay.js
Expand Up @@ -55,8 +55,6 @@ class ClubDisplay extends React.Component {
favorites,
updateFavorites,
display,
updateTag,
selectedTags,
} = this.props
const clubsToShow = displayClubs.slice(0, this.state.end)

Expand All @@ -68,8 +66,6 @@ class ClubDisplay extends React.Component {
key={club.code}
club={club}
tags={tags}
selectedTags={selectedTags}
updateTag={updateTag}
updateFavorites={updateFavorites}
favorite={favorites.includes(club.code)}
/>
Expand All @@ -85,8 +81,6 @@ class ClubDisplay extends React.Component {
club={club}
key={club.code}
tags={tags}
selectedTags={selectedTags}
updateTag={updateTag}
updateFavorites={updateFavorites}
favorite={favorites.includes(club.code)}
/>
Expand Down
8 changes: 1 addition & 7 deletions frontend/components/ClubTableRow.js
Expand Up @@ -76,8 +76,6 @@ class ClubTableRow extends React.Component {
club,
updateFavorites,
favorite,
selectedTags,
updateTag,
} = this.props
const {
name,
Expand All @@ -98,11 +96,7 @@ class ClubTableRow extends React.Component {
<div className="column is-4-desktop is-12-mobile">
<Name>{name}</Name>
<div>
<TagGroup
tags={tags}
selectedTags={selectedTags}
updateTag={updateTag}
/>
<TagGroup tags={tags} />
</div>
</div>
<div className="column is-8-desktop is-12-mobile">
Expand Down
60 changes: 7 additions & 53 deletions frontend/components/common/TagGroup.js
@@ -1,62 +1,22 @@
import PropTypes from 'prop-types'
import { BlueTag, SelectedTag } from './Tags'
import { BlueTag } from './Tags'

export const TagGroup = ({ tags = [], selectedTags = [], updateTag }) => {
export const TagGroup = ({ tags = [] }) => {
if (!tags || !tags.length) return null

// TODO: Use same tag format between DropdownFilter and TagGroup
return tags.map(tag => {
const matchedTag = selectedTags.find(
({ value, name: filterType }) => filterType === 'Type' && value === tag.id
)
const key = `${tag.id}-${tag.value}`
if (matchedTag) {
return (
<SelectedTag
key={key}
className="tag is-rounded has-text-white"
onClick={e => {
// Prevent click event from propagating so clicking on the tag doesn't
// fire the generic club handle click
e.preventDefault()
e.stopPropagation()
updateTag && updateTag(matchedTag, matchedTag.name)
}}
>
{tag.name}
<button className="delete is-small" />
</SelectedTag>
)
}
return (
return <>
{tags.map(tag => (
<BlueTag
key={key}
key={`${tag.id}-${tag.value}`}
className="tag is-rounded has-text-white"
onClick={e => {
// Stop propagation of click event for same reasons as above
e.preventDefault()
e.stopPropagation()
updateTag &&
updateTag(
{
value: tag.id,
label: tag.name,
name: 'Type',
},
'Type'
)
}}
>
{tag.name}
</BlueTag>
)
})
))}
</>
}

TagGroup.defaultProps = {
selectedTags: [],
tags: [],
updateTag: undefined,
}

TagGroup.propTypes = {
Expand All @@ -66,10 +26,4 @@ TagGroup.propTypes = {
id: PropTypes.number,
})
),
selectedTags: PropTypes.arrayOf(
PropTypes.shape({
value: PropTypes.string,
})
),
updateTag: PropTypes.func,
}
2 changes: 0 additions & 2 deletions frontend/pages/index.js
Expand Up @@ -288,8 +288,6 @@ class Splash extends React.Component {
tags={tags}
favorites={favorites}
updateFavorites={updateFavorites}
selectedTags={selectedTags}
updateTag={this.updateTag.bind(this)}
/>
</WideContainer>
</Container>
Expand Down

0 comments on commit 2209b87

Please sign in to comment.