-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
149 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import FontAwesome from 'react-fontawesome'; | ||
|
||
const Tag = ({ tag, children }) => ( | ||
<h6 key={tag} className={`tag tag--${tag}`}> | ||
{tag === 'game' && | ||
<FontAwesome name="gamepad" /> | ||
} | ||
{tag === 'cancelled' && | ||
<FontAwesome name="ban" /> | ||
} | ||
{tag === 'article' && | ||
<FontAwesome name="book" /> | ||
} | ||
{tag === 'open-source' && | ||
<FontAwesome name="code-fork" /> | ||
} | ||
{tag === 'music' && | ||
<FontAwesome name="music" /> | ||
} | ||
{tag === 'podcast' && | ||
<FontAwesome name="podcast" /> | ||
} | ||
{tag === 'video' && | ||
<FontAwesome name="youtube-play" /> | ||
} | ||
{tag === 'collaboration' && | ||
<FontAwesome name="users" /> | ||
} | ||
{tag === 'in-development' && | ||
<FontAwesome name="edit" /> | ||
} | ||
{tag === 'clear' && | ||
<FontAwesome name="times-circle" /> | ||
} | ||
{children} | ||
</h6> | ||
); | ||
|
||
export default Tag; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
import { findIndex, orderBy } from 'lodash'; | ||
import { connect } from 'react-redux'; | ||
import Tag from './Tag'; | ||
import projects from '../data/projects.json'; | ||
import { setFilter, clearFilter } from '../actions/projects'; | ||
import './styles/TagFilter.css'; | ||
|
||
const TagFilter = ({ dispatch }) => { | ||
let tags = []; | ||
projects.forEach((project) => { | ||
project.tags.forEach((tag) => { | ||
const tagIndex = findIndex(tags, { name: tag }); | ||
if (tagIndex === -1) { | ||
tags.push({ name: tag, count: 1 }); | ||
} else { | ||
const currentTag = tags[tagIndex]; | ||
tags[tagIndex] = { name: tag, count: currentTag.count + 1 }; | ||
} | ||
}); | ||
}); | ||
tags = orderBy(tags, ['count', 'name'], ['desc', 'asc']); | ||
return ( | ||
<div className="tagfilter"> | ||
{tags.map((tag) => ( | ||
<a key={tag.name} onClick={() => { dispatch(setFilter(tag.name)) }}> | ||
<Tag tag={tag.name}> | ||
{tag.name} ({tag.count}) | ||
</Tag> | ||
</a> | ||
))} | ||
<a onClick={() => { dispatch(clearFilter()) }}> | ||
<Tag tag="clear"> | ||
clear | ||
</Tag> | ||
</a> | ||
</div> | ||
); | ||
}; | ||
|
||
export default connect()(TagFilter); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
.infobox-small { | ||
position: fixed; | ||
top: 0; | ||
bottom: 0; | ||
right: 0; | ||
display: flex; | ||
align-items: center; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.tagfilter { | ||
margin: 1rem 0; | ||
} | ||
|
||
.tagfilter .tag { | ||
margin: 2px; | ||
} | ||
|
||
.tagfilter .tag.tag--clear { | ||
border-color: #ff6666; | ||
color: #ff6666; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters