From 3ebe44f86a5d84d6471ddaeb7531eaf5f74f09b9 Mon Sep 17 00:00:00 2001
From: kyleplo <31634240+kyleplo@users.noreply.github.com>
Date: Fri, 27 Jul 2018 12:06:06 -0400
Subject: [PATCH 01/16] Add css for dropdown
---
src/views/search/search.scss | 39 +++++++++++++++++++++++++++++-------
1 file changed, 32 insertions(+), 7 deletions(-)
diff --git a/src/views/search/search.scss b/src/views/search/search.scss
index 2588ac6ef..fa93c50a1 100644
--- a/src/views/search/search.scss
+++ b/src/views/search/search.scss
@@ -104,15 +104,40 @@ $base-bg: $ui-white;
}
}
}
+
+ /* HACK: sort controls are terrible. There's some sort of magic formula for height of formsy components that I can't control. */
- .select {
- select {
- margin-bottom: 0;
- color: $header-gray;
- }
+ .sort-controls {
+ display: flex;
+ margin: 0 auto;
+ border-bottom: 1px solid $ui-border;
+ padding: 8px 0;
+ width: 58.75rem;
+ justify-content: space-between;
+ }
- .help-block {
- display: none;
+ .sort-mode {
+ margin-top: -4px;
+ width: 13.75rem;
+
+ .select {
+
+ select {
+ margin-bottom: 0;
+ border: 0;
+ background-color: transparent;
+ height: 32px;
+ color: $header-gray;
+
+ &:focus,
+ &:active {
+ background-color: transparent;
+ }
+ }
+
+ .help-block {
+ display: none;
+ }
}
}
From 539cfa5bcdab89a4e25fa0edc9f0e2175da1d4c2 Mon Sep 17 00:00:00 2001
From: kyleplo <31634240+kyleplo@users.noreply.github.com>
Date: Fri, 27 Jul 2018 12:54:59 -0400
Subject: [PATCH 02/16] Add filter mode dropdown
---
src/views/search/search.jsx | 53 ++++++++++++++++++++++++++++++++++++-
1 file changed, 52 insertions(+), 1 deletion(-)
diff --git a/src/views/search/search.jsx b/src/views/search/search.jsx
index d9fd1655a..092dae2f9 100644
--- a/src/views/search/search.jsx
+++ b/src/views/search/search.jsx
@@ -8,6 +8,7 @@ const React = require('react');
const api = require('../../lib/api');
const Button = require('../../components/forms/button.jsx');
+const Form = require('../../components/forms/form.jsx');
const Grid = require('../../components/grid/grid.jsx');
const navigationActions = require('../../redux/navigation.js');
const TitleBanner = require('../../components/title-banner/title-banner.jsx');
@@ -23,12 +24,14 @@ class Search extends React.Component {
super(props);
bindAll(this, [
'getSearchState',
+ 'handleChangeSortMode',
'handleGetSearchMore',
'getTab'
]);
this.state = this.getSearchState();
this.state.loaded = [];
this.state.loadNumber = 16;
+ this.state.mode = '';
this.state.offset = 0;
this.state.loadMore = false;
}
@@ -47,6 +50,20 @@ class Search extends React.Component {
}
term = decodeURIComponent(term.split('+').join(' '));
this.props.dispatch(navigationActions.setSearchTerm(term));
+
+ let mode = '';
+ const m = query.lastIndexOf('m=');
+ if (m !== -1) {
+ mode = query.substring(m + 2, query.length).toLowerCase();
+ }
+ while (mode.indexOf('/') > -1) {
+ mode = mode.substring(0, term.indexOf('/'));
+ }
+ while (term.indexOf('&') > -1) {
+ mode = mode.substring(0, term.indexOf('&'));
+ }
+ mode = decodeURIComponent(mode.split('+').join(' '));
+ this.state.mode = mode;
}
componentDidUpdate (prevProps) {
if (this.props.searchTerm !== prevProps.searchTerm) {
@@ -60,11 +77,20 @@ class Search extends React.Component {
}
const start = pathname.lastIndexOf('/');
const type = pathname.substring(start + 1, pathname.length);
+ const modeOptions = ['trending', 'popular', 'recent', ''];
return {
+ acceptableModes: modeOptions,
tab: type,
loadNumber: 16
};
}
+ handleChangeSortMode (name, value) {
+ if (this.state.acceptableModes.indexOf(value) !== -1) {
+ const term = this.props.searchTerm.split(' ').join('+');
+ window.location =
+ `${window.location.origin}/search/${this.state.tab}?q=${term}&m=${value}`;
+ }
+ }
handleGetSearchMore () {
let termText = '';
if (this.props.searchTerm !== '') {
@@ -73,7 +99,8 @@ class Search extends React.Component {
const locale = this.props.intl.locale;
const loadNumber = this.state.loadNumber;
const offset = this.state.offset;
- const queryString = `limit=${loadNumber}&offset=${offset}&language=${locale}&mode=popular${termText}`;
+ const mode = this.state.mode;
+ const queryString = `limit=${loadNumber}&offset=${offset}&language=${locale}&mode=${mode}${termText}`;
api({
uri: `/search/${this.state.tab}?${queryString}`
@@ -167,6 +194,29 @@ class Search extends React.Component {
{this.getTab('projects')}
{this.getTab('studios')}
+
+
+
{this.getProjectBox()}
@@ -177,6 +227,7 @@ class Search extends React.Component {
Search.propTypes = {
dispatch: PropTypes.func,
intl: intlShape,
+ mode: PropTypes.string,
searchTerm: PropTypes.string
};
From 6c5d655bd5de59dbfcd661240260b64a2d7841fd Mon Sep 17 00:00:00 2001
From: kyleplo <31634240+kyleplo@users.noreply.github.com>
Date: Fri, 27 Jul 2018 12:56:27 -0400
Subject: [PATCH 03/16] Add language file
---
src/views/search/l10n.json | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 src/views/search/l10n.json
diff --git a/src/views/search/l10n.json b/src/views/search/l10n.json
new file mode 100644
index 000000000..5628054c5
--- /dev/null
+++ b/src/views/search/l10n.json
@@ -0,0 +1,5 @@
+{
+ "search.trending": "Trending",
+ "search.popular": "Popular",
+ "search.recent": "Recent"
+}
From 190cb7553e3b4b3436290149709ab5e82ed276ca Mon Sep 17 00:00:00 2001
From: kyleplo <31634240+kyleplo@users.noreply.github.com>
Date: Fri, 27 Jul 2018 13:09:48 -0400
Subject: [PATCH 04/16] Fix errors
---
src/views/search/search.jsx | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/views/search/search.jsx b/src/views/search/search.jsx
index 092dae2f9..fe0713f1d 100644
--- a/src/views/search/search.jsx
+++ b/src/views/search/search.jsx
@@ -11,6 +11,7 @@ const Button = require('../../components/forms/button.jsx');
const Form = require('../../components/forms/form.jsx');
const Grid = require('../../components/grid/grid.jsx');
const navigationActions = require('../../redux/navigation.js');
+const Select = require('../../components/forms/select.jsx');
const TitleBanner = require('../../components/title-banner/title-banner.jsx');
const Tabs = require('../../components/tabs/tabs.jsx');
@@ -63,7 +64,9 @@ class Search extends React.Component {
mode = mode.substring(0, term.indexOf('&'));
}
mode = decodeURIComponent(mode.split('+').join(' '));
- this.state.mode = mode;
+ this.setState({
+ mode: mode
+ });
}
componentDidUpdate (prevProps) {
if (this.props.searchTerm !== prevProps.searchTerm) {
@@ -227,7 +230,6 @@ class Search extends React.Component {
Search.propTypes = {
dispatch: PropTypes.func,
intl: intlShape,
- mode: PropTypes.string,
searchTerm: PropTypes.string
};
From 0494822f7ccfe01655266b07d8d774fce0ba6e5e Mon Sep 17 00:00:00 2001
From: kyleplo <31634240+kyleplo@users.noreply.github.com>
Date: Fri, 27 Jul 2018 13:15:53 -0400
Subject: [PATCH 05/16] Fix more errors
---
src/views/search/search.jsx | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/views/search/search.jsx b/src/views/search/search.jsx
index fe0713f1d..a19509e44 100644
--- a/src/views/search/search.jsx
+++ b/src/views/search/search.jsx
@@ -64,9 +64,7 @@ class Search extends React.Component {
mode = mode.substring(0, term.indexOf('&'));
}
mode = decodeURIComponent(mode.split('+').join(' '));
- this.setState({
- mode: mode
- });
+ this.props.dispatch(navigationActions.setMode(mode));
}
componentDidUpdate (prevProps) {
if (this.props.searchTerm !== prevProps.searchTerm) {
From 5ad2476790459aed06c92f7e6138f8c79a01ac90 Mon Sep 17 00:00:00 2001
From: kyleplo <31634240+kyleplo@users.noreply.github.com>
Date: Fri, 27 Jul 2018 14:16:57 -0400
Subject: [PATCH 06/16] Fix indent
---
src/views/search/search.scss | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/views/search/search.scss b/src/views/search/search.scss
index fa93c50a1..93e3c3fc0 100644
--- a/src/views/search/search.scss
+++ b/src/views/search/search.scss
@@ -105,7 +105,7 @@ $base-bg: $ui-white;
}
}
- /* HACK: sort controls are terrible. There's some sort of magic formula for height of formsy components that I can't control. */
+ /* HACK: sort controls are terrible. There's some sort of magic formula for height of formsy components that I can't control. */
.sort-controls {
display: flex;
From 9bf2f7d4369b6ed33caac9086e225982aaa0b088 Mon Sep 17 00:00:00 2001
From: kyleplo <31634240+kyleplo@users.noreply.github.com>
Date: Sat, 28 Jul 2018 07:36:08 -0400
Subject: [PATCH 07/16] Add mode
---
src/redux/navigation.js | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/redux/navigation.js b/src/redux/navigation.js
index 088fc7fb6..10f5f0db5 100644
--- a/src/redux/navigation.js
+++ b/src/redux/navigation.js
@@ -1,6 +1,7 @@
const keyMirror = require('keymirror');
const Types = keyMirror({
+ SET_MODE: null,
SET_SEARCH_TERM: null
});
@@ -9,6 +10,8 @@ module.exports.navigationReducer = (state, action) => {
state = '';
}
switch (action.type) {
+ case Types.SET_MODE:
+ return action.mode;
case Types.SET_SEARCH_TERM:
return action.searchTerm;
default:
@@ -16,6 +19,11 @@ module.exports.navigationReducer = (state, action) => {
}
};
+module.exports.setMode = mode => ({
+ type: Types.SET_MODE,
+ mode: mode
+});
+
module.exports.setSearchTerm = searchTerm => ({
type: Types.SET_SEARCH_TERM,
searchTerm: searchTerm
From a6bb77de8ab25278ec8d94ee42e1da2f7fe72140 Mon Sep 17 00:00:00 2001
From: kyleplo <31634240+kyleplo@users.noreply.github.com>
Date: Tue, 31 Jul 2018 17:26:03 -0400
Subject: [PATCH 08/16] Rename m query parameter to mode
---
src/views/search/search.jsx | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/views/search/search.jsx b/src/views/search/search.jsx
index a19509e44..abd9500f7 100644
--- a/src/views/search/search.jsx
+++ b/src/views/search/search.jsx
@@ -53,9 +53,9 @@ class Search extends React.Component {
this.props.dispatch(navigationActions.setSearchTerm(term));
let mode = '';
- const m = query.lastIndexOf('m=');
+ const m = query.lastIndexOf('mode=');
if (m !== -1) {
- mode = query.substring(m + 2, query.length).toLowerCase();
+ mode = query.substring(m + 5, query.length).toLowerCase();
}
while (mode.indexOf('/') > -1) {
mode = mode.substring(0, term.indexOf('/'));
@@ -89,7 +89,7 @@ class Search extends React.Component {
if (this.state.acceptableModes.indexOf(value) !== -1) {
const term = this.props.searchTerm.split(' ').join('+');
window.location =
- `${window.location.origin}/search/${this.state.tab}?q=${term}&m=${value}`;
+ `${window.location.origin}/search/${this.state.tab}?q=${term}&mode=${value}`;
}
}
handleGetSearchMore () {
From 7091e65fb5804b6a43fd19d8936930f71bb48ba9 Mon Sep 17 00:00:00 2001
From: kyleplo <31634240+kyleplo@users.noreply.github.com>
Date: Wed, 1 Aug 2018 09:16:41 -0400
Subject: [PATCH 09/16] Remove recent option
---
src/views/search/search.jsx | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/views/search/search.jsx b/src/views/search/search.jsx
index abd9500f7..596711b70 100644
--- a/src/views/search/search.jsx
+++ b/src/views/search/search.jsx
@@ -78,7 +78,7 @@ class Search extends React.Component {
}
const start = pathname.lastIndexOf('/');
const type = pathname.substring(start + 1, pathname.length);
- const modeOptions = ['trending', 'popular', 'recent', ''];
+ const modeOptions = ['trending', 'popular', ''];
return {
acceptableModes: modeOptions,
tab: type,
@@ -202,15 +202,11 @@ class Search extends React.Component {
options={[
{
value: 'trending',
- label: this.props.intl.formatMessage({id: 'explore.trending'})
+ label: this.props.intl.formatMessage({id: 'search.trending'})
},
{
value: 'popular',
- label: this.props.intl.formatMessage({id: 'explore.popular'})
- },
- {
- value: 'recent',
- label: this.props.intl.formatMessage({id: 'explore.recent'})
+ label: this.props.intl.formatMessage({id: 'search.popular'})
}
]}
value={this.state.mode}
From 86befd1e31f965700346388a404119c0771d4675 Mon Sep 17 00:00:00 2001
From: kyleplo <31634240+kyleplo@users.noreply.github.com>
Date: Wed, 1 Aug 2018 09:17:01 -0400
Subject: [PATCH 10/16] Remove recent from language
---
src/views/search/l10n.json | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/views/search/l10n.json b/src/views/search/l10n.json
index 5628054c5..29de14190 100644
--- a/src/views/search/l10n.json
+++ b/src/views/search/l10n.json
@@ -1,5 +1,4 @@
{
"search.trending": "Trending",
- "search.popular": "Popular",
- "search.recent": "Recent"
+ "search.popular": "Popular"
}
From 4435408cdc5d38f9df4f012dde56306aafa5ea8a Mon Sep 17 00:00:00 2001
From: kyleplo <31634240+kyleplo@users.noreply.github.com>
Date: Wed, 22 Aug 2018 07:57:19 -0400
Subject: [PATCH 11/16] Revert "Add mode"
---
src/redux/navigation.js | 8 --------
1 file changed, 8 deletions(-)
diff --git a/src/redux/navigation.js b/src/redux/navigation.js
index 10f5f0db5..088fc7fb6 100644
--- a/src/redux/navigation.js
+++ b/src/redux/navigation.js
@@ -1,7 +1,6 @@
const keyMirror = require('keymirror');
const Types = keyMirror({
- SET_MODE: null,
SET_SEARCH_TERM: null
});
@@ -10,8 +9,6 @@ module.exports.navigationReducer = (state, action) => {
state = '';
}
switch (action.type) {
- case Types.SET_MODE:
- return action.mode;
case Types.SET_SEARCH_TERM:
return action.searchTerm;
default:
@@ -19,11 +16,6 @@ module.exports.navigationReducer = (state, action) => {
}
};
-module.exports.setMode = mode => ({
- type: Types.SET_MODE,
- mode: mode
-});
-
module.exports.setSearchTerm = searchTerm => ({
type: Types.SET_SEARCH_TERM,
searchTerm: searchTerm
From 458170390ce51b0e9520487a97f91ea10f096944 Mon Sep 17 00:00:00 2001
From: kyleplo <31634240+kyleplo@users.noreply.github.com>
Date: Wed, 22 Aug 2018 08:05:20 -0400
Subject: [PATCH 12/16] Fix acceptableModes
---
src/views/search/search.jsx | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/views/search/search.jsx b/src/views/search/search.jsx
index 596711b70..fde867281 100644
--- a/src/views/search/search.jsx
+++ b/src/views/search/search.jsx
@@ -18,6 +18,8 @@ const Tabs = require('../../components/tabs/tabs.jsx');
const Page = require('../../components/page/www/page.jsx');
const render = require('../../lib/render.jsx');
+const ACCEPTABLE_MODES = ['trending', 'popular', ''];
+
require('./search.scss');
class Search extends React.Component {
@@ -64,7 +66,7 @@ class Search extends React.Component {
mode = mode.substring(0, term.indexOf('&'));
}
mode = decodeURIComponent(mode.split('+').join(' '));
- this.props.dispatch(navigationActions.setMode(mode));
+ this.setState({mode: mode});
}
componentDidUpdate (prevProps) {
if (this.props.searchTerm !== prevProps.searchTerm) {
@@ -78,15 +80,13 @@ class Search extends React.Component {
}
const start = pathname.lastIndexOf('/');
const type = pathname.substring(start + 1, pathname.length);
- const modeOptions = ['trending', 'popular', ''];
return {
- acceptableModes: modeOptions,
tab: type,
loadNumber: 16
};
}
handleChangeSortMode (name, value) {
- if (this.state.acceptableModes.indexOf(value) !== -1) {
+ if (ACCEPTABLE_MODES.indexOf(value) !== -1) {
const term = this.props.searchTerm.split(' ').join('+');
window.location =
`${window.location.origin}/search/${this.state.tab}?q=${term}&mode=${value}`;
From 78b88443c0eb301fc18663f6b42852575c1776a1 Mon Sep 17 00:00:00 2001
From: kyleplo <31634240+kyleplo@users.noreply.github.com>
Date: Wed, 22 Aug 2018 14:17:26 -0400
Subject: [PATCH 13/16] Fix setting mode
---
src/views/search/search.jsx | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/views/search/search.jsx b/src/views/search/search.jsx
index fde867281..d9d87f659 100644
--- a/src/views/search/search.jsx
+++ b/src/views/search/search.jsx
@@ -37,6 +37,20 @@ class Search extends React.Component {
this.state.mode = '';
this.state.offset = 0;
this.state.loadMore = false;
+
+ let mode = '';
+ const m = query.lastIndexOf('mode=');
+ if (m !== -1) {
+ mode = query.substring(m + 5, query.length).toLowerCase();
+ }
+ while (mode.indexOf('/') > -1) {
+ mode = mode.substring(0, term.indexOf('/'));
+ }
+ while (term.indexOf('&') > -1) {
+ mode = mode.substring(0, term.indexOf('&'));
+ }
+ mode = decodeURIComponent(mode.split('+').join(' '));
+ this.state.mode = mode;
}
componentDidMount () {
const query = window.location.search;
@@ -53,20 +67,6 @@ class Search extends React.Component {
}
term = decodeURIComponent(term.split('+').join(' '));
this.props.dispatch(navigationActions.setSearchTerm(term));
-
- let mode = '';
- const m = query.lastIndexOf('mode=');
- if (m !== -1) {
- mode = query.substring(m + 5, query.length).toLowerCase();
- }
- while (mode.indexOf('/') > -1) {
- mode = mode.substring(0, term.indexOf('/'));
- }
- while (term.indexOf('&') > -1) {
- mode = mode.substring(0, term.indexOf('&'));
- }
- mode = decodeURIComponent(mode.split('+').join(' '));
- this.setState({mode: mode});
}
componentDidUpdate (prevProps) {
if (this.props.searchTerm !== prevProps.searchTerm) {
From 0b9ceb413fa494ea60e01cbfe8debe0945815e8a Mon Sep 17 00:00:00 2001
From: kyleplo <31634240+kyleplo@users.noreply.github.com>
Date: Wed, 22 Aug 2018 14:25:31 -0400
Subject: [PATCH 14/16] Fix getting querystring
---
src/views/search/search.jsx | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/views/search/search.jsx b/src/views/search/search.jsx
index d9d87f659..adc221964 100644
--- a/src/views/search/search.jsx
+++ b/src/views/search/search.jsx
@@ -39,6 +39,8 @@ class Search extends React.Component {
this.state.loadMore = false;
let mode = '';
+ const query = window.location.search;
+ const q = query.lastIndexOf('q=');
const m = query.lastIndexOf('mode=');
if (m !== -1) {
mode = query.substring(m + 5, query.length).toLowerCase();
From d2721f0bbc9a3971bee91cd8108d104a0a17a177 Mon Sep 17 00:00:00 2001
From: kyleplo <31634240+kyleplo@users.noreply.github.com>
Date: Wed, 22 Aug 2018 14:43:00 -0400
Subject: [PATCH 15/16] Fix getting query
---
src/views/search/search.jsx | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/views/search/search.jsx b/src/views/search/search.jsx
index adc221964..48dcbafdf 100644
--- a/src/views/search/search.jsx
+++ b/src/views/search/search.jsx
@@ -40,16 +40,15 @@ class Search extends React.Component {
let mode = '';
const query = window.location.search;
- const q = query.lastIndexOf('q=');
const m = query.lastIndexOf('mode=');
if (m !== -1) {
mode = query.substring(m + 5, query.length).toLowerCase();
}
while (mode.indexOf('/') > -1) {
- mode = mode.substring(0, term.indexOf('/'));
+ mode = mode.substring(0, mode.indexOf('/'));
}
while (term.indexOf('&') > -1) {
- mode = mode.substring(0, term.indexOf('&'));
+ mode = mode.substring(0, mode.indexOf('&'));
}
mode = decodeURIComponent(mode.split('+').join(' '));
this.state.mode = mode;
From d7feb5169500f44ba6bf7ab61579acf26ccb6fc0 Mon Sep 17 00:00:00 2001
From: kyleplo <31634240+kyleplo@users.noreply.github.com>
Date: Wed, 22 Aug 2018 14:50:19 -0400
Subject: [PATCH 16/16] Fix non-existent term
---
src/views/search/search.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/views/search/search.jsx b/src/views/search/search.jsx
index 48dcbafdf..d35f2c937 100644
--- a/src/views/search/search.jsx
+++ b/src/views/search/search.jsx
@@ -47,7 +47,7 @@ class Search extends React.Component {
while (mode.indexOf('/') > -1) {
mode = mode.substring(0, mode.indexOf('/'));
}
- while (term.indexOf('&') > -1) {
+ while (mode.indexOf('&') > -1) {
mode = mode.substring(0, mode.indexOf('&'));
}
mode = decodeURIComponent(mode.split('+').join(' '));