From c3dd51231e5b579702679ae9aa60ee69b8c7bd14 Mon Sep 17 00:00:00 2001 From: Jennifer Kirsch Date: Tue, 21 Dec 2021 10:52:05 +0100 Subject: [PATCH 1/4] Fix rollup build warnings --- rollup.config.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index ffcc42e..e94bba5 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -9,7 +9,6 @@ import svgr from '@svgr/rollup'; import React from 'react'; import ReactDOM from 'react-dom'; -import PropTypes from 'prop-types'; import {terser} from 'rollup-plugin-terser'; const env = process.env.NODE_ENV; @@ -42,12 +41,6 @@ const config = { }), commonjs({ exclude: 'assets/**', - namedExports: { - 'react': Object.keys(React), - 'react-dom': Object.keys(ReactDOM), - 'react-is': Object.keys(require('react-is')), - 'prop-types': Object.keys(PropTypes), - }, }), babel({ 'babelHelpers': 'runtime', @@ -77,7 +70,10 @@ const config = { ], }), globals(), - replace({'process.env.NODE_ENV': JSON.stringify(env === 'production' ? 'production' : 'development')}), + replace({ + 'process.env.NODE_ENV': JSON.stringify(env === 'production' ? 'production' : 'development'), + 'preventAssignment': true, + }), ], }; From fb217c0aa68f4c0f5202958244d589aa5cd9b97a Mon Sep 17 00:00:00 2001 From: Jennifer Kirsch Date: Tue, 21 Dec 2021 10:55:14 +0100 Subject: [PATCH 2/4] Fix website and directions links being displayed in the same line --- assets/js/Root.js | 3 +-- assets/js/components/PointCard.js | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/Root.js b/assets/js/Root.js index 60e694a..c851714 100644 --- a/assets/js/Root.js +++ b/assets/js/Root.js @@ -8,7 +8,6 @@ import ExampleMarker2 from '../img/exampleMarker2.svg'; import SpecialExampleMarker from '../img/specialExampleMarker.svg'; const Main = styled.div` - box-sizing: border-box; width: 100%; height: 100%; `; @@ -30,6 +29,7 @@ const Root = () => { position: {latitude: 47.850670, longitude: 13.090983}, text: 'This is an example', additionalInfo: 'Sportplatz', + website: 'example.invalid.tld', hours: { sunday: [{from: ['7', '0'], until: ['22', '0']}], monday: [{from: ['7', '0'], until: ['22', '0']}], @@ -38,7 +38,6 @@ const Root = () => { thursday: [{from: ['7', '0'], until: ['22', '0']}], friday: [{from: ['7', '0'], until: ['22', '0']}], saturday: [{from: ['7', '0'], until: ['22', '0']}], - }, }, { diff --git a/assets/js/components/PointCard.js b/assets/js/components/PointCard.js index ba524d6..9b013e8 100644 --- a/assets/js/components/PointCard.js +++ b/assets/js/components/PointCard.js @@ -17,7 +17,8 @@ const Link = styled.a` font-size: 1.2rem!important; ` -const SmallLink = styled.a` +const SmallLink = styled(Link)` + line-height: 0.8rem; font-size: 0.8rem!important; ` From b1e74e46eb497a7ad0cad4a934d1c3c8fad57799 Mon Sep 17 00:00:00 2001 From: Jennifer Kirsch Date: Tue, 21 Dec 2021 11:04:59 +0100 Subject: [PATCH 3/4] Only show open hours if not all days are false --- assets/js/Root.js | 6 +++--- assets/js/components/PointCard.js | 27 ++++++++++++++++++++------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/assets/js/Root.js b/assets/js/Root.js index c851714..9d252ac 100644 --- a/assets/js/Root.js +++ b/assets/js/Root.js @@ -47,10 +47,10 @@ const Root = () => { icon: SpecialExampleMarker, hours: { sunday: false, - monday: true, + monday: false, tuesday: false, - wednesday: [{from: ['9', '0'], until: ['23', '0']}], - thursday: [{from: ['15', '0'], until: ['24', '0']}], + wednesday: false, + thursday: false, friday: false, saturday: false, }, diff --git a/assets/js/components/PointCard.js b/assets/js/components/PointCard.js index 9b013e8..d745aba 100644 --- a/assets/js/components/PointCard.js +++ b/assets/js/components/PointCard.js @@ -1,5 +1,6 @@ import PropTypes from 'prop-types'; import React from 'react'; +import {weekdays} from '../data/helpers'; import {localStringsPropTypes} from '../data/propTypes'; import {Card, CardContent} from './Card'; import OpenHours from './OpenHours'; @@ -14,13 +15,24 @@ const TypeText = styled.span` const Link = styled.a` display: block; - font-size: 1.2rem!important; -` + font-size: 1.2rem !important; +`; const SmallLink = styled(Link)` line-height: 0.8rem; - font-size: 0.8rem!important; -` + font-size: 0.8rem !important; +`; + +const checkPointHours = (pointHours) => { + if (pointHours) { + for (const index of weekdays) { + if (pointHours[index]) { + return true; + } + } + } + return false; +}; const PointCard = (props) => { const {point, handleSidebarMarkerClick, selected} = props; @@ -28,17 +40,18 @@ const PointCard = (props) => { return handleSidebarMarkerClick(e, point)}> + onClick={(e) => handleSidebarMarkerClick(e, point)}> {point.text ? point.text : point.address} {!!point.address && !!point.text && {point.address}} {!!point.additionalInfo && {point.additionalInfo}} {!!point.website && {props.localStrings?.website ?? 'Website'}} - + {props.localStrings?.directions ?? 'Directions (Google Maps)'} {point.type} - {point.hours && } + {checkPointHours(point.hours) && } ; }; From 091f289e43b2242c0527097a107982e28fcee0bd Mon Sep 17 00:00:00 2001 From: Jennifer Kirsch Date: Tue, 21 Dec 2021 11:05:10 +0100 Subject: [PATCH 4/4] Only show "show closed" checkbox if open hours exist Closes #3. Also fixes an issue that caused the center map button to not be disabled when no user position was available. --- assets/js/components/ButterflyMap.js | 8 ++++++-- assets/js/components/ControlBar.js | 6 ++++-- assets/js/components/PointBar.js | 2 ++ assets/js/components/PointCard.js | 15 ++++++++++++--- package-lock.json | 4 ++-- package.json | 2 +- 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/assets/js/components/ButterflyMap.js b/assets/js/components/ButterflyMap.js index e44e3d7..c11087b 100644 --- a/assets/js/components/ButterflyMap.js +++ b/assets/js/components/ButterflyMap.js @@ -62,6 +62,7 @@ export const ButterflyMap = (props) => { const [centerMapDisabled, setCenterMapDisabled] = React.useState(true); const [paginationPage, setPaginationPage] = React.useState(1); const [hideMap, setHideMap] = React.useState(false); + const [hoursSet, setHoursSet] = React.useState(false); const [viewport, setViewport] = React.useState({ ...props.center, @@ -281,6 +282,7 @@ export const ButterflyMap = (props) => { setReduceMotion={setReduceMotion} hideMap={hideMap} setHideMap={setHideMap} + hoursSet={hoursSet} /> {!hideMap && <> { - {props.localStrings?.centerMap ?? 'Center map on current location'} + + {props.localStrings?.centerMap ?? 'Center map on current location'} + } {typeOptions.length > 0 && { localStrings={props.localStrings} page={paginationPage} setPage={setPaginationPage} + setHoursSet={setHoursSet} />} ; }; diff --git a/assets/js/components/ControlBar.js b/assets/js/components/ControlBar.js index 2a47f94..43d67d3 100644 --- a/assets/js/components/ControlBar.js +++ b/assets/js/components/ControlBar.js @@ -253,6 +253,7 @@ const ControlBar = (props) => { setReduceMotion, hideMap, setHideMap, + hoursSet } = props; return @@ -267,14 +268,14 @@ const ControlBar = (props) => { {localStrings?.showAll ?? 'Show all'} -
  • + {hoursSet &&
  • -
  • + } {options.map((option, index) => { return