Skip to content

Commit 6105b5d

Browse files
committed
feat: Add desktop view for search (fix #2560)
1 parent 0158cd6 commit 6105b5d

File tree

25 files changed

+715
-307
lines changed

25 files changed

+715
-307
lines changed
-31.5 KB
Binary file not shown.

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/Search/index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { compose } from 'redux';
55

66
import { setViewContext } from 'amo/actions/viewContext';
77
import Link from 'amo/components/Link';
8+
import SearchContextCard from 'amo/components/SearchContextCard';
89
import Paginate from 'core/components/Paginate';
910
import { VIEW_CONTEXT_EXPLORE } from 'core/constants';
1011
import SearchResults from 'amo/components/SearchResults';
@@ -16,6 +17,8 @@ import {
1617
} from 'core/searchUtils';
1718
import { safeAsyncConnect } from 'core/utils';
1819

20+
import './styles.scss';
21+
1922

2023
export class SearchBase extends React.Component {
2124
static propTypes = {
@@ -54,8 +57,15 @@ export class SearchBase extends React.Component {
5457

5558
render() {
5659
const {
57-
LinkComponent, count, enableSearchSort, filters, hasSearchParams,
58-
loading, page, pathname, results,
60+
LinkComponent,
61+
count,
62+
enableSearchSort,
63+
filters,
64+
hasSearchParams,
65+
loading,
66+
page,
67+
pathname,
68+
results,
5969
} = this.props;
6070
const queryParams = this.props.queryParams ||
6171
convertFiltersToQueryParams(filters);
@@ -69,6 +79,7 @@ export class SearchBase extends React.Component {
6979

7080
return (
7181
<div className="Search">
82+
<SearchContextCard />
7283
{searchSort}
7384
<SearchResults count={count} hasSearchParams={hasSearchParams}
7485
filters={filters} loading={loading} pathname={pathname}
Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,49 @@
11
@import "~amo/css/inc/vars";
2+
@import "~core/css/inc/mixins";
23

34
.Search {
4-
padding: $padding-page $padding-page 0;
5+
.Card,
6+
.SearchSort {
7+
margin: $padding-page;
8+
}
9+
}
10+
11+
@include respond-to(large) {
12+
.Search {
13+
display: grid;
14+
grid-auto-flow: column dense;
15+
grid-gap: 10px;
16+
grid-template-columns: minmax(300px, 35%) auto;
17+
padding: $padding-page;
18+
19+
.Card,
20+
.SearchSort {
21+
margin: 0;
22+
}
23+
24+
.SearchContextCard {
25+
grid-column: 1 / -1;
26+
grid-row: 1;
27+
}
28+
29+
.SearchSort {
30+
grid-column: 1 / 2;
31+
grid-row: 2;
32+
}
33+
34+
.SearchResults {
35+
grid-column: 2;
36+
grid-row: 2 / 4;
37+
}
38+
39+
// .SearchResult {
40+
// background: red;
41+
// max-width: 300px;
42+
// }
43+
44+
.Paginate {
45+
grid-column: 1 / -1;
46+
grid-row: 4;
47+
}
48+
}
549
}
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/SearchResult.js

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

0 commit comments

Comments
 (0)