Skip to content

Commit

Permalink
Merge pull request #442 from mlibrary/cleaning-up-umich-lib-core-temp
Browse files Browse the repository at this point in the history
Removing the need for `umich-lib-core-temp`.
  • Loading branch information
erinesullivan authored Mar 20, 2024
2 parents e0bf9cf + 6cc8c2d commit 059a72a
Show file tree
Hide file tree
Showing 28 changed files with 533 additions and 824 deletions.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ReactDOM from 'react-dom/client';
import { Provider } from 'react-redux';
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
import './stylesheets/colors.css';
import './stylesheets/spacing.css';
import './stylesheets/main.css';
import './stylesheets/utilities.css';
import { Alert } from './modules/reusable';
Expand Down
156 changes: 50 additions & 106 deletions src/modules/advanced/components/AdvancedSearchContainer/index.js
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 src/modules/advanced/components/AdvancedSearchContainer/styles.css
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;
}
}
12 changes: 2 additions & 10 deletions src/modules/advanced/components/FieldInput/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
/** @jsxImportSource @emotion/react */
import React from 'react';
import { MEDIA_QUERIES } from '../../../reusable/umich-lib-core-temp';
import Icon from '../../../reusable/components/Icon';
import { MultipleChoice } from '../../../core';
import styled from '@emotion/styled';
import SearchByOptions from '../../../search/components/SearchByOptions';
import PropTypes from 'prop-types';

const StyledFieldSet = styled('fieldset')({
[MEDIA_QUERIES.LARGESCREEN]: {
textAlign: 'center'
}
});

function FieldInput ({
fieldedSearchIndex,
fieldedSearch,
Expand All @@ -22,7 +14,7 @@ function FieldInput ({
activeDatastore
}) {
return (
<StyledFieldSet className='y-spacing'>
<fieldset className='y-spacing advanced-fieldset'>
<legend className='offpage'>Search field {fieldedSearchIndex + 1}</legend>
{fieldedSearchIndex === 0
? null
Expand Down Expand Up @@ -92,7 +84,7 @@ function FieldInput ({
: null}
</div>
</div>
</StyledFieldSet>
</fieldset>
);
};

Expand Down
10 changes: 3 additions & 7 deletions src/modules/advanced/components/FiltersContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Icon } from '../../../reusable';
import getFilters from './getFilters';
import AdvancedFilter from '../AdvancedFilter';
import { setAdvancedFilter } from '../../../advanced';
import { SPACING, COLORS } from '../../../reusable/umich-lib-core-temp';

function ActiveAdvancedFilters (datastore) {
const currentDatastore = datastore.datastore.uid;
Expand Down Expand Up @@ -61,17 +60,14 @@ function ActiveAdvancedFilters (datastore) {
>
<h2
id='active-filters'
className='u-margin-top-none'
style={{
fontSize: '1rem',
marginBottom: SPACING.XS
}}
className='u-margin-top-none margin-bottom__xs'
style={{ fontSize: '1rem' }}
>
Active filters
</h2>
<span
style={{
color: COLORS.neutral['300'],
color: 'var(--ds-color-neutral-300)',
paddingRight: '0.5em'
}}
>
Expand Down
9 changes: 4 additions & 5 deletions src/modules/affiliation/components/choose-affiliation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React, { useState } from 'react';
import { useCookies } from 'react-cookie';
import { useSelector } from 'react-redux';
import qs from 'qs';
import { COLORS } from '../../reusable/umich-lib-core-temp';
import { Dialog } from '../../reusable';

export default function ChooseAffiliation () {
Expand Down Expand Up @@ -64,7 +63,7 @@ export default function ChooseAffiliation () {
<button
className='btn btn--secondary no-background'
css={{
borderColor: COLORS.blue[300],
borderColor: 'var(--ds-color-blue-300)',
color: 'white',
display: 'flex',
padding: '0',
Expand All @@ -77,7 +76,7 @@ export default function ChooseAffiliation () {
textDecoration: 'underline'
},
'&.active-affiliation': {
background: COLORS.blue[300]
background: 'var(--ds-color-blue-300)'
}
}
}}
Expand All @@ -100,7 +99,7 @@ export default function ChooseAffiliation () {
<button
className='btn btn--secondary no-background'
css={{
borderColor: COLORS.blue[300],
borderColor: 'var(--ds-color-blue-300)',
color: 'white',
display: 'flex',
padding: '0',
Expand All @@ -113,7 +112,7 @@ export default function ChooseAffiliation () {
textDecoration: 'underline'
},
'&.active-affiliation': {
background: COLORS.blue[300]
background: 'var(--ds-color-blue-300)'
}
}
}}
Expand Down
61 changes: 10 additions & 51 deletions src/modules/core/components/SearchHeader/index.js
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;
Loading

0 comments on commit 059a72a

Please sign in to comment.