Skip to content

Commit 62ca8c7

Browse files
author
Brian Earwood
committed
Add ability of UI to remove sidebar when no Sort or Filter fields exist and adjust styling
1 parent ba31ee4 commit 62ca8c7

File tree

4 files changed

+93
-86
lines changed

4 files changed

+93
-86
lines changed

src/components/Body.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
ResultsPerPage,
1010
Sorting
1111
} from "../containers";
12-
import { buildSortOptionsFromConfig } from "../config/config-helper";
12+
import { getFacetFields, getSortFields, buildSortOptionsFromConfig } from "../config/config-helper";
1313

1414
export default function Body() {
1515
return (
@@ -19,7 +19,7 @@ export default function Body() {
1919
Type a search above to begin.
2020
</div>
2121
<div className="search-results">
22-
<div className="sidebar">
22+
<div className={"sidebar" + (getFacetFields().length > 0 || getSortFields().length > 0 ? '' : ' hidden')}>
2323
<Sorting sortOptions={buildSortOptionsFromConfig()} />
2424
<Facets />
2525
</div>

src/config/config-helper.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ export function getUrlField() {
4646
return getConfig().urlField;
4747
}
4848

49+
export function getFacetFields() {
50+
return getConfig().facets || [];
51+
}
52+
53+
export function getSortFields() {
54+
return getConfig().sortFields || [];
55+
}
56+
4957
export function getUrlFieldTemplate() {
5058
return getConfig().urlFieldTemplate;
5159
}

src/styles/styles.css

Lines changed: 77 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,10 @@ a {
393393
padding: 0 24px; }
394394

395395
.sidebar {
396-
flex: 0 1 30%; }
396+
flex: 0 1 30%;
397+
padding-right: 12px; }
398+
.sidebar.hidden {
399+
display: none; }
397400

398401
.sorting {
399402
padding-top: 32px; }
@@ -476,77 +479,79 @@ a {
476479
width: 100%;
477480
justify-content: space-between;
478481
align-items: center; }
479-
.active-search .results {
480-
padding: 32px 0 0 32px;
481-
border-left: 1px solid #eeeeee; }
482-
483-
.result {
484-
border-top: 1px solid #eeeeee;
485-
padding: 24px 0; }
486-
.result + .result {
487-
margin-top: 20px; }
488-
.result em {
489-
position: relative;
490-
color: #3a56e4;
491-
font-weight: 900;
492-
font-style: inherit; }
493-
.result em:after {
494-
content: "";
495-
position: absolute;
496-
top: -3px;
497-
left: -3px;
498-
width: calc(100% + 6px);
499-
height: calc(100% + 6px);
500-
background: rgba(37, 139, 248, 0.08);
501-
pointer-events: none; }
502-
.result__header {
503-
display: flex;
504-
justify-content: space-between;
505-
align-items: center; }
506-
.result__title {
507-
font-size: 1.8em;
508-
font-weight: 700; }
509-
.result__key {
510-
font-family: monospace;
511-
font-weight: 400;
512-
font-size: 14px;
513-
flex: 0 1 50%;
514-
color: #777777; }
515-
.result__key:before {
516-
content: '"'; }
517-
.result__key:after {
518-
content: '": '; }
519-
.result__value {
520-
font-weight: 400;
521-
font-size: 14px; }
522-
.result__version {
523-
font-size: 12px;
524-
display: inline;
525-
vertical-align: bottom; }
526-
.result__lisence {
527-
font-size: 12px;
528-
color: #999999;
529-
display: inline-block;
530-
border: 1px solid #ccc;
531-
border-radius: 3px;
532-
line-height: 1;
533-
padding: 4px 4px 3px 4px; }
534-
.result__body {
535-
margin-top: 1rem;
536-
line-height: 1.5; }
537-
.result__body p {
538-
margin: 0; }
539-
.result__details {
540-
max-height: 300px;
541-
position: relative;
542-
overflow: hidden;
543-
overflow-y: auto;
544-
padding: 24px;
545-
background-color: #f9f9f9; }
546-
.result__footer {
547-
padding: 0 2rem;
548-
margin-top: 1rem;
549-
line-height: 1; }
482+
483+
.result em {
484+
position: relative;
485+
color: #3a56e4;
486+
font-weight: 900;
487+
font-style: inherit; }
488+
.result em:after {
489+
content: "";
490+
position: absolute;
491+
top: -3px;
492+
left: -3px;
493+
width: calc(100% + 6px);
494+
height: calc(100% + 6px);
495+
background: rgba(37, 139, 248, 0.08);
496+
pointer-events: none; }
497+
498+
.result__header {
499+
display: flex;
500+
justify-content: space-between;
501+
align-items: center; }
502+
503+
.result__title {
504+
font-size: 1.8em;
505+
font-weight: 700;
506+
margin-top: 24px; }
507+
508+
.result__key {
509+
font-family: monospace;
510+
font-weight: 400;
511+
font-size: 14px;
512+
flex: 0 1 50%;
513+
color: #777777; }
514+
.result__key:before {
515+
content: '"'; }
516+
.result__key:after {
517+
content: '": '; }
518+
519+
.result__value {
520+
font-weight: 400;
521+
font-size: 14px; }
522+
523+
.result__version {
524+
font-size: 12px;
525+
display: inline;
526+
vertical-align: bottom; }
527+
528+
.result__lisence {
529+
font-size: 12px;
530+
color: #999999;
531+
display: inline-block;
532+
border: 1px solid #ccc;
533+
border-radius: 3px;
534+
line-height: 1;
535+
padding: 4px 4px 3px 4px; }
536+
537+
.result__body {
538+
margin-top: 1rem;
539+
line-height: 1.5; }
540+
.result__body p {
541+
margin: 0; }
542+
543+
.result__details {
544+
max-height: 300px;
545+
position: relative;
546+
overflow: hidden;
547+
overflow-y: auto;
548+
padding: 24px;
549+
background-color: #f9f9f9; }
550+
551+
.result__footer {
552+
padding: 0 2rem;
553+
margin-top: 1rem;
554+
line-height: 1; }
550555

551556
.rc-pagination {
552557
display: flex;

src/styles/styles.scss

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ a {
181181

182182
.sidebar {
183183
flex: 0 1 30%;
184+
padding-right: $sizeM;
185+
186+
&.hidden {
187+
display: none;
188+
}
184189
}
185190

186191
.sorting {
@@ -289,21 +294,9 @@ a {
289294
justify-content: space-between;
290295
align-items: center;
291296
}
292-
293-
.active-search & {
294-
padding: $sizeXL 0 0 $sizeXL;
295-
border-left: 1px solid $resultsLeftBorderColor;
296-
}
297297
}
298298

299299
.result {
300-
border-top: 1px solid $resultBorderColor;
301-
padding: $sizeL 0;
302-
303-
& + & {
304-
margin-top: 20px;
305-
}
306-
307300
em {
308301
position: relative;
309302
color: $textMatchColor;
@@ -331,6 +324,7 @@ a {
331324
&__title {
332325
font-size: 1.8em;
333326
font-weight: $fontWeightBold;
327+
margin-top: $sizeL;
334328
}
335329

336330
&__key {

0 commit comments

Comments
 (0)