Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS-9 Mess around with layout (proof of concept) #74

Open
wants to merge 19 commits into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/components/_fs-aside.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
*/

.fs-aside {
width: 22.85714%;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how these specific widths were calculated before but we should have grid-template-columns in .fs-container match them by default to keep the layout the same by default.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

22.85714% 74.28571%

float: left;
margin-right: -100%;
margin-left: 0;
clear: both;
margin-bottom: rhythm(1);
background-color: $c-bg-gray;
@include breakpoint($bp2) {
}
}

.fs-aside__mobile-reverse {
order: 2;
}

// Layout option to move aside to right on desktop
.fs-aside__desktop-reverse {
@include breakpoint($bp2) {
padding-top: rhythm(1);
order: 6; // Should be higher than all mobile orders.
}
}
16 changes: 16 additions & 0 deletions src/components/_fs-container.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* container.scss
* Define container styles.
*
* @copyright Copyright (c) 2017-2020 Palantir.net
*/

.fs-container {
display: flex;
flex-direction: column;
@include breakpoint($bp2) {
display: grid;
grid-column-gap: 1em;
grid-template-columns: 33% 66%;
}
}
8 changes: 0 additions & 8 deletions src/components/_fs-main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@
*/

.fs-main {
width: 74.28571%;
float: right;
margin-left: 0;
margin-right: 0;
clear: none;
margin-bottom: rhythm(1);

@include breakpoint($bp2) {
padding-top: rhythm(1);
}
}
7 changes: 4 additions & 3 deletions src/components/federated-solr-faceted-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ class FederatedSolrFacetedSearch extends React.Component {

return (
<LiveAnnouncer>
<div className="fs-container">
<aside className="fs-aside">
<div className={`fs-container ${this.props.options.layoutAndClasses.containerClass}`} style={{ gridTemplateColumns: this.props.options.layoutAndClasses.layout }}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need checks if the the following exist before we use them:
this.props.options.layoutAndClasses.containerClass
this.props.options.layoutAndClasses.layout
this.props.options.layoutAndClasses.asideClass
this.props.options.layoutAndClasses.mainClass

We could use the ternary check like we have on this.props.options.layoutAndClasses.reverseDesktopColumns to be consistent.

<aside className={`fs-aside ${this.props.options.layoutAndClasses.asideClass} ${this.props.options.layoutAndClasses.reverseDesktopColumns ? "fs-aside__desktop-reverse" : ""} ${this.props.options.layoutAndClasses.reverseMobileOrder ? "fs-aside__mobile-reverse" : ""}`}>
<SearchFieldContainerComponent
bootstrapCss={bootstrapCss}
onNewSearch={this.resetFilters}
resultsCount={this.props.results.numFound}
options={this.props.options}
>
{/* Only render the visible facets / filters.
Note: their values may still be used in the query, if they were pre-set. */}
Expand Down Expand Up @@ -137,7 +138,7 @@ class FederatedSolrFacetedSearch extends React.Component {
}
</SearchFieldContainerComponent>
</aside>
<div className="fs-main">
<div className={`fs-main ${this.props.options.layoutAndClasses.mainClass}`}>
{pageTitle}
<div className="fs-search-form" autoComplete="on">
<FederatedTextSearch
Expand Down
20 changes: 18 additions & 2 deletions src/components/search-field-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,29 @@ class FederatedSearchFieldContainer extends React.Component {
super(props);

// This will return the width of the viewport.
const intFrameWidth = window.innerWidth;
let intFrameWidth = window.innerWidth;

// Get our breakpoint option from env.
const breakpointDesktop = this.props.options.layoutAndClasses.breakpointDesktop || 900;

this.state = {
// Filters are visible for large / hidden for small screens by default.
expanded: intFrameWidth > 900,
expanded: intFrameWidth > breakpointDesktop,
};

this.handleClick = this.handleClick.bind(this);

window.addEventListener('resize', () => {
// Desktop height.
let height = 'auto';
// In mobile view, when resized, lets close things.
if (window.innerWidth < breakpointDesktop) {
height = 0;
}
this.setState({
expanded: height,
});
});
}

handleClick() {
Expand Down Expand Up @@ -66,6 +81,7 @@ class FederatedSearchFieldContainer extends React.Component {
FederatedSearchFieldContainer.propTypes = {
children: PropTypes.array,
onNewSearch: PropTypes.func,
options: PropTypes.object,
};

export default FederatedSearchFieldContainer;
42 changes: 22 additions & 20 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -524,41 +524,43 @@
.fs-search-accordion__title.js-fs-search-accordion-open:after {
content: "–"; }

/**
* container.scss
* Define container styles.
*
* @copyright Copyright (c) 2017-2020 Palantir.net
*/
.fs-container {
display: flex;
flex-direction: column; }
@media (min-width: 900px) {
.fs-container {
display: grid;
grid-column-gap: 1em;
grid-template-columns: 33% 66%; } }

/**
* aside.scss
* Define aside styles.
*
* @copyright Copyright (c) 2017-2019 Palantir.net
*/
.fs-aside {
width: 22.85714%;
float: left;
margin-right: -100%;
margin-left: 0;
clear: both;
margin-bottom: 1.46667em;
background-color: #f6f6f6; }
@media (min-width: 900px) {
.fs-aside {
padding-top: 1.46667em; } }

.fs-aside__mobile-reverse {
order: 2; }

@media (min-width: 900px) {
.fs-aside__desktop-reverse {
order: 6; } }

/**
* aside.scss
* Define aside styles.
*
* @copyright Copyright (c) 2017-2020 Palantir.net
*/
.fs-main {
width: 74.28571%;
float: right;
margin-left: 0;
margin-right: 0;
clear: none;
margin-bottom: 1.46667em; }
@media (min-width: 900px) {
.fs-main {
padding-top: 1.46667em; } }

/**
* fs-search-results.scss
* Define search results styles.
Expand Down
1 change: 1 addition & 0 deletions src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
@import "components/text-search/fs-search-form";
@import "components/text-search/fs-autocomplete";
@import "components/fs-search-filters";
@import "components/fs-container";
@import "components/fs-aside";
@import "components/fs-main";
@import "components/results/fs-search-results";
Expand Down