Skip to content

Commit cb5b43a

Browse files
committed
Add Tag example page, improvements to tag component
1 parent 2cf94fa commit cb5b43a

File tree

18 files changed

+239
-153
lines changed

18 files changed

+239
-153
lines changed

src/shared/components/Content/index.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ export default function Content() {
152152
load <code>.svg</code> assets with use
153153
of <code>babel-plugin-inline-react-svg</code>.
154154
</li>
155+
<li>
156+
<Link to="/examples/tags/">Tags</Link> - Demo/test of standard
157+
tags already available in the code, and customizable with help
158+
of <code>react-css-themr</code>.
159+
</li>
155160
<li>
156161
<Link to="/examples/themr">Themr</Link> - Test/demo of
157162
react-css-themr.

src/shared/components/buttons/index.jsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import dangerButton from './danger.scss';
4747
import defaultButton from './default.scss';
4848
import primaryDesignButton from './primaryDesign.scss';
4949
import secondaryButton from './secondary.scss';
50-
import tagButton from './tags.scss';
5150

5251
/* Generic button, not wrapped by themr, but accepting theme property.
5352
* In most cases you will want to use some of the themable exports below
@@ -124,7 +123,4 @@ export const PrimaryButton =
124123
export const SecondaryButton =
125124
themr('SecondaryButton', secondaryButton)(GenericButton);
126125

127-
export const TagButton =
128-
themr('TagButton', tagButton)(GenericButton);
129-
130126
export default undefined;

src/shared/components/buttons/tags.scss

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/shared/components/challenge-detail/Header/ChallengeTags.jsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,14 @@ import React from 'react';
1010
import PT from 'prop-types';
1111
import _ from 'lodash';
1212
import { Link } from 'utils/router';
13-
import style from './style.scss';
14-
import { Tag } from 'components/tags';
15-
import { EventTag } from 'components/tags';
16-
import { PrimaryTag } from 'components/tags';
13+
14+
import { Tag, EventTag, PrimaryTag } from 'components/tags';
1715

1816
export default function ChallengeTags(props) {
1917
const {
2018
subTrack,
2119
events,
2220
technPlatforms,
23-
subTrackStyle,
24-
eventStyle,
2521
setChallengeListingFilter,
2622
challengeSubtracksMap,
2723
} = props;
@@ -55,6 +51,7 @@ export default function ChallengeTags(props) {
5551
technPlatforms.map(
5652
tag =>
5753
(
54+
tag &&
5855
<Tag
5956
to="/challenges"
6057
onClick={() => setChallengeListingFilter({ tags: [tag] })}
@@ -77,8 +74,6 @@ ChallengeTags.propTypes = {
7774
subTrack: PT.string,
7875
events: PT.arrayOf(PT.string),
7976
technPlatforms: PT.arrayOf(PT.string),
80-
subTrackStyle: PT.string.isRequired,
81-
eventStyle: PT.string.isRequired,
8277
setChallengeListingFilter: PT.func.isRequired,
8378
challengeSubtracksMap: PT.shape().isRequired,
8479
};

src/shared/components/challenge-detail/Header/index.jsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ export default function ChallengeHeader(props) {
6666
}
6767

6868
const theme = themeFactory(trackLower);
69-
70-
const subTrackStyle = `${trackLower}-accent-background`;
71-
const eventStyle = `${trackLower}-accent-color`;
69+
const stylizedSubTrack = (subTrack || '').replace('_', ' ')
70+
.replace(/\w\S*/g, txt => _.capitalize(txt));
7271
const eventNames = (events || []).map((event => (event.eventName || '').toUpperCase()));
7372
const miscTags = _.union((technologies || '').split(', '), platforms.split(', '));
7473

@@ -184,8 +183,6 @@ export default function ChallengeHeader(props) {
184183
challengeSubtracksMap={challengeSubtracksMap}
185184
events={eventNames}
186185
technPlatforms={miscTags}
187-
subTrackStyle={subTrackStyle}
188-
eventStyle={eventStyle}
189186
setChallengeListingFilter={setChallengeListingFilter}
190187
/>
191188
<div styleName="prizes-ops-container">

src/shared/components/challenge-detail/themeFactory.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010

1111
import { COMPETITION_TRACKS } from 'utils/tc';
1212

13-
import primaryDesignTagStyle from '../tags/primaryDesign.scss';
1413
import primaryDevelopTagStyle from '../tags/primaryDevelop.scss';
1514
import primaryDataScienceTagStyle from '../tags/primaryDataScience.scss';
16-
import eventDesignTagStyle from '../tags/eventDesign.scss';
1715
import eventDevelopTagStyle from '../tags/eventDevelop.scss';
1816
import eventDataScienceTagStyle from '../tags/eventDataScience.scss';
1917

@@ -23,19 +21,15 @@ export default function factory(track) {
2321
* to normalize. */
2422
switch (track.toLowerCase()) {
2523
case COMPETITION_TRACKS.DATA_SCIENCE:
26-
console.log('track: ' + track);
2724
return {
2825
PrimaryTag: primaryDataScienceTagStyle,
2926
EventTag: eventDataScienceTagStyle,
3027
};
3128
case COMPETITION_TRACKS.DESIGN:
32-
console.log('track: ' + track);
3329
return {
34-
//PrimaryTag: primaryDesignTagStyle,
35-
//EventTag: eventDesignTagStyle,
30+
3631
};
3732
case COMPETITION_TRACKS.DEVELOP:
38-
console.log('track: ' + track);
3933
return {
4034
PrimaryTag: primaryDevelopTagStyle,
4135
EventTag: eventDevelopTagStyle,

src/shared/components/challenge-listing/ChallengeCard/index.jsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Prize from './Prize';
1111
import ChallengeStatus from './Status';
1212
import TrackAbbreviationTooltip from '../Tooltips/TrackAbbreviationTooltip';
1313
import './style.scss';
14+
import { Tag } from 'components/tags';
1415

1516
export const PRIZE_MODE = {
1617
HIDDEN: 'hidden',
@@ -228,15 +229,10 @@ class Tags extends React.Component {
228229
technologyList.push(lastItem);
229230
}
230231
return technologyList.map(c => (
231-
<a
232-
key={c}
233-
styleName="technology"
234-
/* TODO: Find out why all tags beside the first one are prepended
235-
* with whitespaces? */
232+
<Tag
236233
onClick={() => this.onClick(c.trim())}
237-
role="button"
238-
tabIndex={0}
239-
>{c}</a>
234+
key={c}
235+
>{c}</Tag>
240236
));
241237
}
242238
return '';
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import React from 'react';
2+
import {
3+
Tag,
4+
PrimaryTag,
5+
EventTag
6+
} from 'components/tags';
7+
import { ThemeProvider } from 'react-css-themr';
8+
9+
import primaryDataScienceTagStyle from '../../tags/primaryDataScience.scss';
10+
import primaryDevelopTagStyle from '../../tags/primaryDevelop.scss';
11+
import eventDevelopTagStyle from '../../tags/eventDevelop.scss';
12+
import eventDataScienceTagStyle from '../../tags/eventDataScience.scss';
13+
14+
import style from './style.scss';
15+
16+
export default function Tags() {
17+
return (
18+
<div styleName="style.page">
19+
<h1>Tags</h1>
20+
<p>
21+
All tags in this page are instances of the generic tag,
22+
implemented in <code>/src/components/tags</code> and wrapped
23+
into different style themes with help
24+
of <code>react-css-themr</code>.
25+
</p>
26+
27+
<h3>Default Tag</h3>
28+
<Tag>Tag</Tag>
29+
<Tag to=".">Link Tag</Tag>
30+
31+
<h3>Primary Tag</h3>
32+
33+
<p>Default &mdash; design color scheme:</p>
34+
<PrimaryTag>Tag</PrimaryTag>
35+
<PrimaryTag to=".">Link Tag</PrimaryTag>
36+
37+
<p>Develop color scheme (underlying source code also
38+
demonstrates the proper context theming in action):</p>
39+
40+
<ThemeProvider
41+
theme={{ PrimaryTag: primaryDevelopTagStyle }}
42+
>
43+
<div>
44+
<PrimaryTag>Tag</PrimaryTag>
45+
<PrimaryTag to=".">Link Tag</PrimaryTag>
46+
</div>
47+
</ThemeProvider>
48+
49+
<p>Data science color scheme:</p>
50+
<ThemeProvider
51+
theme={{ PrimaryTag: primaryDataScienceTagStyle }}
52+
>
53+
<div>
54+
<PrimaryTag>Tag</PrimaryTag>
55+
<PrimaryTag to=".">Link Tag</PrimaryTag>
56+
</div>
57+
</ThemeProvider>
58+
59+
<h3>Event Tag</h3>
60+
<p>Default &mdash; design color scheme:</p>
61+
<EventTag>Tag</EventTag>
62+
<EventTag to=".">Link Tag</EventTag>
63+
<p>Develop color scheme:</p>
64+
<ThemeProvider
65+
theme={{ EventTag: eventDevelopTagStyle }}
66+
>
67+
<div>
68+
<EventTag>Tag</EventTag>
69+
<EventTag to=".">Link Tag</EventTag>
70+
</div>
71+
</ThemeProvider>
72+
<p>Data Science color scheme:</p>
73+
<ThemeProvider
74+
theme={{ EventTag: eventDataScienceTagStyle }}
75+
>
76+
<div>
77+
<EventTag>Tag</EventTag>
78+
<EventTag to=".">Link Tag</EventTag>
79+
</div>
80+
</ThemeProvider>
81+
</div>
82+
);
83+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
@import "~styles/tc-styles";
2+
3+
.page {
4+
@include roboto-light;
5+
6+
line-height: 150%;
7+
margin: auto;
8+
max-width: $screen-lg;
9+
padding: 24px;
10+
11+
h1 {
12+
margin: 0 0 18px;
13+
}
14+
15+
h3 {
16+
margin: 24px 0 6px;
17+
}
18+
19+
code {
20+
background: whitesmoke;
21+
padding: 2px 4px;
22+
}
23+
24+
em {
25+
font-style: italic;
26+
}
27+
28+
p {
29+
margin: $base-unit 0;
30+
}
31+
}
32+
33+
.btnXS {
34+
@include btn-xs;
35+
}
36+
37+
.btnSM {
38+
@include btn-sm;
39+
}
40+
41+
.btnLG {
42+
@include btn-lg;
43+
}

src/shared/components/tags/default.scss

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@
44
@import "~styles/tc-styles";
55

66
@mixin feedback {
7-
&:active,
8-
&:focus,
7+
&:active,
8+
&:focus,
99
&:hover {
1010
color: $tc-gray-80;
11-
background-color: $tc-dark-blue-30;
11+
background-color: $tc-dark-blue-30;
1212
}
1313
&:visited {
1414
color: $tc-gray-80;
1515
}
1616
}
1717

18-
19-
.tag {
20-
display: inline-block;
21-
text-align: center;
22-
padding: 0 7px;
23-
line-height: 20px;
24-
background-color: $tc-gray-neutral-dark;
25-
font-size: 11px;
26-
font-family: Roboto;
27-
font-weight: 500;
28-
color: $tc-gray-80;
29-
margin-right: 5px;
30-
border-radius: 4px;
31-
height: 20px;
32-
margin-bottom: 2px;
33-
cursor: pointer;
34-
@include feedback;
18+
div, span {
19+
.tag, a.tag {
20+
display: inline-block;
21+
text-align: center;
22+
padding: 0 7px;
23+
line-height: 20px;
24+
background-color: $tc-gray-neutral-dark;
25+
font-size: 11px;
26+
font-family: Roboto;
27+
font-weight: 500;
28+
color: $tc-gray-80;
29+
margin-right: 5px;
30+
border-radius: 4px;
31+
margin-bottom: 2px;
32+
cursor: pointer;
33+
@include feedback;
34+
}
3535
}

0 commit comments

Comments
 (0)