Skip to content

Commit 00bec69

Browse files
author
vikasrohit
committed
Merge branch 'amolskh-TaggedValue-React-Component'
2 parents 199634c + ae9483e commit 00bec69

File tree

6 files changed

+179
-1
lines changed

6 files changed

+179
-1
lines changed

components/Router/Router.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import SearchSuggestionsExamples from '../SearchSuggestions/SearchSuggestion
2525
import SearchBarExample from '../SearchBar/SearchBarExamples.jsx'
2626
import NavbarExample from '../Navbar/NavbarExample.jsx'
2727
import TCFooterExamples from '../TCFooter/TCFooterExamples.jsx'
28+
import TaggedValueExamples from '../TaggedValue/TaggedValueExamples.jsx'
2829
import SubTrackDetailsExample from '../SubTrackDetails/SubTrackDetailsExample.jsx'
2930
import PrizeExamples from '../Prize/PrizeExamples.jsx'
3031
import TooltipExamples from '../Tooltip/TooltipExamples.jsx'
@@ -75,12 +76,13 @@ const Component = () => (
7576
<Route path="/NavbarExample" component={NavbarExample} />
7677

7778
<Route path="/TCFooterExamples" component={TCFooterExamples} />
79+
80+
<Route path="/TaggedValueExamples" component={TaggedValueExamples} />
7881

7982
<Route path="/SubTrackDetailsExample" component={SubTrackDetailsExample} />
8083

8184
<Route path="/TooltipExamples" component={TooltipExamples} />
8285

83-
8486
<Route path="/PrizeExamples" component={PrizeExamples}/>
8587

8688
<Route path="/ProgressBarExample" component={ProgressBarExample}/>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require('./TaggedValue.scss')
2+
3+
import React from 'react'
4+
import classNames from 'classnames'
5+
6+
const TaggedValue = ({title,subText,style,count}) => {
7+
const taggedValueClass = classNames(
8+
'TaggedValue',
9+
{ [`${style}`]: style,
10+
'count-one' : !style && count === '1'}
11+
)
12+
if(count) {
13+
subText = `${subText} x ${count}`
14+
}
15+
return (
16+
<div className={taggedValueClass}>
17+
<div className="tagged-value-bg">{title}</div>
18+
<span className="subText">{subText}</span>
19+
</div>
20+
)
21+
}
22+
23+
TaggedValue.propTypes = {
24+
title : React.PropTypes.string,
25+
subText : React.PropTypes.string,
26+
style : React.PropTypes.string,
27+
count : React.PropTypes.string
28+
}
29+
30+
export default TaggedValue
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@import 'topcoder/tc-includes';
2+
3+
$gray-30: #C3C3C8;
4+
$gray: #47474F;
5+
$purple: #B47DD6;
6+
$accent: #59A7FF;
7+
8+
.TaggedValue {
9+
display:inline-block;
10+
height: 20px;
11+
.tagged-value-bg {
12+
display: inline;
13+
padding: 4px 4px 1px 4px;
14+
min-width: 15px;
15+
max-height: 15px;
16+
background: $accent;
17+
border-radius: 8px;
18+
text-align: center;
19+
font-size: 11px;
20+
line-height: 13px;
21+
font-family: "Roboto", Arial, Helvetica, sans-serif;
22+
font-weight: bold;
23+
color: $gray;
24+
padding: 1px 7px 2px 7px;
25+
}
26+
.subText {
27+
font-family: "Roboto", Arial, Helvetica, sans-serif;
28+
font-size: 13px;
29+
line-height: 15px;
30+
color: $white;
31+
font-weight: 500;
32+
padding-left: 6px;
33+
padding-right: 10px;
34+
}
35+
}
36+
.count-one {
37+
.tagged-value-bg {
38+
background: $purple;
39+
}
40+
}
41+
.TaggedValueList {
42+
.items{
43+
white-space: normal;
44+
}
45+
.items-scroll {
46+
overflow-x: scroll;
47+
white-space: nowrap;
48+
}
49+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
require('./TaggedValueExamples.scss')
2+
3+
import React from 'react'
4+
import TaggedValue from './TaggedValue'
5+
import TaggedValueList from './TaggedValueList'
6+
7+
const taggedValueData1 = {
8+
title : 'title1',
9+
subText : 'SubText1',
10+
style : 'sample1'
11+
}
12+
13+
const taggedValueData2 = {
14+
title : 'title2',
15+
subText : 'SubText2',
16+
style : 'sample2',
17+
count:'5'
18+
}
19+
20+
const taggedValueItems1 = {
21+
items : [taggedValueData1,taggedValueData2,taggedValueData1,taggedValueData2]
22+
}
23+
24+
const TaggedValueExamples = () => (
25+
<div>
26+
<div className="divStyle">
27+
<TaggedValue title={taggedValueData1.title} subText={taggedValueData1.subText} count="1"/>
28+
<TaggedValue title={taggedValueData1.title} subText={taggedValueData1.subText}/>
29+
<TaggedValue title={taggedValueData2.title} subText={taggedValueData2.subText} style={taggedValueData2.style} count={taggedValueData2.count}/>
30+
</div>
31+
<br/>
32+
<div className="divStyle">
33+
<TaggedValueList items={taggedValueItems1.items} layout="scroll"/>
34+
</div>
35+
<br/>
36+
<div className="divStyle">
37+
<TaggedValueList items={taggedValueItems1.items} layout="wrap"/>
38+
</div>
39+
</div>
40+
)
41+
42+
module.exports = TaggedValueExamples
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
$gray: #47474F;
2+
$blue : #59A7FF;
3+
$purple: #B47DD6;
4+
5+
.sample1 {
6+
.tagged-value-bg {
7+
background-color: $purple;
8+
color: white;
9+
}
10+
.subText {
11+
color: white;
12+
}
13+
}
14+
15+
.sample2 {
16+
.tagged-value-bg {
17+
color: $gray;
18+
}
19+
.subText{
20+
color: lightblue;
21+
}
22+
}
23+
.divStyle {
24+
background-color:#47474F;
25+
padding:20px;
26+
width:320px
27+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require('./TaggedValue.scss')
2+
3+
import React from 'react'
4+
import TaggedValue from './TaggedValue'
5+
import classNames from 'classnames'
6+
7+
const TaggedValueList = ({items,layout}) => {
8+
const itemClass = classNames(
9+
items,
10+
{'items-scroll' : layout === 'scroll'}
11+
)
12+
return (
13+
<div className="TaggedValueList">
14+
<div className={itemClass}>
15+
{items.map((item,index) => {
16+
return <TaggedValue title={item.title} subText={item.subText} style={item.style} count={item.count} key={index}/>
17+
})}
18+
</div>
19+
</div>
20+
)
21+
}
22+
23+
TaggedValueList.propTypes = {
24+
items : React.PropTypes.array,
25+
layout : React.PropTypes.string
26+
}
27+
28+
export default TaggedValueList

0 commit comments

Comments
 (0)