-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #442 from mlibrary/cleaning-up-umich-lib-core-temp
Removing the need for `umich-lib-core-temp`.
- Loading branch information
Showing
28 changed files
with
533 additions
and
824 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 50 additions & 106 deletions
156
src/modules/advanced/components/AdvancedSearchContainer/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,112 +1,56 @@ | ||
/** @jsxImportSource @emotion/react */ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import _ from 'underscore'; | ||
import { MEDIA_QUERIES, SEARCH_COLORS } from '../../../reusable/umich-lib-core-temp'; | ||
import { | ||
Breadcrumb, | ||
H1, | ||
Tabs, | ||
TabList, | ||
TabPanel, | ||
Tab | ||
} from '../../../reusable'; | ||
import './styles.css'; | ||
import { useSelector } from 'react-redux'; | ||
import { Breadcrumb, H1, Tabs, TabList, TabPanel, Tab } from '../../../reusable'; | ||
import AdvancedSearchForm from '../AdvancedSearchForm'; | ||
import PropTypes from 'prop-types'; | ||
|
||
/* | ||
Structure of the AdvancedSearch components: | ||
- AdvancedSearchContainer | ||
- Tabs | ||
- Form | ||
- FieldedInputs | ||
- FieldInput (many) | ||
- ... | ||
- AddAnotherFieldInput | ||
- Filter | ||
- Checkbox, NarrowSelect, DateInput, or MultipleSelect (many) | ||
- ... | ||
- SubmitSearch | ||
*/ | ||
|
||
class AdvancedSearchContainer extends React.Component { | ||
render () { | ||
const { | ||
datastores, | ||
activeDatastore, | ||
activeDatastoreIndex | ||
} = this.props; | ||
|
||
return ( | ||
<div | ||
css={{ | ||
marginTop: '1rem' | ||
}} | ||
className='container container-narrow' | ||
> | ||
<Breadcrumb | ||
items={[ | ||
{ text: `${activeDatastore.name}`, to: `/${activeDatastore.slug}${document.location.search}` }, | ||
{ text: 'Advanced Search' } | ||
]} | ||
/> | ||
|
||
<H1 className='heading-xlarge'>Advanced Search</H1> | ||
<p className='font-lede'>Select a search category below for associated advanced search options.</p> | ||
|
||
<Tabs defaultIndex={activeDatastoreIndex}> | ||
<TabList className='advanced-tabs'> | ||
{datastores.map((ds) => { | ||
return ( | ||
<Tab key={`tab-${ds.uid}`}> | ||
{ds.name} | ||
</Tab> | ||
); | ||
})} | ||
</TabList> | ||
|
||
<div | ||
css={{ | ||
boxShadow: 'rgba(0, 0, 0, 0.12) 0px 2px 2px 0px, rgba(0, 0, 0, 0.24) 0px 2px 4px 0px', | ||
padding: '1rem', | ||
background: SEARCH_COLORS.grey[100], | ||
borderRadius: '0 0 4px 4px', | ||
[MEDIA_QUERIES.LARGESCREEN]: { | ||
padding: '2rem' | ||
} | ||
}} | ||
> | ||
{datastores.map((ds) => { | ||
return ( | ||
<TabPanel key={`tabpanel-${ds.uid}`}> | ||
<AdvancedSearchForm datastore={ds} /> | ||
</TabPanel> | ||
); | ||
})} | ||
</div> | ||
</Tabs> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
AdvancedSearchContainer.propTypes = { | ||
datastores: PropTypes.array, | ||
activeDatastore: PropTypes.object, | ||
activeDatastoreIndex: PropTypes.number | ||
}; | ||
|
||
function mapStateToProps (state) { | ||
const datastores = state.datastores.datastores; | ||
const activeDatastoreIndex = _.findIndex(datastores, { | ||
uid: state.datastores.active | ||
function AdvancedSearchContainer () { | ||
const datastores = useSelector((state) => { | ||
return state.datastores.datastores; | ||
}); | ||
|
||
return { | ||
datastores, | ||
activeDatastore: datastores[activeDatastoreIndex], | ||
activeDatastoreIndex | ||
}; | ||
const activeDatastoreUid = useSelector((state) => { | ||
return state.datastores.active; | ||
}); | ||
const activeDatastoreIndex = datastores.findIndex((datastore) => { | ||
return datastore.uid === activeDatastoreUid; | ||
}); | ||
const activeDatastore = datastores[activeDatastoreIndex]; | ||
|
||
return ( | ||
<div className='container container-narrow margin-top__m'> | ||
<Breadcrumb | ||
items={[ | ||
{ text: `${activeDatastore.name}`, to: `/${activeDatastore.slug}${document.location.search}` }, | ||
{ text: 'Advanced Search' } | ||
]} | ||
/> | ||
|
||
<H1 className='heading-xlarge'>Advanced Search</H1> | ||
<p className='font-lede'>Select a search category below for associated advanced search options.</p> | ||
|
||
<Tabs defaultIndex={activeDatastoreIndex}> | ||
<TabList className='advanced-tabs'> | ||
{datastores.map((ds) => { | ||
return ( | ||
<Tab key={`tab-${ds.uid}`}> | ||
{ds.name} | ||
</Tab> | ||
); | ||
})} | ||
</TabList> | ||
|
||
<div className='tab-panel-container'> | ||
{datastores.map((ds) => { | ||
return ( | ||
<TabPanel key={`tabpanel-${ds.uid}`}> | ||
<AdvancedSearchForm datastore={ds} /> | ||
</TabPanel> | ||
); | ||
})} | ||
</div> | ||
</Tabs> | ||
</div> | ||
); | ||
} | ||
|
||
export default connect(mapStateToProps)(AdvancedSearchContainer); | ||
export default AdvancedSearchContainer; |
12 changes: 12 additions & 0 deletions
12
src/modules/advanced/components/AdvancedSearchContainer/styles.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.tab-panel-container { | ||
box-shadow: rgba(0, 0, 0, 0.12) 0px 2px 2px 0px, rgba(0, 0, 0, 0.24) 0px 2px 4px 0px; | ||
padding: 1rem; | ||
background: var(--search-color-grey-100); | ||
border-radius: 0 0 4px 4px; | ||
} | ||
|
||
@media only screen and (min-width: 641px) { | ||
.tab-panel-container { | ||
padding: 2rem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,24 @@ | ||
/** @jsxImportSource @emotion/react */ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
import './styles.css'; | ||
import { useSelector } from 'react-redux'; | ||
import { ChooseAffiliation } from '../../../affiliation'; | ||
import { Anchor } from '../../../reusable'; | ||
import { MEDIA_QUERIES } from '../../../reusable/umich-lib-core-temp'; | ||
import { Authentication } from '../../../profile'; | ||
|
||
function SearchHeader (props) { | ||
function SearchHeader () { | ||
const isAuthenticated = useSelector((state) => { | ||
return state.profile.status === 'Logged in'; | ||
}); | ||
|
||
return ( | ||
<m-website-header name='Search' variant='dark' to='/everything'> | ||
<nav | ||
aria-label='utility' | ||
css={{ | ||
background: 'var(--color-blue-400)', | ||
gridTemplateColumns: 'repeat(4, auto)', | ||
alignItems: 'baseline', | ||
display: 'block', | ||
'& > *': { | ||
color: 'white', | ||
display: 'inline-block', | ||
marginTop: '1rem' | ||
}, | ||
'& > *:not(:last-child)': { | ||
marginRight: '1rem', | ||
marginBottom: '0.5rem' | ||
}, | ||
a: { | ||
textDecoration: 'none', | ||
'&:hover': { | ||
textDecoration: 'underline' | ||
} | ||
}, | ||
[MEDIA_QUERIES.LARGESCREEN]: { | ||
'& > *': { | ||
margin: '0' | ||
}, | ||
'& > *:not(:last-child)': { | ||
marginBottom: '0' | ||
} | ||
} | ||
}} | ||
> | ||
<nav aria-label='utility'> | ||
<Anchor href='https://account.lib.umich.edu/'>Account</Anchor> | ||
<Authentication logout={props.isAuthenticated} /> | ||
<Authentication logout={isAuthenticated} /> | ||
<ChooseAffiliation /> | ||
</nav> | ||
</m-website-header> | ||
); | ||
} | ||
|
||
SearchHeader.propTypes = { | ||
isAuthenticated: PropTypes.bool | ||
}; | ||
|
||
function mapStateToProps (state) { | ||
return { | ||
isAuthenticated: state.profile.status === 'Logged in', | ||
datastore: state.datastores.active, | ||
search: state.search | ||
}; | ||
} | ||
|
||
export default connect(mapStateToProps)(SearchHeader); | ||
export default SearchHeader; |
Oops, something went wrong.