Skip to content

Commit bb08e5d

Browse files
authored
Merge dd6282f into 0820874
2 parents 0820874 + dd6282f commit bb08e5d

File tree

30 files changed

+748
-334
lines changed

30 files changed

+748
-334
lines changed

src/amo/components/Addon/styles.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
padding: 20px 10px;
77
}
88

9+
.Addon .Card {
10+
margin-bottom: 10px;
11+
}
12+
913
.Addon-icon-image {
1014
height: 48px;
1115
width: 48px;
@@ -144,6 +148,7 @@
144148
grid-auto-flow: column dense;
145149
grid-gap: 10px;
146150
grid-template-columns: minmax(300px, 35%) auto;
151+
margin: 10px 0 0;
147152

148153
.AddonDescription {
149154
grid-column: 2;

src/amo/components/AddonsCard/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
44
import SearchResult from 'amo/components/SearchResult';
55
import CardList from 'ui/components/CardList';
66

7+
import './styles.scss';
8+
79

810
export default class AddonsCard extends React.Component {
911
static propTypes = {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@import "~amo/css/inc/vars";
2+
@import "~core/css/inc/mixins";
3+
@import "~ui/css/vars";
4+
5+
@include respond-to(large) {
6+
ul.AddonsCard-list {
7+
display: grid;
8+
grid-auto-flow: column dense;
9+
grid-template-columns: 50% 50%;
10+
11+
.SearchResult {
12+
background: $white;
13+
grid-column: 1 / -1;
14+
}
15+
}
16+
}

src/amo/components/LandingPage.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
align-items: center;
1010
display: flex;
1111
flex-direction: column;
12-
margin: $padding-page $padding-page ($padding-page * 2);
12+
margin: $padding-page;
1313
}
1414

1515
.LandingPage-header-top {

src/amo/components/SearchPage.js renamed to src/amo/components/Search/index.js

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1-
import React from 'react';
21
import PropTypes from 'prop-types';
2+
import React from 'react';
3+
import { connect } from 'react-redux';
4+
import { compose } from 'redux';
35

46
import { setViewContext } from 'amo/actions/viewContext';
57
import Link from 'amo/components/Link';
8+
import SearchContextCard from 'amo/components/SearchContextCard';
69
import Paginate from 'core/components/Paginate';
710
import { VIEW_CONTEXT_EXPLORE } from 'core/constants';
811
import SearchResults from 'amo/components/SearchResults';
912
import SearchSort from 'amo/components/SearchSort';
10-
import { convertFiltersToQueryParams } from 'core/searchUtils';
13+
import {
14+
convertFiltersToQueryParams,
15+
loadSearchResultsIfNeeded,
16+
mapStateToProps,
17+
} from 'core/searchUtils';
18+
import { safeAsyncConnect } from 'core/utils';
1119

20+
import './styles.scss';
1221

13-
export default class SearchPage extends React.Component {
22+
23+
export class SearchBase extends React.Component {
1424
static propTypes = {
1525
LinkComponent: PropTypes.node.isRequired,
1626
count: PropTypes.number,
@@ -47,8 +57,15 @@ export default class SearchPage extends React.Component {
4757

4858
render() {
4959
const {
50-
LinkComponent, count, enableSearchSort, filters, hasSearchParams,
51-
loading, page, pathname, results,
60+
LinkComponent,
61+
count,
62+
enableSearchSort,
63+
filters,
64+
hasSearchParams,
65+
loading,
66+
page,
67+
pathname,
68+
results,
5269
} = this.props;
5370
const queryParams = this.props.queryParams ||
5471
convertFiltersToQueryParams(filters);
@@ -61,7 +78,8 @@ export default class SearchPage extends React.Component {
6178
) : null;
6279

6380
return (
64-
<div className="SearchPage">
81+
<div className="Search">
82+
<SearchContextCard />
6583
{searchSort}
6684
<SearchResults count={count} hasSearchParams={hasSearchParams}
6785
filters={filters} loading={loading} pathname={pathname}
@@ -71,3 +89,8 @@ export default class SearchPage extends React.Component {
7189
);
7290
}
7391
}
92+
93+
export default compose(
94+
safeAsyncConnect([{ promise: loadSearchResultsIfNeeded }]),
95+
connect(mapStateToProps),
96+
)(SearchBase);
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
@import "~amo/css/inc/vars";
2+
@import "~core/css/inc/mixins";
3+
4+
.Search {
5+
@include respond-to(large) {
6+
display: grid;
7+
grid-auto-flow: column dense;
8+
grid-gap: 10px;
9+
grid-template-columns: minmax(300px, 35%) auto;
10+
padding: $padding-page;
11+
}
12+
13+
.Card {
14+
margin: $padding-page;
15+
16+
@include respond-to(large) {
17+
margin: 0;
18+
}
19+
}
20+
21+
.SearchSort {
22+
margin: $padding-page;
23+
24+
@include respond-to(large) {
25+
margin: 0;
26+
}
27+
}
28+
29+
.SearchContextCard {
30+
@include respond-to(large) {
31+
grid-column: 1 / -1;
32+
grid-row: 1;
33+
}
34+
}
35+
36+
.SearchSort {
37+
@include respond-to(large) {
38+
grid-column: 1 / 2;
39+
grid-row: 2;
40+
}
41+
}
42+
43+
.SearchResults {
44+
@include respond-to(large) {
45+
grid-column: 2;
46+
grid-row: 2 / 4;
47+
}
48+
}
49+
50+
.Paginate {
51+
@include respond-to(large) {
52+
grid-column: 1 / -1;
53+
grid-row: 4;
54+
}
55+
}
56+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import PropTypes from 'prop-types';
2+
import React from 'react';
3+
import { connect } from 'react-redux';
4+
import { compose } from 'redux';
5+
6+
import translate from 'core/i18n/translate';
7+
import Card from 'ui/components/Card';
8+
9+
import './styles.scss';
10+
11+
12+
export class SearchContextCardBase extends React.Component {
13+
static propTypes = {
14+
count: PropTypes.number,
15+
filters: PropTypes.object,
16+
i18n: PropTypes.object.isRequired,
17+
loading: PropTypes.bool.isRequired,
18+
}
19+
20+
static defaultProps = {
21+
count: 0,
22+
filters: {},
23+
}
24+
25+
render() {
26+
const { count, filters, i18n, loading } = this.props;
27+
const { query } = filters;
28+
29+
let searchText;
30+
31+
if (!loading && query) {
32+
searchText = i18n.sprintf(i18n.ngettext(
33+
'%(count)s result for "%(query)s"',
34+
'%(count)s results for "%(query)s"',
35+
count), { count: i18n.formatNumber(count), query }
36+
);
37+
} else if (loading && query) {
38+
searchText = i18n.sprintf(i18n.gettext(
39+
'Searching for "%(query)s"'), { query });
40+
} else if (loading) {
41+
searchText = i18n.gettext('Loading add-ons');
42+
} else if (!loading && count === 0) {
43+
searchText = i18n.gettext('No add-ons found');
44+
} else {
45+
searchText = i18n.sprintf(i18n.ngettext(
46+
'%(count)s add-on found"',
47+
'%(count)s add-ons found',
48+
count), { count: i18n.formatNumber(count) }
49+
);
50+
}
51+
52+
return (
53+
<Card className="SearchContextCard">
54+
<h1 className="SearchContextCard-header">{searchText}</h1>
55+
</Card>
56+
);
57+
}
58+
}
59+
60+
export function mapStateToProps(state) {
61+
return {
62+
count: state.search.count,
63+
filters: state.search.filters,
64+
loading: state.search.loading,
65+
};
66+
}
67+
68+
export default compose(
69+
connect(mapStateToProps),
70+
translate(),
71+
)(SearchContextCardBase);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@import "~ui/css/vars";
2+
3+
.SearchContextCard-header {
4+
font-size: $font-size-l;
5+
margin: 0;
6+
}

src/amo/components/SearchPage.scss

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

src/amo/components/SearchResult.js

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

0 commit comments

Comments
 (0)