Skip to content

Commit

Permalink
feat(#15): create & apply TagBadge component
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayank0255 committed Nov 4, 2020
1 parent 41d5cfb commit ff24133
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 40 deletions.
14 changes: 14 additions & 0 deletions client/src/components/TagBadge/TagBadge.component.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React, { Fragment } from "react";
import { Link } from "react-router-dom";

const TagBadge = ({ tag_name, size, display }) => {
return <Fragment>
<div className='tags-badge' style={{display: display}}>
<Link className={`${size}`} to={`/tags/${tag_name}`}>
{tag_name}
</Link>
</div>
</Fragment>
}

export default TagBadge;
5 changes: 5 additions & 0 deletions client/src/components/TagBadge/TagBadge.styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.tags-badge {
color: #242729;
line-height: 18px;
float: left;
}
10 changes: 5 additions & 5 deletions client/src/components/postItem/postItem.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';

import UserCard from "../UserCard/UserCard.component";
import TagBadge from "../TagBadge/TagBadge.component";

import './postItem.styles.scss';

Expand Down Expand Up @@ -47,11 +48,10 @@ const PostItem = ({ post: { id, title, body, tagname, username, user_id, answer_
<div className='brief'>
{body.substring(0, 200)}...
</div>
<div className='question-tags'>
<Link className='s-tag' to={`/tags/${tagname}`}>
{tagname}
</Link>
</div>
<TagBadge
tag_name={tagname}
size={'s-tag'}
/>
<UserCard
created_at={created_at}
user_id={user_id}
Expand Down
10 changes: 1 addition & 9 deletions client/src/components/postItem/postItem.styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
border: 1px solid #63b47c;
border-radius: 3px;
}

}

.summary {
Expand All @@ -58,19 +57,12 @@
}

.brief {
padding: 0;
padding-bottom: 5px;
padding: 0 0 5px 0;
margin: 0;
font-family: Arial, serif;
font-size: 13px;
}

.question-tags {
color: #242729;
line-height: 18px;
float: left;
}

.question-user {
width: 200px;
line-height: 18px;
Expand Down
9 changes: 6 additions & 3 deletions client/src/components/rightSideBar/rightSideBar.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { getTags } from '../../redux/tags/tags.actions';

import TagBadge from "../TagBadge/TagBadge.component";
import { ReactComponent as Stackoverflow } from '../../assets/LogoGlyphXxs.svg';
import { ReactComponent as Stackoverflowhite } from '../../assets/LogoGlyphXxswhite.svg';

Expand Down Expand Up @@ -140,9 +141,11 @@ const RightSideBar = ({ getTags , tag: { tags, loading }}) => {
<h4 className='tag-headline'>Top Ten Tags</h4>
{tags.slice(0, 10).map(tag => (
<div key={tag.tagname} className='tag-content'>
<a className='s-tag s-tag__md' href={`/tags/${tag.tagname}`}>
{tag.tagname}
</a>
<TagBadge
tag_name={tag.tagname}
size={'s-tag s-tag__md'}
display={'inline'}
/>
&nbsp;
<span className='tag-mult'>
<span>&times;</span>
Expand Down
8 changes: 5 additions & 3 deletions client/src/pages/Post/Post.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import UserCard from "../../components/UserCard/UserCard.component";

import './Post.styles.scss'
import Spinner from "../../components/spinner/spinner.component";
import TagBadge from "../../components/TagBadge/TagBadge.component";

const Post = (
{
Expand Down Expand Up @@ -125,9 +126,10 @@ const Post = (
{post.post_body}
</div>
<div className='post-tags fc-black-800'>
<div className='tag-cell'>
<Link className='s-tag' to={`/tags/${post.tagname}`}>{post.tagname}</Link>
</div>
<TagBadge
tag_name={post.tagname}
size={'s-tag'}
/>
</div>
<div className='post-actions fc-black-800'>
<div className='post-actions-extended'>
Expand Down
15 changes: 6 additions & 9 deletions client/src/pages/TagsPage/TagPanel.component.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import React from 'react';
import moment from 'moment';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import TagBadge from "../../components/TagBadge/TagBadge.component";

import './TagPanel.styles.scss';


const TagPanel = ({ tag: {tagname, description, created_at, posts_count} }) => {
return (
<div className='tag-card'>
<div className='grid'>
<div className='grid-cell'>
<Link
className='s-tag'
to={{ pathname: `/tags/${tagname}` }}
>
{tagname}
</Link>
</div>
<TagBadge
tag_name={tagname}
size={'s-tag'}
/>
</div>
<div className="description">{description}</div>
<div className='tag-caption'>
Expand Down
25 changes: 14 additions & 11 deletions client/src/pages/UserPage/UserPage.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { ReactComponent as Logo } from '../../assets/LogoGlyphMd.svg';
import SideBar from '../../components/sideBar/sideBar.component';
import RightSideBar from '../../components/rightSideBar/rightSideBar.component';
import PageTitle from "../../components/pageTitle/pageTitle.component";

import './UserPage.styles.scss'
import Spinner from "../../components/spinner/spinner.component";
import TagBadge from "../../components/TagBadge/TagBadge.component";

import './UserPage.styles.scss'

const UserPage = ({ getUser, user: { user, loading }, match }) => {
useEffect(() => {
Expand Down Expand Up @@ -159,9 +159,10 @@ const UserPage = ({ getUser, user: { user, loading }, match }) => {
<div className='top-tags-cells'>
<div className='top-cell'>
<div className='tag-cell bg-black-025'>
<Link className='s-tag s-tag__lg' to='/tags/java'>
java
</Link>
<TagBadge
tag_name={'java'}
size={'s-tag s-tag__lg'}
/>
<div className='score'>
<div className='score-txt'>
<div className='score-tab'>
Expand All @@ -176,9 +177,10 @@ const UserPage = ({ getUser, user: { user, loading }, match }) => {
<div className='top-tags-cells'>
<div className='top-cell'>
<div className='tag-cell bg-black-025'>
<Link className='s-tag s-tag__md' to='/tags/node.js'>
node.js
</Link>
<TagBadge
tag_name={'node.js'}
size={'s-tag s-tag__md'}
/>
<div className='score'>
<div className='score-txt'>
<div className='score-tab'>
Expand All @@ -193,9 +195,10 @@ const UserPage = ({ getUser, user: { user, loading }, match }) => {
<div className='top-tags-cells'>
<div className='top-cell'>
<div className='tag-cell bg-black-025'>
<Link className='s-tag s-tag__md' to='/tags/react'>
react
</Link>
<TagBadge
tag_name={'react'}
size={'s-tag s-tag__md'}
/>
<div className='score'>
<div className='score-txt'>
<div className='score-tab'>
Expand Down

0 comments on commit ff24133

Please sign in to comment.