From f41aef84ab849ac473626c729c54fcb90176d6fe Mon Sep 17 00:00:00 2001 From: Jennifer Chen Date: Fri, 17 Sep 2021 09:40:09 -0400 Subject: [PATCH 1/5] [wip] search examples --- .../components/SearchExamples.jsx.js | 48 +++++++++------ .../Recommender/models/searchExamples.js | 61 +++++++++++++++---- 2 files changed, 78 insertions(+), 31 deletions(-) diff --git a/src/js/react/Recommender/components/SearchExamples.jsx.js b/src/js/react/Recommender/components/SearchExamples.jsx.js index abfd4a872..e2317610d 100644 --- a/src/js/react/Recommender/components/SearchExamples.jsx.js +++ b/src/js/react/Recommender/components/SearchExamples.jsx.js @@ -61,6 +61,10 @@ define([ dispatch(emitAnalytics(['send', 'event', 'interaction.suggestion-used'])); }; + const generateRandom = (max) => { + return Math.floor(Math.random() * max); + }; + return (
- {searchExamples.slice(0, 7).map((entry) => ( - onClick(entry.example)} - key={entry.label} - /> - ))} + {searchExamples.slice(0, 7).map((entry) => { + const index = generateRandom(entry.examples.length - 1); + const example = entry.syntax.replace('%', entry.examples[index]); + return ( + onClick(example)} + key={entry.label} + /> + ); + })}
- {searchExamples.slice(7).map((entry) => ( - onClick(entry.example)} - key={entry.label} - /> - ))} + {searchExamples.slice(7).map((entry) => { + const index = generateRandom(entry.examples.length - 1); + const example = entry.syntax.replace('%', entry.examples[index]); + return ( + onClick(example)} + key={entry.label} + /> + ); + })}
diff --git a/src/js/react/Recommender/models/searchExamples.js b/src/js/react/Recommender/models/searchExamples.js index 8f625f0df..0f5e64fca 100644 --- a/src/js/react/Recommender/models/searchExamples.js +++ b/src/js/react/Recommender/models/searchExamples.js @@ -1,64 +1,99 @@ define([], function() { + const authors = [ + 'Penrose, Roger', + 'Genzel, Reinhard', + 'Ghez, Andrea M.', + 'Lupton, Robert', + 'Paxton, Bill', + 'Impey, Chris', + 'Dressing, Courtney', + 'Weinberg, David', + 'López Rodríguez, Enrique', + 'Kreidberg, Laura', + 'Scoville, Nick', + 'Dawson, Rebekah', + 'Demorest, Paul', + 'Suyu, Sherry H.', + 'KamionkowskiMarc', + 'Seljak, Uroš', + 'Zaldarriaga, Matias', + 'Kaspi, Victoria M.', + 'Kouveliotou, Chryssa', + ]; + const searchExamples = [ { label: 'author', - example: 'author:"huchra, john"', + syntax: 'author:"%"', + examples: authors, }, { label: 'first author', - example: 'author:"^huchra, john"', + syntax: 'author:"^%"', + examples: authors, }, { label: 'abstract + title', - example: 'abs:"dark energy"', + syntax: 'abs:"%"', + examples: ['dark energy'], }, { label: 'year', - example: 'year:2000', + syntax: 'year:%', + examples: ['2000'], }, { label: 'year range', - example: 'year:2000-2005', + syntax: 'year:%', + examples: ['2000-2005'], }, { label: 'full text', - example: 'full:"gravity waves"', + syntax: 'full:"%"', + examples: ['gravity waves'], }, { label: 'publication', - example: 'bibstem:ApJ', + syntax: 'bibstem:%', + examples: ['ApJ'], tooltip: "this field requires the bibstem, or journal abbreviation--try going to the 'Paper' tab above for an easy-to-use form version", }, { label: 'citations', - example: 'citations(author:"huchra, j")', + syntax: 'citations(author:"%")', + examples: authors, tooltip: 'finds all papers that cite a given set of papers', }, { label: 'references', - example: 'references(author:"huchra, j")', + syntax: 'references(author:"%")', + examples: authors, tooltip: 'finds all papers referenced by a given set of papers', }, { label: 'reviews', - example: 'reviews("gamma-ray bursts")', + syntax: 'reviews("%")', + examples: ['gamma-ray bursts'], tooltip: 'finds articles citing the most relevant papers on the topic being researched', }, { label: 'refereed', - example: 'property:refereed', + syntax: 'property:%', + examples: ['refereed'], tooltip: 'limit to non-refereed papers by searching property:notrefereed', }, { label: 'astronomy', - example: 'database:astronomy', + syntax: 'database:%', + examples: ['astronomy'], tooltip: 'limit to physics papers by searching collection:physics', }, { label: 'OR', - example: 'abs:(planet OR star)', + syntax: 'abs:(planet OR star)', + examples: [], tooltip: 'default logic is AND, e.g. abs:(planet star) would be interpreted as abs:(planet AND star)', }, From e704734929b4046775edb3bd2286c6dfc7f22f7d Mon Sep 17 00:00:00 2001 From: Jennifer Chen Date: Fri, 17 Sep 2021 14:45:16 -0400 Subject: [PATCH 2/5] Random search examples --- .../components/SearchExamples.jsx.js | 13 ++----- .../landing-page-layout.html | 36 ------------------- src/styles/sass/ads-sass/search-bar.scss | 9 +++++ 3 files changed, 12 insertions(+), 46 deletions(-) diff --git a/src/js/react/Recommender/components/SearchExamples.jsx.js b/src/js/react/Recommender/components/SearchExamples.jsx.js index e2317610d..d56eee5c4 100644 --- a/src/js/react/Recommender/components/SearchExamples.jsx.js +++ b/src/js/react/Recommender/components/SearchExamples.jsx.js @@ -54,7 +54,7 @@ define([ tooltip: PropTypes.string, }; - const SearchExamples = () => { + const SearchExamples = React.memo(() => { const dispatch = useDispatch(); const onClick = (text) => { dispatch(updateSearchBar(text)); @@ -66,14 +66,7 @@ define([ }; return ( -
+
{searchExamples.slice(0, 7).map((entry) => { @@ -110,7 +103,7 @@ define([
); - }; + }); return SearchExamples; }); diff --git a/src/js/wraps/landing_page_manager/landing-page-layout.html b/src/js/wraps/landing_page_manager/landing-page-layout.html index 6d748202a..b1e8e5cb7 100644 --- a/src/js/wraps/landing_page_manager/landing-page-layout.html +++ b/src/js/wraps/landing_page_manager/landing-page-layout.html @@ -13,7 +13,6 @@
-


@@ -23,40 +22,5 @@
- -
diff --git a/src/styles/sass/ads-sass/search-bar.scss b/src/styles/sass/ads-sass/search-bar.scss index 2f63c5806..a74bb294c 100644 --- a/src/styles/sass/ads-sass/search-bar.scss +++ b/src/styles/sass/ads-sass/search-bar.scss @@ -195,6 +195,15 @@ input.hasbigquery { max-width: 800px; } + .search-examples { + padding-top: 1rem; + display: flex; + justify-content: space-between; + @media screen and (max-width: $screen-sm) { + display: unset; + } + } + .quick-reference { display: block; font-size: 17px; From 6f4fc7f515853a760304df62f2da6d2626be6a6b Mon Sep 17 00:00:00 2001 From: Jennifer Chen Date: Mon, 20 Sep 2021 09:16:46 -0400 Subject: [PATCH 3/5] Search examples layout evenly --- src/js/react/Recommender/components/SearchExamples.jsx.js | 2 +- src/js/react/Recommender/models/searchExamples.js | 2 +- src/styles/sass/ads-sass/search-bar.scss | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/js/react/Recommender/components/SearchExamples.jsx.js b/src/js/react/Recommender/components/SearchExamples.jsx.js index d56eee5c4..07bb8084c 100644 --- a/src/js/react/Recommender/components/SearchExamples.jsx.js +++ b/src/js/react/Recommender/components/SearchExamples.jsx.js @@ -24,7 +24,7 @@ define([ // eslint-disable-next-line react/jsx-fragments
{label}
-
+
diff --git a/src/js/react/Recommender/models/searchExamples.js b/src/js/react/Recommender/models/searchExamples.js index 0f5e64fca..4e08b1e78 100644 --- a/src/js/react/Recommender/models/searchExamples.js +++ b/src/js/react/Recommender/models/searchExamples.js @@ -14,7 +14,7 @@ define([], function() { 'Dawson, Rebekah', 'Demorest, Paul', 'Suyu, Sherry H.', - 'KamionkowskiMarc', + 'Kamionkowski, Marc', 'Seljak, Uroš', 'Zaldarriaga, Matias', 'Kaspi, Victoria M.', diff --git a/src/styles/sass/ads-sass/search-bar.scss b/src/styles/sass/ads-sass/search-bar.scss index a74bb294c..d3af68f1d 100644 --- a/src/styles/sass/ads-sass/search-bar.scss +++ b/src/styles/sass/ads-sass/search-bar.scss @@ -222,6 +222,7 @@ input.hasbigquery { } @media screen and (min-width: $screen-sm-min) { + width: 50%; .col-sm-6:first-of-type { width: 46%; } From b53c4c69f4c96542e256b55e11c8fc2a587b80fd Mon Sep 17 00:00:00 2001 From: Jennifer Chen Date: Mon, 20 Sep 2021 14:17:37 -0400 Subject: [PATCH 4/5] Updated examples --- .../Recommender/models/searchExamples.js | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/js/react/Recommender/models/searchExamples.js b/src/js/react/Recommender/models/searchExamples.js index 4e08b1e78..f86409397 100644 --- a/src/js/react/Recommender/models/searchExamples.js +++ b/src/js/react/Recommender/models/searchExamples.js @@ -50,7 +50,7 @@ define([], function() { { label: 'full text', syntax: 'full:"%"', - examples: ['gravity waves'], + examples: ['super Earth'], }, { label: 'publication', @@ -61,41 +61,41 @@ define([], function() { }, { label: 'citations', - syntax: 'citations(author:"%")', - examples: authors, + syntax: 'citations(%)', + examples: ['abstract:JWST'], tooltip: 'finds all papers that cite a given set of papers', }, - { - label: 'references', - syntax: 'references(author:"%")', - examples: authors, - tooltip: 'finds all papers referenced by a given set of papers', - }, - { - label: 'reviews', - syntax: 'reviews("%")', - examples: ['gamma-ray bursts'], - tooltip: - 'finds articles citing the most relevant papers on the topic being researched', - }, { label: 'refereed', syntax: 'property:%', examples: ['refereed'], - tooltip: 'limit to non-refereed papers by searching property:notrefereed', + tooltip: 'limit to refereed papers', }, { label: 'astronomy', - syntax: 'database:%', + syntax: 'collection:%', examples: ['astronomy'], - tooltip: 'limit to physics papers by searching collection:physics', + tooltip: 'limit search to collection', }, { - label: 'OR', - syntax: 'abs:(planet OR star)', - examples: [], - tooltip: - 'default logic is AND, e.g. abs:(planet star) would be interpreted as abs:(planet AND star)', + label: 'exact search', + syntax: '=%', + examples: ['body:"intracluster medium"'], + }, + { + label: 'institution', + syntax: 'inst:%', + examples: ['CfA'], + }, + { + label: 'author count', + syntax: 'author_count:%', + examples: ['[1 TO 10]'], + }, + { + label: 'doctype', + syntax: 'doctype:%', + examples: ['software'], }, ]; From 6dd91c9b243d7d37c66bac63438e6d3aaa0d0620 Mon Sep 17 00:00:00 2001 From: Jennifer Chen Date: Mon, 20 Sep 2021 15:29:15 -0400 Subject: [PATCH 5/5] Update label text --- src/js/react/Recommender/models/searchExamples.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/react/Recommender/models/searchExamples.js b/src/js/react/Recommender/models/searchExamples.js index f86409397..16ce66c33 100644 --- a/src/js/react/Recommender/models/searchExamples.js +++ b/src/js/react/Recommender/models/searchExamples.js @@ -93,7 +93,7 @@ define([], function() { examples: ['[1 TO 10]'], }, { - label: 'doctype', + label: 'record type', syntax: 'doctype:%', examples: ['software'], },