Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/separate ulog hashtags #119

Merged
merged 2 commits into from
Sep 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"secure-random": "^1.1.1",
"showdown": "^1.8.6",
"speakingurl": "^11.0.0",
"steemscript": "https://github.com/busyorg/steemscript.git",
"steemscript": "https://github.com/bonuschain/steemscript",
"store": "^1.3.20",
"striptags": "^2.1.1",
"text-ellipsis": "^1.0.3",
Expand Down
70 changes: 46 additions & 24 deletions src/client/components/Sidebar/Topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,94 @@ import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import Topic from '../Button/Topic';
import Loading from '../Icon/Loading';
import ulogTopics from '../../helpers/ulogTopics';
import './Topics.less';

class Topics extends React.Component {
static propTypes = {
favorite: PropTypes.bool,
topics: PropTypes.arrayOf(PropTypes.string),
maxItems: PropTypes.number,
maxUlogTopics: PropTypes.number,
loading: PropTypes.bool,
};

static defaultProps = {
favorite: false,
topics: [],
maxItems: 5,
maxUlogTopics: 7,
loading: false,
};

constructor(props) {
super(props);
this.state = {
showMore: false,
showMoreUlogTopics: false,
};
}

changeVisibility(showMore) {
this.setState({ showMore });
}

changeMoreUlogTopicsVisibility(showMoreUlogTopics) {
this.setState({ showMoreUlogTopics });
}

render() {
const { topics, favorite, maxItems, loading } = this.props;
const { topics, favorite, maxItems, maxUlogTopics, loading } = this.props;

const displayedTopics = this.state.showMore ? topics : topics.slice(0, maxItems);
const displayedUlogTopics = this.state.showMoreUlogTopics ? ulogTopics : ulogTopics.slice(0, maxUlogTopics);

return (
<div className="Topics">
<h4>
<FormattedMessage
id={favorite ? 'favorite_topics' : 'trending_topics'}
defaultMessage={favorite ? 'Favorite topics' : 'Trending topics'}
id={'ulog_and_ulog_subtags'}
defaultMessage={'Ulog & Ulog sub-tags'}
/>
</h4>
{loading && <Loading center={false} />}
{!loading && (
<ul className="Topics__list">
<li key='ulog'>
<Topic name='ulog' favorite={favorite} />
</li>
<li key='ulogs'>
<Topic name='ulogs' favorite={favorite} />
</li>
<li key='surpassinggoogle'>
<Topic name='surpassinggoogle' favorite={favorite} />
</li>
<li key='steemgigs'>
<Topic name='steemgigs' favorite={favorite} />
</li>
<li key='teardrops'>
<Topic name='teardrops' favorite={favorite} />
</li>
<li key='untalented'>
<Topic name='untalented' favorite={favorite} />
</li>
<li key='philippines'>
<Topic name='philippines' favorite={favorite} />
{displayedUlogTopics.map(topic => (
<li key={topic}>
<Topic name={topic} favorite={favorite} />
</li>

))}
</ul>
)}
{!loading && ulogTopics.length > maxUlogTopics && !this.state.showMoreUlogTopics ? (
<a role="button" tabIndex={0} onClick={() => this.changeMoreUlogTopicsVisibility(true)}>
<FormattedMessage id="show_more" defaultMessage="View more" />
</a>
) : null}
{!loading && ulogTopics.length > maxUlogTopics && this.state.showMoreUlogTopics ? (
<a role="button" tabIndex={0} onClick={() => this.changeMoreUlogTopicsVisibility(false)}>
<FormattedMessage id="show_less" defaultMessage="View less" />
</a>
) : null}
<h4>
<FormattedMessage
id={favorite ? 'favorite_topics' : 'steem_hashtags'}
defaultMessage={favorite ? 'Favorite topics' : 'Steem Hashtags'}
/>
</h4>
{loading && <Loading center={false} />}
{!loading && (
<ul className="Topics__list">
<li key='teardrops'>
<Topic name='teardrops' favorite={favorite} />
</li>
<li key='untalented'>
<Topic name='untalented' favorite={favorite} />
</li>
<li key='surpassinggoogle'>
<Topic name='surpassinggoogle' favorite={favorite} />
</li>
{displayedTopics.map(topic => (
<li key={topic}>
<Topic name={topic} favorite={favorite} />
Expand Down
38 changes: 38 additions & 0 deletions src/client/helpers/ulogTopics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export default [
'ulog',
'ulogs',
'ulog-quotes',
'ulog-diy',
'ulog-ned',
'ulography',
'ulog-mamas',
'ulog-gratefulvibes',
'ulog-resolutions',
'ulog-memes',
'ulog-blocktrades',
'ulog-podcasts',
'ulog-showerthoughts',
'ulog-snookmademedoit',
'ulog-terrysays',
'ulog-curie',
'ulog-ocd',
'ulog-recipes',
'ulog-hugot',
'ulog-steem',
'ulog-steemit',
'ulog-cryptocurrency',
'ulog-poetry',
'ulog-steemstem',
'ulog-utopian',
'ulog-macrohard',
'ulog-ifs',
'ulog-exchange',
'ulog-wiki',
'ulog-freebies',
'ulog-curated',
'ulog-pets',
'ulog-books',
'ulog-funny',
'ulog-savetheday',
'ulog-zoo',
];
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8413,9 +8413,9 @@ stealthy-require@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b"

"steemscript@https://github.com/busyorg/steemscript.git":
version "0.0.1"
resolved "https://github.com/busyorg/steemscript.git#0a2ffcba66e9ebb093a0e511e78ffa22b7b9023d"
"steemscript@https://github.com/bonuschain/steemscript":
version "1.0.2"
resolved "https://github.com/bonuschain/steemscript#f36af55abb2287c804514671dd97cd540eaa543d"

store@^1.3.20:
version "1.3.20"
Expand Down Expand Up @@ -9534,4 +9534,4 @@ yargs@~3.10.0:
camelcase "^1.0.2"
cliui "^2.1.0"
decamelize "^1.0.0"
window-size "0.1.0"
window-size "0.1.0"