diff --git a/app/assets/styles/_loader.scss b/app/assets/styles/_loader.scss index 70d79bca9..b7c640cab 100644 --- a/app/assets/styles/_loader.scss +++ b/app/assets/styles/_loader.scss @@ -2,3 +2,19 @@ position: relative; min-height: 100px; } + +.loader-ease-in { + animation: easeIn 0.3s; +} + +@keyframes easeIn { + 0% { + opacity: 0; + transform: scale(0); + } + + 100% { + opacity: 1; + transform: scale(1); + } +} \ No newline at end of file diff --git a/app/pages/resource/ResourcePage.js b/app/pages/resource/ResourcePage.js index edf7cecb3..a0a4ccfd6 100644 --- a/app/pages/resource/ResourcePage.js +++ b/app/pages/resource/ResourcePage.js @@ -3,7 +3,7 @@ import isEmpty from 'lodash/isEmpty'; import findIndex from 'lodash/findIndex'; import moment from 'moment'; import PropTypes from 'prop-types'; -import React, { Component } from 'react'; +import React, { Component, Suspense, lazy } from 'react'; import Loader from 'react-loader'; import { connect } from 'react-redux'; import Glyphicon from 'react-bootstrap/lib/Glyphicon'; @@ -20,7 +20,6 @@ import { clearReservations, toggleResourceMap } from 'actions/uiActions'; import PageWrapper from 'pages/PageWrapper'; import NotFoundPage from 'pages/not-found'; import ResourceCalendar from 'shared/resource-calendar'; -import ResourceMap from 'shared/resource-map'; import { injectT } from 'i18n'; import userManager from 'utils/userManager'; import { @@ -37,6 +36,8 @@ import { fetchResourceOutlookCalendarLinks, } from 'resource-outlook-linker/actions'; +const ResourceMap = lazy(() => import('shared/resource-map')); + class UnconnectedResourcePage extends Component { constructor(props) { super(props); @@ -269,12 +270,14 @@ class UnconnectedResourcePage extends Component { /> {showMap && unit && } {showMap && ( - + }> + + )} {!showMap && ( { expect(resourceMapInfo.prop('currentLanguage')).toBe(defaultProps.currentLanguage); }); - test('renders a ResourceMap', () => { - const wrapper = getShowMapWrapper(); - const resourceMap = wrapper.find(ResourceMap); - expect(resourceMap).toHaveLength(1); - expect(resourceMap.prop('location')).toBe(defaultProps.location); - expect(resourceMap.prop('resourceIds')).toEqual([defaultProps.resource.id]); - expect(resourceMap.prop('selectedUnitId')).toBe(defaultProps.unit.id); - expect(resourceMap.prop('showMap')).toBe(true); - }); - test('does not render a ResourceInfo', () => { const wrapper = getShowMapWrapper(); const resourceInfo = wrapper.find(ResourceInfo); diff --git a/app/pages/search/SearchPage.js b/app/pages/search/SearchPage.js index 26808b996..4d1bb62ff 100644 --- a/app/pages/search/SearchPage.js +++ b/app/pages/search/SearchPage.js @@ -1,11 +1,12 @@ import isEqual from 'lodash/isEqual'; import PropTypes from 'prop-types'; -import React, { Component } from 'react'; +import React, { Component, lazy, Suspense } from 'react'; import { connect } from 'react-redux'; import queryString from 'query-string'; import { bindActionCreators } from 'redux'; import Row from 'react-bootstrap/lib/Row'; import Col from 'react-bootstrap/lib/Col'; +import Loader from 'react-loader'; import { searchResources, toggleMap } from 'actions/searchActions'; import { changeSearchFilters } from 'actions/uiActions'; @@ -13,13 +14,14 @@ import { fetchPurposes } from 'actions/purposeActions'; import { fetchUnits } from 'actions/unitActions'; import PageWrapper from 'pages/PageWrapper'; import { injectT } from 'i18n'; -import ResourceMap from 'shared/resource-map'; import SearchControls from './controls'; import searchPageSelector from './searchPageSelector'; import SearchResults from './results/SearchResults'; import Sort from './Sort'; import MapToggle from './results/MapToggle'; +const ResourceMap = lazy(() => import('shared/resource-map')); + class UnconnectedSearchPage extends Component { constructor(props) { super(props); @@ -119,14 +121,15 @@ class UnconnectedSearchPage extends Component {
{showMap && ( - + }> + + )} - {(searchDone || isFetchingSearchResults) && ( { expect(mapToggle.prop('contrast')).toBe('high-contrast'); }); - test('renders a ResourceMap with correct props', () => { - const props = { - searchResultIds: Immutable(['resource-1', 'resource-2']), - selectedUnitId: '123', - showMap: true, - }; - const resourceMap = getWrapper(props).find(ResourceMap); - expect(resourceMap).toHaveLength(1); - expect(resourceMap.prop('showMap')).toBe(true); - expect(resourceMap.prop('resourceIds')).toEqual(props.searchResultIds); - expect(resourceMap.prop('selectedUnitId')).toBe(props.selectedUnitId); - }); - test('renders search results header', () => { const header = getWrapper().find('.app-SearchPage__header'); expect(header).toHaveLength(1);