@defra/interactive-map 0.0.5-alpha → 0.0.6-alpha

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.
@@ -44,22 +44,6 @@ export const AppProvider = ({ options, children }) => {
44
44
 
45
45
  useMediaQueryDispatch(rawDispatch, options)
46
46
 
47
- const handleBreakpointChange = breakpointDetector.subscribe((breakpoint) => {
48
- dispatch({
49
- type: 'SET_BREAKPOINT',
50
- payload: {
51
- behaviour: options.behaviour,
52
- breakpoint,
53
- hybridWidth: options.hybridWidth,
54
- maxMobileWidth: options.maxMobileWidth
55
- }
56
- })
57
- })
58
-
59
- const handleInterfaceTypeChange = subscribeToInterfaceChanges((newType) => {
60
- dispatch({ type: 'SET_INTERFACE_TYPE', payload: newType })
61
- })
62
-
63
47
  const handleSetMode = (mode) => {
64
48
  dispatch({ type: 'SET_MODE', payload: mode })
65
49
  }
@@ -72,11 +56,27 @@ export const AppProvider = ({ options, children }) => {
72
56
  eventBus.on(events.APP_SET_MODE, handleSetMode)
73
57
  eventBus.on(events.APP_REVERT_MODE, handleRevertMode)
74
58
 
59
+ const unsubBreakpoint = breakpointDetector.subscribe((breakpoint) => {
60
+ dispatch({
61
+ type: 'SET_BREAKPOINT',
62
+ payload: {
63
+ behaviour: options.behaviour,
64
+ breakpoint,
65
+ hybridWidth: options.hybridWidth,
66
+ maxMobileWidth: options.maxMobileWidth
67
+ }
68
+ })
69
+ })
70
+
71
+ const unsubInterface = subscribeToInterfaceChanges((newType) => {
72
+ dispatch({ type: 'SET_INTERFACE_TYPE', payload: newType })
73
+ })
74
+
75
75
  return () => {
76
76
  eventBus.off(events.APP_SET_MODE, handleSetMode)
77
77
  eventBus.off(events.APP_REVERT_MODE, handleRevertMode)
78
- handleBreakpointChange()
79
- handleInterfaceTypeChange()
78
+ unsubBreakpoint()
79
+ unsubInterface()
80
80
  }
81
81
  }, [])
82
82
 
@@ -91,6 +91,9 @@ const setBreakpoint = (state, payload) => {
91
91
  }
92
92
 
93
93
  const setInterfaceType = (state, payload) => {
94
+ if (state.interfaceType === payload) {
95
+ return state
96
+ }
94
97
  return {
95
98
  ...state,
96
99
  interfaceType: payload
@@ -83,6 +83,11 @@ describe('actionsMap full coverage', () => {
83
83
  expect(result.interfaceType).toBe('compact')
84
84
  })
85
85
 
86
+ test('SET_INTERFACE_TYPE returns same state reference when interfaceType unchanged', () => {
87
+ const result = actionsMap.SET_INTERFACE_TYPE(state, state.interfaceType)
88
+ expect(result).toBe(state)
89
+ })
90
+
86
91
  test('OPEN_PANEL adds a panel with props', () => {
87
92
  const result = actionsMap.OPEN_PANEL(state, { panelId: 'panel2', props: { foo: 'bar' } })
88
93
  expect(result.openPanels.panel2?.props).toEqual({ foo: 'bar' })
@@ -43,7 +43,7 @@
43
43
  --fixed-foreground-color: #0b0c0c;
44
44
 
45
45
  // Content
46
- --app-border-color: #b1b4b6;
46
+ --app-border-color: #cecece;
47
47
  --content-border-color: #f3f2f1;
48
48
  --secondary-text-color: #505a5f;
49
49
  --image-placeholder-color: #b1b4b6;
@@ -12,8 +12,8 @@
12
12
 
13
13
  // Borders and focus
14
14
  --app-border-width: 1px;
15
- --button-border-radius: 4px;
16
- --panel-border-radius: 8px;
15
+ --button-border-radius: 0px; // 4px;
16
+ --panel-border-radius: 0px; // 8px;
17
17
  --focus-border-width: 3px;
18
18
  --focus-outline-width: 3px;
19
19
 
@@ -33,7 +33,7 @@ function notifyListeners (newType) {
33
33
  function createInterfaceDetector () {
34
34
  const mql = window.matchMedia('(pointer: coarse)')
35
35
 
36
- // handle DevTools / system pointer type changes
36
+ // System pointer type changes
37
37
  const handleMediaChange = e => {
38
38
  notifyListeners(e.matches ? 'touch' : 'mouse')
39
39
  }
@@ -66,6 +66,7 @@ function createInterfaceDetector () {
66
66
 
67
67
  function getInterfaceType () {
68
68
  if (lastInterfaceType === 'unknown') {
69
+ lastInterfaceType = 'mouse'
69
70
  return 'mouse'
70
71
  }
71
72