mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-03 13:04:46 +00:00
* Remove useless CSS declaration * Remove commented out styles * Merge duplicate declarations * Remove even more commented out code * Move footer mq to footer declaration * Remove more useless code * Stop vendor prefixing for IE below 11 * Remove useless vendor prefixing * Merge identical declarations * Fix 1px overflow in content wrapper * Fix explorer scrolling when open on mobile * Remove unused import * Add Redux performance measurements to explorer menu * Rewrite explorer reducer to avoid unnecessary operations * Stop changing reducer state on every action regardless of type * Remove redundant children.isFetching property in nodes reducer * Remove redundant children.isLoaded property in nodes reducer * Remove redundant children.isError property in nodes reducer * Refactor nodes explorer reducer with sub-reducer * Fix linting issue * Remove unused class name * Change default icon className from empty string to null * Remove old TODO comment * Hoist icons in ExplorerItem component for better performance * Add comment * Add tooling for performance measurement of React components * Clean up explorer panel component definition * Make performance measurements opt-in * Improve alignment of page explorer menu on mobile * Close explorer on touchend rather than touchstart * Comment out performance measurement code * Remove fade transition completely
38 lines
792 B
JavaScript
38 lines
792 B
JavaScript
const defaultState = {
|
|
isVisible: false,
|
|
path: [],
|
|
};
|
|
|
|
/**
|
|
* Oversees the state of the explorer. Defines:
|
|
* - Where in the page tree the explorer is at.
|
|
* - Whether the explorer is open or not.
|
|
*/
|
|
export default function explorer(prevState = defaultState, { type, payload }) {
|
|
switch (type) {
|
|
case 'OPEN_EXPLORER':
|
|
// Provide a starting page when opening the explorer.
|
|
return {
|
|
isVisible: true,
|
|
path: [payload.id],
|
|
};
|
|
|
|
case 'CLOSE_EXPLORER':
|
|
return defaultState;
|
|
|
|
case 'PUSH_PAGE':
|
|
return {
|
|
isVisible: prevState.isVisible,
|
|
path: prevState.path.concat([payload.id]),
|
|
};
|
|
|
|
case 'POP_PAGE':
|
|
return {
|
|
isVisible: prevState.isVisible,
|
|
path: prevState.path.slice(0, -1),
|
|
};
|
|
|
|
default:
|
|
return prevState;
|
|
}
|
|
}
|