homeflowjs 0.7.22 → 0.7.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Jenkinsfile CHANGED
@@ -39,6 +39,8 @@ pipeline {
39
39
 
40
40
  stage('Publish Verification') {
41
41
  when {
42
+ branch 'master'
43
+
42
44
  anyOf {
43
45
  triggeredBy 'BitBucketPushCause'
44
46
  triggeredBy 'UserIdCause'
@@ -1,17 +1,18 @@
1
1
  import React from 'react';
2
+ import PropTypes from 'prop-types';
2
3
  import L from 'leaflet';
3
4
  import { MapContainer, TileLayer, Marker } from 'react-leaflet';
4
5
 
5
- const BranchLeafletMap = () => {
6
+ const BranchLeafletMap = ({ iconConfig }) => {
6
7
  const branch = Homeflow.get('branch');
7
8
 
8
- const defaultIcon = L.icon({
9
+ const defaultIconConfig = {
9
10
  iconRetinaUrl: '/assets/marker-icon.png',
10
11
  iconUrl: '/assets/marker-icon.png',
11
12
  shadowUrl: '/assets/marker-shadow.png',
12
- });
13
+ };
13
14
 
14
- // debugger;
15
+ const icon = L.icon(iconConfig || defaultIconConfig);
15
16
 
16
17
  return (
17
18
  <MapContainer
@@ -24,9 +25,17 @@ const BranchLeafletMap = () => {
24
25
  attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
25
26
  url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
26
27
  />
27
- <Marker position={[branch.lat, branch.lng]} icon={defaultIcon} />
28
+ <Marker position={[branch.lat, branch.lng]} icon={icon} />
28
29
  </MapContainer>
29
30
  );
30
31
  };
31
32
 
33
+ BranchLeafletMap.propTypes = {
34
+ iconConfig: PropTypes.object,
35
+ };
36
+
37
+ BranchLeafletMap.defaultProps = {
38
+ iconConfig: null,
39
+ };
40
+
32
41
  export default BranchLeafletMap;
@@ -59,10 +59,10 @@ class BranchMap extends React.Component {
59
59
  }
60
60
 
61
61
  render() {
62
- const { google } = this.props;
62
+ const { google, iconConfig } = this.props;
63
63
 
64
64
  if (!google) {
65
- return <LazyLeafletMap />;
65
+ return <LazyLeafletMap iconConfig={iconConfig} />;
66
66
  }
67
67
 
68
68
  return (
@@ -79,6 +79,7 @@ BranchMap.propTypes = {
79
79
  disableStreetview: PropTypes.bool,
80
80
  initGoogleMaps: PropTypes.func.isRequired,
81
81
  google: PropTypes.bool,
82
+ iconConfig: PropTypes.object,
82
83
  };
83
84
 
84
85
  BranchMap.defaultProps = {
@@ -88,6 +89,7 @@ BranchMap.defaultProps = {
88
89
  zoom: 15,
89
90
  disableStreetview: false,
90
91
  google: false,
92
+ iconConfig: null,
91
93
  };
92
94
 
93
95
  const mapDispatchToProps = {
@@ -12,14 +12,25 @@ import ReactLeafletGoogleLayer from 'react-leaflet-google-layer';
12
12
 
13
13
  import 'leaflet/dist/leaflet.css';
14
14
 
15
- const BranchesMap = ({ CustomPopup, google, gmapsKey }) => {
16
- const branches = Homeflow.get('branches');
15
+ const BranchesMap = ({
16
+ CustomPopup, google, gmapsKey, iconConfig, fallbackLatLng,
17
+ }) => {
18
+ let branches = Homeflow.get('branches');
19
+ let showMarkers = true;
20
+
21
+ // If no branches found use fallback lat, long and set showMarkers to false
22
+ if (!branches) {
23
+ branches = [fallbackLatLng];
24
+ showMarkers = false;
25
+ }
17
26
 
18
- const defaultIcon = L.icon({
27
+ const defaultIconConfig = {
19
28
  iconRetinaUrl: '/assets/marker-icon.png',
20
29
  iconUrl: '/assets/marker-icon.png',
21
30
  shadowUrl: '/assets/marker-shadow.png',
22
- });
31
+ };
32
+
33
+ const icon = L.icon(iconConfig || defaultIconConfig);
23
34
 
24
35
  const bounds = latLngBounds([branches[0].lat, branches[0].lng]);
25
36
 
@@ -29,7 +40,7 @@ const BranchesMap = ({ CustomPopup, google, gmapsKey }) => {
29
40
  return (
30
41
  <Marker
31
42
  position={[branch.lat, branch.lng]}
32
- icon={defaultIcon}
43
+ icon={icon}
33
44
  key={branch.branch_id}
34
45
  >
35
46
  {CustomPopup ? (
@@ -77,7 +88,7 @@ const BranchesMap = ({ CustomPopup, google, gmapsKey }) => {
77
88
  url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
78
89
  />
79
90
  )}
80
- {markers}
91
+ {showMarkers && markers}
81
92
  </MapContainer>
82
93
  );
83
94
  };
@@ -86,12 +97,16 @@ BranchesMap.propTypes = {
86
97
  google: PropTypes.bool,
87
98
  CustomPopup: PropTypes.elementType,
88
99
  gmapsKey: PropTypes.string,
100
+ iconConfig: PropTypes.object,
101
+ fallbackLatLng: PropTypes.object,
89
102
  };
90
103
 
91
104
  BranchesMap.defaultProps = {
92
105
  google: false,
93
106
  CustomPopup: null,
94
107
  gmapsKey: null,
108
+ iconConfig: null,
109
+ fallbackLatLng: { lat: 51.509865, lng: -0.118092 },
95
110
  };
96
111
 
97
112
  const mapStateToProps = (state) => ({
@@ -3,9 +3,16 @@ import { connect } from 'react-redux';
3
3
  import PropTypes from 'prop-types';
4
4
  import Autosuggest from 'react-autosuggest';
5
5
  import { setBranchesSearch } from '../../actions/branches.actions';
6
+ import { autosuggestTheme } from '../../search/location-input/location-input.styles';
6
7
 
7
8
  const BranchesSearchInput = ({
8
- branchesSearch, setBranchesSearch, placeholder, isSelected, setIsSelected,
9
+ branchesSearch,
10
+ setBranchesSearch,
11
+ placeholder,
12
+ isSelected,
13
+ setIsSelected,
14
+ className,
15
+ unstyled
9
16
  }) => {
10
17
  const [placeID, setPlaceID] = useState('');
11
18
  const [suggestions, setSuggestions] = useState([]);
@@ -68,12 +75,14 @@ const BranchesSearchInput = ({
68
75
  renderSuggestion={(suggestion) => renderSuggestion(suggestion.label)}
69
76
  inputProps={{
70
77
  placeholder,
78
+ className,
71
79
  value: branchesSearch,
72
80
  onChange: (_, { newValue, method }) => {
73
81
  setBranchesSearch(newValue);
74
82
  },
75
83
  }}
76
84
  highlightFirstSuggestion
85
+ theme={unstyled ? null : autosuggestTheme}
77
86
  />
78
87
  </>
79
88
  );
@@ -91,12 +100,16 @@ BranchesSearchInput.propTypes = {
91
100
  PropTypes.func,
92
101
  PropTypes.string,
93
102
  ]),
103
+ className: PropTypes.string,
104
+ unstyled: PropTypes.bool,
94
105
  };
95
106
 
96
107
  BranchesSearchInput.defaultProps = {
97
108
  placeholder: '',
98
109
  isSelected: '',
99
110
  setIsSelected: '',
111
+ className: '',
112
+ unstyled: false,
100
113
  };
101
114
 
102
115
  const mapStateToProps = (state) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "0.7.22",
3
+ "version": "0.7.26",
4
4
  "description": "JavaScript toolkit for Homeflow themes",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -56,6 +56,8 @@ const searchReducer = (state = INITIAL_STATE, action) => {
56
56
  currentSearch: {
57
57
  ...state.currentSearch,
58
58
  ...action.payload,
59
+ // delete poly if user enters new search query
60
+ poly: action.payload.q ? null : state.currentSearch.poly,
59
61
  },
60
62
  };
61
63
  case SearchActionTypes.ADD_TAG: {